diff --git a/src/mintpy/prep_hyp3.py b/src/mintpy/prep_hyp3.py index dbd1fc874..2de4066d7 100644 --- a/src/mintpy/prep_hyp3.py +++ b/src/mintpy/prep_hyp3.py @@ -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') @@ -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 ######################################################################### diff --git a/tests/configs/RidgecrestSenDT71.txt b/tests/configs/RidgecrestSenDT71.txt index cb966c44d..1b5344a69 100644 --- a/tests/configs/RidgecrestSenDT71.txt +++ b/tests/configs/RidgecrestSenDT71.txt @@ -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