dbekaert / RAiDER

Raytracing Atmospheric Delay Estimation for RADAR
Apache License 2.0
70 stars 39 forks source link

RasterRDR class xpts attribute not set #623

Closed vbrancat closed 2 months ago

vbrancat commented 8 months ago

Describe the bug The RasterRDR class derived from the class AOI does not have members called xptsand ypts. However, the tropo_delay.py functions assumes that these members are available when computing the troposphere delay. The tropo_delay.py function fails with the following error:

/mnt/aurora-r0/vbrancat/codes/miniconda3/envs/compass/lib/python3.11/site-packages/rasterio/__init__.py:304: NotGeoreferencedWarning: Dataset has no geotransform, gcps, or rpcs. The identity matrix will be returned.
  dataset = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
Assuming lat/lon files are in EPSG:4326
Traceback (most recent call last):
  File "/mnt/aurora-r0/vbrancat/codes/COMPASS/src/compass/s1_cslc.py", line 58, in <module>
    main()
  File "/mnt/aurora-r0/vbrancat/codes/COMPASS/src/compass/s1_cslc.py", line 53, in main
    run(parser.run_config_path, parser.args.grid_type)
  File "/mnt/aurora-r0/vbrancat/codes/COMPASS/src/compass/s1_cslc.py", line 45, in run
    s1_geocode_slc.run(cfg)
  File "/mnt/aurora-r0/vbrancat/codes/miniconda3/envs/compass/lib/python3.11/site-packages/compass/s1_geocode_slc.py", line 92, in run
    cumulative_correction_luts(burst, dem_path=cfg.dem,
  File "/mnt/aurora-r0/vbrancat/codes/miniconda3/envs/compass/lib/python3.11/site-packages/compass/utils/lut.py", line 64, in cumulative_correction_luts
    compute_geocoding_correction_luts(burst,
  File "/mnt/aurora-r0/vbrancat/codes/miniconda3/envs/compass/lib/python3.11/site-packages/compass/utils/lut.py", line 271, in compute_geocoding_correction_luts
    zen_wet, zen_dry = tropo_delay(burst.sensing_start,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/aurora-r0/vbrancat/codes/miniconda3/envs/compass/lib/python3.11/site-packages/RAiDER/delay.py", line 90, in tropo_delay
    ds = _get_delays_on_cube(dt, weather_model_file, wm_proj, aoi, height_levels,
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/aurora-r0/vbrancat/codes/miniconda3/envs/compass/lib/python3.11/site-packages/RAiDER/delay.py", line 145, in _get_delays_on_cube
    aoi.xpts, aoi.ypts, zpts,
    ^^^^^^^^
AttributeError: 'RasterRDR' object has no attribute 'xpts'

To Reproduce With RAiDER installed from source (main branch), run the following lines in Python

from RAiDER.delay import tropo_delay from RAiDER.llreader import RasterRDR from RAiDER.losreader import Zenith

Instantiate an "aoi" object to read lat/lon/height files

aoi = RasterRDR(rdr2geo_raster_paths[1], rdr2geo_raster_paths[0], rdr2geo_raster_paths[2])

los = Zenith()

Compute the troposphere delay along the Zenith

zen_wet, zen_dry = tropo_delay(burst.sensing_start, weather_model_path, aoi, los)

Expected behavior A clear and concise description of what you expected to happen.

Additional context The resolution of this issue is time sensitive as it requires changes in the code of the downstream modules using RAiDER. Please, provide an estimate on when this issue will be solved or alternative solutions to avoid it.

bbuzz31 commented 8 months ago

Hi @vbrancat RAiDER expects the AOI object to have a grid (xpts and ypts) of target locations set prior to the call to tropo_delay

Our workflow sets this in the add_buffer method of the AOI class, which is needed for delay calculations on a slant.

So you could do this:

from RAiDER.models.hres import HRES
wm  = HRES()
res = wm.getLLRes() # get the lat/lon spacing of HRES
aoi.add_buffer(res)

Since you're just calculating along Zenith, you don't actually need the buffer. To set up the output grid you need to give the AOI object xy/spacing:

## set evenly spaced output grid in degrees lat/lon
aoi.set_output_spacing(ll_res=0.1) 
aoi.set_output_xygrid()

Alternatively, you could set the output grid spacing in meters, which is internally converted to lat/lon spacing by approximating 100 km / degº

aoi._cube_spacing_m = 10000
aoi.set_output_spacing()
aoi.set_output_xygrid()
vbrancat commented 8 months ago

@bbuzz31 Thank you for the explanation. What I am trying to do is compute the hydrostatic and wet troposphere delay on a pre-defined lat/lon grid. The coordinates of the grid corresponds to slant range and azimuth times location of a coarse radar grid. Is there a way of doing this i.e., assign to the object a pre-defined lat/lon grid? If yes, how? :)

jlmaurer commented 2 months ago

Fixed by #627