Skip to content

Commit d541a52

Browse files
Liang Yuvbrancat
authored andcommitted
GSLC carriers (#912)
* add az and range phase carrier params to geocode SLC * fix pybind * added missing docstring info * removed extra semicolon * Remove az and rg carriers before interpolation * reuse carrier_phase computation * GSLC carrier removal like resample SLC * phase to chipPhase * add offset in range and slight shuffle/reorg * correct carrier restoration indices * fix misordered eval inputs * parallelize carrier removal * simplify indexing * GSLC frequency removal/reintroduction made modular * moved doppler calculation back to interpolate added files for carrier remove/restore * updated documentation + comments and some cleanup * geocodeSlc templated * move ramping/interpolate functions inside geocodeSlc.cpp * correct frequency and phrase usage * self describing template name * replace std::valarray with isce3::core::matrix * added more comments for clarity renamed variables for clarity cleaned up commented out code * carriers eval with az/range instead of indices * fix sign bug rename carrierRampAndFlatten to carrierPhaseRampAndFlatten for consistency documentation updates and fixes * fix documentation and typo * refactor double loops to single for speed up * renames for clarity and docstring fix * add pybind docstring * apply doppler frac to chip instead of interped value * fill invalid pixels to NaN Co-authored-by: vbrancat <[email protected]>
1 parent 7d2a724 commit d541a52

File tree

10 files changed

+413
-238
lines changed

10 files changed

+413
-238
lines changed

cxx/isce3/Headers.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ focus/Presum.icc
8383
focus/RangeComp.h
8484
geocode/baseband.h
8585
geocode/geocodeSlc.h
86-
geocode/interpolate.h
8786
geocode/loadDem.h
8887
geometry/DEMInterpolator.h
8988
geometry/forward.h

cxx/isce3/Sources.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ focus/Presum.cpp
4343
focus/RangeComp.cpp
4444
geocode/baseband.cpp
4545
geocode/geocodeSlc.cpp
46-
geocode/interpolate.cpp
4746
geocode/loadDem.cpp
4847
geometry/DEMInterpolator.cpp
4948
geometry/Geo2rdr.cpp

cxx/isce3/geocode/geocodeSlc.cpp

Lines changed: 335 additions & 78 deletions
Large diffs are not rendered by default.

cxx/isce3/geocode/geocodeSlc.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include <cstddef>
33
#include <isce3/core/forward.h>
4+
#include <isce3/core/Poly2d.h>
45
#include <isce3/io/forward.h>
56
#include <isce3/product/forward.h>
67

@@ -14,15 +15,19 @@ namespace isce3 { namespace geocode {
1415
* \param[in] radarGrid radar grid parameters
1516
* \param[in] geoGrid geo grid parameters
1617
* \param[in] orbit orbit
17-
* \param[in] nativeDoppler 2D LUT Doppler of the SLC image
18-
* \param[in] imageGridDoppler 2D LUT Doppler of the image grid
19-
* \param[in] ellipsoid ellipsoid object
20-
* \param[in] thresholdGeo2rdr threshold for geo2rdr computations
18+
* \param[in] nativeDoppler 2D LUT Doppler of the SLC image
19+
* \param[in] imageGridDoppler 2D LUT Doppler of the image grid
20+
* \param[in] ellipsoid ellipsoid object
21+
* \param[in] thresholdGeo2rdr threshold for geo2rdr computations
2122
* \param[in] numiterGeo2rdr maximum number of iterations for Geo2rdr convergence
2223
* \param[in] linesPerBlock number of lines in each block
2324
* \param[in] demBlockMargin margin of a DEM block in degrees
2425
* \param[in] flatten flag to flatten the geocoded SLC
26+
* \param[in] azCarrier azimuth carrier phase of the SLC data, in radians, as a function of azimuth and range
27+
* \param[in] rgCarrier range carrier phase of the SLC data, in radians, as a function of azimuth and range
28+
* \tparam[in] AzRgFunc 2-D real-valued function of azimuth and range
2529
*/
30+
template<typename AzRgFunc = isce3::core::Poly2d>
2631
void geocodeSlc(isce3::io::Raster& outputRaster, isce3::io::Raster& inputRaster,
2732
isce3::io::Raster& demRaster,
2833
const isce3::product::RadarGridParameters& radarGrid,
@@ -33,6 +38,8 @@ void geocodeSlc(isce3::io::Raster& outputRaster, isce3::io::Raster& inputRaster,
3338
const isce3::core::Ellipsoid& ellipsoid,
3439
const double& thresholdGeo2rdr, const int& numiterGeo2rdr,
3540
const size_t& linesPerBlock, const double& demBlockMargin,
36-
const bool flatten = true);
41+
const bool flatten = true,
42+
const AzRgFunc& azCarrier = AzRgFunc(),
43+
const AzRgFunc& rgCarrier = AzRgFunc());
3744

3845
}} // namespace isce3::geocode

cxx/isce3/geocode/interpolate.cpp

Lines changed: 0 additions & 97 deletions
This file was deleted.

cxx/isce3/geocode/interpolate.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

python/extensions/pybind_isce3/geocode/GeocodeSlc.cpp

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <isce3/core/Ellipsoid.h>
44
#include <isce3/core/LUT2d.h>
55
#include <isce3/core/Orbit.h>
6+
#include <isce3/core/Poly2d.h>
67
#include <isce3/io/Raster.h>
78
#include <isce3/product/RadarGridParameters.h>
89
#include <isce3/product/GeoGridParameters.h>
@@ -11,9 +12,10 @@
1112

1213
namespace py = pybind11;
1314

15+
template<typename AzRgFunc = isce3::core::Poly2d>
1416
void addbinding_geocodeslc(py::module & m)
1517
{
16-
m.def("geocode_slc", &isce3::geocode::geocodeSlc,
18+
m.def("geocode_slc", &isce3::geocode::geocodeSlc<AzRgFunc>,
1719
py::arg("output_raster"),
1820
py::arg("input_raster"),
1921
py::arg("dem_raster"),
@@ -27,5 +29,46 @@ void addbinding_geocodeslc(py::module & m)
2729
py::arg("numiter_geo2rdr") = 25,
2830
py::arg("lines_per_block") = 1000,
2931
py::arg("dem_block_margin") = 0.1,
30-
py::arg("flatten") = true);
32+
py::arg("flatten") = true,
33+
py::arg("azimuth_carrier") = AzRgFunc(),
34+
py::arg("range_carrier") = AzRgFunc(),
35+
R"(
36+
Geocode a SLC
37+
38+
Parameters
39+
----------
40+
outputRaster: Raster
41+
Output raster containing geocoded SLC
42+
inputRaster: Raster
43+
Input raster of the SLC in radar coordinates
44+
demRaster: Raster
45+
Raster of the DEM
46+
radargrid: RadarGridParameters
47+
Radar grid parameters of input SLC raster
48+
geogrid: GeoGridParameters
49+
Geo grid parameters of output raster
50+
native_doppler: LUT2d
51+
2D LUT doppler of the SLC image
52+
image_grid_doppler: LUT2d
53+
2d LUT doppler of the image grid
54+
ellipsoid: Ellipsoid
55+
Ellipsoid object
56+
threshold_geo2rdr: float
57+
Threshold for geo2rdr computations
58+
numiter_geo2rdr: int
59+
Maximum number of iterations for geo2rdr convergence
60+
lines_per_block: int
61+
Number of lines per block
62+
dem_block_margin: float
63+
Margin of a DEM block in degrees
64+
flatten: bool
65+
Flag to flatten the geocoded SLC
66+
azimuth_carrier: [LUT2d, Poly2d]
67+
Azimuth carrier phase of the SLC data, in radians, as a function of azimuth and range
68+
range_carrier: [LUT2d, Poly2d]
69+
Range carrier phase of the SLC data, in radians, as a function of azimuth and range
70+
)");
3171
}
72+
73+
template void addbinding_geocodeslc<isce3::core::LUT2d<double>>(py::module & m);
74+
template void addbinding_geocodeslc<isce3::core::Poly2d>(py::module & m);

python/extensions/pybind_isce3/geocode/GeocodeSlc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
#include <pybind11/pybind11.h>
44

5+
template<typename T>
56
void addbinding_geocodeslc(pybind11::module&);

python/extensions/pybind_isce3/geocode/geocode.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ void addsubmodule_geocode(py::module & m)
1010
{
1111
py::module geocode = m.def_submodule("geocode");
1212

13-
addbinding_geocodeslc(geocode);
13+
addbinding_geocodeslc<isce3::core::LUT2d<double>>(geocode);
14+
addbinding_geocodeslc<isce3::core::Poly2d>(geocode);
1415

1516
// forward declare bound classes
1617
py::class_<isce3::geocode::Geocode<float>>

tests/cxx/isce3/geocode/geocode.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <isce3/core/LUT2d.h>
1212
#include <isce3/core/Metadata.h>
1313
#include <isce3/core/Orbit.h>
14+
#include <isce3/core/Poly2d.h>
1415
#include <isce3/geocode/geocodeSlc.h>
1516
#include <isce3/geocode/GeocodeCov.h>
1617
#include <isce3/geometry/Topo.h>
@@ -185,7 +186,7 @@ TEST(GeocodeTest, TestGeocodeCov) {
185186
offset_az_raster, offset_rg_raster, geocode_memory_mode_1,
186187
min_block_size, max_block_size);
187188
}
188-
}
189+
}
189190

