Skip to content

Commit

Permalink
prep_hyp3: support burst-wide interferograms from hyp3-isce2 (#1074)
Browse files Browse the repository at this point in the history
* prep_hyp3: support burst-wide interferogram from ASF hyp3-isce2 processor/instance

* docs/dir_structure: add example directory structure from ASF hyp3_isce2

---------

Co-authored-by: Zhang Yunjun <yunjunz@outlook.com>
  • Loading branch information
cirrusasf and yunjunz committed Aug 25, 2023
1 parent b800d64 commit 1493c9a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
28 changes: 28 additions & 0 deletions docs/dir_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

HyP3 produces two types of InSAR products: 1) scene-wide products using Gamma and 2) burst-wide products using ISCE2.

+ INSAR_GAMMA directory structure:

```
$DATA_DIR/RidgecrestSenDT71
├── hyp3
Expand All @@ -410,6 +414,30 @@ $DATA_DIR/RidgecrestSenDT71
└── RidgecrestSenDT71.txt
```

+ INSAR_ISCE2_BURST directory structure:

```
$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
│   │   ├── 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
│   │   └── ...
│   └── ...
└── mintpy
└── MtEdgecumbeSenAT174.txt
```

The corresponding template options for `load_data`:

```cfg
Expand Down
29 changes: 17 additions & 12 deletions src/mintpy/prep_hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,29 @@ def add_hyp3_metadata(fname, meta, is_ifg=True):
Metadata dictionary (meta)
'''

# 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])
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']
Expand Down Expand Up @@ -96,11 +106,6 @@ 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']
Expand Down

0 comments on commit 1493c9a

Please sign in to comment.