From ffd8aa776264836bead9dbeb782cde9f30f9c8a5 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Mon, 30 Jun 2025 15:56:43 -0700 Subject: [PATCH 01/19] Add an option in the GCOV workflow to assign values to regions with missing radar samples --- cxx/isce3/geocode/GeocodeCov.cpp | 94 ++++++++++++++----- cxx/isce3/geocode/GeocodeCov.h | 35 +++++-- .../pybind_isce3/geocode/GeocodeCov.cpp | 10 +- python/packages/nisar/workflows/gcov.py | 3 + share/nisar/defaults/gcov.yaml | 6 ++ share/nisar/schemas/gcov.yaml | 6 ++ tests/cxx/isce3/geocode/geocodeCov.cpp | 7 +- 7 files changed, 126 insertions(+), 35 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index 2bdc05967..bbfe03012 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -128,7 +128,8 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, geocodeOutputMode output_mode, bool flag_az_baseband_doppler, bool flatten, double geogrid_upsampling, - bool flag_upsample_radar_grid, bool flag_apply_rtc, + float shadow_no_data_value, bool flag_upsample_radar_grid, + bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, int exponent, float rtc_min_value_db, double rtc_geogrid_upsampling, @@ -158,7 +159,8 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, bool flag_run_geocode_interp = output_mode == geocodeOutputMode::INTERP; if (flag_run_geocode_interp && !flag_complex_to_real) geocodeInterp(radar_grid, input_raster, output_raster, dem_raster, - flag_apply_rtc, flag_az_baseband_doppler, flatten, + shadow_no_data_value, flag_apply_rtc, + flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -174,7 +176,8 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, (std::is_same::value || std::is_same>::value)) geocodeInterp(radar_grid, input_raster, output_raster, - dem_raster, flag_apply_rtc, flag_az_baseband_doppler, flatten, + dem_raster, shadow_no_data_value, + flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -188,7 +191,8 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else if (flag_run_geocode_interp) geocodeInterp(radar_grid, input_raster, output_raster, - dem_raster, flag_apply_rtc, flag_az_baseband_doppler, flatten, + dem_raster, shadow_no_data_value, + flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -202,7 +206,8 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else if (!flag_complex_to_real) geocodeAreaProj(radar_grid, input_raster, output_raster, dem_raster, - geogrid_upsampling, flag_upsample_radar_grid, flag_apply_rtc, + geogrid_upsampling, shadow_no_data_value, + flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -218,7 +223,8 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, else if (std::is_same::value || std::is_same>::value) geocodeAreaProj(radar_grid, input_raster, output_raster, - dem_raster, geogrid_upsampling, flag_upsample_radar_grid, + dem_raster, geogrid_upsampling, shadow_no_data_value, + flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -233,7 +239,8 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else geocodeAreaProj(radar_grid, input_raster, output_raster, - dem_raster, geogrid_upsampling, flag_upsample_radar_grid, + dem_raster, geogrid_upsampling, shadow_no_data_value, + flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -253,8 +260,8 @@ template void Geocode::geocodeInterp( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& inputRaster, isce3::io::Raster& outputRaster, - isce3::io::Raster& demRaster, bool flag_apply_rtc, - bool flag_az_baseband_doppler, bool flatten, + isce3::io::Raster& demRaster, float shadow_no_data_value, + bool flag_apply_rtc, bool flag_az_baseband_doppler, bool flatten, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, float rtc_min_value_db, double rtc_geogrid_upsampling, @@ -860,9 +867,10 @@ void Geocode::geocodeInterp( rdrBlockWidth, rdrBlockLength, azimuthFirstLine, rangeFirstPixel, interp.get(), radar_grid, flag_az_baseband_doppler, flatten, phase_screen_raster, - phase_screen_array, rtc_min_value, + phase_screen_array, shadow_no_data_value, rtc_min_value, abs_cal_factor_effective, clip_min, clip_max, - flag_apply_rtc, rtc_area_array, rtc_area_sigma0_array, out_geo_rtc_band, + flag_apply_rtc, rtc_area_array, rtc_area_sigma0_array, + out_geo_rtc_band, out_geo_rtc_array, out_geo_rtc_gamma0_to_sigma0_band, out_geo_rtc_gamma0_to_sigma0_array, input_layover_shadow_mask_raster, @@ -947,7 +955,7 @@ inline void Geocode::_interpolate( const bool flag_az_baseband_doppler, const bool flatten, isce3::io::Raster* phase_screen_raster, isce3::core::Matrix& phase_screen_array, - float rtc_min_value, + float shadow_no_data_value, float rtc_min_value, double abs_cal_factor_effective, float clip_min, float clip_max, bool flag_apply_rtc, const isce3::core::Matrix& rtc_area, @@ -1036,6 +1044,21 @@ inline void Geocode::_interpolate( } if (flag_has_invalid_sample) { + + // set NaN values according to T_out, i.e. real (NaN) + // or complex (NaN, NaN) + T_out v = static_cast(shadow_no_data_value); + geoDataBlock(i, j) = v; + + if (flag_apply_rtc && out_geo_rtc != nullptr) { + out_geo_rtc_array(i, j) = + std::numeric_limits::quiet_NaN(); + } + if (flag_apply_rtc && + out_geo_rtc_gamma0_to_sigma0 != nullptr) { + out_geo_rtc_gamma0_to_sigma0_array(i, j) = + std::numeric_limits::quiet_NaN(); + } continue; } } @@ -1866,7 +1889,8 @@ void Geocode::geocodeAreaProj( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling, - bool flag_upsample_radar_grid, bool flag_apply_rtc, + float shadow_no_data_value, bool flag_upsample_radar_grid, + bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, float rtc_min_value_db, double rtc_geogrid_upsampling, @@ -1910,10 +1934,10 @@ void Geocode::geocodeAreaProj( const float upsampled_radar_grid_nlooks = radar_grid_nlooks / 2; geocodeAreaProj(upsampled_radar_grid, input_raster, output_raster, dem_raster, geogrid_upsampling, - flag_upsample_radar_grid, flag_apply_rtc, - input_terrain_radiometry, output_terrain_radiometry, - rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, - rtc_area_beta_mode, + shadow_no_data_value, flag_upsample_radar_grid, + flag_apply_rtc, input_terrain_radiometry, + output_terrain_radiometry, rtc_min_value_db, + rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, abs_cal_factor, clip_min, clip_max, min_nlooks, upsampled_radar_grid_nlooks, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2271,7 +2295,8 @@ void Geocode::geocodeAreaProj( is_radar_grid_single_block, rdrData, block_size_y, block_size_with_upsampling_y, block_y, block_size_x, block_size_with_upsampling_x, block_x, numdone, - progress_block, geogrid_upsampling, nbands, + progress_block, geogrid_upsampling, + shadow_no_data_value, nbands, nbands_off_diag_terms, dem_interp_method, dem_raster, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2298,7 +2323,8 @@ void Geocode::geocodeAreaProj( is_radar_grid_single_block, rdrDataT, block_size_y, block_size_with_upsampling_y, block_y, block_size_x, block_size_with_upsampling_x, block_x, numdone, - progress_block, geogrid_upsampling, nbands, + progress_block, geogrid_upsampling, + shadow_no_data_value, nbands, nbands_off_diag_terms, dem_interp_method, dem_raster, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2486,7 +2512,8 @@ void Geocode::_runBlock( int block_size_y, int block_size_with_upsampling_y, int block_y, int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, - double geogrid_upsampling, int nbands, int nbands_off_diag_terms, + double geogrid_upsampling, float shadow_no_data_value, + int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, isce3::io::Raster* out_off_diag_terms, isce3::io::Raster* out_geo_rdr, isce3::io::Raster* out_geo_dem, @@ -3355,13 +3382,34 @@ void Geocode::_runBlock( out_mask_array(i, j) = 0; } + // x, y positions are binned by integer quotient (floor) + const int x = static_cast(j / geogrid_upsampling); + const int y = static_cast(i / geogrid_upsampling); + // ignoring boundary or low-sampled area elements if (std::isnan(nlooks) || nlooks == 0 || nlooks < isce3::core::AREA_PROJECTION_MIN_VALID_SAMPLES_RATIO * std::abs(w_total) || (!std::isnan(min_nlooks) && - nlooks * radar_grid_nlooks <= min_nlooks)) + nlooks * radar_grid_nlooks <= min_nlooks)) { + + if (!std::isnan(shadow_no_data_value)) { + + T_out v = static_cast(shadow_no_data_value); + for (int band = 0; band < nbands; ++band) { + geoDataBlock[band]->operator()(y, x) = v; + } + if (nbands_off_diag_terms > 0) { + + T2 v2 = static_cast(shadow_no_data_value); + for (int band = 0; band < nbands_off_diag_terms; ++band) { + geoDataBlockOffDiag[band]->operator()(y, x) = v2; + } + } + } + continue; + } /* If we need to output the mask layer AND the geogrid pixel contains @@ -3410,10 +3458,6 @@ void Geocode::_runBlock( out_geo_rdr_r(i + 1, j + 1) = x11; } - // x, y positions are binned by integer quotient (floor) - const int x = static_cast(j / geogrid_upsampling); - const int y = static_cast(i / geogrid_upsampling); - if (flag_apply_rtc) { area_total /= nlooks; if (out_geo_rtc_gamma0_to_sigma0 != nullptr) { diff --git a/cxx/isce3/geocode/GeocodeCov.h b/cxx/isce3/geocode/GeocodeCov.h index dcd704044..1a72972a2 100644 --- a/cxx/isce3/geocode/GeocodeCov.h +++ b/cxx/isce3/geocode/GeocodeCov.h @@ -68,6 +68,10 @@ class Geocode { * baseband (using Doppler centroid) before interpolation * @param[in] flatten Flatten the geocoded SLC * @param[in] geogrid_upsampling Geogrid upsampling + * @param[in] shadow_no_data_value Value to represent areas without + * valid radar samples. If output is complex (e.g., off-diagonal terms), + * this value will be used for the real-part whereas the imaginary part + * will be set to 0 * @param[in] flag_upsample_radar_grid Double the radar grid sampling rate * @param[in] flag_apply_rtc Apply radiometric terrain correction * (RTC) @@ -151,6 +155,7 @@ class Geocode { geocodeOutputMode output_mode = geocodeOutputMode::INTERP, bool flag_az_baseband_doppler = false, bool flatten = false, double geogrid_upsampling = 1, + float shadow_no_data_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry:: @@ -222,6 +227,12 @@ class Geocode { * `abs_cal_factor parameters`, which default to `false` and `1`, * respectively. * @param[in] dem_raster Input DEM raster + * @param[in] shadow_no_data_value Value to represent areas without + * valid radar samples. If output is complex (e.g., off-diagonal terms), + * this value will be used for the real-part whereas the imaginary part + * will be set to 0 + * @param[in] flag_apply_rtc Apply radiometric terrain correction + * (RTC) * @param[in] flag_az_baseband_doppler Shift SLC azimuth spectrum to * baseband (using Doppler centroid) before interpolation * @param[in] input_terrain_radiometry Input terrain radiometry @@ -288,7 +299,9 @@ class Geocode { template void geocodeInterp(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, - isce3::io::Raster& dem_raster, bool flag_apply_rtc = false, + isce3::io::Raster& dem_raster, + float shadow_no_data_value = std::numeric_limits::quiet_NaN(), + bool flag_apply_rtc = false, bool flag_az_baseband_doppler = false, bool flatten = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry:: @@ -356,6 +369,10 @@ class Geocode { * respectively. * @param[in] dem_raster Input DEM raster * @param[in] geogrid_upsampling Geogrid upsampling + * @param[in] shadow_no_data_value Value to represent areas without + * valid radar samples. If output is complex (e.g., off-diagonal terms), + * this value will be used for the real-part whereas the imaginary part + * will be set to 0 * @param[in] flag_upsample_radar_grid Double the radar grid sampling rate * @param[in] flag_apply_rtc Apply radiometric terrain correction * (RTC) @@ -433,6 +450,7 @@ class Geocode { isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling = 1, + float shadow_no_data_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = @@ -621,7 +639,9 @@ class Geocode { int block_size_y, int block_size_with_upsampling_y, int block_y, int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, - double geogrid_upsampling, int nbands, int nbands_off_diag_terms, + double geogrid_upsampling, + float shadow_no_data_value, + int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, isce3::io::Raster* out_off_diag_terms, @@ -672,8 +692,11 @@ class Geocode { * @param[in] flatten flag to flatten the geocoded SLC * @param[in] phase_screen_raster Phase screen raster * @param[in] phase_screen_array Phase screen array - * @param[in] rtc_min_value_db Minimum value for the RTC area factor. - * Radar data with RTC area factor below this limit will be set to NaN. + * @param[in] shadow_no_data_value Value to represent areas without + * valid radar samples. If output is complex (e.g., off-diagonal terms), + * this value will be used for the real-part whereas the imaginary part + * will be set to 0 + * @param[in] rtc_min_value Minimum value for the RTC area factor. * @param[in] abs_cal_factor Absolute calibration factor applied * to real-valued output datasets (assumed to be proportional to * power/intensity). If the output is complex valued, its considered @@ -724,8 +747,8 @@ class Geocode { const bool flag_az_baseband_doppler, const bool flatten, isce3::io::Raster* phase_screen_raster, isce3::core::Matrix& phase_screen_array, - float rtc_min_value, double abs_cal_factor, - float clip_min, float clip_max, + float shadow_no_data_value, float rtc_min_value, + double abs_cal_factor, float clip_min, float clip_max, bool flag_run_rtc, const isce3::core::Matrix& rtc_area, const isce3::core::Matrix& rtc_area_sigma, isce3::io::Raster* out_geo_rtc, diff --git a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp index 409ce0c4c..725701c85 100644 --- a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp +++ b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp @@ -72,6 +72,7 @@ void addbinding(py::class_>& pyGeocode) py::arg("flag_az_baseband_doppler") = false, py::arg("flatten") = false, py::arg("geogrid_upsampling") = 1, + py::arg("shadow_no_data_value") = std::numeric_limits::quiet_NaN(), py::arg("flag_upsample_radar_grid") = false, py::arg("flag_apply_rtc") = false, py::arg("input_terrain_radiometry") = @@ -160,6 +161,11 @@ void addbinding(py::class_>& pyGeocode) Flatten the geocoded SLC geogrid_upsampling: int, optional Geogrid upsampling + shadow_no_data_value: float, optional + Value to represent areas without valid radar samples. + If output is complex (e.g., off-diagonal terms), + this value will be used for the real-part whereas the imaginary part + will be set to 0 flag_upsample_radar_grid: bool, optional Double the radar grid sampling rate flag_apply_rtc: bool, optional @@ -175,9 +181,9 @@ void addbinding(py::class_>& pyGeocode) rtc_min_value_db: float, optional Minimum value for the RTC area factor. Radar data with RTC area factor below this limit will be set to NaN. - rtc_geogrid_upsampling: int, optional + rtc_upsampling: int, optional Geogrid upsampling to compute the radiometric terrain - correction RTC. + correction (RTC). rtc_algorithm: isce3.geometry.RtcAlgorithm, optional RTC algorithm rtc_factor_area_mode : isce3.geometry.RtcAreaBetaMode, optional diff --git a/python/packages/nisar/workflows/gcov.py b/python/packages/nisar/workflows/gcov.py index c4d6a3328..7bcd3c059 100644 --- a/python/packages/nisar/workflows/gcov.py +++ b/python/packages/nisar/workflows/gcov.py @@ -401,6 +401,7 @@ def _run(cfg, raster_scratch_dir): apply_valid_samples_sub_swath_masking = \ geocode_dict['apply_valid_samples_sub_swath_masking'] geogrid_upsampling = geocode_dict['geogrid_upsampling'] + shadow_no_data_value = geocode_dict['shadow_no_data_value'] abs_cal_factor = geocode_dict['abs_rad_cal'] clip_max = geocode_dict['clip_max'] clip_min = geocode_dict['clip_min'] @@ -571,6 +572,8 @@ def _run(cfg, raster_scratch_dir): root_ds = f'/science/LSAR/GCOV/grids/frequency{frequency}' optional_geo_kwargs['geogrid_upsampling'] = geogrid_upsampling + if shadow_no_data_value is not None: + optional_geo_kwargs['shadow_no_data_value'] = shadow_no_data_value optional_geo_kwargs['abs_cal_factor'] = abs_cal_factor optional_geo_kwargs['clip_min'] = clip_min optional_geo_kwargs['clip_max'] = clip_max diff --git a/share/nisar/defaults/gcov.yaml b/share/nisar/defaults/gcov.yaml index db0c71352..405e81489 100644 --- a/share/nisar/defaults/gcov.yaml +++ b/share/nisar/defaults/gcov.yaml @@ -277,6 +277,12 @@ runconfig: # OPTIONAL - Processing upsampling factor applied to input geogrid geogrid_upsampling: 1 + # Value to represent areas without valid radar samples. + # If output is complex (e.g., off-diagonal terms), this value + # will be used for real- and imaginary parts. For example, + # `0` will become `complex(0, 0)`. + shadow_no_data_value: + # Save the number of looks used to compute GCOV save_nlooks: True diff --git a/share/nisar/schemas/gcov.yaml b/share/nisar/schemas/gcov.yaml index d5d882681..04b9ca376 100644 --- a/share/nisar/schemas/gcov.yaml +++ b/share/nisar/schemas/gcov.yaml @@ -316,6 +316,12 @@ geocode_options: # Processing upsampling factor on top of the input geogrid geogrid_upsampling: int(required=False) + # Value to represent areas without valid radar samples. + # If output is complex (e.g., off-diagonal terms), this value + # will be used for real- and imaginary parts. For example, + # `0` will become `complex(0, 0)`. + shadow_no_data_value: num(required=False) + # Save the number of looks used to compute GCOV save_nlooks: bool(required=False) diff --git a/tests/cxx/isce3/geocode/geocodeCov.cpp b/tests/cxx/isce3/geocode/geocodeCov.cpp index f75ec95bc..88d1818a6 100644 --- a/tests/cxx/isce3/geocode/geocodeCov.cpp +++ b/tests/cxx/isce3/geocode/geocodeCov.cpp @@ -116,6 +116,7 @@ TEST(GeocodeTest, TestGeocodeCov) { bool flag_az_baseband_doppler = false; bool flatten = false; double geogrid_upsampling = 1; + double shadow_no_data_value = std::numeric_limits::quiet_NaN(); bool flag_upsample_radar_grid = false; isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry::rtcInputTerrainRadiometry::BETA_NAUGHT; @@ -241,7 +242,8 @@ TEST(GeocodeTest, TestGeocodeCov) { // run geocode geoObj.geocode(radar_grid_shifted, radarRaster, geocodedRaster, demRaster, output_mode, flag_az_baseband_doppler, - flatten, geogrid_upsampling, flag_upsample_radar_grid, + flatten, geogrid_upsampling, + shadow_no_data_value, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, exponent, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, @@ -298,7 +300,8 @@ TEST(GeocodeTest, TestGeocodeCov) { geoComplexObj.geocode(radar_grid, slc_raster_xy, geocoded_diag_raster, demRaster, output_mode, flag_az_baseband_doppler, flatten, - geogrid_upsampling, flag_upsample_radar_grid, flag_apply_rtc, + geogrid_upsampling, shadow_no_data_value, + flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, exponent, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, abs_cal_factor, clip_min, From d33f91fa3e94400a3594e215d5bf994c598374bd Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Wed, 12 Aug 2026 10:01:05 -0700 Subject: [PATCH 02/19] Add parameter to the module --- cxx/isce3/geocode/GeocodeCov.cpp | 96 ++++++++----------- cxx/isce3/geocode/GeocodeCov.h | 38 ++++---- .../pybind_isce3/geocode/GeocodeCov.cpp | 11 +-- python/packages/nisar/workflows/gcov.py | 3 - share/nisar/defaults/gcov.yaml | 6 -- share/nisar/schemas/gcov.yaml | 6 -- tests/cxx/isce3/geocode/geocodeCov.cpp | 6 +- 7 files changed, 64 insertions(+), 102 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index 822cef38c..3eb84e7b7 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -128,7 +128,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, geocodeOutputMode output_mode, bool flag_az_baseband_doppler, bool flatten, double geogrid_upsampling, - float shadow_no_data_value, bool flag_upsample_radar_grid, + float fill_value, bool flag_upsample_radar_grid, bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, @@ -160,7 +160,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, bool flag_run_geocode_interp = output_mode == geocodeOutputMode::INTERP; if (flag_run_geocode_interp && !flag_complex_to_real) geocodeInterp(radar_grid, input_raster, output_raster, dem_raster, - shadow_no_data_value, flag_apply_rtc, + fill_value, flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, @@ -177,7 +177,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, (std::is_same::value || std::is_same>::value)) geocodeInterp(radar_grid, input_raster, output_raster, - dem_raster, shadow_no_data_value, + dem_raster, fill_value, flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, @@ -192,7 +192,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else if (flag_run_geocode_interp) geocodeInterp(radar_grid, input_raster, output_raster, - dem_raster, shadow_no_data_value, + dem_raster, fill_value, flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, @@ -207,7 +207,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else if (!flag_complex_to_real) geocodeAreaProj(radar_grid, input_raster, output_raster, dem_raster, - geogrid_upsampling, shadow_no_data_value, + geogrid_upsampling, fill_value, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, @@ -224,7 +224,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, else if (std::is_same::value || std::is_same>::value) geocodeAreaProj(radar_grid, input_raster, output_raster, - dem_raster, geogrid_upsampling, shadow_no_data_value, + dem_raster, geogrid_upsampling, fill_value, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, @@ -241,7 +241,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else geocodeAreaProj(radar_grid, input_raster, output_raster, - dem_raster, geogrid_upsampling, shadow_no_data_value, + dem_raster, geogrid_upsampling, fill_value, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, @@ -263,7 +263,7 @@ template void Geocode::geocodeInterp( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& inputRaster, isce3::io::Raster& outputRaster, - isce3::io::Raster& demRaster, float shadow_no_data_value, + isce3::io::Raster& demRaster, float fill_value, bool flag_apply_rtc, bool flag_az_baseband_doppler, bool flatten, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, @@ -873,7 +873,7 @@ void Geocode::geocodeInterp( rdrBlockWidth, rdrBlockLength, azimuthFirstLine, rangeFirstPixel, interp.get(), radar_grid, flag_az_baseband_doppler, flatten, phase_screen_raster, - phase_screen_array, shadow_no_data_value, rtc_min_value, + phase_screen_array, fill_value, rtc_min_value, abs_cal_factor_effective, clip_min, clip_max, flag_apply_rtc, rtc_area_array, rtc_area_sigma0_array, out_geo_rtc_band, @@ -961,7 +961,7 @@ inline void Geocode::_interpolate( const bool flag_az_baseband_doppler, const bool flatten, isce3::io::Raster* phase_screen_raster, isce3::core::Matrix& phase_screen_array, - float shadow_no_data_value, float rtc_min_value, + float fill_value, float rtc_min_value, double abs_cal_factor_effective, float clip_min, float clip_max, bool flag_apply_rtc, const isce3::core::Matrix& rtc_area, @@ -1050,21 +1050,6 @@ inline void Geocode::_interpolate( } if (flag_has_invalid_sample) { - - // set NaN values according to T_out, i.e. real (NaN) - // or complex (NaN, NaN) - T_out v = static_cast(shadow_no_data_value); - geoDataBlock(i, j) = v; - - if (flag_apply_rtc && out_geo_rtc != nullptr) { - out_geo_rtc_array(i, j) = - std::numeric_limits::quiet_NaN(); - } - if (flag_apply_rtc && - out_geo_rtc_gamma0_to_sigma0 != nullptr) { - out_geo_rtc_gamma0_to_sigma0_array(i, j) = - std::numeric_limits::quiet_NaN(); - } continue; } } @@ -1895,7 +1880,7 @@ void Geocode::geocodeAreaProj( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling, - float shadow_no_data_value, bool flag_upsample_radar_grid, + float fill_value, bool flag_upsample_radar_grid, bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, @@ -1941,7 +1926,7 @@ void Geocode::geocodeAreaProj( const float upsampled_radar_grid_nlooks = radar_grid_nlooks / 2; geocodeAreaProj(upsampled_radar_grid, input_raster, output_raster, dem_raster, geogrid_upsampling, - shadow_no_data_value, flag_upsample_radar_grid, + fill_value, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -2312,7 +2297,7 @@ void Geocode::geocodeAreaProj( block_size_with_upsampling_y, block_y, block_size_x, block_size_with_upsampling_x, block_x, numdone, progress_block, geogrid_upsampling, - shadow_no_data_value, nbands, + fill_value, nbands, nbands_off_diag_terms, dem_interp_method, dem_raster, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2341,7 +2326,7 @@ void Geocode::geocodeAreaProj( block_size_with_upsampling_y, block_y, block_size_x, block_size_with_upsampling_x, block_x, numdone, progress_block, geogrid_upsampling, - shadow_no_data_value, nbands, + fill_value, nbands, nbands_off_diag_terms, dem_interp_method, dem_raster, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2530,7 +2515,7 @@ void Geocode::_runBlock( int block_size_y, int block_size_with_upsampling_y, int block_y, int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, - double geogrid_upsampling, float shadow_no_data_value, + double geogrid_upsampling, float fill_value, int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, isce3::io::Raster* out_off_diag_terms, @@ -3418,34 +3403,13 @@ void Geocode::_runBlock( out_mask_array(i, j) = 0; } - // x, y positions are binned by integer quotient (floor) - const int x = static_cast(j / geogrid_upsampling); - const int y = static_cast(i / geogrid_upsampling); - // ignoring boundary or low-sampled area elements if (std::isnan(nlooks) || nlooks == 0 || nlooks < isce3::core::AREA_PROJECTION_MIN_VALID_SAMPLES_RATIO * std::abs(w_total) || (!std::isnan(min_nlooks) && - nlooks * radar_grid_nlooks <= min_nlooks)) { - - if (!std::isnan(shadow_no_data_value)) { - - T_out v = static_cast(shadow_no_data_value); - for (int band = 0; band < nbands; ++band) { - geoDataBlock[band]->operator()(y, x) = v; - } - if (nbands_off_diag_terms > 0) { - - T2 v2 = static_cast(shadow_no_data_value); - for (int band = 0; band < nbands_off_diag_terms; ++band) { - geoDataBlockOffDiag[band]->operator()(y, x) = v2; - } - } - } - + nlooks * radar_grid_nlooks <= min_nlooks)) continue; - } /* If we need to output the mask layer AND the geogrid pixel contains @@ -3494,6 +3458,10 @@ void Geocode::_runBlock( out_geo_rdr_r(i + 1, j + 1) = x11; } + // x, y positions are binned by integer quotient (floor) + const int x = static_cast(j / geogrid_upsampling); + const int y = static_cast(i / geogrid_upsampling); + if (flag_apply_rtc) { area_total /= nlooks; if (out_geo_rtc_gamma0_to_sigma0 != nullptr) { @@ -3575,10 +3543,16 @@ void Geocode::_runBlock( for (int j = 0; j < this_block_size_x; ++j) { T_out geo_value = geoDataBlock[band]->operator()(i, j); - // no data - if (std::isnan(std::abs(geo_value))) + // if the geogrid pixel is `NaN` and `fill_value` is `NaN`, + // continue to the next pixel + if (std::isnan(std::abs(geo_value)) && std::isnan(fill_value)) continue; - + // otherwise, if the geogrid pixel is `Nan` and `fill_value` is + // not `NaN`, update the geogrid pixel with `fill_value` + else if (std::isnan(std::abs(geo_value))) { + T_out v = static_cast(shadow_no_data_value); + geoDataBlock[band]->operator()(i, j) = v; + } // clip min (complex) else if (!std::isnan(clip_min) && std::abs(geo_value) < clip_min && @@ -3623,9 +3597,17 @@ void Geocode::_runBlock( T geo_value_off_diag = geoDataBlockOffDiag[band]->operator()(i, j); - // no data (complex) - if (std::isnan(std::abs(geo_value_off_diag))) + // if the geogrid pixel is `NaN` and `fill_value` is `NaN`, + // continue to the next pixel + if (std::isnan(std::abs(geo_value_off_diag)) && + std::isnan(fill_value)) continue; + // otherwise, if the geogrid pixel is `Nan` and `fill_value` is + // not `NaN`, update the geogrid pixel with `fill_value` + else if (std::isnan(std::abs(geo_value_off_diag))) { + T2 v = static_cast(shadow_no_data_value); + geoDataBlockOffDiag[band]->operator()(i, j) = v; + } // clip min (complex) else if (!std::isnan(clip_min) && diff --git a/cxx/isce3/geocode/GeocodeCov.h b/cxx/isce3/geocode/GeocodeCov.h index c7ed15b95..d9eba5c29 100644 --- a/cxx/isce3/geocode/GeocodeCov.h +++ b/cxx/isce3/geocode/GeocodeCov.h @@ -68,10 +68,9 @@ class Geocode { * baseband (using Doppler centroid) before interpolation * @param[in] flatten Flatten the geocoded SLC * @param[in] geogrid_upsampling Geogrid upsampling - * @param[in] shadow_no_data_value Value to represent areas without - * valid radar samples. If output is complex (e.g., off-diagonal terms), - * this value will be used for the real-part whereas the imaginary part - * will be set to 0 + * @param[in] fill_value Fill value. Defaults to NaN. If the + * output is complex (e.g., off-diagonal terms), this value is used for + * the real part with the imaginary part set to 0 * @param[in] flag_upsample_radar_grid Double the radar grid sampling rate * @param[in] flag_apply_rtc Apply radiometric terrain correction * (RTC) @@ -157,7 +156,7 @@ class Geocode { geocodeOutputMode output_mode = geocodeOutputMode::INTERP, bool flag_az_baseband_doppler = false, bool flatten = false, double geogrid_upsampling = 1, - float shadow_no_data_value = std::numeric_limits::quiet_NaN(), + float fill_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry:: @@ -230,10 +229,9 @@ class Geocode { * `abs_cal_factor parameters`, which default to `false` and `1`, * respectively. * @param[in] dem_raster Input DEM raster - * @param[in] shadow_no_data_value Value to represent areas without - * valid radar samples. If output is complex (e.g., off-diagonal terms), - * this value will be used for the real-part whereas the imaginary part - * will be set to 0 + * @param[in] fill_value Fill value. Defaults to NaN. If the + * output is complex (e.g., off-diagonal terms), this value is used for + * the real part with the imaginary part set to 0 * @param[in] flag_apply_rtc Apply radiometric terrain correction * (RTC) * @param[in] flag_az_baseband_doppler Shift SLC azimuth spectrum to @@ -305,7 +303,7 @@ class Geocode { void geocodeInterp(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, - float shadow_no_data_value = std::numeric_limits::quiet_NaN(), + float fill_value = std::numeric_limits::quiet_NaN(), bool flag_apply_rtc = false, bool flag_az_baseband_doppler = false, bool flatten = false, isce3::geometry::rtcInputTerrainRadiometry @@ -375,10 +373,9 @@ class Geocode { * respectively. * @param[in] dem_raster Input DEM raster * @param[in] geogrid_upsampling Geogrid upsampling - * @param[in] shadow_no_data_value Value to represent areas without - * valid radar samples. If output is complex (e.g., off-diagonal terms), - * this value will be used for the real-part whereas the imaginary part - * will be set to 0 + * @param[in] fill_value Fill value. Defaults to NaN. If the + * output is complex (e.g., off-diagonal terms), this value is used for + * the real part with the imaginary part set to 0 * @param[in] flag_upsample_radar_grid Double the radar grid sampling rate * @param[in] flag_apply_rtc Apply radiometric terrain correction * (RTC) @@ -458,7 +455,7 @@ class Geocode { isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling = 1, - float shadow_no_data_value = std::numeric_limits::quiet_NaN(), + float fill_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = @@ -649,7 +646,7 @@ class Geocode { int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, double geogrid_upsampling, - float shadow_no_data_value, + float fill_value, int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, @@ -702,10 +699,9 @@ class Geocode { * @param[in] flatten flag to flatten the geocoded SLC * @param[in] phase_screen_raster Phase screen raster * @param[in] phase_screen_array Phase screen array - * @param[in] shadow_no_data_value Value to represent areas without - * valid radar samples. If output is complex (e.g., off-diagonal terms), - * this value will be used for the real-part whereas the imaginary part - * will be set to 0 + * @param[in] fill_value Fill value. Defaults to NaN. If the + * output is complex (e.g., off-diagonal terms), this value is used for + * the real part with the imaginary part set to 0 * @param[in] rtc_min_value Minimum value for the RTC area factor. * @param[in] abs_cal_factor Absolute calibration factor applied * to real-valued output datasets (assumed to be proportional to @@ -757,7 +753,7 @@ class Geocode { const bool flag_az_baseband_doppler, const bool flatten, isce3::io::Raster* phase_screen_raster, isce3::core::Matrix& phase_screen_array, - float shadow_no_data_value, float rtc_min_value, + float fill_value, float rtc_min_value, double abs_cal_factor, float clip_min, float clip_max, bool flag_run_rtc, const isce3::core::Matrix& rtc_area, const isce3::core::Matrix& rtc_area_sigma, diff --git a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp index d780285b6..e910d8c48 100644 --- a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp +++ b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp @@ -72,7 +72,7 @@ void addbinding(py::class_>& pyGeocode) py::arg("flag_az_baseband_doppler") = false, py::arg("flatten") = false, py::arg("geogrid_upsampling") = 1, - py::arg("shadow_no_data_value") = std::numeric_limits::quiet_NaN(), + py::arg("fill_value") = std::numeric_limits::quiet_NaN(), py::arg("flag_upsample_radar_grid") = false, py::arg("flag_apply_rtc") = false, py::arg("input_terrain_radiometry") = @@ -162,11 +162,10 @@ void addbinding(py::class_>& pyGeocode) Flatten the geocoded SLC geogrid_upsampling: int, optional Geogrid upsampling - shadow_no_data_value: float, optional - Value to represent areas without valid radar samples. - If output is complex (e.g., off-diagonal terms), - this value will be used for the real-part whereas the imaginary part - will be set to 0 + fill_value: float, optional + Fill value. Defaults to NaN. If the output is complex + (e.g., off-diagonal terms), this value is used for + the real part with the imaginary part set to 0 flag_upsample_radar_grid: bool, optional Double the radar grid sampling rate flag_apply_rtc: bool, optional diff --git a/python/packages/nisar/workflows/gcov.py b/python/packages/nisar/workflows/gcov.py index 49289444a..3b43a5dcd 100644 --- a/python/packages/nisar/workflows/gcov.py +++ b/python/packages/nisar/workflows/gcov.py @@ -401,7 +401,6 @@ def _run(cfg, raster_scratch_dir): apply_valid_samples_sub_swath_masking = \ geocode_dict['apply_valid_samples_sub_swath_masking'] geogrid_upsampling = geocode_dict['geogrid_upsampling'] - shadow_no_data_value = geocode_dict['shadow_no_data_value'] abs_cal_factor = geocode_dict['abs_rad_cal'] clip_max = geocode_dict['clip_max'] clip_min = geocode_dict['clip_min'] @@ -582,8 +581,6 @@ def _run(cfg, raster_scratch_dir): root_ds = f'{rslc.RootPath}/GCOV/grids/frequency{frequency}' optional_geo_kwargs['geogrid_upsampling'] = geogrid_upsampling - if shadow_no_data_value is not None: - optional_geo_kwargs['shadow_no_data_value'] = shadow_no_data_value optional_geo_kwargs['abs_cal_factor'] = abs_cal_factor optional_geo_kwargs['clip_min'] = clip_min optional_geo_kwargs['clip_max'] = clip_max diff --git a/share/nisar/defaults/gcov.yaml b/share/nisar/defaults/gcov.yaml index 2160edb69..2b9f0c461 100644 --- a/share/nisar/defaults/gcov.yaml +++ b/share/nisar/defaults/gcov.yaml @@ -338,12 +338,6 @@ runconfig: # Processing upsampling factor applied to input geogrid geogrid_upsampling: 1 - # Value to represent areas without valid radar samples. - # If output is complex (e.g., off-diagonal terms), this value - # will be used for real- and imaginary parts. For example, - # `0` will become `complex(0, 0)`. - shadow_no_data_value: - # Save the number of looks used to compute GCOV save_nlooks: True diff --git a/share/nisar/schemas/gcov.yaml b/share/nisar/schemas/gcov.yaml index 76bac914c..40df96809 100644 --- a/share/nisar/schemas/gcov.yaml +++ b/share/nisar/schemas/gcov.yaml @@ -429,12 +429,6 @@ geocode_options: # Processing upsampling factor on top of the input geogrid geogrid_upsampling: int(required=False) - # Value to represent areas without valid radar samples. - # If output is complex (e.g., off-diagonal terms), this value - # will be used for real- and imaginary parts. For example, - # `0` will become `complex(0, 0)`. - shadow_no_data_value: num(required=False) - # Save the number of looks used to compute GCOV save_nlooks: bool(required=False) diff --git a/tests/cxx/isce3/geocode/geocodeCov.cpp b/tests/cxx/isce3/geocode/geocodeCov.cpp index 5f23733d4..5de06a73d 100644 --- a/tests/cxx/isce3/geocode/geocodeCov.cpp +++ b/tests/cxx/isce3/geocode/geocodeCov.cpp @@ -116,7 +116,7 @@ TEST(GeocodeTest, TestGeocodeCov) { bool flag_az_baseband_doppler = false; bool flatten = false; double geogrid_upsampling = 1; - double shadow_no_data_value = std::numeric_limits::quiet_NaN(); + double fill_value = std::numeric_limits::quiet_NaN(); bool flag_upsample_radar_grid = false; isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry::rtcInputTerrainRadiometry::BETA_NAUGHT; @@ -244,7 +244,7 @@ TEST(GeocodeTest, TestGeocodeCov) { geoObj.geocode(radar_grid_shifted, radarRaster, geocodedRaster, demRaster, output_mode, flag_az_baseband_doppler, flatten, geogrid_upsampling, - shadow_no_data_value, flag_upsample_radar_grid, + fill_value, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, exponent, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, @@ -301,7 +301,7 @@ TEST(GeocodeTest, TestGeocodeCov) { geoComplexObj.geocode(radar_grid, slc_raster_xy, geocoded_diag_raster, demRaster, output_mode, flag_az_baseband_doppler, flatten, - geogrid_upsampling, shadow_no_data_value, + geogrid_upsampling, fill_value, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, exponent, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, From 8f08f5d9adddb5df6d3320a832b1369f575ea580 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Wed, 12 Aug 2026 10:17:22 -0700 Subject: [PATCH 03/19] Add parameter to the module --- cxx/isce3/geocode/GeocodeCov.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index 3eb84e7b7..cdc6adafa 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -3550,7 +3550,7 @@ void Geocode::_runBlock( // otherwise, if the geogrid pixel is `Nan` and `fill_value` is // not `NaN`, update the geogrid pixel with `fill_value` else if (std::isnan(std::abs(geo_value))) { - T_out v = static_cast(shadow_no_data_value); + T_out v = static_cast(fill_value); geoDataBlock[band]->operator()(i, j) = v; } // clip min (complex) @@ -3605,7 +3605,7 @@ void Geocode::_runBlock( // otherwise, if the geogrid pixel is `Nan` and `fill_value` is // not `NaN`, update the geogrid pixel with `fill_value` else if (std::isnan(std::abs(geo_value_off_diag))) { - T2 v = static_cast(shadow_no_data_value); + T2 v = static_cast(fill_value); geoDataBlockOffDiag[band]->operator()(i, j) = v; } From 317c12a3282017e0482da52530a91146e6ace1fc Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Wed, 12 Aug 2026 10:22:37 -0700 Subject: [PATCH 04/19] Add parameter to the module --- cxx/isce3/geocode/GeocodeCov.cpp | 4 ++-- cxx/isce3/geocode/GeocodeCov.h | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index cdc6adafa..437f8d74f 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -873,7 +873,7 @@ void Geocode::geocodeInterp( rdrBlockWidth, rdrBlockLength, azimuthFirstLine, rangeFirstPixel, interp.get(), radar_grid, flag_az_baseband_doppler, flatten, phase_screen_raster, - phase_screen_array, fill_value, rtc_min_value, + phase_screen_array, rtc_min_value, abs_cal_factor_effective, clip_min, clip_max, flag_apply_rtc, rtc_area_array, rtc_area_sigma0_array, out_geo_rtc_band, @@ -961,7 +961,7 @@ inline void Geocode::_interpolate( const bool flag_az_baseband_doppler, const bool flatten, isce3::io::Raster* phase_screen_raster, isce3::core::Matrix& phase_screen_array, - float fill_value, float rtc_min_value, + float rtc_min_value, double abs_cal_factor_effective, float clip_min, float clip_max, bool flag_apply_rtc, const isce3::core::Matrix& rtc_area, diff --git a/cxx/isce3/geocode/GeocodeCov.h b/cxx/isce3/geocode/GeocodeCov.h index d9eba5c29..4547e1a87 100644 --- a/cxx/isce3/geocode/GeocodeCov.h +++ b/cxx/isce3/geocode/GeocodeCov.h @@ -699,9 +699,6 @@ class Geocode { * @param[in] flatten flag to flatten the geocoded SLC * @param[in] phase_screen_raster Phase screen raster * @param[in] phase_screen_array Phase screen array - * @param[in] fill_value Fill value. Defaults to NaN. If the - * output is complex (e.g., off-diagonal terms), this value is used for - * the real part with the imaginary part set to 0 * @param[in] rtc_min_value Minimum value for the RTC area factor. * @param[in] abs_cal_factor Absolute calibration factor applied * to real-valued output datasets (assumed to be proportional to @@ -753,8 +750,8 @@ class Geocode { const bool flag_az_baseband_doppler, const bool flatten, isce3::io::Raster* phase_screen_raster, isce3::core::Matrix& phase_screen_array, - float fill_value, float rtc_min_value, - double abs_cal_factor, float clip_min, float clip_max, + float rtc_min_value, double abs_cal_factor, + float clip_min, float clip_max, bool flag_run_rtc, const isce3::core::Matrix& rtc_area, const isce3::core::Matrix& rtc_area_sigma, isce3::io::Raster* out_geo_rtc, From e0d5c4458afafef6ced165a91d48cb726842ce40 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Wed, 12 Aug 2026 10:32:27 -0700 Subject: [PATCH 05/19] Add parameter to the module --- cxx/isce3/geocode/GeocodeCov.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index 437f8d74f..7842825a0 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -756,6 +756,8 @@ void Geocode::geocodeInterp( using T_out_real = typename isce3::real::type; T_out nan_t_out = 0; nan_t_out *= std::numeric_limits::quiet_NaN(); + + T_out fill_value_t_out = static_cast(fill_value); // define the geo-block matrix based on the raster bands data type isce3::core::Matrix geoDataBlock( @@ -765,7 +767,7 @@ void Geocode::geocodeInterp( if (azimuthFirstLine > azimuthLastLine || rangeFirstPixel > rangeLastPixel) { - geoDataBlock.fill(nan_t_out); + geoDataBlock.fill(fill_value_t_out); for (int band = 0; band < nbands; ++band) { outputRaster.setBlock(geoDataBlock.data(), 0, lineStart, geogrid.width(), geoBlockLength, band + 1); @@ -867,7 +869,7 @@ void Geocode::geocodeInterp( geoDataBlock with NaNs before each use. This prevents residual values from previous iterations from being mistakenly retained. */ - geoDataBlock.fill(nan_t_out); + geoDataBlock.fill(fill_value_t_out); _interpolate(rdrDataBlock, geoDataBlock, radarX, radarY, rdrBlockWidth, rdrBlockLength, azimuthFirstLine, From 5271c94682395145f63d271b4cb346d563775abf Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Wed, 12 Aug 2026 10:32:27 -0700 Subject: [PATCH 06/19] Set layover/shadow mask layer fill value to 255. --- cxx/isce3/geocode/GeocodeCov.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index 437f8d74f..7842825a0 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -756,6 +756,8 @@ void Geocode::geocodeInterp( using T_out_real = typename isce3::real::type; T_out nan_t_out = 0; nan_t_out *= std::numeric_limits::quiet_NaN(); + + T_out fill_value_t_out = static_cast(fill_value); // define the geo-block matrix based on the raster bands data type isce3::core::Matrix geoDataBlock( @@ -765,7 +767,7 @@ void Geocode::geocodeInterp( if (azimuthFirstLine > azimuthLastLine || rangeFirstPixel > rangeLastPixel) { - geoDataBlock.fill(nan_t_out); + geoDataBlock.fill(fill_value_t_out); for (int band = 0; band < nbands; ++band) { outputRaster.setBlock(geoDataBlock.data(), 0, lineStart, geogrid.width(), geoBlockLength, band + 1); @@ -867,7 +869,7 @@ void Geocode::geocodeInterp( geoDataBlock with NaNs before each use. This prevents residual values from previous iterations from being mistakenly retained. */ - geoDataBlock.fill(nan_t_out); + geoDataBlock.fill(fill_value_t_out); _interpolate(rdrDataBlock, geoDataBlock, radarX, radarY, rdrBlockWidth, rdrBlockLength, azimuthFirstLine, From eb45442b89bb69eecf107f0f4aea38b2edcfa229 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Wed, 12 Aug 2026 11:22:51 -0700 Subject: [PATCH 07/19] Set layover/shadow mask layer fill value to 255. --- python/packages/nisar/static/layover_shadow_mask.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/packages/nisar/static/layover_shadow_mask.py b/python/packages/nisar/static/layover_shadow_mask.py index 4f77a54b3..13d48ae03 100644 --- a/python/packages/nisar/static/layover_shadow_mask.py +++ b/python/packages/nisar/static/layover_shadow_mask.py @@ -238,6 +238,7 @@ def geocode_layover_shadow_mask( min_block_size=min_block_size, max_block_size=max_block_size, dem_interp_method=normalize_data_interp_method(dem_interp_method), + fill_value=255, ) return geocoded_layover_shadow_mask From 06d1c5b84e0a3f6cee248d314b682a818d353d17 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Wed, 12 Aug 2026 14:13:12 -0700 Subject: [PATCH 08/19] update data type --- cxx/isce3/geocode/GeocodeCov.cpp | 8 ++++---- cxx/isce3/geocode/GeocodeCov.h | 9 ++++----- python/extensions/pybind_isce3/geocode/GeocodeCov.cpp | 2 +- tests/cxx/isce3/geocode/geocodeCov.cpp | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index 7842825a0..e44deec14 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -128,7 +128,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, geocodeOutputMode output_mode, bool flag_az_baseband_doppler, bool flatten, double geogrid_upsampling, - float fill_value, bool flag_upsample_radar_grid, + double fill_value, bool flag_upsample_radar_grid, bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, @@ -263,7 +263,7 @@ template void Geocode::geocodeInterp( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& inputRaster, isce3::io::Raster& outputRaster, - isce3::io::Raster& demRaster, float fill_value, + isce3::io::Raster& demRaster, double fill_value, bool flag_apply_rtc, bool flag_az_baseband_doppler, bool flatten, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, @@ -1882,7 +1882,7 @@ void Geocode::geocodeAreaProj( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling, - float fill_value, bool flag_upsample_radar_grid, + double fill_value, bool flag_upsample_radar_grid, bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, @@ -2517,7 +2517,7 @@ void Geocode::_runBlock( int block_size_y, int block_size_with_upsampling_y, int block_y, int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, - double geogrid_upsampling, float fill_value, + double geogrid_upsampling, double fill_value, int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, isce3::io::Raster* out_off_diag_terms, diff --git a/cxx/isce3/geocode/GeocodeCov.h b/cxx/isce3/geocode/GeocodeCov.h index 4547e1a87..bd411266a 100644 --- a/cxx/isce3/geocode/GeocodeCov.h +++ b/cxx/isce3/geocode/GeocodeCov.h @@ -156,7 +156,7 @@ class Geocode { geocodeOutputMode output_mode = geocodeOutputMode::INTERP, bool flag_az_baseband_doppler = false, bool flatten = false, double geogrid_upsampling = 1, - float fill_value = std::numeric_limits::quiet_NaN(), + double fill_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry:: @@ -303,7 +303,7 @@ class Geocode { void geocodeInterp(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, - float fill_value = std::numeric_limits::quiet_NaN(), + double fill_value = std::numeric_limits::quiet_NaN(), bool flag_apply_rtc = false, bool flag_az_baseband_doppler = false, bool flatten = false, isce3::geometry::rtcInputTerrainRadiometry @@ -455,7 +455,7 @@ class Geocode { isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling = 1, - float fill_value = std::numeric_limits::quiet_NaN(), + double fill_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = @@ -645,8 +645,7 @@ class Geocode { int block_size_y, int block_size_with_upsampling_y, int block_y, int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, - double geogrid_upsampling, - float fill_value, + double geogrid_upsampling, double fill_value, int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, diff --git a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp index e910d8c48..f0680fbe7 100644 --- a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp +++ b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp @@ -72,7 +72,7 @@ void addbinding(py::class_>& pyGeocode) py::arg("flag_az_baseband_doppler") = false, py::arg("flatten") = false, py::arg("geogrid_upsampling") = 1, - py::arg("fill_value") = std::numeric_limits::quiet_NaN(), + py::arg("fill_value") = std::numeric_limits::quiet_NaN(), py::arg("flag_upsample_radar_grid") = false, py::arg("flag_apply_rtc") = false, py::arg("input_terrain_radiometry") = diff --git a/tests/cxx/isce3/geocode/geocodeCov.cpp b/tests/cxx/isce3/geocode/geocodeCov.cpp index 5de06a73d..f91e16151 100644 --- a/tests/cxx/isce3/geocode/geocodeCov.cpp +++ b/tests/cxx/isce3/geocode/geocodeCov.cpp @@ -116,7 +116,7 @@ TEST(GeocodeTest, TestGeocodeCov) { bool flag_az_baseband_doppler = false; bool flatten = false; double geogrid_upsampling = 1; - double fill_value = std::numeric_limits::quiet_NaN(); + double fill_value = std::numeric_limits::quiet_NaN(); bool flag_upsample_radar_grid = false; isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry::rtcInputTerrainRadiometry::BETA_NAUGHT; From 25d28083ed182d7e965ed344393c76bbb2f8e44d Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 10:58:04 -0700 Subject: [PATCH 09/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 28 ++++++++++++++++--- cxx/isce3/geogrid/getRadarGrid.h | 4 ++- .../pybind_isce3/geogrid/getRadarGrid.cpp | 3 ++ python/packages/nisar/workflows/static.py | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index 377578eec..00506b1ae 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -75,7 +75,8 @@ void getRadarGrid(isce3::core::LookSide lookside, isce3::io::Raster* ground_track_velocity_raster, isce3::io::Raster* local_incidence_angle_raster, isce3::io::Raster* projection_angle_raster, - isce3::io::Raster* simulated_radar_brightness_raster) + isce3::io::Raster* simulated_radar_brightness_raster, + isce3::product::RadarGridParameters* radar_grid) { pyre::journal::info_t info("isce.geogrid.getRadarGrid"); @@ -167,12 +168,18 @@ void getRadarGrid(isce3::core::LookSide lookside, const isce3::core::Vec3 input_dem = GetDemCoords(pos_x, pos_y, dem_interp, proj.get()); - if (interpolated_dem_raster != nullptr) { + // Populate the DEM raster if the radar grid has not been provided. + // If the radar grid has been provided, first verify whether + // the point is inside the radar grid. + if (interpolated_dem_raster != nullptr && radar_grid == nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } - // If nothing else to save, skip - if (slant_range_raster == nullptr && + // Skip if there is nothing else to save. + // For the DEM raster, the only condition that prevents skipping is when + // both `interpolated_dem_raster` and `radar_grid` are provided. + if (!(interpolated_dem_raster != nullptr && radar_grid != nullptr) && + slant_range_raster == nullptr && azimuth_time_raster == nullptr && incidence_angle_raster == nullptr && los_unit_vector_x_raster == nullptr && @@ -207,6 +214,19 @@ void getRadarGrid(isce3::core::LookSide lookside, continue; } + // If the radar grid has been provided, check whether the + // point is inside the radar grid. + if (radar_grid != nullptr) { + // If not inside, continue to the next pixel + if (!radar_grid->contains(azimuth_time, slant_range)) { + continue + } + // Otherwise, check if DEM raster needs to be populated + if (interpolated_dem_raster != nullptr) { + interpolated_dem_array(i, j) = input_dem[2]; + } + } + // save grid Doppler slant-range position if (slant_range_raster != nullptr) { slant_range_array(i, j) = slant_range; diff --git a/cxx/isce3/geogrid/getRadarGrid.h b/cxx/isce3/geogrid/getRadarGrid.h index 8512564b9..c97c8ef3e 100644 --- a/cxx/isce3/geogrid/getRadarGrid.h +++ b/cxx/isce3/geogrid/getRadarGrid.h @@ -50,6 +50,7 @@ namespace isce3 { namespace geogrid { * @param[out] projection_angle_raster Projection angle raster * @param[out] simulated_radar_brightness_raster Simulated radar brightness * raster + * @param[in] radar_grid Radar grid */ void getRadarGrid( isce3::core::LookSide lookside, @@ -74,6 +75,7 @@ void getRadarGrid( isce3::io::Raster* ground_track_velocity_raster = nullptr, isce3::io::Raster* local_incidence_angle_raster = nullptr, isce3::io::Raster* projection_angle_raster = nullptr, - isce3::io::Raster* simulated_radar_brightness_raster = nullptr); + isce3::io::Raster* simulated_radar_brightness_raster = nullptr, + isce3::product::RadarGridParameters* radar_grid = nullptr); }} \ No newline at end of file diff --git a/python/extensions/pybind_isce3/geogrid/getRadarGrid.cpp b/python/extensions/pybind_isce3/geogrid/getRadarGrid.cpp index 251de582d..8ee95dfb9 100644 --- a/python/extensions/pybind_isce3/geogrid/getRadarGrid.cpp +++ b/python/extensions/pybind_isce3/geogrid/getRadarGrid.cpp @@ -32,6 +32,7 @@ void addbinding_get_radar_grid(pybind11::module& m) py::arg("local_incidence_angle_raster") = nullptr, py::arg("projection_angle_raster") = nullptr, py::arg("simulated_radar_brightness_raster") = nullptr, + py::arg("radar_grid") = nullptr, R"(Get radar grid from L2 products Each output layer is saved onto the first band of its @@ -90,6 +91,8 @@ void addbinding_get_radar_grid(pybind11::module& m) Projection angle raster simulated_radar_brightness_raster : isce3.io.Raster, optional Simulated radar brightness raster + radar_grid : isce3.product.RadarGridParameters + Grid of the SAR data in slant-range )"); } diff --git a/python/packages/nisar/workflows/static.py b/python/packages/nisar/workflows/static.py index 2ec010eb2..8f24d6975 100644 --- a/python/packages/nisar/workflows/static.py +++ b/python/packages/nisar/workflows/static.py @@ -282,6 +282,7 @@ def run_static_layers_workflow(config_file: os.PathLike | str) -> None: geo2rdr_params = processing_params["geo2rdr"] with log_elapsed_time(logger.info, "Computing static geometry layers"): geometry_layers = compute_geometry_layers( + radar_grid=radar_grid, geo_grid=geo_grid, dem_raster=dem_raster, orbit=orbit, From 22c98740a7f34d2589ac81892b12b50d53be4a05 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 11:29:29 -0700 Subject: [PATCH 10/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index 00506b1ae..bdd82b43a 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -219,7 +219,7 @@ void getRadarGrid(isce3::core::LookSide lookside, if (radar_grid != nullptr) { // If not inside, continue to the next pixel if (!radar_grid->contains(azimuth_time, slant_range)) { - continue + continue; } // Otherwise, check if DEM raster needs to be populated if (interpolated_dem_raster != nullptr) { From 93c7a1c51950a7cf4f76810d04e54cfca665c844 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 12:04:13 -0700 Subject: [PATCH 11/19] add `radar_grid` parameter to L2 metadata cubes --- python/packages/nisar/static/geometry_layers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/packages/nisar/static/geometry_layers.py b/python/packages/nisar/static/geometry_layers.py index 16f525a6f..f48688b50 100644 --- a/python/packages/nisar/static/geometry_layers.py +++ b/python/packages/nisar/static/geometry_layers.py @@ -17,6 +17,7 @@ def compute_geometry_layers( + radar_grid: isce3.product.RadarGridParameters, geo_grid: isce3.product.GeoGridParameters, dem_raster: Raster, orbit: isce3.core.Orbit, @@ -37,6 +38,9 @@ def compute_geometry_layers( Parameters ---------- + radar_grid : isce3.product.RadarGridParameters + Grid of the SAR data in slant-range, used to ensure that all layers have + the same extents (radar grid). geo_grid : isce3.product.GeoGridParameters The geocoded coordinate grid on which to compute each of the output layers. dem_raster : isce3.io.Raster @@ -132,6 +136,7 @@ def make_output_raster(prefix: str) -> Raster: los_unit_vector_x_raster=los_east, los_unit_vector_y_raster=los_north, local_incidence_angle_raster=local_inc_angle, + radar_grid=radar_grid, ) return reprojected_dem, los_east, los_north, local_inc_angle From 2cc4af2f5af54f04a845462ab460f490d199a1b0 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 12:10:21 -0700 Subject: [PATCH 12/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index bdd82b43a..03bf3f259 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace isce3 { namespace geogrid { @@ -217,15 +218,20 @@ void getRadarGrid(isce3::core::LookSide lookside, // If the radar grid has been provided, check whether the // point is inside the radar grid. if (radar_grid != nullptr) { + std::cout << "1" << std::endl; // If not inside, continue to the next pixel if (!radar_grid->contains(azimuth_time, slant_range)) { + std::cout << "2" << std::endl; continue; } + std::cout << "3" << std::endl; // Otherwise, check if DEM raster needs to be populated if (interpolated_dem_raster != nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } + std::cout << "4" << std::endl; } + std::cout << "5" << std::endl; // save grid Doppler slant-range position if (slant_range_raster != nullptr) { From e4891c3af446e9b1750e466c01bd6d8620dc5bcd Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 12:14:48 -0700 Subject: [PATCH 13/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index 03bf3f259..6636a6633 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -172,9 +172,11 @@ void getRadarGrid(isce3::core::LookSide lookside, // Populate the DEM raster if the radar grid has not been provided. // If the radar grid has been provided, first verify whether // the point is inside the radar grid. + std::cout << "a" << std::endl; if (interpolated_dem_raster != nullptr && radar_grid == nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } + std::cout << "b" << std::endl; // Skip if there is nothing else to save. // For the DEM raster, the only condition that prevents skipping is when @@ -194,6 +196,7 @@ void getRadarGrid(isce3::core::LookSide lookside, simulated_radar_brightness_raster == nullptr) { continue; } + std::cout << "c" << std::endl; // Get target coordinates in the output projection system const isce3::core::Vec3 target_proj {pos_x, pos_y, input_dem[2]}; @@ -215,6 +218,8 @@ void getRadarGrid(isce3::core::LookSide lookside, continue; } + std::cout << "d" << std::endl; + // If the radar grid has been provided, check whether the // point is inside the radar grid. if (radar_grid != nullptr) { From e380388f2f0f06981e947b214fbd9bd926ed1271 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 12:18:28 -0700 Subject: [PATCH 14/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index 6636a6633..4ae6d20d8 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace isce3 { namespace geogrid { @@ -172,11 +171,11 @@ void getRadarGrid(isce3::core::LookSide lookside, // Populate the DEM raster if the radar grid has not been provided. // If the radar grid has been provided, first verify whether // the point is inside the radar grid. - std::cout << "a" << std::endl; + info << "a" << pyre::journal::newline; if (interpolated_dem_raster != nullptr && radar_grid == nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } - std::cout << "b" << std::endl; + info << "b" << pyre::journal::newline; // Skip if there is nothing else to save. // For the DEM raster, the only condition that prevents skipping is when @@ -196,7 +195,7 @@ void getRadarGrid(isce3::core::LookSide lookside, simulated_radar_brightness_raster == nullptr) { continue; } - std::cout << "c" << std::endl; + info << "c" << pyre::journal::newline; // Get target coordinates in the output projection system const isce3::core::Vec3 target_proj {pos_x, pos_y, input_dem[2]}; @@ -218,25 +217,25 @@ void getRadarGrid(isce3::core::LookSide lookside, continue; } - std::cout << "d" << std::endl; + info << "d" << pyre::journal::newline; // If the radar grid has been provided, check whether the // point is inside the radar grid. if (radar_grid != nullptr) { - std::cout << "1" << std::endl; + info << "1" << pyre::journal::newline; // If not inside, continue to the next pixel if (!radar_grid->contains(azimuth_time, slant_range)) { - std::cout << "2" << std::endl; + info << "2" << pyre::journal::newline; continue; } - std::cout << "3" << std::endl; + info << "3" << pyre::journal::newline; // Otherwise, check if DEM raster needs to be populated if (interpolated_dem_raster != nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } - std::cout << "4" << std::endl; + info << "4" << pyre::journal::newline; } - std::cout << "5" << std::endl; + info << "5" << pyre::journal::newline; // save grid Doppler slant-range position if (slant_range_raster != nullptr) { From 8091ba88637ea9413bd3d84571b9c763b05b173f Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 12:22:16 -0700 Subject: [PATCH 15/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index 4ae6d20d8..c32a30483 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -151,6 +151,7 @@ void getRadarGrid(isce3::core::LookSide lookside, getNanArray(projection_angle_raster, geogrid); auto simulated_radar_brightness_array = getNanArray(simulated_radar_brightness_raster, geogrid); + info << "starting computation" << pyre::journal::endl; #pragma omp parallel for for (int i = 0; i < geogrid.length(); ++i) { @@ -171,11 +172,11 @@ void getRadarGrid(isce3::core::LookSide lookside, // Populate the DEM raster if the radar grid has not been provided. // If the radar grid has been provided, first verify whether // the point is inside the radar grid. - info << "a" << pyre::journal::newline; + info << "a" << pyre::journal::endl; if (interpolated_dem_raster != nullptr && radar_grid == nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } - info << "b" << pyre::journal::newline; + info << "b" << pyre::journal::endl; // Skip if there is nothing else to save. // For the DEM raster, the only condition that prevents skipping is when @@ -195,7 +196,7 @@ void getRadarGrid(isce3::core::LookSide lookside, simulated_radar_brightness_raster == nullptr) { continue; } - info << "c" << pyre::journal::newline; + info << "c" << pyre::journal::endl; // Get target coordinates in the output projection system const isce3::core::Vec3 target_proj {pos_x, pos_y, input_dem[2]}; @@ -217,25 +218,25 @@ void getRadarGrid(isce3::core::LookSide lookside, continue; } - info << "d" << pyre::journal::newline; + info << "d" << pyre::journal::endl; // If the radar grid has been provided, check whether the // point is inside the radar grid. if (radar_grid != nullptr) { - info << "1" << pyre::journal::newline; + info << "1" << pyre::journal::endl; // If not inside, continue to the next pixel if (!radar_grid->contains(azimuth_time, slant_range)) { - info << "2" << pyre::journal::newline; + info << "2" << pyre::journal::endl; continue; } - info << "3" << pyre::journal::newline; + info << "3" << pyre::journal::endl; // Otherwise, check if DEM raster needs to be populated if (interpolated_dem_raster != nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } - info << "4" << pyre::journal::newline; + info << "4" << pyre::journal::endl; } - info << "5" << pyre::journal::newline; + info << "5" << pyre::journal::endl; // save grid Doppler slant-range position if (slant_range_raster != nullptr) { From 396a448e596b8e1b7105023bbb60af845f83f39e Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 12:25:09 -0700 Subject: [PATCH 16/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index c32a30483..cd9c10cdf 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -91,11 +91,14 @@ void getRadarGrid(isce3::core::LookSide lookside, auto proj = isce3::core::makeProjection(geogrid.epsg()); + info << "000" << pyre::journal::endl; + // Get DEM interpolator const double minX = geogrid.startX(); const double maxX = geogrid.startX() + geogrid.spacingX() * geogrid.width(); double minY = geogrid.startY(); double maxY = geogrid.startY() + geogrid.spacingY() * geogrid.length(); + info << "111" << pyre::journal::endl; const double refheight = 0; isce3::geometry::DEMInterpolator dem_interp(refheight, dem_interp_method); @@ -107,6 +110,7 @@ void getRadarGrid(isce3::core::LookSide lookside, "ERROR loading DEM for given area"; throw isce3::except::RuntimeError(ISCE_SRCINFO(), error_message); } + info << "222" << pyre::journal::endl; /* Get function GetDemCoords to convert DEM coordinates to the geogrid EPSG coordinates */ @@ -121,6 +125,7 @@ void getRadarGrid(isce3::core::LookSide lookside, } else { GetDemCoords = isce3::geometry::getDemCoordsDiffEpsg; } + info << "333" << pyre::journal::endl; const isce3::core::Ellipsoid& ellipsoid = proj->ellipsoid(); @@ -137,6 +142,7 @@ void getRadarGrid(isce3::core::LookSide lookside, getNanArray(los_unit_vector_x_raster, geogrid); auto los_unit_vector_y_array = getNanArray(los_unit_vector_y_raster, geogrid); + info << "444" << pyre::journal::endl; auto along_track_unit_vector_x_array = getNanArray(along_track_unit_vector_x_raster, geogrid); auto along_track_unit_vector_y_array = From f6e669202c475c245696f8f1f4a01bf3d60f827e Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Thu, 13 Aug 2026 12:29:30 -0700 Subject: [PATCH 17/19] add `radar_grid` parameter to L2 metadata cubes --- cxx/isce3/geogrid/getRadarGrid.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index cd9c10cdf..bdd82b43a 100644 --- a/cxx/isce3/geogrid/getRadarGrid.cpp +++ b/cxx/isce3/geogrid/getRadarGrid.cpp @@ -91,14 +91,11 @@ void getRadarGrid(isce3::core::LookSide lookside, auto proj = isce3::core::makeProjection(geogrid.epsg()); - info << "000" << pyre::journal::endl; - // Get DEM interpolator const double minX = geogrid.startX(); const double maxX = geogrid.startX() + geogrid.spacingX() * geogrid.width(); double minY = geogrid.startY(); double maxY = geogrid.startY() + geogrid.spacingY() * geogrid.length(); - info << "111" << pyre::journal::endl; const double refheight = 0; isce3::geometry::DEMInterpolator dem_interp(refheight, dem_interp_method); @@ -110,7 +107,6 @@ void getRadarGrid(isce3::core::LookSide lookside, "ERROR loading DEM for given area"; throw isce3::except::RuntimeError(ISCE_SRCINFO(), error_message); } - info << "222" << pyre::journal::endl; /* Get function GetDemCoords to convert DEM coordinates to the geogrid EPSG coordinates */ @@ -125,7 +121,6 @@ void getRadarGrid(isce3::core::LookSide lookside, } else { GetDemCoords = isce3::geometry::getDemCoordsDiffEpsg; } - info << "333" << pyre::journal::endl; const isce3::core::Ellipsoid& ellipsoid = proj->ellipsoid(); @@ -142,7 +137,6 @@ void getRadarGrid(isce3::core::LookSide lookside, getNanArray(los_unit_vector_x_raster, geogrid); auto los_unit_vector_y_array = getNanArray(los_unit_vector_y_raster, geogrid); - info << "444" << pyre::journal::endl; auto along_track_unit_vector_x_array = getNanArray(along_track_unit_vector_x_raster, geogrid); auto along_track_unit_vector_y_array = @@ -157,7 +151,6 @@ void getRadarGrid(isce3::core::LookSide lookside, getNanArray(projection_angle_raster, geogrid); auto simulated_radar_brightness_array = getNanArray(simulated_radar_brightness_raster, geogrid); - info << "starting computation" << pyre::journal::endl; #pragma omp parallel for for (int i = 0; i < geogrid.length(); ++i) { @@ -178,11 +171,9 @@ void getRadarGrid(isce3::core::LookSide lookside, // Populate the DEM raster if the radar grid has not been provided. // If the radar grid has been provided, first verify whether // the point is inside the radar grid. - info << "a" << pyre::journal::endl; if (interpolated_dem_raster != nullptr && radar_grid == nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } - info << "b" << pyre::journal::endl; // Skip if there is nothing else to save. // For the DEM raster, the only condition that prevents skipping is when @@ -202,7 +193,6 @@ void getRadarGrid(isce3::core::LookSide lookside, simulated_radar_brightness_raster == nullptr) { continue; } - info << "c" << pyre::journal::endl; // Get target coordinates in the output projection system const isce3::core::Vec3 target_proj {pos_x, pos_y, input_dem[2]}; @@ -224,25 +214,18 @@ void getRadarGrid(isce3::core::LookSide lookside, continue; } - info << "d" << pyre::journal::endl; - // If the radar grid has been provided, check whether the // point is inside the radar grid. if (radar_grid != nullptr) { - info << "1" << pyre::journal::endl; // If not inside, continue to the next pixel if (!radar_grid->contains(azimuth_time, slant_range)) { - info << "2" << pyre::journal::endl; continue; } - info << "3" << pyre::journal::endl; // Otherwise, check if DEM raster needs to be populated if (interpolated_dem_raster != nullptr) { interpolated_dem_array(i, j) = input_dem[2]; } - info << "4" << pyre::journal::endl; } - info << "5" << pyre::journal::endl; // save grid Doppler slant-range position if (slant_range_raster != nullptr) { From 7001119d5b31e5187bc86f36331fb9b607483353 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Mon, 17 Aug 2026 11:42:49 -0700 Subject: [PATCH 18/19] revert unnecessary changes --- cxx/isce3/geocode/GeocodeCov.cpp | 78 ++++++------------- .../pybind_isce3/geocode/GeocodeCov.cpp | 9 +-- .../nisar/static/layover_shadow_mask.py | 1 - tests/cxx/isce3/geocode/geocodeCov.cpp | 7 +- 4 files changed, 29 insertions(+), 66 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.cpp b/cxx/isce3/geocode/GeocodeCov.cpp index e44deec14..09f9e6ce4 100644 --- a/cxx/isce3/geocode/GeocodeCov.cpp +++ b/cxx/isce3/geocode/GeocodeCov.cpp @@ -128,8 +128,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, geocodeOutputMode output_mode, bool flag_az_baseband_doppler, bool flatten, double geogrid_upsampling, - double fill_value, bool flag_upsample_radar_grid, - bool flag_apply_rtc, + bool flag_upsample_radar_grid, bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, int exponent, float rtc_min_value_db, double rtc_geogrid_upsampling, @@ -160,8 +159,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, bool flag_run_geocode_interp = output_mode == geocodeOutputMode::INTERP; if (flag_run_geocode_interp && !flag_complex_to_real) geocodeInterp(radar_grid, input_raster, output_raster, dem_raster, - fill_value, flag_apply_rtc, - flag_az_baseband_doppler, flatten, + flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -177,8 +175,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, (std::is_same::value || std::is_same>::value)) geocodeInterp(radar_grid, input_raster, output_raster, - dem_raster, fill_value, - flag_apply_rtc, flag_az_baseband_doppler, flatten, + dem_raster, flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -192,8 +189,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else if (flag_run_geocode_interp) geocodeInterp(radar_grid, input_raster, output_raster, - dem_raster, fill_value, - flag_apply_rtc, flag_az_baseband_doppler, flatten, + dem_raster, flag_apply_rtc, flag_az_baseband_doppler, flatten, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -207,8 +203,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else if (!flag_complex_to_real) geocodeAreaProj(radar_grid, input_raster, output_raster, dem_raster, - geogrid_upsampling, fill_value, - flag_upsample_radar_grid, flag_apply_rtc, + geogrid_upsampling, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -224,8 +219,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, else if (std::is_same::value || std::is_same>::value) geocodeAreaProj(radar_grid, input_raster, output_raster, - dem_raster, geogrid_upsampling, fill_value, - flag_upsample_radar_grid, + dem_raster, geogrid_upsampling, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -241,8 +235,7 @@ void Geocode::geocode(const isce3::product::RadarGridParameters& radar_grid, dem_interp_method); else geocodeAreaProj(radar_grid, input_raster, output_raster, - dem_raster, geogrid_upsampling, fill_value, - flag_upsample_radar_grid, + dem_raster, geogrid_upsampling, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, @@ -263,8 +256,8 @@ template void Geocode::geocodeInterp( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& inputRaster, isce3::io::Raster& outputRaster, - isce3::io::Raster& demRaster, double fill_value, - bool flag_apply_rtc, bool flag_az_baseband_doppler, bool flatten, + isce3::io::Raster& demRaster, bool flag_apply_rtc, + bool flag_az_baseband_doppler, bool flatten, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, float rtc_min_value_db, double rtc_geogrid_upsampling, @@ -756,8 +749,6 @@ void Geocode::geocodeInterp( using T_out_real = typename isce3::real::type; T_out nan_t_out = 0; nan_t_out *= std::numeric_limits::quiet_NaN(); - - T_out fill_value_t_out = static_cast(fill_value); // define the geo-block matrix based on the raster bands data type isce3::core::Matrix geoDataBlock( @@ -767,7 +758,7 @@ void Geocode::geocodeInterp( if (azimuthFirstLine > azimuthLastLine || rangeFirstPixel > rangeLastPixel) { - geoDataBlock.fill(fill_value_t_out); + geoDataBlock.fill(nan_t_out); for (int band = 0; band < nbands; ++band) { outputRaster.setBlock(geoDataBlock.data(), 0, lineStart, geogrid.width(), geoBlockLength, band + 1); @@ -869,7 +860,7 @@ void Geocode::geocodeInterp( geoDataBlock with NaNs before each use. This prevents residual values from previous iterations from being mistakenly retained. */ - geoDataBlock.fill(fill_value_t_out); + geoDataBlock.fill(nan_t_out); _interpolate(rdrDataBlock, geoDataBlock, radarX, radarY, rdrBlockWidth, rdrBlockLength, azimuthFirstLine, @@ -877,8 +868,7 @@ void Geocode::geocodeInterp( flag_az_baseband_doppler, flatten, phase_screen_raster, phase_screen_array, rtc_min_value, abs_cal_factor_effective, clip_min, clip_max, - flag_apply_rtc, rtc_area_array, rtc_area_sigma0_array, - out_geo_rtc_band, + flag_apply_rtc, rtc_area_array, rtc_area_sigma0_array, out_geo_rtc_band, out_geo_rtc_array, out_geo_rtc_gamma0_to_sigma0_band, out_geo_rtc_gamma0_to_sigma0_array, input_layover_shadow_mask_raster, @@ -1882,8 +1872,7 @@ void Geocode::geocodeAreaProj( const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling, - double fill_value, bool flag_upsample_radar_grid, - bool flag_apply_rtc, + bool flag_upsample_radar_grid, bool flag_apply_rtc, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry, isce3::geometry::rtcOutputTerrainRadiometry output_terrain_radiometry, float rtc_min_value_db, double rtc_geogrid_upsampling, @@ -1928,10 +1917,10 @@ void Geocode::geocodeAreaProj( const float upsampled_radar_grid_nlooks = radar_grid_nlooks / 2; geocodeAreaProj(upsampled_radar_grid, input_raster, output_raster, dem_raster, geogrid_upsampling, - fill_value, flag_upsample_radar_grid, - flag_apply_rtc, input_terrain_radiometry, - output_terrain_radiometry, rtc_min_value_db, - rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, + flag_upsample_radar_grid, flag_apply_rtc, + input_terrain_radiometry, output_terrain_radiometry, + rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, + rtc_area_beta_mode, abs_cal_factor, clip_min, clip_max, min_nlooks, upsampled_radar_grid_nlooks, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2298,8 +2287,7 @@ void Geocode::geocodeAreaProj( is_radar_grid_single_block, rdrData, block_size_y, block_size_with_upsampling_y, block_y, block_size_x, block_size_with_upsampling_x, block_x, numdone, - progress_block, geogrid_upsampling, - fill_value, nbands, + progress_block, geogrid_upsampling, nbands, nbands_off_diag_terms, dem_interp_method, dem_raster, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2327,8 +2315,7 @@ void Geocode::geocodeAreaProj( is_radar_grid_single_block, rdrDataT, block_size_y, block_size_with_upsampling_y, block_y, block_size_x, block_size_with_upsampling_x, block_x, numdone, - progress_block, geogrid_upsampling, - fill_value, nbands, + progress_block, geogrid_upsampling, nbands, nbands_off_diag_terms, dem_interp_method, dem_raster, out_off_diag_terms, out_geo_rdr, out_geo_dem, out_geo_nlooks, out_geo_rtc, @@ -2517,8 +2504,7 @@ void Geocode::_runBlock( int block_size_y, int block_size_with_upsampling_y, int block_y, int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, - double geogrid_upsampling, double fill_value, - int nbands, int nbands_off_diag_terms, + double geogrid_upsampling, int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, isce3::io::Raster* out_off_diag_terms, isce3::io::Raster* out_geo_rdr, isce3::io::Raster* out_geo_dem, @@ -3545,16 +3531,10 @@ void Geocode::_runBlock( for (int j = 0; j < this_block_size_x; ++j) { T_out geo_value = geoDataBlock[band]->operator()(i, j); - // if the geogrid pixel is `NaN` and `fill_value` is `NaN`, - // continue to the next pixel - if (std::isnan(std::abs(geo_value)) && std::isnan(fill_value)) + // no data + if (std::isnan(std::abs(geo_value))) continue; - // otherwise, if the geogrid pixel is `Nan` and `fill_value` is - // not `NaN`, update the geogrid pixel with `fill_value` - else if (std::isnan(std::abs(geo_value))) { - T_out v = static_cast(fill_value); - geoDataBlock[band]->operator()(i, j) = v; - } + // clip min (complex) else if (!std::isnan(clip_min) && std::abs(geo_value) < clip_min && @@ -3599,17 +3579,9 @@ void Geocode::_runBlock( T geo_value_off_diag = geoDataBlockOffDiag[band]->operator()(i, j); - // if the geogrid pixel is `NaN` and `fill_value` is `NaN`, - // continue to the next pixel - if (std::isnan(std::abs(geo_value_off_diag)) && - std::isnan(fill_value)) + // no data (complex) + if (std::isnan(std::abs(geo_value_off_diag))) continue; - // otherwise, if the geogrid pixel is `Nan` and `fill_value` is - // not `NaN`, update the geogrid pixel with `fill_value` - else if (std::isnan(std::abs(geo_value_off_diag))) { - T2 v = static_cast(fill_value); - geoDataBlockOffDiag[band]->operator()(i, j) = v; - } // clip min (complex) else if (!std::isnan(clip_min) && diff --git a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp index f0680fbe7..255df9108 100644 --- a/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp +++ b/python/extensions/pybind_isce3/geocode/GeocodeCov.cpp @@ -72,7 +72,6 @@ void addbinding(py::class_>& pyGeocode) py::arg("flag_az_baseband_doppler") = false, py::arg("flatten") = false, py::arg("geogrid_upsampling") = 1, - py::arg("fill_value") = std::numeric_limits::quiet_NaN(), py::arg("flag_upsample_radar_grid") = false, py::arg("flag_apply_rtc") = false, py::arg("input_terrain_radiometry") = @@ -162,10 +161,6 @@ void addbinding(py::class_>& pyGeocode) Flatten the geocoded SLC geogrid_upsampling: int, optional Geogrid upsampling - fill_value: float, optional - Fill value. Defaults to NaN. If the output is complex - (e.g., off-diagonal terms), this value is used for - the real part with the imaginary part set to 0 flag_upsample_radar_grid: bool, optional Double the radar grid sampling rate flag_apply_rtc: bool, optional @@ -181,9 +176,9 @@ void addbinding(py::class_>& pyGeocode) rtc_min_value_db: float, optional Minimum value for the RTC area factor. Radar data with RTC area factor below this limit will be set to NaN. - rtc_upsampling: int, optional + rtc_geogrid_upsampling: int, optional Geogrid upsampling to compute the radiometric terrain - correction (RTC). + correction RTC. rtc_algorithm: isce3.geometry.RtcAlgorithm, optional RTC algorithm rtc_factor_area_mode : isce3.geometry.RtcAreaBetaMode, optional diff --git a/python/packages/nisar/static/layover_shadow_mask.py b/python/packages/nisar/static/layover_shadow_mask.py index 13d48ae03..4f77a54b3 100644 --- a/python/packages/nisar/static/layover_shadow_mask.py +++ b/python/packages/nisar/static/layover_shadow_mask.py @@ -238,7 +238,6 @@ def geocode_layover_shadow_mask( min_block_size=min_block_size, max_block_size=max_block_size, dem_interp_method=normalize_data_interp_method(dem_interp_method), - fill_value=255, ) return geocoded_layover_shadow_mask diff --git a/tests/cxx/isce3/geocode/geocodeCov.cpp b/tests/cxx/isce3/geocode/geocodeCov.cpp index f91e16151..26e2eb922 100644 --- a/tests/cxx/isce3/geocode/geocodeCov.cpp +++ b/tests/cxx/isce3/geocode/geocodeCov.cpp @@ -116,7 +116,6 @@ TEST(GeocodeTest, TestGeocodeCov) { bool flag_az_baseband_doppler = false; bool flatten = false; double geogrid_upsampling = 1; - double fill_value = std::numeric_limits::quiet_NaN(); bool flag_upsample_radar_grid = false; isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry::rtcInputTerrainRadiometry::BETA_NAUGHT; @@ -243,8 +242,7 @@ TEST(GeocodeTest, TestGeocodeCov) { // run geocode geoObj.geocode(radar_grid_shifted, radarRaster, geocodedRaster, demRaster, output_mode, flag_az_baseband_doppler, - flatten, geogrid_upsampling, - fill_value, flag_upsample_radar_grid, + flatten, geogrid_upsampling, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, exponent, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, @@ -301,8 +299,7 @@ TEST(GeocodeTest, TestGeocodeCov) { geoComplexObj.geocode(radar_grid, slc_raster_xy, geocoded_diag_raster, demRaster, output_mode, flag_az_baseband_doppler, flatten, - geogrid_upsampling, fill_value, - flag_upsample_radar_grid, flag_apply_rtc, + geogrid_upsampling, flag_upsample_radar_grid, flag_apply_rtc, input_terrain_radiometry, output_terrain_radiometry, exponent, rtc_min_value_db, rtc_geogrid_upsampling, rtc_algorithm, rtc_area_beta_mode, abs_cal_factor, clip_min, From a350e172547221e3cdb9d3da7b47d8f91465e7c8 Mon Sep 17 00:00:00 2001 From: "Gustavo H. X. Shiroma" Date: Mon, 17 Aug 2026 11:44:32 -0700 Subject: [PATCH 19/19] revert unnecessary changes --- cxx/isce3/geocode/GeocodeCov.h | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/cxx/isce3/geocode/GeocodeCov.h b/cxx/isce3/geocode/GeocodeCov.h index bd411266a..d3c437717 100644 --- a/cxx/isce3/geocode/GeocodeCov.h +++ b/cxx/isce3/geocode/GeocodeCov.h @@ -68,9 +68,6 @@ class Geocode { * baseband (using Doppler centroid) before interpolation * @param[in] flatten Flatten the geocoded SLC * @param[in] geogrid_upsampling Geogrid upsampling - * @param[in] fill_value Fill value. Defaults to NaN. If the - * output is complex (e.g., off-diagonal terms), this value is used for - * the real part with the imaginary part set to 0 * @param[in] flag_upsample_radar_grid Double the radar grid sampling rate * @param[in] flag_apply_rtc Apply radiometric terrain correction * (RTC) @@ -156,7 +153,6 @@ class Geocode { geocodeOutputMode output_mode = geocodeOutputMode::INTERP, bool flag_az_baseband_doppler = false, bool flatten = false, double geogrid_upsampling = 1, - double fill_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry:: @@ -229,11 +225,6 @@ class Geocode { * `abs_cal_factor parameters`, which default to `false` and `1`, * respectively. * @param[in] dem_raster Input DEM raster - * @param[in] fill_value Fill value. Defaults to NaN. If the - * output is complex (e.g., off-diagonal terms), this value is used for - * the real part with the imaginary part set to 0 - * @param[in] flag_apply_rtc Apply radiometric terrain correction - * (RTC) * @param[in] flag_az_baseband_doppler Shift SLC azimuth spectrum to * baseband (using Doppler centroid) before interpolation * @param[in] input_terrain_radiometry Input terrain radiometry @@ -302,9 +293,7 @@ class Geocode { template void geocodeInterp(const isce3::product::RadarGridParameters& radar_grid, isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, - isce3::io::Raster& dem_raster, - double fill_value = std::numeric_limits::quiet_NaN(), - bool flag_apply_rtc = false, + isce3::io::Raster& dem_raster, bool flag_apply_rtc = false, bool flag_az_baseband_doppler = false, bool flatten = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = isce3::geometry:: @@ -373,9 +362,6 @@ class Geocode { * respectively. * @param[in] dem_raster Input DEM raster * @param[in] geogrid_upsampling Geogrid upsampling - * @param[in] fill_value Fill value. Defaults to NaN. If the - * output is complex (e.g., off-diagonal terms), this value is used for - * the real part with the imaginary part set to 0 * @param[in] flag_upsample_radar_grid Double the radar grid sampling rate * @param[in] flag_apply_rtc Apply radiometric terrain correction * (RTC) @@ -455,7 +441,6 @@ class Geocode { isce3::io::Raster& input_raster, isce3::io::Raster& output_raster, isce3::io::Raster& dem_raster, double geogrid_upsampling = 1, - double fill_value = std::numeric_limits::quiet_NaN(), bool flag_upsample_radar_grid = false, bool flag_apply_rtc = false, isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry = @@ -645,8 +630,7 @@ class Geocode { int block_size_y, int block_size_with_upsampling_y, int block_y, int block_size_x, int block_size_with_upsampling_x, int block_x, long long& numdone, const long long& progress_block, - double geogrid_upsampling, double fill_value, - int nbands, int nbands_off_diag_terms, + double geogrid_upsampling, int nbands, int nbands_off_diag_terms, isce3::core::dataInterpMethod dem_interp_method, isce3::io::Raster& dem_raster, isce3::io::Raster* out_off_diag_terms, @@ -698,7 +682,8 @@ class Geocode { * @param[in] flatten flag to flatten the geocoded SLC * @param[in] phase_screen_raster Phase screen raster * @param[in] phase_screen_array Phase screen array - * @param[in] rtc_min_value Minimum value for the RTC area factor. + * @param[in] rtc_min_value_db Minimum value for the RTC area factor. + * Radar data with RTC area factor below this limit will be set to NaN. * @param[in] abs_cal_factor Absolute calibration factor applied * to real-valued output datasets (assumed to be proportional to * power/intensity). If the output is complex valued, its considered