Skip to content

Commit 17a6177

Browse files
Liang YuGitHub Enterprise
authored andcommitted
Fix just geocode insar block processing (#955)
* added CUDA geocoding block processing done on C++ * pybind for block processing C++ function * CPU geocode_insar discontinuity errors fixed CUDA geocode_insar less nested created shared input/output raster creator
1 parent e4bc04b commit 17a6177

File tree

5 files changed

+273
-194
lines changed

5 files changed

+273
-194
lines changed

cxx/isce3/cuda/geocode/Geocode.cu

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <thrust/functional.h>
66
#include <thrust/host_vector.h>
77

8+
#include <gdal_priv.h>
89
#include <pyre/journal.h>
910

1011
#include <isce3/core/Ellipsoid.h>
@@ -414,6 +415,57 @@ void Geocode::geocodeRasterBlock(Raster& output_raster, Raster& input_raster)
414415
_geogrid.width(), _geo_block_length, 1);
415416
}
416417

418+
void Geocode::geocodeRasters(
419+
std::vector<std::reference_wrapper<isce3::io::Raster>> output_rasters,
420+
std::vector<std::reference_wrapper<isce3::io::Raster>> input_rasters)
421+
{
422+
// check if vectors are of same length
423+
if (output_rasters.size() != input_rasters.size()) {
424+
throw isce3::except::LengthError(
425+
ISCE_SRCINFO(), "number of input and output rasters not equal");
426+
}
427+
428+
const auto n_raster_pairs = output_rasters.size();
429+
430+
// iterate over blocks
431+
for (size_t i_block = 0; i_block < _n_blocks; ++i_block) {
432+
433+
// set radar coords for each geocode obj for curret block
434+
setBlockRdrCoordGrid(i_block);
435+
436+
for (size_t i_raster = 0; i_raster < n_raster_pairs; ++i_raster)
437+
{
438+
const int dtype = input_rasters[i_raster].get().dtype();
439+
switch (dtype) {
440+
case GDT_Float32: {
441+
geocodeRasterBlock<float>(
442+
output_rasters[i_raster], input_rasters[i_raster]);
443+
break; }
444+
case GDT_CFloat32: {
445+
geocodeRasterBlock<thrust::complex<float>>(
446+
output_rasters[i_raster], input_rasters[i_raster]);
447+
break;}
448+
case GDT_Float64: {
449+
geocodeRasterBlock<double>(
450+
output_rasters[i_raster], input_rasters[i_raster]);
451+
break; }
452+
case GDT_CFloat64: {
453+
geocodeRasterBlock<thrust::complex<double>>(
454+
output_rasters[i_raster], input_rasters[i_raster]);
455+
break;}
456+
case GDT_Byte: {
457+
geocodeRasterBlock<unsigned char>(
458+
output_rasters[i_raster], input_rasters[i_raster]);
459+
break;}
460+
default: {
461+
throw isce3::except::RuntimeError(ISCE_SRCINFO(),
462+
"unsupported datatype");
463+
}
464+
}
465+
}
466+
}
467+
}
468+
417469
#define EXPLICIT_INSTATIATION(T) \
418470
template void Geocode::geocodeRasterBlock<T>( \
419471
Raster & output_raster, Raster & input_raster);

cxx/isce3/cuda/geocode/Geocode.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#pragma once
22

3+
#include <functional>
4+
#include <vector>
5+
36
#include <isce3/core/forward.h>
47
#include <isce3/geometry/forward.h>
58

@@ -104,6 +107,16 @@ class Geocode {
104107
void geocodeRasterBlock(
105108
isce3::io::Raster& output_raster, isce3::io::Raster& input_raster);
106109

110+
/** Geocode rasters with a shared geogrid. Block processing handled
111+
* internally in function.
112+
*
113+
* \param[in] output_rasters Geocoded rasters
114+
* \param[in] input_rasters Rasters to be geocoded
115+
*/
116+
void geocodeRasters(
117+
std::vector<std::reference_wrapper<isce3::io::Raster>> output_rasters,
118+
std::vector<std::reference_wrapper<isce3::io::Raster>> input_rasters);
119+
107120
size_t numBlocks() const { return _n_blocks; }
108121
size_t linesPerBlock() const { return _lines_per_block; }
109122

python/extensions/pybind_isce3/cuda/geocode/cuGeocode.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "cuGeocode.h"
2-
#include <isce3/core/forward.h>
32

43
#include <gdal_priv.h>
4+
#include <pybind11/stl.h>
55

66
#include <isce3/container/RadarGeometry.h>
77
#include <isce3/core/Constants.h>
@@ -119,7 +119,20 @@ void addbinding(pybind11::class_<Geocode>& pyGeocode)
119119
input_raster: io::Raster
120120
Raster to be geocoded
121121
)")
122-
.def_property_readonly("n_blocks", &Geocode::numBlocks)
123-
.def_property_readonly("lines_per_block", &Geocode::linesPerBlock);
122+
.def("geocode_rasters", &Geocode::geocodeRasters,
123+
py::arg("output_rasters"),
124+
py::arg("input_rasters"),
125+
R"(
126+
Geocode rasters with a shared geogrid with block processing handled internally.
127+
128+
Parameters
129+
----------
130+
output_rasters: list(io::Raster)
131+
List of geocoded rasters.
132+
input_rasters: list(io::Raster)
133+
List of rasters to be geocoded.
134+
)")
135+
.def_property_readonly("n_blocks", &Geocode::numBlocks)
136+
.def_property_readonly("lines_per_block", &Geocode::linesPerBlock);
124137
;
125138
}

0 commit comments

Comments
 (0)