Skip to content

Commit 23b3847

Browse files
Liang YuGitHub Enterprise
authored andcommitted
resample SLC reference radar grid constructor, carrier indexing, and CUDA doppler fix (#969)
* untested: modify reference grid constructor * carrier eval with az and range instead of index * removed unnecessary modulos * added docstrings
1 parent 70ff9d1 commit 23b3847

File tree

9 files changed

+390
-225
lines changed

9 files changed

+390
-225
lines changed

cxx/isce3/cuda/image/ResampSlc.cpp

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//-*- C++ -*-
2-
//-*- coding: utf-8 -*-
3-
//
4-
// Author: Joshua Cohen, Bryan V. Riel, Liang Yu
5-
// Copyright 2017-2018
6-
//
7-
81
#include "ResampSlc.h"
92

103
#include <algorithm>
@@ -14,7 +7,7 @@
147

158
// isce3::core
169
#include <isce3/core/Constants.h>
17-
#include <isce3/core/LUT1d.h>
10+
#include <isce3/core/LUT2d.h>
1811

1912
#include <isce3/image/Tile.h>
2013

@@ -30,9 +23,9 @@ resamp(const std::string & inputFilename, // filename of input SLC
3023
const std::string & outputFilename, // filename of output resampled SLC
3124
const std::string & rgOffsetFilename, // filename of range offsets
3225
const std::string & azOffsetFilename, // filename of azimuth offsets
33-
int inputBand, bool flatten, bool isComplex, int rowBuffer,
34-
int chipSize) {
35-
26+
int inputBand, bool flatten, int rowBuffer,
27+
int chipSize)
28+
{
3629
// Make input rasters
3730
Raster inputSlc(inputFilename, GA_ReadOnly);
3831
Raster rgOffsetRaster(rgOffsetFilename, GA_ReadOnly);
@@ -45,21 +38,16 @@ resamp(const std::string & inputFilename, // filename of input SLC
4538

4639
// Call generic resamp
4740
resamp(inputSlc, outputSlc, rgOffsetRaster, azOffsetRaster, inputBand, flatten,
48-
isComplex, rowBuffer, chipSize);
41+
rowBuffer, chipSize);
4942
}
5043

5144
// Generic resamp entry point from externally created rasters
5245
void isce3::cuda::image::ResampSlc::
5346
resamp(isce3::io::Raster & inputSlc, isce3::io::Raster & outputSlc,
5447
isce3::io::Raster & rgOffsetRaster, isce3::io::Raster & azOffsetRaster,
55-
int inputBand, bool flatten, bool isComplex, int rowBuffer,
56-
int chipSize) {
57-
58-
// Check if data are not complex
59-
if (!isComplex) {
60-
std::cout << "Real data interpolation not implemented yet.\n";
61-
return;
62-
}
48+
int inputBand, bool flatten, int rowBuffer,
49+
int chipSize)
50+
{
6351
// Set the band number for input SLC
6452
_inputBand = inputBand;
6553
// Cache width of SLC image
@@ -70,17 +58,18 @@ resamp(isce3::io::Raster & inputSlc, isce3::io::Raster & outputSlc,
7058
const int outWidth = rgOffsetRaster.width();
7159

7260
// Check if reference data is available
73-
if (!this->haveRefData()) {
74-
flatten = false;
61+
if (flatten && !this->haveRefData()) {
62+
std::string error_msg{"Unable to flatten; reference data not provided."};
63+
throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_msg);
7564
}
7665

7766
// initialize interpolator
7867
isce3::cuda::core::gpuSinc2dInterpolator<thrust::complex<float>> interp(chipSize-1, isce3::core::SINC_SUB);
7968

8069
// Determine number of tiles needed to process image
8170
const int nTiles = _computeNumberOfTiles(outLength, _linesPerTile);
82-
std::cout <<
83-
"GPU resampling using " << nTiles << " tiles of " << _linesPerTile
71+
std::cout <<
72+
"GPU resampling using " << nTiles << " tiles of " << _linesPerTile
8473
<< " lines per tile\n";
8574
// Start timer
8675
auto timerStart = std::chrono::steady_clock::now();
@@ -106,15 +95,16 @@ resamp(isce3::io::Raster & inputSlc, isce3::io::Raster & outputSlc,
10695

10796
// Get corresponding image indices
10897
std::cout << "Reading in image data for tile " << tileCount << std::endl;
109-
_initializeTile(tile, inputSlc, azOffTile, outLength, rowBuffer, chipSize/2);
98+
_initializeTile(tile, inputSlc, azOffTile, outLength, rowBuffer, chipSize/2);
11099

111100
// Perform interpolation
112101
std::cout << "Interpolating tile " << tileCount << std::endl;
113-
gpuTransformTile(tile, outputSlc, rgOffTile, azOffTile, _rgCarrier, _azCarrier,
114-
isce3::core::avgLUT2dToLUT1d<double>(_dopplerLUT), interp, inWidth, inLength, this->startingRange(),
115-
this->rangePixelSpacing(), this->prf(), this->wavelength(),
116-
this->refStartingRange(), this->refRangePixelSpacing(),
117-
this->refWavelength(), flatten, chipSize);
102+
gpuTransformTile(tile, outputSlc, rgOffTile, azOffTile, _rgCarrier, _azCarrier,
103+
_dopplerLUT, interp, inWidth, inLength, this->startingRange(),
104+
this->rangePixelSpacing(), this->sensingStart(), this->prf(),
105+
this->wavelength(), this->refStartingRange(),
106+
this->refRangePixelSpacing(), this->refWavelength(), flatten,
107+
chipSize, _invalid_value);
118108

119109
}
120110

@@ -124,5 +114,3 @@ resamp(isce3::io::Raster & inputSlc, isce3::io::Raster & outputSlc,
124114
timerEnd - timerStart).count();
125115
std::cout << "Elapsed processing time: " << elapsed << " sec" << "\n";
126116
}
127-
128-
// end of file

cxx/isce3/cuda/image/ResampSlc.h

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,84 @@ class isce3::cuda::image::ResampSlc : public isce3::image::ResampSlc {
1111
public:
1212
// Meta-methods
1313
// Constructor from an isce3::product::RadarGridProduct
14-
inline ResampSlc(const isce3::product::RadarGridProduct &product, char frequency = 'A') :
15-
isce3::image::ResampSlc(product, frequency) {}
14+
inline ResampSlc(const isce3::product::RadarGridProduct &product, char frequency = 'A',
15+
std::complex<float> invalid_value = std::complex<float>(0.0, 0.0)) :
16+
isce3::image::ResampSlc(product, frequency, invalid_value) {}
1617

1718
// Constructor from an isce3::product::RadarGridProduct and reference product (flattening)
1819
inline ResampSlc(const isce3::product::RadarGridProduct & product,
1920
const isce3::product::RadarGridProduct & refProduct,
20-
char frequency = 'A') :
21-
isce3::image::ResampSlc(product, refProduct, frequency) {}
21+
char frequency = 'A',
22+
std::complex<float> invalid_value = std::complex<float>(0.0, 0.0)) :
23+
isce3::image::ResampSlc(product, refProduct, frequency, invalid_value) {}
2224

2325
/** Constructor from an isce3::product::RadarGridParameters (no flattening) */
2426
inline ResampSlc(const isce3::product::RadarGridParameters & rdr_grid,
25-
const isce3::core::LUT2d<double> & doppler) :
26-
isce3::image::ResampSlc(rdr_grid, doppler) {}
27+
const isce3::core::LUT2d<double> & doppler,
28+
std::complex<float> invalid_value = std::complex<float>(0.0, 0.0)) :
29+
isce3::image::ResampSlc(rdr_grid, doppler, invalid_value) {}
2730

2831
/** Constructor from an isce3::product::RadarGridParameters and reference radar grid (flattening) */
2932
inline ResampSlc(const isce3::product::RadarGridParameters & rdr_grid,
3033
const isce3::product::RadarGridParameters & ref_rdr_grid,
3134
const isce3::core::LUT2d<double> & doppler,
32-
double wvl, double ref_wvl) :
33-
isce3::image::ResampSlc(rdr_grid, ref_rdr_grid, doppler, wvl, ref_wvl) {}
35+
std::complex<float> invalid_value = std::complex<float>(0.0, 0.0)) :
36+
isce3::image::ResampSlc(rdr_grid, ref_rdr_grid, doppler, invalid_value) {}
3437

