Skip to content

Commit 18f251e

Browse files
Virginia Brancatovbrancat
authored andcommitted
WIP: Workflow rubbersheet (#771)
* Add rubbersheet parameters to insar schema and defaults runconfig * Rubbersheet runconfig * Rubbersheet main * Add rubbersheet as InSAR workflow step * Correct mispelled out_paths for rubbersheet * Copying culled dense offsets from RIFG to RUNW * Add culled offsets among the datasets to geocode * Turn off rubbersheet when executing insar.py CPU unit test * Separate median filter kernel from moving average kernel * Add rubbersheet unit test and its CMake dependency * Remove horizontal comments for dense offsets unit test runconfig * Correct mistake in smoothing function * Simply mask application for range/azmuth dense offsets * Simplify code for geocoding along track and slant range offsets * Remove unnecessary parenthesis for rubbersheet step execution * Simply copy of datasets from RIFG to RUNW * Have one line function comments in rubbersheet unit test * Add checks to run rubbersheet only if user has enabled dense offsets * Modify schemas, defaults and rubbersheet.py to optionally apply mask refinement * Doc string for functions in rubbersheet * Expose number of iteration for fill_smoothed and check for residual NaNs * Remove hybrid outlier filling method (redundancy of solutions) * Reorganize rubbersheet parameters in schema and expose more filter options * Organize rubbersheet schema and expose more filter options * Correct formatting * Alphabetical order of module imports * Rename mask3x3 to mask_refine * Check dense offsets and rubbersheet enabled flag in insar_runconfig.py * Sum rubbersheet offsets to geo2rdr offsets * Remove comment on failing rubbersheeting without flag enabled * Expose interpolation method to the user * Correct description of VRT file generation * Simplify string notation Co-authored-by: vbrancat <[email protected]>
1 parent 51b304e commit 18f251e

File tree

14 files changed

+727
-31
lines changed

14 files changed

+727
-31
lines changed

python/packages/pybind_nisar/workflows/geocode_insar.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ def run(cfg, runw_hdf5, output_hdf5):
9898
if not geocode_this_dataset:
9999
continue
100100

101+
if dataset_name in ['alongTrackOffset','slantRangeOffset']:
102+
src_group_path = f"/science/LSAR/RUNW/swaths/frequency{freq}/pixelOffsets/{pol}"
103+
dst_group_path = f"/science/LSAR/GUNW/grids/frequency{freq}/pixelOffsets/{pol}"
104+
105+
# prepare input raster
106+
101107
if (dataset_name == "layoverShadowMask"):
102108
# prepare input raster
103109
raster_ref = scratch_path / 'rdr2geo' / f'freq{freq}' / 'mask.rdr'
@@ -119,6 +125,7 @@ def run(cfg, runw_hdf5, output_hdf5):
119125
radar_grid = radar_grid_multilook
120126
dataset_path = f"{dst_group_path}/{dataset_name}"
121127

128+
122129
geocoded_dataset = dst_h5[dataset_path]
123130

124131
# Construct the output ratster directly from HDF5 dataset
@@ -168,6 +175,7 @@ def run(cfg, runw_hdf5, output_hdf5):
168175
info_channel.log(f"Successfully ran geocode in {t_all_elapsed:.3f} seconds")
169176

170177

178+
171179
if __name__ == "__main__":
172180
"""
173181
run geocode from command line

python/packages/pybind_nisar/workflows/geocode_insar_runconfig.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def yaml_check(self):
4646
self.cfg['processing']['geocode']['datasets'] = {}
4747

4848
# default to True for datasets not found
49-
gunw_datasets = ["connectedComponents", "coherenceMagnitude", "unwrappedPhase", "layoverShadowMask"]
49+
gunw_datasets = ["connectedComponents", "coherenceMagnitude", "unwrappedPhase",
50+
"alongTrackOffset", "slantRangeOffset", "layoverShadowMask"]
5051
for gunw_dataset in gunw_datasets:
5152
if gunw_dataset not in self.cfg['processing']['geocode']:
5253
self.cfg['processing']['geocode']['datasets'][gunw_dataset] = True

python/packages/pybind_nisar/workflows/insar.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import journal
55
from pybind_nisar.workflows import (crossmul, dense_offsets, geo2rdr,
66
geocode_insar, h5_prep, rdr2geo,
7-
resample_slc, unwrap)
7+
resample_slc, rubbersheet, unwrap)
88
from pybind_nisar.workflows.insar_runconfig import InsarRunConfig
99
from pybind_nisar.workflows.persistence import Persistence
1010
from pybind_nisar.workflows.yaml_argparse import YamlArgparse
@@ -15,6 +15,7 @@ def run(cfg: dict, out_paths: dict, run_steps: dict):
1515
Run INSAR workflow with parameters in cfg dictionary
1616
'''
1717
info_channel = journal.info("insar.run")
18+
error_channel = journal.error('insar.run')
1819
info_channel.log("starting INSAR")
1920

2021
t_all = time.time()
@@ -32,6 +33,10 @@ def run(cfg: dict, out_paths: dict, run_steps: dict):
3233
(cfg['processing']['dense_offsets']['enabled']):
3334
dense_offsets.run(cfg)
3435

36+
if run_steps['rubbersheet'] and \
37+
cfg['processing']['rubbersheet']['enabled']:
38+
rubbersheet.run(cfg, out_paths['RIFG'])
39+
3540
if run_steps['crossmul']:
3641
crossmul.run(cfg, out_paths['RIFG'])
3742

python/packages/pybind_nisar/workflows/insar_runconfig.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ def yaml_check(self):
1414
'''
1515
scratch_path = self.cfg['ProductPathGroup']['ScratchPath']
1616

17+
# If dense_offsets is disabled and rubbersheet is enabled
18+
# throw an exception and do not run the workflow
19+
if not self.cfg['processing']['dense_offsets']['enabled'] and \
20+
self.cfg['processing']['rubbersheet']['enabled']:
21+
err_str = "Dense_offsets must be enabled to run rubbersheet"
22+
error_channel.log(err_str)
23+
raise RuntimeError(err_str)
24+
1725
# for each submodule check if user path for input data assigned
1826
# if not assigned, assume it'll be in scratch
1927
if 'topo_path' not in self.cfg['processing']['geo2rdr']:
@@ -26,6 +34,16 @@ def yaml_check(self):
2634
self.cfg['processing']['dense_offsets'][
2735
'coregistered_slc_path'] = scratch_path
2836

37+
# When running insar.py dense_offsets_path and geo2rdr_offsets_path
38+
# come from previous step through scratch_path
39+
if self.cfg['processing']['rubbersheet']['dense_offsets_path'] is None:
40+
self.cfg['processing']['rubbersheet'][
41+
'dense_offsets_path'] = scratch_path
42+
43+
if self.cfg['processing']['rubbersheet']['geo2rdr_offsets_path'] is None:
44+
self.cfg['processing']['rubbersheet'][
45+
'geo2rdr_offsets_path'] = scratch_path
46+
2947
if 'coregistered_slc_path' not in self.cfg['processing']['crossmul']:
3048
self.cfg['processing']['crossmul'][
3149
'coregistered_slc_path'] = scratch_path
@@ -55,7 +73,9 @@ def yaml_check(self):
5573

5674
# default to True for datasets not found
5775
gunw_datasets = ["connectedComponents", "coherenceMagnitude",
58-
"unwrappedPhase", 'layoverShadowMask']
76+
"unwrappedPhase", "alongTrackOffset", "slantRangeOffset",
77+
'layoverShadowMask']
78+
5979
for gunw_dataset in gunw_datasets:
6080
if gunw_dataset not in self.cfg['processing']['geocode']:
6181
self.cfg['processing']['geocode']['datasets'][

python/packages/pybind_nisar/workflows/persistence.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class Persistence():
77
basic class that determines InSAR persistence
88
'''
99
# init InSAR steps in reverse chronological run order
10-
insar_steps = ['geocode', 'unwrap', 'crossmul', 'dense_offsets', 'resample', 'geo2rdr', 'rdr2geo', 'h5_prep']
10+
insar_steps = ['geocode', 'unwrap', 'crossmul', 'rubbersheet',
11+
'dense_offsets', 'resample', 'geo2rdr', 'rdr2geo', 'h5_prep']
12+
1113
def __init__(self, restart=False):
1214
# bool flag that determines if insar.run is called
1315
# prevents calling of insar.run if last run was successful and no restart

0 commit comments

Comments
 (0)