From 0c80203b6acce76cb2bf39ebf20bf81acbfc2e26 Mon Sep 17 00:00:00 2001 From: KavyaKinjalk Date: Mon, 5 May 2025 03:52:20 -0400 Subject: [PATCH 1/3] add support for Hyp3 isce2-multi-burst format. Added relative orbits for HDF-EOS5 metadata. --- src/mintpy/prep_hyp3.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/mintpy/prep_hyp3.py b/src/mintpy/prep_hyp3.py index d24586601..a5e561d81 100644 --- a/src/mintpy/prep_hyp3.py +++ b/src/mintpy/prep_hyp3.py @@ -24,7 +24,18 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): content: Reference Granule: S1_213524_IW1_20170411T133605_VV_BD30-BURST ... - 2. gamma_scene (scene-wide product using Gamma) metadata file: + + 2. isce2_multi_burst (multi-burst product using ISCE2): + - Metadata filename format: + {SAT}_{PATH}_{LON_L}_{LON_U}_{LAT_L}_{LAT_U}_{DATE1}_{DATE2}_{POL}_{RES}_{JOBID} + - Example: + S1A_064_E053_1_N27_3_E054_1_N27_8_20200604_20200616_VV_INT80_7EB5.txt + - Content: + Reference Granule: S1_290876_IW1_20200604T005150_VV_XXXX-BURST, S1_290875_IW1_20200604T005147_VV_XXXX-BURST + Secondary Granule: S1_290876_IW1_20200616T005150_VV_YYYY-BURST, S1_290875_IW1_20200616T005147_VV_YYYY-BURST + ... + + 3. gamma_scene (scene-wide product using Gamma) metadata file: format: {SAT}_{DATE1}_{DATE2}_{POL}_{RES}_{SOFT}_{PROC}_{IDS}.txt example: S1AA_20190610T135156_20190622T135157_VVP012_INT80_G_ueF_F8BF.txt content: @@ -38,11 +49,17 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): ''' # job_id -> prod_type and date1/2 objects - job_id = '_'.join(os.path.basename(fname).split('_')[:8]) - if job_id.split('_')[2].startswith('IW'): + job_id = '_'.join(os.path.splitext(os.path.basename(os.path.dirname(fname)))[0].split('_')) + parts = job_id.split('_') + + if parts[2].startswith('IW'): # burst-wide product using ISCE2 prod_type = 'isce2_burst' date1, date2 = (dt.datetime.strptime(x,'%Y%m%d') for x in job_id.split('_')[3:5]) + elif parts[10].isdigit() and parts[11].isdigit(): + prod_type = 'isce2_multi_burst' + date1, date2 = (dt.datetime.strptime(x, '%Y%m%d') for x in parts[10:12]) + print(f"date1: {date1}, date2: {date2}") else: # scene-wide product using Gamma prod_type = 'gamma_scene' @@ -55,7 +72,7 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): for line in f: key, value = line.strip().replace(' ','').split(':')[:2] hyp3_meta[key] = value - ref_granule = hyp3_meta['ReferenceGranule'] + ref_granule = hyp3_meta['ReferenceGranule'].split(',')[0].strip() # add universal hyp3 metadata meta['PROCESSOR'] = 'hyp3' @@ -118,11 +135,17 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): # beam_mode meta['beam_mode'] = 'IW' - if prod_type == 'isce2_burst': + if prod_type == 'isce2_burst' or prod_type == 'isce2_multi_burst': # burst-wide product using ISCE2 meta['beam_swath'] = job_id.split('_')[2][2:] - # relative_orbit [to be added] + # relative_orbit -> https://forum.step.esa.int/t/sentinel-1-relative-orbit-from-filename/7042 + abs_orbit = int(hyp3_meta['ReferenceOrbitNumber']) + if job_id.startswith('S1A'): + meta['relative_orbit'] = ((abs_orbit - 73) % 175) + 1 + elif job_id.startswith('S1B'): + meta['relative_orbit'] = ((abs_orbit - 202) % 175) + 1 + # first/last_frame [to be added] else: @@ -137,7 +160,7 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): meta['relative_orbit'] = ((abs_orbit - 202) % 175) + 1 else: # add equation for Sentinel-C/D in the future - raise ValueError('Un-recognized Sentinel-1 satellite from {ref_granule}!') + raise ValueError(f'Un-recognized Sentinel-1 satellite from {ref_granule}!') # first/last_frame [to be completed] t0, t1 = ref_granule.split('_')[-5:-3] From dfbbe7284d5b0bf04ce1a8f00e6df50cb6a0df58 Mon Sep 17 00:00:00 2001 From: KavyaKinjalk Date: Mon, 5 May 2025 04:18:09 -0400 Subject: [PATCH 2/3] Remove debug statement and make it easier to read --- src/mintpy/prep_hyp3.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mintpy/prep_hyp3.py b/src/mintpy/prep_hyp3.py index a5e561d81..73589a839 100644 --- a/src/mintpy/prep_hyp3.py +++ b/src/mintpy/prep_hyp3.py @@ -52,19 +52,25 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): job_id = '_'.join(os.path.splitext(os.path.basename(os.path.dirname(fname)))[0].split('_')) parts = job_id.split('_') + if len(parts) < 8: + raise ValueError(f"Unexpected format: {job_id}") + if parts[2].startswith('IW'): # burst-wide product using ISCE2 prod_type = 'isce2_burst' - date1, date2 = (dt.datetime.strptime(x,'%Y%m%d') for x in job_id.split('_')[3:5]) - elif parts[10].isdigit() and parts[11].isdigit(): + date1 = dt.datetime.strptime(parts[3], '%Y%m%d') + date2 = dt.datetime.strptime(parts[4], '%Y%m%d') + + elif len(parts) >= 12 and parts[10].isdigit() and parts[11].isdigit(): prod_type = 'isce2_multi_burst' - date1, date2 = (dt.datetime.strptime(x, '%Y%m%d') for x in parts[10:12]) - print(f"date1: {date1}, date2: {date2}") + date1 = dt.datetime.strptime(parts[10], '%Y%m%d') + date2 = dt.datetime.strptime(parts[11], '%Y%m%d') + else: # scene-wide product using Gamma prod_type = 'gamma_scene' - date1, date2 = (dt.datetime.strptime(x,'%Y%m%dT%H%M%S') for x in job_id.split('_')[1:3]) - + date1 = dt.datetime.strptime(parts[1], '%Y%m%dT%H%M%S') + date2 = dt.datetime.strptime(parts[2], '%Y%m%dT%H%M%S') # read hyp3 metadata file meta_file = os.path.join(os.path.dirname(fname), f'{job_id}.txt') hyp3_meta = {} From bcdc72b26c3174ebd4212367a957c72dff5687fc Mon Sep 17 00:00:00 2001 From: KavyaKinjalk Date: Mon, 5 May 2025 04:18:57 -0400 Subject: [PATCH 3/3] Remove debug statement and make it easier to read --- src/mintpy/prep_hyp3.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mintpy/prep_hyp3.py b/src/mintpy/prep_hyp3.py index 73589a839..f4b69ae98 100644 --- a/src/mintpy/prep_hyp3.py +++ b/src/mintpy/prep_hyp3.py @@ -71,6 +71,7 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): prod_type = 'gamma_scene' date1 = dt.datetime.strptime(parts[1], '%Y%m%dT%H%M%S') date2 = dt.datetime.strptime(parts[2], '%Y%m%dT%H%M%S') + # read hyp3 metadata file meta_file = os.path.join(os.path.dirname(fname), f'{job_id}.txt') hyp3_meta = {}