From 33935b632cc2055f28f722a14f1012cf49acc6f7 Mon Sep 17 00:00:00 2001 From: jiangzhu Date: Mon, 21 Aug 2023 15:30:20 -0800 Subject: [PATCH 1/3] modify prep_hyp3.py to preapare hyp3-isce2 burst pairs for timeseries analysis with mintpy --- src/mintpy/prep_hyp3.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mintpy/prep_hyp3.py b/src/mintpy/prep_hyp3.py index d9282a3a5..35f0d0f44 100644 --- a/src/mintpy/prep_hyp3.py +++ b/src/mintpy/prep_hyp3.py @@ -27,11 +27,21 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): ''' # determine interferogram pair info and hyp3 metadata file name - sat, date1_str, date2_str, pol, res, soft, proc, ids, *_ = os.path.basename(fname).split('_') - job_id = '_'.join([sat, date1_str, date2_str, pol, res, soft, proc, ids]) + if len(os.path.basename(fname).split("_")[0]) != 2: + sat, date1_str, date2_str, pol, res, soft, proc, ids, *_ = os.path.basename(fname).split('_') + job_id = '_'.join([sat, date1_str, date2_str, pol, res, soft, proc, ids]) + date1 = dt.datetime.strptime(date1_str,'%Y%m%dT%H%M%S') + date2 = dt.datetime.strptime(date2_str,'%Y%m%dT%H%M%S') + # directory = os.path.dirname(fname) + # meta_file = f'{os.path.join(directory,job_id)}.txt' + else: + sat, frame, beammode, date1_str, date2_str, pol, res, ids, *_ = os.path.basename(fname).split('_') + job_id = '_'.join([sat, frame, beammode, date1_str, date2_str, pol, res, ids]) + date1 = dt.datetime.strptime(f'{date1_str}T000000','%Y%m%dT%H%M%S') + date2 = dt.datetime.strptime(f'{date2_str}T000000','%Y%m%dT%H%M%S') + directory = os.path.dirname(fname) meta_file = f'{os.path.join(directory,job_id)}.txt' - # open and read hyp3 metadata hyp3_meta = {} with open(meta_file) as f: @@ -96,15 +106,12 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): # add metadata that is only relevant to interferogram files if is_ifg: - date1 = dt.datetime.strptime(date1_str,'%Y%m%dT%H%M%S') - date2 = dt.datetime.strptime(date2_str,'%Y%m%dT%H%M%S') #date_avg = date1 + (date2 - date1) / 2 #date_avg_seconds = (date_avg - date_avg.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds() #meta['CENTER_LINE_UTC'] = date_avg_seconds meta['DATE12'] = f'{date1.strftime("%y%m%d")}-{date2.strftime("%y%m%d")}' meta['P_BASELINE_TOP_HDR'] = hyp3_meta['Baseline'] meta['P_BASELINE_BOTTOM_HDR'] = hyp3_meta['Baseline'] - return(meta) From 5fab0227eac683e6c79418bd26cbe4d13c151dca Mon Sep 17 00:00:00 2001 From: jiangzhu Date: Wed, 23 Aug 2023 15:24:16 -0800 Subject: [PATCH 2/3] add hyp3_isce2 burst INSAR product directory structure in the dir_structure.md --- docs/dir_structure.md | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/dir_structure.md b/docs/dir_structure.md index 82726e8de..41e2451e4 100644 --- a/docs/dir_structure.md +++ b/docs/dir_structure.md @@ -388,6 +388,10 @@ mintpy.load.waterMaskFile = $DATA_DIR/SanFranSenDT42/mask/watermask.msk Here is an example workflow: [smallbaselineApp_hyp3](https://nbviewer.jupyter.org/github/insarlab/MintPy-tutorial/blob/main/smallbaselineApp_hyp3.ipynb). +Currently, HyP3 produces two INSAR products. One is INSAR by HyP3_GAMMA, the other is burst_based INSAR by HyP3_ISCE2_burst. + +HyP3_GAMMA INSAR product + ``` $DATA_DIR/RidgecrestSenDT71 ├── hyp3 @@ -409,7 +413,6 @@ $DATA_DIR/RidgecrestSenDT71 └── mintpy └── RidgecrestSenDT71.txt ``` - The corresponding template options for `load_data`: ```cfg @@ -424,6 +427,43 @@ mintpy.load.azAngleFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*lv_phi_clip.t mintpy.load.waterMaskFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*water_mask_clip.tif ``` +HyP3_ISCE2 Burst INSAR product +``` +$DATA_DIR/2014_mount_edgecumbe +├── data +│ ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044 +│   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_dem_clipped.tif +│   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_corr_clipped.tif +│   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_lv_theta_clipped.tif +│   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_lv_phi_clipped.tif +│   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_unw_phase_clipped.tif +│   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_water_mask_clipped.tif +│   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044.txt +│   │   └── ... +│ ├── S1_372326_IW3_20141110_20141204_VV_INT80_1894 +│   │   ├── S1_372326_IW3_20141110_20141204_VV_INT80_1894_corr_clipped.tif +│   │   ├── S1_372326_IW3_20141110_20141204_VV_INT80_1894_unw_phase_clipped.tif +│   │   ├── S1_372326_IW3_20141110_20141204_VV_INT80_1894.txt +│   │   └── ... +│   └── ... +└── 2014_mount_edgecumbe.txt +``` + +The corresponding template options for `load_data`: + +```cfg +mintpy.load.processor = hyp3 +##---------interferogram datasets: +mintpy.load.unwFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_unw_phase_clipped.tif +mintpy.load.corFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_corr_clipped.tif +##---------geometry datasets: +mintpy.load.demFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_dem_clipped.tif +mintpy.load.incAngleFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_lv_theta_clipped.tif +mintpy.load.azAngleFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_lv_phi_clipped.tif +mintpy.load.waterMaskFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_water_mask_clipped.tif +mintpy.troposphericDelay.method = no +``` + ### [GMTSAR](https://github.com/gmtsar/gmtsar) ### Below is a recipe to prepare a stack of interferograms from Sentinel-1: From 8b3ec9c4c079fa66eb1d2901192595b58dc145f2 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Thu, 24 Aug 2023 10:58:29 +0800 Subject: [PATCH 3/3] refactoring --- docs/dir_structure.md | 38 +++++++++++++------------------------- src/mintpy/prep_hyp3.py | 38 ++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/docs/dir_structure.md b/docs/dir_structure.md index 41e2451e4..0ef30fc06 100644 --- a/docs/dir_structure.md +++ b/docs/dir_structure.md @@ -388,9 +388,9 @@ mintpy.load.waterMaskFile = $DATA_DIR/SanFranSenDT42/mask/watermask.msk Here is an example workflow: [smallbaselineApp_hyp3](https://nbviewer.jupyter.org/github/insarlab/MintPy-tutorial/blob/main/smallbaselineApp_hyp3.ipynb). -Currently, HyP3 produces two INSAR products. One is INSAR by HyP3_GAMMA, the other is burst_based INSAR by HyP3_ISCE2_burst. +HyP3 produces two types of InSAR products: 1) scene-wide products using Gamma and 2) burst-wide products using ISCE2. -HyP3_GAMMA INSAR product ++ INSAR_GAMMA directory structure: ``` $DATA_DIR/RidgecrestSenDT71 @@ -413,24 +413,12 @@ $DATA_DIR/RidgecrestSenDT71 └── mintpy └── RidgecrestSenDT71.txt ``` -The corresponding template options for `load_data`: -```cfg -mintpy.load.processor = hyp3 -##---------interferogram datasets: -mintpy.load.unwFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*unw_phase_clip.tif -mintpy.load.corFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*corr_clip.tif -##---------geometry datasets: -mintpy.load.demFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*dem_clip.tif -mintpy.load.incAngleFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*lv_theta_clip.tif -mintpy.load.azAngleFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*lv_phi_clip.tif -mintpy.load.waterMaskFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*water_mask_clip.tif -``` ++ INSAR_ISCE2_BURST directory structure: -HyP3_ISCE2 Burst INSAR product ``` -$DATA_DIR/2014_mount_edgecumbe -├── data +$DATA_DIR/MtEdgecumbeSenAT174 +├── hyp3 │ ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044 │   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_dem_clipped.tif │   │   ├── S1_372326_IW3_20141017_20141110_VV_INT80_7044_corr_clipped.tif @@ -446,7 +434,8 @@ $DATA_DIR/2014_mount_edgecumbe │   │   ├── S1_372326_IW3_20141110_20141204_VV_INT80_1894.txt │   │   └── ... │   └── ... -└── 2014_mount_edgecumbe.txt +└── mintpy + └── MtEdgecumbeSenAT174.txt ``` The corresponding template options for `load_data`: @@ -454,14 +443,13 @@ The corresponding template options for `load_data`: ```cfg mintpy.load.processor = hyp3 ##---------interferogram datasets: -mintpy.load.unwFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_unw_phase_clipped.tif -mintpy.load.corFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_corr_clipped.tif +mintpy.load.unwFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*unw_phase_clip.tif +mintpy.load.corFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*corr_clip.tif ##---------geometry datasets: -mintpy.load.demFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_dem_clipped.tif -mintpy.load.incAngleFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_lv_theta_clipped.tif -mintpy.load.azAngleFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_lv_phi_clipped.tif -mintpy.load.waterMaskFile = $DATA_DIR/2014_mount_edgecumbe/data/*/*_water_mask_clipped.tif -mintpy.troposphericDelay.method = no +mintpy.load.demFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*dem_clip.tif +mintpy.load.incAngleFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*lv_theta_clip.tif +mintpy.load.azAngleFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*lv_phi_clip.tif +mintpy.load.waterMaskFile = $DATA_DIR/RidgecrestSenDT71/hyp3/*/*water_mask_clip.tif ``` ### [GMTSAR](https://github.com/gmtsar/gmtsar) ### diff --git a/src/mintpy/prep_hyp3.py b/src/mintpy/prep_hyp3.py index 35f0d0f44..2817d1b1b 100644 --- a/src/mintpy/prep_hyp3.py +++ b/src/mintpy/prep_hyp3.py @@ -26,29 +26,29 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): Metadata dictionary (meta) ''' - # determine interferogram pair info and hyp3 metadata file name - if len(os.path.basename(fname).split("_")[0]) != 2: - sat, date1_str, date2_str, pol, res, soft, proc, ids, *_ = os.path.basename(fname).split('_') - job_id = '_'.join([sat, date1_str, date2_str, pol, res, soft, proc, ids]) - date1 = dt.datetime.strptime(date1_str,'%Y%m%dT%H%M%S') - date2 = dt.datetime.strptime(date2_str,'%Y%m%dT%H%M%S') - # directory = os.path.dirname(fname) - # meta_file = f'{os.path.join(directory,job_id)}.txt' - else: - sat, frame, beammode, date1_str, date2_str, pol, res, ids, *_ = os.path.basename(fname).split('_') - job_id = '_'.join([sat, frame, beammode, date1_str, date2_str, pol, res, ids]) - date1 = dt.datetime.strptime(f'{date1_str}T000000','%Y%m%dT%H%M%S') - date2 = dt.datetime.strptime(f'{date2_str}T000000','%Y%m%dT%H%M%S') - - directory = os.path.dirname(fname) - meta_file = f'{os.path.join(directory,job_id)}.txt' - # open and read hyp3 metadata + # read hyp3 metadata file + # e.g.: burst-wide product using ISCE2: {SAT}_{FRAME}_{SUBSWATH}_{DATE1}_{DATE2}_{POL}_{RES}_{IDS}.txt + # scene-wide product using Gamma: {SAT}_{DATE1}_{DATE2}_{POL}_{RES}_{SOFT}_{PROC}_{IDS}.txt + job_id = '_'.join(os.path.basename(fname).split('_')[:8]) + meta_file = os.path.join(os.path.dirname(fname), f'{job_id}.txt') hyp3_meta = {} with open(meta_file) as f: for line in f: key, value = line.strip().replace(' ','').split(':')[:2] hyp3_meta[key] = value + # get date1/2 objects + if job_id.split('_')[2].startswith('IW'): + # burst-wide product using ISCE2 + 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') + # add universal hyp3 metadata meta['PROCESSOR'] = 'hyp3' meta['CENTER_LINE_UTC'] = hyp3_meta['UTCtime'] @@ -106,12 +106,10 @@ def add_hyp3_metadata(fname, meta, is_ifg=True): # add metadata that is only relevant to interferogram files if is_ifg: - #date_avg = date1 + (date2 - date1) / 2 - #date_avg_seconds = (date_avg - date_avg.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds() - #meta['CENTER_LINE_UTC'] = date_avg_seconds meta['DATE12'] = f'{date1.strftime("%y%m%d")}-{date2.strftime("%y%m%d")}' meta['P_BASELINE_TOP_HDR'] = hyp3_meta['Baseline'] meta['P_BASELINE_BOTTOM_HDR'] = hyp3_meta['Baseline'] + return(meta)