GeoscienceAustralia / PyRate

A Python tool for estimating velocity and time-series from Interferometric Synthetic Aperture Radar (InSAR) data.
https://geoscienceaustralia.github.io/PyRate/
Apache License 2.0
199 stars 69 forks source link

Change so reference pixel is validated in function rather than callin… #357

Closed adeane-ga closed 2 years ago

adeane-ga commented 2 years ago

This pull request contains a simple change in the way PyRate validates the custom (user defined) reference pixel location.

Caveat: There was no test originally, so this issue was not picked up. I have also not created a test yet. I will aim to do that either before or after this gets merged.

The Problem PyRate gives configuration options for the user to determine where the reference pixel will be refx and refy in longitude and latitude. There is also the option to crop the dataset with user defined coordinates so that PyRate only processes a smaller extent with ifgcropopt: 3. It is common for a user to use both of these options. The reference pixel selection is done during the correct step, whilst the cropping is conducted prior, in the prepifg step.

It results in this error:

Traceback (most recent call last):
  File "/home/547/ad6200/PyRateVenv/bin/pyrate", line 11, in <module>
    load_entry_point('Py-Rate==0.6.0', 'console_scripts', 'pyrate')()
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/main.py", line 116, in main
    correct.main(config)
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/correct.py", line 142, in main
    return correct_ifgs(config)
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/correct.py", line 226, in correct_ifgs
    params[C.REFX_FOUND], params[C.REFY_FOUND] = ref_pixel_calc_wrapper(params)
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/core/refpixel.py", line 423, in ref_pixel_calc_wrapper
    __validate_supplied_lat_lon(params)
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/core/refpixel.py", line 401, in __validate_supplied_lat_lon
    C.IFG_XLAST], params[C.IFG_YLAST])
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/core/prepifg_helper.py", line 81, in get_analysis_extent
    return _get_extents(rasters, crop_opt, user_exts)
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/core/prepifg_helper.py", line 146, in _get_extents
    extents = _custom_bounds(ifgs, *user_exts)
  File "/home/547/ad6200/PyRateVenv/lib/python3.7/site-packages/pyrate/core/prepifg_helper.py", line 332, in _custom_bounds
    raise PreprocessError(msg)
pyrate.core.prepifg_helper.PreprocessError: Cropped image bounds are outside the original image bounds

Solution As the above user supplied cropping coordinates check is not relevant during this step, I have removed the call to the get_analysis_extent() from the prepifg_helper.py and implemented a validation of the user supplied reference pixel by getting dataset extents independently from within the __validate_supplied_lat_lon() function itself.

In summary

Old Code: https://github.com/GeoscienceAustralia/PyRate/blob/d7222c27d98aa4339a5271713a9c3155f9826736/pyrate/core/refpixel.py#L389-L410

New Code: https://github.com/GeoscienceAustralia/PyRate/blob/4aae0b95bc56aca9d7193045307d2f670eceef9b/pyrate/core/refpixel.py#L390-L419

adeane-ga commented 2 years ago

Closing this PR because 0.6.0 release already occurred. Will create a new PR to merge this into develop.

adeane-ga commented 2 years ago

Closing this PR because 0.6.0 release already occurred. Will create a new PR to merge this into develop.