@@ -292,16 +292,23 @@ def cpu_run(cfg, runw_hdf5, output_hdf5):
292
292
src_freq_path = f"/science/LSAR/RUNW/swaths/frequency{ freq } "
293
293
dst_freq_path = f"/science/LSAR/GUNW/grids/frequency{ freq } "
294
294
295
+ # flag to ensure layover shadown only geocoded once per freq
296
+ # layover shadow has no polarization
297
+ skip_layover_shadow = False
295
298
for pol in pol_list :
296
299
# iterate over key: dataset name value: bool flag to perform geocode
297
300
for dataset_name , geocode_this_dataset in gunw_datasets .items ():
298
301
if not geocode_this_dataset :
299
302
continue
300
303
304
+ if dataset_name == "layoverShadowMask" and skip_layover_shadow :
305
+ continue
306
+
301
307
# Create radar grid for the offsets (and dataset path)
302
308
if (dataset_name == "layoverShadowMask" ):
303
309
input_raster , dataset_path = get_shadow_input_output (
304
310
scratch_path , freq , dst_freq_path )
311
+ skip_layover_shadow = True
305
312
else :
306
313
input_raster , dataset_path = get_input_output (src_freq_path ,
307
314
dst_freq_path ,
@@ -422,6 +429,19 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
422
429
interp_method ,
423
430
invalid_value = np .nan )
424
431
432
+ '''
433
+ connectedComponents raster has type unsigned char and an invalid
434
+ value of NaN becomes 0 which conflicts with 0 being used to indicate
435
+ an unmasked value/pixel. 255 is chosen as it is the most distant
436
+ value from components assigned in ascending order [0, 1, ...)
437
+ '''
438
+ geocode_conn_comp_obj = isce3 .cuda .geocode .Geocode (geogrid , rdr_geometry ,
439
+ dem_raster ,
440
+ dem_block_margin ,
441
+ lines_per_block ,
442
+ isce3 .core .DataInterpMethod .NEAREST ,
443
+ invalid_value = 0 )
444
+
425
445
# If needed create geocode object for offset datasets
426
446
if gunw_datasets ['alongTrackOffset' ] or gunw_datasets ['slantRangeOffset' ]:
427
447
# Create offset unique radar grid
@@ -449,9 +469,9 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
449
469
grid_zero_doppler )
450
470
451
471
'''
452
- layover shadow raster has type unsigned char and an invalid
472
+ layover shadow raster has type char and an invalid
453
473
value of NaN becomes 0 which conflicts with 0 being used
454
- to indicate an unmasked value/pixel. 255 is chosen as it is
474
+ to indicate an unmasked value/pixel. 127 is chosen as it is
455
475
the most distant value from the allowed set of [0, 1, 2, 3].
456
476
'''
457
477
geocode_shadow_obj = isce3 .cuda .geocode .Geocode (geogrid ,
@@ -460,18 +480,22 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
460
480
dem_block_margin ,
461
481
lines_per_block ,
462
482
isce3 .core .DataInterpMethod .NEAREST ,
463
- invalid_value = 255 )
483
+ invalid_value = 127 )
464
484
465
485
pol_list = freq_pols [freq ]
486
+ src_freq_path = f"/science/LSAR/RUNW/swaths/frequency{ freq } "
487
+ dst_freq_path = f"/science/LSAR/GUNW/grids/frequency{ freq } "
488
+ # flag to ensure layover shadown only geocoded once per freq
489
+ # layover shadow has no polarization
490
+ skip_layover_shadow = False
466
491
# Loop over polarizations
467
492
for pol in pol_list :
468
- src_freq_path = f"/science/LSAR/RUNW/swaths/frequency{ freq } "
469
- dst_freq_path = f"/science/LSAR/GUNW/grids/frequency{ freq } "
470
493
471
494
# Loop over number blocks
472
495
for i_block in range (geocode_obj .n_blocks ):
473
496
# Set interpolation grid for current block
474
497
geocode_obj .set_block_radar_coord_grid (i_block )
498
+ geocode_conn_comp_obj .set_block_radar_coord_grid (i_block )
475
499
476
500
if gunw_datasets ['alongTrackOffset' ] or gunw_datasets ['slantRangeOffset' ]:
477
501
geocode_offset_obj .set_block_radar_coord_grid (i_block )
@@ -481,6 +505,8 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
481
505
482
506
# Iterate over/input output raster pairs and geocode
483
507
for dataset_name , geocode_this_dataset in gunw_datasets .items ():
508
+ if dataset_name == "layoverShadowMask" and skip_layover_shadow :
509
+ continue
484
510
485
511
# Prepare input raster
486
512
if (dataset_name == "layoverShadowMask" ):
@@ -507,6 +533,8 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
507
533
block_geocode_obj = geocode_offset_obj
508
534
elif dataset_name == "layoverShadowMask" :
509
535
block_geocode_obj = geocode_shadow_obj
536
+ elif dataset_name == "connectedComponents" :
537
+ block_geocode_obj = geocode_conn_comp_obj
510
538
else :
511
539
block_geocode_obj = geocode_obj
512
540
@@ -520,6 +548,9 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
520
548
del input_raster
521
549
del geocoded_raster
522
550
551
+ if gunw_datasets ['layoverShadowMask' ]:
552
+ skip_layover_shadow = True
553
+
523
554
# spec for NISAR GUNW does not require freq B so skip radar cube
524
555
if freq .upper () == 'B' :
525
556
continue
@@ -543,6 +574,7 @@ def gpu_run(cfg, runw_hdf5, output_hdf5):
543
574
geocode_insar_runconfig = GeocodeInsarRunConfig (args )
544
575
545
576
# prepare RIFG HDF5
577
+ geocode_insar_runconfig .cfg ['PrimaryExecutable' ]['ProductType' ] = 'GUNW_STANDALONE'
546
578
out_paths = h5_prep .run (geocode_insar_runconfig .cfg )
547
579
runw_path = geocode_insar_runconfig .cfg ['processing' ]['geocode' ][
548
580
'runw_path' ]
0 commit comments