Skip to content

Commit 4522534

Browse files
jungkyoJungGitHub Enterprise
authored andcommitted
Merge pull request #770 from jungkyoj/layover_shadow_mask
Add Layover/shadow mask in InSAR workflow
2 parents 962e84c + 0fc26fa commit 4522534

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

python/extensions/pybind_isce3/geometry/rdr2geo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void addbinding(py::class_<Topo> & pyRdr2Geo)
178178
py::arg("extraiter") = 10,
179179
py::arg("dem_interp_method") = isce3::core::BIQUINTIC_METHOD,
180180
py::arg("epsg_out") = 4326,
181-
py::arg("compute_mask") = false)
181+
py::arg("compute_mask") = true)
182182
.def("topo", py::overload_cast<isce3::io::Raster &, const std::string &>
183183
(&Topo::topo),
184184
py::arg("dem_raster"),

python/packages/pybind_nisar/workflows/geocode_insar.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import h5py
1010
import journal
11+
import pathlib
1112
import pybind_isce3 as isce3
1213
from pybind_nisar.products.readers import SLC
1314
from pybind_nisar.workflows import h5_prep
@@ -34,6 +35,7 @@ def run(cfg, runw_hdf5, output_hdf5):
3435
rg_looks = cfg["processing"]["crossmul"]["range_looks"]
3536
interp_method = cfg["processing"]["geocode"]["interp_method"]
3637
gunw_datasets = cfg["processing"]["geocode"]["datasets"]
38+
scratch_path = pathlib.Path(cfg['ProductPathGroup']['ScratchPath'])
3739

3840
slc = SLC(hdf5file=ref_hdf5)
3941

@@ -67,9 +69,9 @@ def run(cfg, runw_hdf5, output_hdf5):
6769
for freq in freq_pols.keys():
6870
pol_list = freq_pols[freq]
6971

70-
radar_grid = slc.getRadarGrid(freq)
72+
radar_grid_slc = slc.getRadarGrid(freq)
7173
if az_looks > 1 or rg_looks > 1:
72-
radar_grid = radar_grid.multilook(az_looks, rg_looks)
74+
radar_grid_multilook = radar_grid_slc.multilook(az_looks, rg_looks)
7375
geo_grid = geogrids[freq]
7476
geo.geogrid(
7577
geo_grid.start_x,
@@ -80,24 +82,39 @@ def run(cfg, runw_hdf5, output_hdf5):
8082
geo_grid.length,
8183
geo_grid.epsg,
8284
)
85+
src_freq_path = f"/science/LSAR/RUNW/swaths/frequency{freq}/interferogram"
86+
dst_freq_path = f"/science/LSAR/GUNW/grids/frequency{freq}/interferogram"
8387

8488
for pol in pol_list:
85-
src_group_path = f"/science/LSAR/RUNW/swaths/frequency{freq}/interferogram/{pol}"
86-
dst_group_path = f"/science/LSAR/GUNW/grids/frequency{freq}/interferogram/{pol}"
89+
src_group_path = f"{src_freq_path}/{pol}"
90+
dst_group_path = f"{dst_freq_path}/{pol}"
8791

8892
# iterate over key: dataset name value: bool flag to perform geocode
8993
for dataset_name, geocode_this_dataset in gunw_datasets.items():
9094
if not geocode_this_dataset:
9195
continue
9296

93-
# prepare input raster
94-
input_raster_str = (
95-
f"HDF5:{runw_hdf5}:/{src_group_path}/{dataset_name}"
96-
)
97-
input_raster = isce3.io.Raster(input_raster_str)
97+
if (dataset_name == "layoverShadowMask"):
98+
# prepare input raster
99+
raster_ref = scratch_path / 'rdr2geo' / f'freq{freq}' / 'mask.rdr'
100+
input_raster = isce3.io.Raster(str(raster_ref))
101+
102+
# access the HDF5 dataset for layover shadow mask
103+
dataset_path = f"{dst_freq_path}/{dataset_name}"
104+
geo.data_interpolator = 'NEAREST'
105+
radar_grid = radar_grid_slc
106+
else:
107+
# prepare input raster
108+
input_raster_str = (
109+
f"HDF5:{runw_hdf5}:/{src_group_path}/{dataset_name}"
110+
)
111+
input_raster = isce3.io.Raster(input_raster_str)
112+
113+
# access the HDF5 dataset for a given frequency and pol
114+
geo.data_interpolator = interp_method
115+
radar_grid = radar_grid_multilook
116+
dataset_path = f"{dst_group_path}/{dataset_name}"
98117

99-
# access the HDF5 dataset for a given frequency and pol
100-
dataset_path = f"{dst_group_path}/{dataset_name}"
101118
geocoded_dataset = dst_h5[dataset_path]
102119

103120
# Construct the output ratster directly from HDF5 dataset

python/packages/pybind_nisar/workflows/geocode_insar_runconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ 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"]
49+
gunw_datasets = ["connectedComponents", "coherenceMagnitude", "unwrappedPhase", "layoverShadowMask"]
5050
for gunw_dataset in gunw_datasets:
5151
if gunw_dataset not in self.cfg['processing']['geocode']:
5252
self.cfg['processing']['geocode']['datasets'][gunw_dataset] = True

python/packages/pybind_nisar/workflows/h5_prep.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,14 @@ def prep_ds_insar(cfg, dst, dst_h5):
669669
'quality',
670670
descr=descr, units=" ", long_name='quality')
671671

672+
# Adding layover-shadow mask
673+
if dst in ['GUNW']:
674+
descr = f"Layover Shadow mask for frequency{freq} layer, 1 - Radar Shadow. 2 - Radar Layover. 3 - Both"
675+
_create_datasets(dst_h5[dst_path_intf], shape, np.byte,
676+
'layoverShadowMask',
677+
descr=descr, units=" ", grids=grids_val,
678+
long_name='layover shadow mask')
679+
672680
# Add datasets in metadata
673681
dst_cal = os.path.join(common_parent_path,
674682
f'{dst}/metadata/calibrationInformation')

python/packages/pybind_nisar/workflows/insar_runconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def yaml_check(self):
5555

5656
# default to True for datasets not found
5757
gunw_datasets = ["connectedComponents", "coherenceMagnitude",
58-
"unwrappedPhase"]
58+
"unwrappedPhase", 'layoverShadowMask']
5959
for gunw_dataset in gunw_datasets:
6060
if gunw_dataset not in self.cfg['processing']['geocode']:
6161
self.cfg['processing']['geocode']['datasets'][

0 commit comments

Comments
 (0)