3538
// Constructor from individual components (no flattening)
3639
inline ResampSlc(const isce3::core::LUT2d<double> & doppler,
3740
double startingRange, double rangePixelSpacing,
38-
double sensingStart, double prf, double wvl) :
41+
double sensingStart, double prf, double wvl,
42+
std::complex<float> invalid_value = std::complex<float>(0.0, 0.0)) :
3943
isce3::image::ResampSlc(doppler, startingRange, rangePixelSpacing, sensingStart,
40-
prf, wvl) {}
44+
prf, wvl, invalid_value) {}
4145

4246
// Constructor from individual components (flattening)
4347
inline ResampSlc(const isce3::core::LUT2d<double> & doppler,
4448
double startingRange, double rangePixelSpacing,
4549
double sensingStart, double prf, double wvl,
4650
double refStartingRange, double refRangePixelSpacing,
47-
double refWvl) :
51+
double refWvl,
52+
std::complex<float> invalid_value = std::complex<float>(0.0, 0.0)) :
4853
isce3::image::ResampSlc(doppler, startingRange, rangePixelSpacing, sensingStart,
49-
prf, wvl, refStartingRange, refRangePixelSpacing, refWvl) {}
54+
prf, wvl, refStartingRange, refRangePixelSpacing, refWvl,
55+
invalid_value) {}
5056