190191
// Test generation of full-covariance elements and block processing
191192

@@ -265,7 +266,7 @@ TEST(GeocodeTest, CheckGeocodeCovFullCovResults) {
265266
double err_y = 0.0;
266267
double err_x_conj_y = 0.0;
267268
double max_err_x = 0.0;
268-
double max_err_y = 0.0;
269+
double max_err_y = 0.0;
269270
double max_err_x_conj_y = 0.0;
270271

271272
std::valarray<double> geocoded_diag_array_x(length * width);
@@ -352,17 +353,17 @@ TEST(GeocodeTest, CheckGeocodeCovFullCovResults) {
352353
nvalid_x_conj_y++;
353354
// }
354355

355-
max_err_x_conj_y = std::max(max_err_x_conj_y,
356+
max_err_x_conj_y = std::max(max_err_x_conj_y,
356357
std::abs(err_x_conj_y));
357-
358+
358359
}
359360
}
360361

361362
stats.mean = total / static_cast<double>(stats.n_valid);
362363
double mean_real_valued = total_real_valued / stats.n_valid;
363364

364365
double sample_stddev_factor = (
365-
static_cast<double>(stats.n_valid)) /
366+
static_cast<double>(stats.n_valid)) /
366367
(static_cast<double>(stats.n_valid - 1));
367368

