Skip to content

Commit e597c21

Browse files
Liang YuGitHub Enterprise
authored andcommitted
Simplify a resamp constructor (#889)
* remove redundant wavelength parameter from resamp constructor * update pybind constructors and add contain method to LUT2d
1 parent 7dea92f commit e597c21

File tree

9 files changed

+49
-19
lines changed

9 files changed

+49
-19
lines changed

cxx/isce3/cuda/image/ResampSlc.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ class isce3::cuda::image::ResampSlc : public isce3::image::ResampSlc {
1414
inline ResampSlc(const isce3::product::Product &product, char frequency = 'A') :
1515
isce3::image::ResampSlc(product, frequency) {}
1616

17-
// Constructor from an isce3::product::Product and reference product (flattening)
17+
// Constructor from an isce3::product::Product and reference product (flattening)
1818
inline ResampSlc(const isce3::product::Product & product,
1919
const isce3::product::Product & refProduct,
2020
char frequency = 'A') :
2121
isce3::image::ResampSlc(product, refProduct, frequency) {}
2222

2323
/** Constructor from an isce3::product::RadarGridParameters (no flattening) */
2424
inline ResampSlc(const isce3::product::RadarGridParameters & rdr_grid,
25-
const isce3::core::LUT2d<double> & doppler,
26-
double wvl) :
27-
isce3::image::ResampSlc(rdr_grid, doppler, wvl) {}
25+
const isce3::core::LUT2d<double> & doppler) :
26+
isce3::image::ResampSlc(rdr_grid, doppler) {}
2827

2928
/** Constructor from an isce3::product::RadarGridParameters and reference radar grid (flattening) */
3029
inline ResampSlc(const isce3::product::RadarGridParameters & rdr_grid,
@@ -53,13 +52,13 @@ class isce3::cuda::image::ResampSlc : public isce3::image::ResampSlc {
5352
// Generic resamp entry point from externally created rasters
5453
void resamp(isce3::io::Raster & inputSlc, isce3::io::Raster & outputSlc,
5554
isce3::io::Raster & rgOffsetRaster, isce3::io::Raster & azOffsetRaster,
56-
int inputBand=1, bool flatten=false, bool isComplex=true, int rowBuffer=40,
55+
int inputBand=1, bool flatten=false, bool isComplex=true, int rowBuffer=40,
5756
int chipSize=isce3::core::SINC_ONE);
5857

5958
// Generic resamp entry point: use filenames to create rasters
6059
void resamp(const std::string & inputFilename, const std::string & outputFilename,
6160
const std::string & rgOffsetFilename, const std::string & azOffsetFilename,
6261
int inputBand=1, bool flatten=false, bool isComplex=true, int rowBuffer=40,
6362
int chipSize=isce3::core::SINC_ONE);
64-
63+
6564
};

cxx/isce3/image/ResampSlc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ResampSlc {
4545
* Constructor from an isce3::product::RadarGridParameters (no flattening)
4646
*/
4747
ResampSlc(const isce3::product::RadarGridParameters& rdr_grid,
48-
const isce3::core::LUT2d<double>& doppler, double wvl);
48+
const isce3::core::LUT2d<double>& doppler);
4949

5050
/**
5151
* Constructor from an isce3::product::RadarGridParameters and reference

cxx/isce3/image/ResampSlc.icc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ inline ResampSlc::ResampSlc(const isce3::product::Swath& swath,
4949

5050
// Constructor from an isce3::product::RadarGridParameters (no flattening)
5151
inline ResampSlc::ResampSlc(const isce3::product::RadarGridParameters& rdr_grid,
52-
const isce3::core::LUT2d<double>& doppler,
53-
double wvl)
52+
const isce3::core::LUT2d<double>& doppler)
5453
: _haveRefData(false), _dopplerLUT(doppler),
5554
_startingRange(rdr_grid.startingRange()),
5655
_rangePixelSpacing(rdr_grid.rangePixelSpacing()),
5756
_sensingStart(rdr_grid.sensingStart()), _prf(rdr_grid.prf()),
58-
_wavelength(wvl)
57+
_wavelength(rdr_grid.wavelength())
5958
{}
6059

6160
// Constructor from an isce3::product::RadarGridParameters and reference radar

python/extensions/pybind_isce3/core/LUT2d.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ void addbinding(py::class_<LUT2d<T>> &pyLUT2d)
123123
py::arg("epoch"),
124124
py::arg("units") = "")
125125

126+
.def("contains", &LUT2d<T>::contains,
127+
"Check if point (y, x) resides in domain of LUT",
128+
py::arg("y"),
129+
py::arg("x"))
126130
.def_property_readonly("have_data", &LUT2d<T>::haveData)
127131
.def_property_readonly("ref_value", &LUT2d<T>::refValue)
128132
.def_property_readonly("x_start", &LUT2d<T>::xStart)

python/extensions/pybind_isce3/cuda/image/ResampSlc.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
#include <isce3/core/Constants.h>
44
#include <isce3/core/LUT2d.h>
5+
#include <isce3/core/Poly2d.h>
56
#include <isce3/io/Raster.h>
67

8+
using isce3::core::Poly2d;
79
using isce3::cuda::image::ResampSlc;
810

911
namespace py = pybind11;
@@ -31,10 +33,22 @@ void addbinding(py::class_<ResampSlc> & pyResampSlc)
3133
py::arg("ref_range_pixel_spacing"),
3234
py::arg("ref_wavelength"))
3335
.def(py::init<const isce3::product::RadarGridParameters &,
34-
const isce3::core::LUT2d<double> &, double>(),
36+
const isce3::core::LUT2d<double> &>(),
37+
py::arg("rdr_grid"),
38+
py::arg("doppler"))
39+
.def(py::init([](const isce3::product::RadarGridParameters & grid,
40+
const isce3::core::LUT2d<double> & doppler,
41+
const Poly2d & az_carrier,
42+
const Poly2d & rg_carrier) {
43+
auto resamp = ResampSlc(grid, doppler);
44+
resamp.azCarrier(az_carrier);
45+
resamp.rgCarrier(rg_carrier);
46+
return resamp;
47+
}),
3548
py::arg("rdr_grid"),
3649
py::arg("doppler"),
37-
py::arg("wavelength"))
50+
py::arg("azimuth_carrier")=Poly2d(),
51+
py::arg("range_carrier")=Poly2d())
3852
.def(py::init<const isce3::product::RadarGridParameters &,
3953
const isce3::product::RadarGridParameters &,
4054
const isce3::core::LUT2d<double> &, double, double>(),

python/extensions/pybind_isce3/image/ResampSlc.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
#include <isce3/core/Constants.h>
44
#include <isce3/core/LUT2d.h>
5+
#include <isce3/core/Poly2d.h>
56
#include <isce3/io/Raster.h>
67

8+
using isce3::core::Poly2d;
79
using isce3::image::ResampSlc;
810

911
namespace py = pybind11;
@@ -31,10 +33,22 @@ void addbinding(py::class_<ResampSlc> & pyResampSlc)
3133
py::arg("ref_range_pixel_spacing"),
3234
py::arg("ref_wavelength"))
3335
.def(py::init<const isce3::product::RadarGridParameters &,
34-
const isce3::core::LUT2d<double> &, double>(),
36+
const isce3::core::LUT2d<double> &>(),
37+
py::arg("rdr_grid"),
38+
py::arg("doppler"))
39+
.def(py::init([](const isce3::product::RadarGridParameters & grid,
40+
const isce3::core::LUT2d<double> & doppler,
41+
const Poly2d & az_carrier,
42+
const Poly2d & rg_carrier) {
43+
auto resamp = ResampSlc(grid, doppler);
44+
resamp.azCarrier(az_carrier);
45+
resamp.rgCarrier(rg_carrier);
46+
return resamp;
47+
}),
3548
py::arg("rdr_grid"),
3649
py::arg("doppler"),
37-
py::arg("wavelength"))
50+
py::arg("azimuth_carrier")=Poly2d(),
51+
py::arg("range_carrier")=Poly2d())
3852
.def(py::init<const isce3::product::RadarGridParameters &,
3953
const isce3::product::RadarGridParameters &,
4054
const isce3::core::LUT2d<double> &, double, double>(),

python/packages/nisar/workflows/resample_slc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def run(cfg, resample_type):
8181
else:
8282
Resamp = isce3.image.ResampSlc
8383

84-
resamp_obj = Resamp(radar_grid, native_doppler, radar_grid.wavelength)
84+
resamp_obj = Resamp(radar_grid, native_doppler)
8585

8686
# If lines per tile is > 0, assign it to resamp_obj
8787
if resamp_args['lines_per_tile']:

tests/python/extensions/pybind/cuda/image/resamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_run():
2020
slc = SLC(hdf5file=h5_path)
2121

2222
# init resamp obj
23-
resamp = isce3.cuda.image.ResampSlc(grid, slc.getDopplerCentroid(), grid.wavelength)
23+
resamp = isce3.cuda.image.ResampSlc(grid, slc.getDopplerCentroid())
2424
resamp.lines_per_tile = 249
2525

2626
# prepare rasters
@@ -47,7 +47,7 @@ def test_validate():
4747

4848
# load reference data and avoid edges
4949
ref_slc = np.fromfile(iscetest.data+'warped_envisat.slc', dtype=np.complex64).reshape(500,500)[20:-20,20:-20]
50-
50+
5151
# get normalized error
5252
abs_error = np.abs(np.sum(test_slc - ref_slc) / test_slc.size)
5353

tests/python/extensions/pybind/image/resamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_run():
2020
slc = SLC(hdf5file=h5_path)
2121

2222
# init resamp obj
23-
resamp = isce3.image.ResampSlc(grid, slc.getDopplerCentroid(), grid.wavelength)
23+
resamp = isce3.image.ResampSlc(grid, slc.getDopplerCentroid())
2424
resamp.lines_per_tile = 249
2525

2626
# prepare rasters
@@ -47,7 +47,7 @@ def test_validate():
4747

4848
# load reference data and avoid edges
4949
ref_slc = np.fromfile(iscetest.data+'warped_envisat.slc', dtype=np.complex64).reshape(500,500)[20:-20,20:-20]
50-
50+
5151
# get normalized error
5252
abs_error = np.abs(np.sum(test_slc - ref_slc) / test_slc.size)
5353

0 commit comments

Comments
 (0)