diff --git a/cxx/isce3/geogrid/getRadarGrid.cpp b/cxx/isce3/geogrid/getRadarGrid.cpp index 377578eec..bdd82b43a 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/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 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,