Skip to content

Commit

Permalink
tropo_pyaps3: bugfix for hyp3 product
Browse files Browse the repository at this point in the history
+ tropo_pyaps3: bugfix for hyp3 products in UTM coordinates:
   - calc_delay_timeseries(): remove the call of `ut.to_latlon()` while preparing the pixel-wised 2D lat/lon matrices, as `ut.get_lat_lon()` handled the UTM/latlon conversion already in insarlab#1052

+ replace `ut.to_latlon()` with `ut.utm2latlon()` as the later supported more file types, in the following occurrences:
   - tropo_pyaps3.get_bounding_box()
   - utils.utils.prepare_geo_los_geometry()

+ utils.utils0.get_lat_lon(): print out UTM/latlon conversion message, to help future tracking/diagnose

+ prep_hyp3: convert UTM to lat/lon for LAT/LON_REF1/2/3/4
  • Loading branch information
yunjunz committed Aug 8, 2023
1 parent 86f693d commit 8f26b29
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/mintpy/prep_hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


#########################################################################
def add_hyp3_metadata(fname,meta,is_ifg=True):
def add_hyp3_metadata(fname, meta, is_ifg=True):
'''Read/extract attribute data from HyP3 metadata file and add to metadata dictionary
Inputs:
*unw_phase.tif, *corr.tif file name, *dem.tif, *inc_map.tif, e.g.
Expand Down Expand Up @@ -57,6 +57,10 @@ def add_hyp3_metadata(fname,meta,is_ifg=True):
S = N + float(meta['Y_STEP']) * int(meta['LENGTH'])
E = W + float(meta['X_STEP']) * int(meta['WIDTH'])

# convert UTM to lat/lon
N, W = ut.utm2latlon(meta, W, N)
S, E = ut.utm2latlon(meta, E, S)

if meta['ORBIT_DIRECTION'] == 'ASCENDING':
meta['LAT_REF1'] = str(S)
meta['LAT_REF2'] = str(S)
Expand Down
8 changes: 2 additions & 6 deletions src/mintpy/tropo_pyaps3.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def get_bounding_box(meta, geom_file=None):
# e.g. meters for UTM projection from ASF HyP3
y_unit = meta.get('Y_UNIT', 'degrees').lower()
if not y_unit.startswith('deg'):
lat0, lon0 = ut.to_latlon(meta['OG_FILE_PATH'], lon0, lat0)
lat1, lon1 = ut.to_latlon(meta['OG_FILE_PATH'], lon1, lat1)
lat0, lon0 = ut.utm2latlon(meta, easting=lon0, northing=lat0)
lat1, lon1 = ut.utm2latlon(meta, easting=lon1, northing=lat1)

else:
# radar coordinates
Expand Down Expand Up @@ -561,10 +561,6 @@ def calc_delay_timeseries(inps):
# for lookup table in geo-coded (gamma, roipac) and obs. in geo-coord
inps.lat, inps.lon = ut.get_lat_lon(geom_obj.metadata)

# convert coordinates to lat/lon, e.g. from UTM for ASF HyPP3
if not geom_obj.metadata.get('Y_UNIT', 'degrees').startswith('deg'):
inps.lat, inps.lon = ut.to_latlon(inps.atr['OG_FILE_PATH'], inps.lon, inps.lat)

else:
# for lookup table in geo-coded (gamma, roipac) and obs. in radar-coord
inps.lat, inps.lon = ut.get_lat_lon_rdc(inps.atr)
Expand Down
4 changes: 2 additions & 2 deletions src/mintpy/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ def prepare_geo_los_geometry(geom_file, unit='rad'):
E = W + x_step * width

# SNWE in meter --> degree
lat0, lon0 = to_latlon(atr['OG_FILE_PATH'], W, N)
lat1, lon1 = to_latlon(atr['OG_FILE_PATH'], E, S)
lat0, lon0 = utm2latlon(atr, W, N)
lat1, lon1 = utm2latlon(atr, E, S)
lat_step = (lat1 - lat0) / length
lon_step = (lon1 - lon0) / width

Expand Down
1 change: 1 addition & 0 deletions src/mintpy/utils/utils0.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def get_lat_lon(meta, geom_file=None, box=None, dimension=2, ystep=1, xstep=1):

# UTM to lat/lon
if not meta['Y_UNIT'].startswith('deg') and 'UTM_ZONE' in meta.keys():
print('UTM coordinates detected, convert UTM into lat/lon')
lats, lons = utm2latlon(meta, easting=lons, northing=lats)

else:
Expand Down

0 comments on commit 8f26b29

Please sign in to comment.