Skip to content

Commit a3c8aac

Browse files
gshiromaGitHub Enterprise
authored andcommitted
Update remaining InSAR runconfig parameters from camel case to snake (#962)
* update remaining InSAR runconfig parameters from camel case to snake case * update remaining InSAR runconfig parameters from camel case to snake case (2)
1 parent 49b5b77 commit a3c8aac

File tree

5 files changed

+37
-29
lines changed

5 files changed

+37
-29
lines changed

python/packages/nisar/workflows/geocode_insar.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from nisar.workflows.yaml_argparse import YamlArgparse
2222
from nisar.workflows.compute_stats import compute_stats_real_data
2323

24-
2524
def run(cfg, runw_hdf5, output_hdf5):
2625
""" Run geocode insar on user specified hardware
2726
@@ -73,7 +72,8 @@ def get_shadow_input_output(scratch_path, freq, dst_freq_path):
7372
return input_raster, dataset_path
7473

7574

76-
def get_ds_input_output(src_freq_path, dst_freq_path, pol, runw_hdf5, dataset_name):
75+
def get_ds_input_output(src_freq_path, dst_freq_path, pol, runw_hdf5,
76+
dataset_name):
7777
""" Create input raster object and output dataset path for datasets outside
7878
7979
Parameters
@@ -96,6 +96,7 @@ def get_ds_input_output(src_freq_path, dst_freq_path, pol, runw_hdf5, dataset_na
9696
dataset_path : str
9797
HDF5 path to geocoded shadow layover dataset
9898
"""
99+
99100
if dataset_name in ['alongTrackOffset', 'slantRangeOffset']:
100101
src_group_path = f'{src_freq_path}/pixelOffsets/{pol}'
101102
dst_group_path = f'{dst_freq_path}/pixelOffsets/{pol}'
@@ -215,6 +216,11 @@ def add_radar_grid_cube(cfg, freq, radar_grid, orbit, dst_h5):
215216
grid_zero_doppler, threshold_geo2rdr,
216217
iteration_geo2rdr)
217218

219+
def _snake_to_camel_case(snake_case_str):
220+
splitted_snake_case_str = snake_case_str.split('_')
221+
return (splitted_snake_case_str[0] +
222+
''.join(w.title() for w in splitted_snake_case_str[1:]))
223+
218224
def get_raster_lists(gunw_datasets, desired, freq, pol_list, runw_hdf5, dst_h5,
219225
scratch_path=''):
220226
'''
@@ -257,13 +263,14 @@ def get_raster_lists(gunw_datasets, desired, freq, pol_list, runw_hdf5, dst_h5,
257263
if skip_layover_shadow:
258264
continue
259265

260-
if ds_name == "layoverShadowMask":
266+
if ds_name == "layover_shadow_mask":
261267
input_raster, out_ds_path = get_shadow_input_output(
262268
scratch_path, freq, dst_freq_path)
263269
skip_layover_shadow = True
264270
else:
271+
ds_name_camel_case = _snake_to_camel_case(ds_name)
265272
input_raster, out_ds_path = get_ds_input_output(
266-
src_freq_path, dst_freq_path, pol, runw_hdf5, ds_name)
273+
src_freq_path, dst_freq_path, pol, runw_hdf5, ds_name_camel_case)
267274

268275
input_rasters.append(input_raster)
269276

@@ -383,25 +390,25 @@ def cpu_run(cfg, runw_hdf5, output_hdf5):
383390
else:
384391
radar_grid = radar_grid_slc
385392

386-
desired = ['coherenceMagnitude', 'unwrappedPhase']
393+
desired = ['coherence_magnitude', 'unwrapped_phase']
387394
geo.data_interpolator = interp_method
388395
cpu_geocode_rasters(geo, gunw_datasets, desired, freq, pol_list,
389396
runw_hdf5, dst_h5, radar_grid, dem_raster)
390397

391-
desired = ["connectedComponents"]
398+
desired = ["connected_components"]
392399
geo.data_interpolator = 'NEAREST'
393400
cpu_geocode_rasters(geo, gunw_datasets, desired, freq, pol_list,
394401
runw_hdf5, dst_h5, radar_grid, dem_raster)
395402

396-
desired = ['alongTrackOffset', 'slantRangeOffset']
403+
desired = ['along_track_offset', 'slant_range_offset']
397404
geo.data_interpolator = interp_method
398405
radar_grid_offset = get_offset_radar_grid(offset_cfg,
399406
radar_grid_slc)
400407
cpu_geocode_rasters(geo, gunw_datasets, desired, freq, pol_list,
401408
runw_hdf5, dst_h5, radar_grid_offset,
402409
dem_raster)
403410

404-
desired = ["layoverShadowMask"]
411+
desired = ["layover_shadow_mask"]
405412
geo.data_interpolator = 'NEAREST'
406413
cpu_geocode_rasters(geo, gunw_datasets, desired, freq, pol_list,
407414
runw_hdf5, dst_h5, radar_grid_slc, dem_raster,
@@ -491,7 +498,7 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
491498
# Multilook radar grid if needed
492499
radar_grid = radar_grid.multilook(az_looks, rg_looks)
493500

494-
desired = ['coherenceMagnitude', 'unwrappedPhase']
501+
desired = ['coherence_magnitude', 'unwrapped_phase']
495502
# Create radar grid geometry used by most datasets
496503
rdr_geometry = isce3.container.RadarGeometry(radar_grid,
497504
slc.getOrbit(),
@@ -508,9 +515,9 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
508515
gpu_geocode_rasters(gunw_datasets, desired, freq, pol_list,
509516
runw_hdf5, dst_h5, geocode_obj)
510517

511-
desired = ["connectedComponents"]
518+
desired = ["connected_components"]
512519
'''
513-
connectedComponents raster has type unsigned char and an invalid
520+
connected_components raster has type unsigned char and an invalid
514521
value of NaN becomes 0 which conflicts with 0 being used to indicate
515522
an unmasked value/pixel. 255 is chosen as it is the most distant
516523
value from components assigned in ascending order [0, 1, ...)
@@ -525,7 +532,7 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
525532
gpu_geocode_rasters(gunw_datasets, desired, freq, pol_list,
526533
runw_hdf5, dst_h5, geocode_conn_comp_obj)
527534

528-
desired = ['alongTrackOffset', 'slantRangeOffset']
535+
desired = ['along_track_offset', 'slant_range_offset']
529536
# If needed create geocode object for offset datasets
530537
# Create offset unique radar grid
531538
radar_grid = get_offset_radar_grid(offset_cfg,
@@ -547,7 +554,7 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
547554
gpu_geocode_rasters(gunw_datasets, desired, freq, pol_list,
548555
runw_hdf5, dst_h5, geocode_offset_obj)
549556

550-
desired = ["layoverShadowMask"]
557+
desired = ["layover_shadow_mask"]
551558
# If needed create geocode object for shadow layover dataset
552559
# Create radar grid geometry required by layover shadow
553560
rdr_geometry = isce3.container.RadarGeometry(slc.getRadarGrid(freq),

python/packages/nisar/workflows/geocode_insar_runconfig.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ 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",
50-
"alongTrackOffset", "slantRangeOffset", "layoverShadowMask"]
49+
gunw_datasets = ["connected_components", "coherence_magnitude",
50+
"unwrapped_phase", "along_track_offset",
51+
"slant_range_offset", "layover_shadow_mask"]
5152
for gunw_dataset in gunw_datasets:
5253
if gunw_dataset not in self.cfg['processing']['geocode']['datasets']:
5354
self.cfg['processing']['geocode']['datasets'][gunw_dataset] = True
@@ -79,9 +80,9 @@ def yaml_check(self):
7980
# the start pixel in range and azimuth. Note, margin and gross_offsets
8081
# are allocated as defaults in share/nisar/defaults/insar.yaml
8182
geocode_azimuth_offset = self.cfg['processing']['geocode']['datasets'][
82-
'alongTrackOffset']
83+
'along_track_offset']
8384
geocode_range_offset = self.cfg['processing']['geocode']['datasets'][
84-
'slantRangeOffset']
85+
'slant_range_offset']
8586
if geocode_azimuth_offset or geocode_range_offset:
8687
offset_cfg = self.cfg['processing']['dense_offsets']
8788
margin = max(offset_cfg['margin'],

python/packages/nisar/workflows/insar_runconfig.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ def yaml_check(self):
159159
self.cfg['processing']['geocode']['datasets'] = {}
160160

161161
# default to True for datasets not found
162-
gunw_datasets = ["connectedComponents", "coherenceMagnitude",
163-
"unwrappedPhase", "alongTrackOffset", "slantRangeOffset",
164-
'layoverShadowMask']
162+
gunw_datasets = ["connected_components", "coherence_magnitude",
163+
"unwrapped_phase", "along_track_offset",
164+
"slant_range_offset", 'layover_shadow_mask']
165165

166166
for gunw_dataset in gunw_datasets:
167167
if gunw_dataset not in self.cfg['processing']['geocode']['datasets']:
@@ -182,9 +182,9 @@ def yaml_check(self):
182182
# the start pixel in range and azimuth. Note, margin and gross_offsets
183183
# are allocated as defaults in share/nisar/defaults/insar.yaml
184184
geocode_azimuth_offset = self.cfg['processing'][
185-
'geocode']['datasets']['alongTrackOffset']
185+
'geocode']['datasets']['along_track_offset']
186186
geocode_range_offset = self.cfg['processing'][
187-
'geocode']['datasets']['slantRangeOffset']
187+
'geocode']['datasets']['slant_range_offset']
188188
if geocode_azimuth_offset or geocode_range_offset:
189189
offset_cfg = self.cfg['processing']['dense_offsets']
190190
margin = max(offset_cfg['margin'], offset_cfg['gross_offset_range'],

share/nisar/schemas/insar.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,12 @@ geocode_options:
611611
lines_per_block: int(min=100, max=10000, required=False)
612612

613613
gunw_datasets:
614-
connectedComponents: bool(required=False)
615-
coherenceMagnitude: bool(required=False)
616-
unwrappedPhase: bool(required=False)
617-
layoverShadowMask: bool(required=False)
618-
alongTrackOffset: bool(required=False)
619-
slantRangeOffset: bool(required=False)
614+
connected_components: bool(required=False)
615+
coherence_magnitude: bool(required=False)
616+
unwrapped_phase: bool(required=False)
617+
layover_shadow_mask: bool(required=False)
618+
along_track_offset: bool(required=False)
619+
slant_range_offset: bool(required=False)
620620

621621
worker_options:
622622
# Enable/disable internet connection (e.g. for download DEM)

tests/python/packages/nisar/workflows/geocode_insar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_geocode_run():
6363
h_runw[f'{runw_product_path}/{ds_name}'][:, :] = arr_mlook
6464

6565
# disable unused runw dataset
66-
runconfig.cfg['processing']['geocode']['datasets']['connectedComponents'] = False
66+
runconfig.cfg['processing']['geocode']['datasets']['connected_components'] = False
6767

6868
# run geocodeing of runw
6969
geocode_insar.run(runconfig.cfg, out_paths['RUNW'], out_paths['GUNW'])

0 commit comments

Comments
 (0)