51-
// All resamp need? to be redefined to ensure derived functions used
52-
// Generic resamp entry point from externally created rasters
57+
/* Generic resamp entry point from externally created rasters
58+
*
59+
* \param[in] inputSlc raster of SLC to be resampled
60+
* \param[in] outputSlc raster of resampled SLC
61+
* \param[in] rgOffsetRaster raster of range shift to be applied
62+
* \param[in] azOffsetRaster raster of azimuth shift to be applied
63+
* \param[in] inputBand band of input raster to resample
64+
* \param[in] flatten flag to flatten resampled SLC
65+
* \param[in] rowBuffer number of rows excluded from top/bottom of azimuth
66+
* raster while searching for min/max indices of
67+
* resampled SLC
68+
* \param[in] chipSize size of chip used in sinc interpolation
69+
*/
5370
void resamp(isce3::io::Raster & inputSlc, isce3::io::Raster & outputSlc,
5471
isce3::io::Raster & rgOffsetRaster, isce3::io::Raster & azOffsetRaster,
55-
int inputBand=1, bool flatten=false, bool isComplex=true, int rowBuffer=40,
72+
int inputBand=1, bool flatten=false, int rowBuffer=40,
5673
int chipSize=isce3::core::SINC_ONE);
5774

58-
// Generic resamp entry point: use filenames to create rasters
75+
/* Generic resamp entry point: use filenames to create rasters
76+
* internally in function.
77+
*
78+
* \param[in] inputFilename path of file containing SLC to be resampled
79+
* \param[in] outputFilename path of file containing resampled SLC
80+
* \param[in] rgOffsetFilename path of file containing range shift to be applied
81+
* \param[in] azOffsetFilename path of file containing azimuth shift to be applied
82+
* \param[in] inputBand band of input raster to resample
83+
* \param[in] flatten flag to flatten resampled SLC
84+
* \param[in] rowBuffer number of rows excluded from top/bottom of azimuth
85+
* raster while searching for min/max indices of
86+
* resampled SLC
87+
* \param[in] chipSize size of chip used in sinc interpolation
88+
*/
5989
void resamp(const std::string & inputFilename, const std::string & outputFilename,
6090
const std::string & rgOffsetFilename, const std::string & azOffsetFilename,
61-
int inputBand=1, bool flatten=false, bool isComplex=true, int rowBuffer=40,
91+
int inputBand=1, bool flatten=false, int rowBuffer=40,
6292
int chipSize=isce3::core::SINC_ONE);
6393

6494
};

0 commit comments

Comments
 (0)