Skip to content

Commit

Permalink
Add HDF-EOS5 metadata for HyP3 products (#1180)
Browse files Browse the repository at this point in the history
+ prep_hyp3: add the following new metadata for HDF-EOS5
   - beam_swath
   - relative_orbit
   - startUTC
   - stopUTC

+ tests/configs/RidgecrestSenDT71: remove the manual setup of relative_orbit, since it's now automatically extracted.

---------

Co-authored-by: Zhang Yunjun <[email protected]>
  • Loading branch information
forrestfwilliams and yunjunz authored Apr 25, 2024
1 parent 3ebf6c6 commit 4e3ad9f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
39 changes: 35 additions & 4 deletions src/mintpy/prep_hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ def add_hyp3_metadata(fname, meta, is_ifg=True):
key, value = line.strip().replace(' ','').split(':')[:2]
hyp3_meta[key] = value

# get date1/2 objects
# get product type and the correponding insar processor
if job_id.split('_')[2].startswith('IW'):
# burst-wide product using ISCE2
prod_type = 'isce2_burst'
else:
# scene-wide product using Gamma
prod_type = 'gamma_scene'

# get date1/2 objects
if prod_type == 'isce2_burst':
date1_str, date2_str = job_id.split('_')[3:5]
date1 = dt.datetime.strptime(f'{date1_str}','%Y%m%d')
date2 = dt.datetime.strptime(f'{date2_str}','%Y%m%d')
else:
# scene-wide product using Gamma
date1_str, date2_str = job_id.split('_')[1:3]
date1 = dt.datetime.strptime(date1_str,'%Y%m%dT%H%M%S')
date2 = dt.datetime.strptime(date2_str,'%Y%m%dT%H%M%S')
Expand Down Expand Up @@ -107,11 +113,36 @@ def add_hyp3_metadata(fname, meta, is_ifg=True):
meta['P_BASELINE_BOTTOM_HDR'] = hyp3_meta['Baseline']

# HDF-EOS5 metadata
if hyp3_meta['ReferenceGranule'].startswith('S1'):
ref_granule = hyp3_meta['ReferenceGranule']
if ref_granule.startswith('S1'):
# beam_mode
meta['beam_mode'] = 'IW'

# beam_swath
if prod_type == 'isce2_burst':
meta['beam_swath'] = job_id.split('_')[2][2:]
else:
meta['beam_swath'] = '123'

# relative_orbit
if ref_granule.startswith('S1A'):
meta['relative_orbit'] = ((int(hyp3_meta['ReferenceOrbitNumber']) - 73) % 175) + 1
elif ref_granule.startswith('S1B'):
meta['relative_orbit'] = ((int(hyp3_meta['ReferenceOrbitNumber']) - 202) % 175) + 1
else:
raise ValueError('Un-recognized Sentinel-1 satellite from {ref_granule}!')

# first/last_frame [from start/stopUTC]
# NOTE by Yunjun, Apr 2024: ascending node time is needed to calculate the first/last frame
# based on the start/end UTC time.
t0, t1 = ref_granule.split('_')[-5:-3]
meta['startUTC'] = dt.datetime.strptime(t0, '%Y%m%dT%H%M%S').strftime('%Y-%m-%d %H:%M:%S.%f')
meta['stopUTC'] = dt.datetime.strptime(t1, '%Y%m%dT%H%M%S').strftime('%Y-%m-%d %H:%M:%S.%f')

# unwrap_method
meta['unwrap_method'] = hyp3_meta['Unwrappingtype']

return(meta)
return meta


#########################################################################
Expand Down
3 changes: 0 additions & 3 deletions tests/configs/RidgecrestSenDT71.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ mintpy.save.hdfEos5 = yes
mintpy.save.hdfEos5.subset = yes
mintpy.plot = no
mintpy.plot.maxMemory = 2

##————————————————————————————— HDF-EOS5 Attributes -—————————————————————————##
relative_orbit = 71

0 comments on commit 4e3ad9f

Please sign in to comment.