Skip to content

Commit f31a4b5

Browse files
gshiromaGitHub Enterprise
authored andcommitted
Add GSLC on-demand software options (#637)
* remove "unitless" units, remove non-exitent CF standard_names, remove NaN fill values, add GCOV default values for save_rtc and save_nlooks * isolate GSLC chnages from "GCOV/GSLC On-Demand PR" #604 * fix unitest errors * refactor code * merge branch "develop" into update_gslc_on_demand (2) * merge branch "develop" into update_gslc_on_demand (3) * apply style changes * Update GSLC RTC * revert changes to the RTC * remove blank spaces * add comments to _baseband * fix RTC.cpp format * make differences between DEM and data interpolators more explicity * fix doxygen * rename GeocodeCov method data_interpolator() to dataInterpolator() * merge develop into update_gslc_on_demand (2) * add DEM interpolation method to geocode::loadDEM() * Clean up white spaces in geocode unitest * fix identation in the GeocodeCov module * simplify variables declaration * add comment to "magic number" 50
1 parent 73edde3 commit f31a4b5

File tree

10 files changed

+846
-233
lines changed

10 files changed

+846
-233
lines changed

cxx/isce3/geocode/GeocodeCov.cpp

Lines changed: 619 additions & 170 deletions
Large diffs are not rendered by default.

cxx/isce3/geocode/GeocodeCov.h

Lines changed: 168 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class Geocode {
4545
* @param[out] output_raster Output raster
4646
* @param[in] dem_raster Input DEM raster
4747
* @param[in] output_mode Geocode method
48+
* @param[in] flag_az_baseband_doppler Shift SLC azimuth spectrum to baseband
49+
* (using Doppler centroid) before interpolation
50+
* @param[in] flatten Flatten the geocoded SLC
4851
* @param[in] geogrid_upsampling Geogrid upsampling (in each direction)
4952
* @param[in] flag_upsample_radar_grid Double the radar grid sampling rate
5053
* @param[in] flag_apply_rtc Apply radiometric terrain correction (RTC)
@@ -54,7 +57,7 @@ class Geocode {
5457
* The value 0 indicates that the the exponent is based on the data type of
5558
* the input raster (1 for real and 2 for complex rasters).
5659
* @param[in] rtc_min_value_db Minimum value for the RTC area factor.
57-
* Radar data with RTC area factor below this limit are ignored.
60+
* Radar data with RTC area factor below this limit will be set to NaN.
5861
* @param[in] rtc_geogrid_upsampling Geogrid upsampling (in each
5962
* direction) used to compute the radiometric terrain correction RTC.
6063
* @param[in] rtc_algorithm RTC algorithm (RTC_BILINEAR_DISTRIBUTION
@@ -72,15 +75,20 @@ class Geocode {
7275
* @param[out] out_geo_rdr Raster to which the radar-grid
7376
* positions (range and azimuth) of the geogrid pixels vertices will be
7477
* saved.
75-
* @param[out] out_geo_dem Raster to which the interpolated DEM
78+
* @param[out] out_geo_dem Raster to which the interpolated DEM
7679
* will be saved.
7780
* @param[out] out_nlooks Raster to which the number of radar-grid
7881
* looks associated with the geogrid will be saved.
7982
* @param[out] out_geo_rtc Output RTC area factor (in
8083
* geo-coordinates).
81-
* @param[in] in_rtc Input RTC area factor (in slant-range).
82-
* @param[out] out_rtc Output RTC area factor (in slant-range).
83-
* @param[in] geocode_memory_mode Select memory mode
84+
* @param[in] phase_screen_raster Phase screen to be removed before geocoding
85+
* @param[in] offset_az_raster Azimuth offset raster (reference
86+
* radar-grid geometry)
87+
* @param[in] offset_rg_raster Range offset raster (reference
88+
* radar-grid geometry)
89+
* @param[in] in_rtc Input RTC area factor (in slant-range).
90+
* @param[out] out_rtc Output RTC area factor (in slant-range).
91+
* @param[in] geocode_memory_mode Select memory mode
8492
* @param[in] min_block_size Minimum block size (per thread)
8593
* @param[in] max_block_size Maximum block size (per thread)
8694
* @param[in] dem_interp_method DEM interpolation method
@@ -89,12 +97,15 @@ class Geocode {
8997
geocode(const isce3::product::RadarGridParameters& radar_grid,
9098
isce3::io::Raster& input_raster, isce3::io::Raster& output_raster,
9199
isce3::io::Raster& dem_raster,
92-
geocodeOutputMode output_mode = geocodeOutputMode::AREA_PROJECTION,
100+
geocodeOutputMode output_mode = geocodeOutputMode::INTERP,
101+
bool flag_az_baseband_doppler = false,
102+
bool flatten = false,
93103
double geogrid_upsampling = 1,
94104
bool flag_upsample_radar_grid = false,
95105
bool flag_apply_rtc = false,
96-
isce3::geometry::rtcInputTerrainRadiometry input_terrain_radiometry =
97-
isce3::geometry::rtcInputTerrainRadiometry::BETA_NAUGHT,
106+
isce3::geometry::rtcInputTerrainRadiometry
107+
input_terrain_radiometry = isce3::geometry::
108+
rtcInputTerrainRadiometry::BETA_NAUGHT,
98109
isce3::geometry::rtcOutputTerrainRadiometry
99110
output_terrain_radiometry = isce3::geometry::
100111
rtcOutputTerrainRadiometry::GAMMA_NAUGHT,
@@ -114,6 +125,9 @@ class Geocode {
114125
isce3::io::Raster* out_geo_dem = nullptr,
115126
isce3::io::Raster* out_geo_nlooks = nullptr,
116127
isce3::io::Raster* out_geo_rtc = nullptr,
128+
isce3::io::Raster* phase_screen_raster = nullptr,
129+
isce3::io::Raster* offset_az_raster = nullptr,
130+
isce3::io::Raster* offset_rg_raster = nullptr,
117131
isce3::io::Raster* input_rtc = nullptr,
118132
isce3::io::Raster* output_rtc = nullptr,
119133
geocodeMemoryMode geocode_memory_mode = geocodeMemoryMode::AUTO,
@@ -130,12 +144,68 @@ class Geocode {
130144
* @param[in] input_raster Input raster
131145
* @param[out] output_raster Output raster
132146
* @param[in] dem_raster Input DEM raster
147+
* @param[in] flag_az_baseband_doppler Shift SLC azimuth spectrum to baseband
148+
* (using Doppler centroid) before interpolation
149+
* @param[in] input_terrain_radiometry Input terrain radiometry
150+
* @param[in] output_terrain_radiometry Output terrain radiometry
151+
* @param[in] rtc_min_value_db Minimum value for the RTC area factor.
152+
* Radar data with RTC area factor below this limit will be set to NaN.
153+
* @param[in] rtc_geogrid_upsampling Geogrid upsampling (in each
154+
* direction) used to compute the radiometric terrain correction RTC.
155+
* @param[in] rtc_algorithm RTC algorithm (RTC_BILINEAR_DISTRIBUTION or
156+
* RTC_AREA_PROJECTION)
157+
* @param[in] abs_cal_factor Absolute calibration factor.
158+
* @param[in] clip_min Clip (limit) minimum output values
159+
* @param[in] clip_max Clip (limit) maximum output values
160+
* @param[out] out_geo_rdr Raster to which the radar-grid
161+
* positions (range and azimuth) of the geogrid pixels centers will be
162+
* saved.
163+
* @param[out] out_geo_dem Raster to which the interpolated DEM
164+
* will be saved.
165+
* @param[out] out_geo_rtc Output RTC area factor (in
166+
* geo-coordinates).
167+
* @param[in] flatten Flatten the geocoded SLC
168+
* @param[in] phase_screen_raster Phase screen to be removed before geocoding
169+
* @param[in] offset_az_raster Azimuth offset raster (reference
170+
* radar-grid geometry)
171+
* @param[in] offset_rg_raster Range offset raster (reference radar-grid
172+
* geometry)
173+
* @param[in] in_rtc Input RTC area factor (in slant-range).
174+
* @param[out] out_rtc Output RTC area factor (in slant-range).
175+
* @param[in] dem_interp_method DEM interpolation method
133176
*/
134177
template<class T_out>
135-
void geocodeInterp(const isce3::product::RadarGridParameters& radar_grid,
136-
isce3::io::Raster& input_raster,
137-
isce3::io::Raster& output_raster,
138-
isce3::io::Raster& demRaster);
178+
void geocodeInterp(
179+
const isce3::product::RadarGridParameters& radar_grid,
180+
isce3::io::Raster& input_raster, isce3::io::Raster& output_raster,
181+
isce3::io::Raster& dem_raster,
182+
bool flag_apply_rtc = false,
183+
bool flag_az_baseband_doppler = false, bool flatten = false,
184+
isce3::geometry::rtcInputTerrainRadiometry
185+
input_terrain_radiometry = isce3::geometry::
186+
rtcInputTerrainRadiometry::BETA_NAUGHT,
187+
isce3::geometry::rtcOutputTerrainRadiometry
188+
output_terrain_radiometry = isce3::geometry::
189+
rtcOutputTerrainRadiometry::GAMMA_NAUGHT,
190+
float rtc_min_value_db = std::numeric_limits<float>::quiet_NaN(),
191+
double rtc_geogrid_upsampling =
192+
std::numeric_limits<double>::quiet_NaN(),
193+
isce3::geometry::rtcAlgorithm rtc_algorithm =
194+
isce3::geometry::rtcAlgorithm::RTC_AREA_PROJECTION,
195+
double abs_cal_factor = 1,
196+
float clip_min = std::numeric_limits<float>::quiet_NaN(),
197+
float clip_max = std::numeric_limits<float>::quiet_NaN(),
198+
isce3::io::Raster* out_geo_rdr = nullptr,
199+
isce3::io::Raster* out_geo_dem = nullptr,
200+
isce3::io::Raster* out_geo_rtc = nullptr,
201+
isce3::io::Raster* phase_screen_raster = nullptr,
202+
isce3::io::Raster* offset_az_raster = nullptr,
203+
isce3::io::Raster* offset_rg_raster = nullptr,
204+
isce3::io::Raster* input_rtc = nullptr,
205+
isce3::io::Raster* output_rtc = nullptr,
206+
isce3::core::dataInterpMethod dem_interp_method =
207+
isce3::core::dataInterpMethod::BIQUINTIC_METHOD);
208+
139209

140210
/** Geocode using the area projection algorithm (adaptive multilooking)
141211
*
@@ -175,10 +245,10 @@ class Geocode {
175245
* geo-coordinates).
176246
* @param[in] in_rtc Input RTC area factor (in slant-range).
177247
* @param[out] out_rtc Output RTC area factor (in slant-range).
178-
* @param[in] dem_interp_method DEM interpolation method
179248
* @param[in] min_block_size Minimum block size (per thread)
180249
* @param[in] max_block_size Maximum block size (per thread)
181250
* @param[in] geocode_memory_mode Select memory mode
251+
* @param[in] dem_interp_method DEM interpolation method
182252
*/
183253
template<class T_out>
184254
void geocodeAreaProj(
@@ -277,6 +347,8 @@ class Geocode {
277347

278348
void doppler(isce3::core::LUT2d<double> doppler) { _doppler = doppler; }
279349

350+
void nativeDoppler(isce3::core::LUT2d<double> nativeDoppler) { _nativeDoppler = nativeDoppler; }
351+
280352
void orbit(isce3::core::Orbit& orbit) { _orbit = orbit; }
281353

282354
void ellipsoid(isce3::core::Ellipsoid& ellipsoid)
@@ -363,18 +435,87 @@ class Geocode {
363435
isce3::core::ProjectionBase* _proj, int lineStart,
364436
int blockLength, int blockWidth, double demMargin);
365437

366-
void _geo2rdr(const isce3::product::RadarGridParameters& radar_grid,
367-
double x, double y, double& azimuthTime, double& slantRange,
368-
isce3::geometry::DEMInterpolator& demInterp,
369-
isce3::core::ProjectionBase* proj);
370-
438+
std::string _get_nbytes_str(long nbytes);
439+
440+
int _geo2rdr(const isce3::product::RadarGridParameters& radar_grid,
441+
double x, double y, double& azimuthTime, double& slantRange,
442+
isce3::geometry::DEMInterpolator& demInterp,
443+
isce3::core::ProjectionBase* proj,
444+
float &dem_value);
445+
446+
/**
447+
* @param[in] rdrDataBlock a basebanded block of data in radar coordinate
448+
* @param[out] geoDataBlock a block of data in geo coordinates
449+
* @param[in] radarX the radar-coordinates x-index of the pixels in geo-grid
450+
* @param[in] radarY the radar-coordinates y-index of the pixels in geo-grid
451+
* @param[in] radarBlockWidth width of the data block in radar coordinates
452+
* @param[in] radarBlockLength length of the data block in radar coordinates
453+
* @param[in] azimuthFirstLine azimuth time of the first sample
454+
* @param[in] rangeFirstPixel range of the first sample
455+
* @param[in] interp interpolator object
456+
* @param[in] radarGrid radar grid parameter
457+
* @param[in] nativeDoppler 2D LUT Doppler of the SLC image
458+
* @param[in] flatten flag to flatten the geocoded SLC
459+
* @param[in] phase_screen_raster Phase screen raster
460+
* @param[in] phase_screen_array Phase screen array
461+
* @param[in] abs_cal_factor Absolute calibration factor.
462+
* @param[in] clip_min Clip (limit) minimum output values
463+
* @param[in] clip_max Clip (limit) maximum output values
464+
* @param[in] flag_run_rtc Flag to indicate if RTC is enabled
465+
* @param[in] rtc_area RTC area normalization factor array
466+
* @param[out] out_geo_rtc Output RTC area factor raster (in
467+
* geo-coordinates)
468+
* @param[out] out_geo_rtc Output RTC area factor array (in
469+
* geo-coordinates)
470+
*/
371471
template<class T_out>
372-
void
373-
_interpolate(isce3::core::Matrix<T_out>& rdrDataBlock,
374-
isce3::core::Matrix<T_out>& geoDataBlock,
375-
std::valarray<double>& radarX, std::valarray<double>& radarY,
376-
int rdrBlockWidth, int rdrBlockLength, int azimuthFirstLine,
377-
int rangeFirstPixel, isce3::core::Interpolator<T_out>* interp);
472+
inline void _interpolate(const isce3::core::Matrix<T_out>& rdrDataBlock,
473+
isce3::core::Matrix<T_out>& geoDataBlock,
474+
const std::valarray<double>& radarX,
475+
const std::valarray<double>& radarY,
476+
const int radarBlockWidth, const int radarBlockLength,
477+
const int azimuthFirstLine, const int rangeFirstPixel,
478+
const isce3::core::Interpolator<T_out>* interp,
479+
const isce3::product::RadarGridParameters& radarGrid,
480+
const bool flag_az_baseband_doppler, const bool flatten,
481+
isce3::io::Raster* phase_screen_raster,
482+
isce3::core::Matrix<float>& phase_screen_array,
483+
double abs_cal_factor, float clip_min, float clip_max,
484+
bool flag_run_rtc, const isce3::core::Matrix<float>& rtc_area,
485+
isce3::io::Raster* out_geo_rtc,
486+
isce3::core::Matrix<float>& out_geo_rtc_arraya);
487+
488+
489+
/**
490+
* param[in,out] data a matrix of data that needs to be base-banded in
491+
* azimuth param[in] starting_range starting range of the data block
492+
* param[in] sensing_start starting azimuth time of the data block
493+
* param[in] range_pixel_spacing spacing of the slant range
494+
* param[in] prf pulse repetition frequency
495+
* param[in] doppler_lut 2D LUT of the image Doppler
496+
*/
497+
template<class T2>
498+
inline void _baseband(isce3::core::Matrix<T2>& data, const double starting_range,
499+
const double sensing_start, const double range_pixel_spacing,
500+
const double prf,
501+
const isce3::core::LUT2d<double>& doppler_lut);
502+
503+
/**
504+
* param[in,out] data a matrix of data that needs to be base-banded in
505+
* azimuth param[in] starting_range starting range of the data block
506+
* param[in] sensing_start starting azimuth time of the data block
507+
* param[in] range_pixel_spacing spacing of the slant range
508+
* param[in] prf pulse repetition frequency
509+
* param[in] doppler_lut 2D LUT of the image Doppler
510+
*/
511+
template<class T2>
512+
inline void _baseband(isce3::core::Matrix<std::complex<T2>>& data,
513+
const double starting_range, const double sensing_start,
514+
const double range_pixel_spacing, const double prf,
515+
const isce3::core::LUT2d<double>& doppler_lut);
516+
517+
518+
378519

379520
// isce3::core objects
380521
isce3::core::Orbit _orbit;
@@ -389,6 +530,9 @@ class Geocode {
389530
// radar grids parameters
390531
isce3::core::LUT2d<double> _doppler;
391532

533+
// native Doppler
534+
isce3::core::LUT2d<double> _nativeDoppler;
535+
392536
// start X position for the output geogrid
393537
double _geoGridStartX = std::numeric_limits<double>::quiet_NaN();
394538

cxx/isce3/geocode/loadDem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ isce3::geometry::DEMInterpolator
55
isce3::geocode::loadDEM(isce3::io::Raster& demRaster,
66
const isce3::product::GeoGridParameters& geoGrid,
77
int lineStart, int blockLength, int blockWidth,
8-
double demMargin)
8+
double demMargin,
9+
isce3::core::dataInterpMethod demInterpMethod)
910
{
1011
// DEM interpolator
11-
isce3::geometry::DEMInterpolator demInterp;
12+
isce3::geometry::DEMInterpolator demInterp(0, demInterpMethod);
1213

1314
// the epsg code of the input DEM
1415
int epsgcode = demRaster.getEPSG();

cxx/isce3/geocode/loadDem.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ namespace isce3 { namespace geocode {
1515
* @param[in] blockLength length of the block of interest in the eocoded grid
1616
* @param[in] blockWidth width of the block of interest in the eocoded grid
1717
* @param[in] demMargin extra margin for the dem relative to the geocoded grid
18+
* @param[in] demInterpMethod DEM interpolation method
1819
*/
1920
isce3::geometry::DEMInterpolator
2021
loadDEM(isce3::io::Raster& demRaster,
2122
const isce3::product::GeoGridParameters& geoGrid, int lineStart,
22-
int blockLength, int blockWidth, double demMargin);
23+
int blockLength, int blockWidth, double demMargin,
24+
isce3::core::dataInterpMethod demInterpMethod = isce3::core::BICUBIC_METHOD);
2325
}} // namespace isce3::geocode

cxx/isce3/geometry/RTC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ void computeRtcBilinearDistribution(isce3::io::Raster& dem_raster,
11251125
auto elapsed_time_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
11261126
std::chrono::high_resolution_clock::now() - start_time);
11271127
float elapsed_time = ((float) elapsed_time_milliseconds.count()) / 1e3;
1128-
info << "elapsed time (RTC-BI) [s]: " << elapsed_time << pyre::journal::endl;
1128+
info << "elapsed time (RTC-BI) [s]: " << elapsed_time << pyre::journal::endl;
11291129
}
11301130

11311131
isce3::error::ErrorCode loadDemFromProj(isce3::io::Raster& dem_raster,

cxx/isce3/geometry/RTC.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ void computeRtc(isce3::product::Product& product, isce3::io::Raster& dem_raster,
145145
* @param[in] input_dop Doppler LUT
146146
* @param[in] dem_raster Input DEM raster
147147
* @param[out] output_raster Output raster
148-
* @param[in] frequency Product frequency
149148
* @param[in] input_terrain_radiometry Input terrain radiometry
150149
* @param[in] output_terrain_radiometry Output terrain radiometry
151150
* @param[in] rtc_area_mode RTC area mode (AREA or AREA_FACTOR)

python/extensions/pybind_isce3/geocode/GeocodeCov.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <isce3/geometry/RTC.h>
77
#include <isce3/io/Raster.h>
88

9+
#include <pybind11/stl.h>
10+
911
namespace py = pybind11;
1012

1113
using isce3::core::parseDataInterpMethod;
@@ -24,6 +26,7 @@ void addbinding(py::class_<Geocode<T>>& pyGeocode)
2426
pyGeocode.def(py::init<>())
2527
.def_property("orbit", nullptr, &Geocode<T>::orbit)
2628
.def_property("doppler", nullptr, &Geocode<T>::doppler)
29+
.def_property("native_doppler", nullptr, &Geocode<T>::nativeDoppler)
2730
.def_property("ellipsoid", nullptr, &Geocode<T>::ellipsoid)
2831
.def_property("threshold_geo2rdr", nullptr,
2932
&Geocode<T>::thresholdGeo2rdr)
@@ -66,6 +69,8 @@ void addbinding(py::class_<Geocode<T>>& pyGeocode)
6669
py::arg("output_raster"), py::arg("dem_raster"),
6770
py::arg("output_mode") =
6871
geocodeOutputMode::AREA_PROJECTION,
72+
py::arg("flag_az_baseband_doppler") = false,
73+
py::arg("flatten") = false,
6974
py::arg("geogrid_upsampling") = 1,
7075
py::arg("flag_upsample_radar_grid") = false,
7176
py::arg("flag_apply_rtc") = false,
@@ -93,6 +98,9 @@ void addbinding(py::class_<Geocode<T>>& pyGeocode)
9398
py::arg("out_geo_dem") = nullptr,
9499
py::arg("out_geo_nlooks") = nullptr,
95100
py::arg("out_geo_rtc") = nullptr,
101+
py::arg("phase_screen") = nullptr,
102+
py::arg("offset_az_raster") = nullptr,
103+
py::arg("offset_rg_raster") = nullptr,
96104
py::arg("input_rtc") = nullptr,
97105
py::arg("output_rtc") = nullptr,
98106
py::arg("memory_mode") = geocodeMemoryMode::AUTO,
@@ -103,11 +111,9 @@ void addbinding(py::class_<Geocode<T>>& pyGeocode)
103111
py::arg("dem_interp_method") = isce3::core::BIQUINTIC_METHOD);
104112
}
105113

106-
107-
108-
void addbinding(pybind11::enum_<geocodeOutputMode> & pyGeocodeMode)
114+
void addbinding(pybind11::enum_<geocodeOutputMode>& pyGeocodeOutputMode)
109115
{
110-
pyGeocodeMode.value("INTERP", geocodeOutputMode::INTERP)
116+
pyGeocodeOutputMode.value("INTERP", geocodeOutputMode::INTERP)
111117
.value("AREA_PROJECTION", geocodeOutputMode::AREA_PROJECTION);
112118
};
113119

0 commit comments

Comments
 (0)