368369
stats.sample_stddev = std::sqrt(sample_stddev_factor *
@@ -488,7 +489,7 @@ TEST(GeocodeTest, CheckGeocodeCovResults) {
488489
stats_y.mean = total_y / stats_y.n_valid;
489490

490491
double sample_stddev_factor = (
491-
static_cast<double>(stats_x.n_valid)) /
492+
static_cast<double>(stats_x.n_valid)) /
492493
(static_cast<double>(stats_x.n_valid - 1));
493494

494495
stats_x.sample_stddev = std::sqrt(sample_stddev_factor *
@@ -510,7 +511,7 @@ TEST(GeocodeTest, CheckGeocodeCovResults) {
510511
std::cout << " maxErrY: " << maxErrY << std::endl;
511512
std::cout << " dx: " << dx << std::endl;
512513
std::cout << " dy: " << dy << std::endl;
513-
514+
514515
ASSERT_GE(stats_x.n_valid, 800);
515516
ASSERT_GE(stats_y.n_valid, 800);
516517

@@ -603,20 +604,20 @@ TEST(GeocodeTest, TestGeocodeSlc)
603604

604605
bool flatten = false;
605606

606-
isce3::geocode::geocodeSlc(geocodedSlc, inputSlc, demRaster, radarGrid,
607-
geoGrid, orbit, nativeDoppler, imageGridDoppler,
608-
ellipsoid, thresholdGeo2rdr, numiterGeo2rdr,
609-
linesPerBlock, demBlockMargin, flatten);
607+
isce3::geocode::geocodeSlc<isce3::core::Poly2d> (
608+
geocodedSlc, inputSlc, demRaster, radarGrid, geoGrid, orbit,
609+
nativeDoppler, imageGridDoppler, ellipsoid, thresholdGeo2rdr,
610+
numiterGeo2rdr, linesPerBlock, demBlockMargin, flatten);
610611

611612
isce3::io::Raster inputSlcY("yslc_rdr.bin", GA_ReadOnly);
612613

613614
isce3::io::Raster geocodedSlcY("yslc_geo.bin", geoGridWidth, geoGridLength, 1,
614615
GDT_CFloat32, "ENVI");
615616

616-
isce3::geocode::geocodeSlc(geocodedSlcY, inputSlcY, demRaster, radarGrid,
617-
geoGrid, orbit, nativeDoppler, imageGridDoppler,
618-
ellipsoid, thresholdGeo2rdr, numiterGeo2rdr,
619-
linesPerBlock, demBlockMargin, flatten);
617+
isce3::geocode::geocodeSlc<isce3::core::LUT2d<double>> (
618+
geocodedSlcY, inputSlcY, demRaster, radarGrid, geoGrid, orbit,
619+
nativeDoppler, imageGridDoppler, ellipsoid, thresholdGeo2rdr,
620+
numiterGeo2rdr, linesPerBlock, demBlockMargin, flatten);
620621

621622
double* _geoTrans = new double[6];
622623
_geoTrans[0] = geoGridStartX;
@@ -726,7 +727,7 @@ void createZeroDem()
726727

727728

728729
template<class T>
729-
void checkStatsReal(isce3::math::Stats<T> computed_stats,
730+
void checkStatsReal(isce3::math::Stats<T> computed_stats,
730731
isce3::io::Raster &raster) {
731732

732733
int band = 0, approx_ok = 0;
@@ -798,7 +799,7 @@ void checkStatsComplex(isce3::math::Stats<T> computed_stats,
798799
ASSERT_LT(std::abs(isce3_stats.max - computed_stats.max), 1.0e-15);
799800

800801
if (!isnan(computed_stats.sample_stddev)) {
801-
ASSERT_LT(std::abs(isce3_stats.sample_stddev -
802+
ASSERT_LT(std::abs(isce3_stats.sample_stddev -
802803
computed_stats.sample_stddev), 1.0e-8);
803804
}
804805

0 commit comments

Comments
 (0)