insarlab / MintPy

Miami InSAR time-series software in Python
https://mintpy.readthedocs.io
Other
560 stars 245 forks source link

UTM conversion raise OutOfRangeError in `prep_hyp3.py` #1098

Closed swdmike closed 9 months ago

swdmike commented 9 months ago

Description of the problem

Recently, I encountered a problem that I had not come across before while using the combination of Hyp3 and MintPy. MintPy threw an error: "OutOfRangeError('easting out of range (must be between 100,000 m and 999,999 m)')." when doing UTM-WGS84 convertsion.

Upon investigating the data produced by Hyp3, I discovered that the west was 88040. Therefore, if the default strict mode of utm2latlon is enabled, it does pose an issue. I am unsure if this is a problem with Hyp3, but after modifying the code in MintPy, the program was able to run smoothly. I am not certain if setting it to non-strict as default mode is feasible or if it would be possible for MintPy to provide an option.

Full script that generated the error

hyp3:

search_results = asf.geo_search(
        platform=asf.SENTINEL1,
        intersectsWith='POINT(120.0392 28.8976)',
        start='2022-01-01',
        end='2023-01-01',
        processingLevel=asf.SLC,
        beamMode=asf.IW,
        flightDirection=asf.ASCENDING,
    )

mintpy:

files = data_dir.glob('*/*_dem.tif')
overlap = get_common_overlap(files)
clip_hyp3_products_to_common_overlap(data_dir, overlap)

mintpy_config = work_dir / 'mintpy_config.txt'
mintpy_config.write_text(
f"""
mintpy.compute.cluster       = local
mintpy.load.processor        = hyp3
##---------interferogram datasets:
mintpy.load.unwFile          = {data_dir}/*/*_unw_phase_clipped.tif
mintpy.load.corFile          = {data_dir}/*/*_corr_clipped.tif
##---------geometry datasets:
mintpy.load.demFile          = {data_dir}/*/*_dem_clipped.tif
mintpy.load.incAngleFile     = {data_dir}/*/*_lv_theta_clipped.tif
mintpy.load.azAngleFile      = {data_dir}/*/*_lv_phi_clipped.tif
""")

Full error message

Traceback (most recent call last):
  File "/usr/local/bin/prep_hyp3.py", line 8, in <module>
    sys.exit(main())
  File "/root/tools/MintPy/src/mintpy/cli/prep_hyp3.py", line 94, in main
    prep_hyp3(inps)
  File "/root/tools/MintPy/src/mintpy/prep_hyp3.py", line 123, in prep_hyp3
    meta = add_hyp3_metadata(fname, meta, is_ifg=is_ifg)
  File "/root/tools/MintPy/src/mintpy/prep_hyp3.py", line 63, in add_hyp3_metadata
    N, W = ut.utm2latlon(meta, W, N)
  File "/root/tools/MintPy/src/mintpy/utils/utils0.py", line 322, in utm2latlon
    lat, lon = utm.to_latlon(easting, northing, zone_num, northern=northern)
  File "/usr/local/lib/python3.10/site-packages/utm/conversion.py", line 124, in to_latlon
    raise OutOfRangeError('easting out of range (must be between 100,000 m and 999,999 m)')
utm.error.OutOfRangeError: easting out of range (must be between 100,000 m and 999,999 m)

MintPy Code Modification

lat, lon = utm.to_latlon(easting, northing, zone_num, northern=northern, strict=False)

System information

welcome[bot] commented 9 months ago

👋 Thanks for opening your first issue here! Please filled out the template with as much details as possible. We appreciate that you took the time to contribute! Make sure you read our contributing guidelines.

yunjunz commented 9 months ago

Thank you @swdmike for reporting this issue, which is raised from the mintpy code. Having coordinates outside the range sounds very reasonable to me, as explained in the utm repo (https://github.com/Turbo87/utm/pull/22) as well. Your suggested modification looks good to me. Could you issue a PR for this?

ditafaith commented 5 months ago

Description of the problem

Recently, I encountered a problem that I had not come across before while using the combination of Hyp3 and MintPy. MintPy threw an error: "OutOfRangeError('easting out of range (must be between 100,000 m and 999,999 m)')." when doing UTM-WGS84 convertsion.

Upon investigating the data produced by Hyp3, I discovered that the west was 88040. Therefore, if the default strict mode of utm2latlon is enabled, it does pose an issue. I am unsure if this is a problem with Hyp3, but after modifying the code in MintPy, the program was able to run smoothly. I am not certain if setting it to non-strict as default mode is feasible or if it would be possible for MintPy to provide an option.

Full script that generated the error

hyp3:

search_results = asf.geo_search(
        platform=asf.SENTINEL1,
        intersectsWith='POINT(120.0392 28.8976)',
        start='2022-01-01',
        end='2023-01-01',
        processingLevel=asf.SLC,
        beamMode=asf.IW,
        flightDirection=asf.ASCENDING,
    )

mintpy:

files = data_dir.glob('*/*_dem.tif')
overlap = get_common_overlap(files)
clip_hyp3_products_to_common_overlap(data_dir, overlap)

mintpy_config = work_dir / 'mintpy_config.txt'
mintpy_config.write_text(
f"""
mintpy.compute.cluster       = local
mintpy.load.processor        = hyp3
##---------interferogram datasets:
mintpy.load.unwFile          = {data_dir}/*/*_unw_phase_clipped.tif
mintpy.load.corFile          = {data_dir}/*/*_corr_clipped.tif
##---------geometry datasets:
mintpy.load.demFile          = {data_dir}/*/*_dem_clipped.tif
mintpy.load.incAngleFile     = {data_dir}/*/*_lv_theta_clipped.tif
mintpy.load.azAngleFile      = {data_dir}/*/*_lv_phi_clipped.tif
""")

Full error message

Traceback (most recent call last):
  File "/usr/local/bin/prep_hyp3.py", line 8, in <module>
    sys.exit(main())
  File "/root/tools/MintPy/src/mintpy/cli/prep_hyp3.py", line 94, in main
    prep_hyp3(inps)
  File "/root/tools/MintPy/src/mintpy/prep_hyp3.py", line 123, in prep_hyp3
    meta = add_hyp3_metadata(fname, meta, is_ifg=is_ifg)
  File "/root/tools/MintPy/src/mintpy/prep_hyp3.py", line 63, in add_hyp3_metadata
    N, W = ut.utm2latlon(meta, W, N)
  File "/root/tools/MintPy/src/mintpy/utils/utils0.py", line 322, in utm2latlon
    lat, lon = utm.to_latlon(easting, northing, zone_num, northern=northern)
  File "/usr/local/lib/python3.10/site-packages/utm/conversion.py", line 124, in to_latlon
    raise OutOfRangeError('easting out of range (must be between 100,000 m and 999,999 m)')
utm.error.OutOfRangeError: easting out of range (must be between 100,000 m and 999,999 m)

MintPy Code Modification

lat, lon = utm.to_latlon(easting, northing, zone_num, northern=northern, strict=False)

System information

  • Operating system: Ubuntu 18
  • Python environment: 3.10
  • MintPy version: 1.5.2

Hi @swdmike Please correct me if I am misunderstanding this issue. Since MintPy doesn't support converting UTM to WGS84 lat/lon, then prep_hyp3 is prepared to all hyp3 products, then the new input files become possible to process using latest version of MintPy. Is it correct?