@@ -4,20 +4,21 @@ void isce3::geocode::interpolate(
4
4
const isce3::core::Matrix<std::complex <float >>& rdrDataBlock,
5
5
isce3::core::Matrix<std::complex <float >>& geoDataBlock,
6
6
const std::valarray<double >& radarX,
7
- const std::valarray<double >& radarY,
8
- const std::valarray<std:: complex < double >>& geometricalPhase ,
9
- const int radarBlockWidth, const int radarBlockLength ,
10
- const int azimuthFirstLine, const int rangeFirstPixel ,
11
- const isce3::core::Interpolator<std:: complex < float >>* interp )
7
+ const std::valarray<double >& radarY, const int azimuthFirstLine,
8
+ const int rangeFirstPixel ,
9
+ const isce3::core::Interpolator<std:: complex < float >>* interp ,
10
+ const isce3::product::RadarGridParameters& radarGrid ,
11
+ const isce3::core::LUT2d< double >& dopplerLUT, const bool & flatten )
12
12
{
13
-
14
- size_t length = geoDataBlock.length ();
15
- size_t width = geoDataBlock.width ();
16
- int extraMargin = isce3::core::SINC_HALF;
13
+ const int chipSize = isce3::core::SINC_ONE;
14
+ const int width = geoDataBlock.width ();
15
+ const int length = geoDataBlock.length ();
16
+ const int inWidth = rdrDataBlock.width ();
17
+ const int inLength = rdrDataBlock.length ();
18
+ const int chipHalf = chipSize / 2 ;
17
19
18
20
#pragma omp parallel for
19
21
for (size_t kk = 0 ; kk < length * width; ++kk) {
20
-
21
22
size_t i = kk / width;
22
23
size_t j = kk % width;
23
24
@@ -26,22 +27,65 @@ void isce3::geocode::interpolate(
26
27
double rdrY = radarY[i * width + j] - azimuthFirstLine;
27
28
double rdrX = radarX[i * width + j] - rangeFirstPixel;
28
29
29
- if (rdrX < extraMargin || rdrY < extraMargin ||
30
- rdrX >= (radarBlockWidth - extraMargin) ||
31
- rdrY >= (radarBlockLength - extraMargin)) {
30
+ const int intX = static_cast <int >(rdrX);
31
+ const int intY = static_cast <int >(rdrY);
32
+ const double fracX = rdrX - intX;
33
+ const double fracY = rdrY - intY;
34
+
35
+ if ((intX < chipHalf) || (intX >= (inWidth - chipHalf)))
36
+ continue ;
37
+ if ((intY < chipHalf) || (intY >= (inLength - chipHalf)))
38
+ continue ;
39
+
40
+ // Slant Range at the current output pixel
41
+ const double rng =
42
+ radarGrid.startingRange () +
43
+ radarX[i * width + j] * radarGrid.rangePixelSpacing ();
44
+
45
+ // Azimuth time at the current output pixel
46
+ const double az = radarGrid.sensingStart () +
47
+ radarY[i * width + j] / radarGrid.prf ();
32
48
33
- geoDataBlock (i,j) = std::complex <float > (0.0 , 0.0 );
49
+ if (not dopplerLUT.contains (az, rng))
50
+ continue ;
34
51
35
- } else {
52
+ // Evaluate Doppler at current range and azimuth time
53
+ const double dop =
54
+ dopplerLUT.eval (az, rng) * 2 * M_PI / radarGrid.prf ();
36
55
37
- // Interpolate chip
38
- const std::complex <double > cval =
39
- interp->interpolate (rdrX, rdrY, rdrDataBlock);
56
+ // Doppler to be added back. Simultaneously evaluate carrier
57
+ // that needs to be added back after interpolation
58
+ double carrier_phase = (dop * fracY); // +
59
+ // _rgCarrier.eval(rdrX, rdrY) +
60
+ // _azCarrier.eval(rdrX, rdrY);
40
61
41
- // geometricalPhase is the sum of carrier (Doppler) phase to be added
42
- // back and the geometrical phase to be removed: exp(1J* (carrier
43
- // - 4.0*PI*slantRange/wavelength))
44
- geoDataBlock (i, j) = cval * geometricalPhase[i * width + j];
62
+ if (flatten) {
63
+ carrier_phase += (4.0 * (M_PI / radarGrid.wavelength ())) * rng;
45
64
}
46
- } // end for
65
+
66
+ isce3::core::Matrix<std::complex <float >> chip (chipSize, chipSize);
67
+ // Read data chip without the carrier phases
68
+ for (int ii = 0 ; ii < chipSize; ++ii) {
69
+ // Row to read from
70
+ const int chipRow = intY + ii - chipHalf;
71
+
72
+ // Carrier phase
73
+ const double phase = dop * (ii - chipHalf);
74
+ const std::complex <float > cval (std::cos (phase), -std::sin (phase));
75
+
76
+ // Set the data values after removing doppler in azimuth
77
+ for (int jj = 0 ; jj < chipSize; ++jj) {
78
+ // Column to read from
79
+ const int chipCol = intX + jj - chipHalf;
80
+ chip (ii, jj) = rdrDataBlock (chipRow, chipCol) * cval;
81
+ }
82
+ }
83
+ // Interpolate chip
84
+ const std::complex <float > cval =
85
+ interp->interpolate (isce3::core::SINC_HALF + fracX,
86
+ isce3::core::SINC_HALF + fracY, chip);
87
+
88
+ geoDataBlock (i, j) = cval * std::complex <float >(std::cos (carrier_phase),
89
+ std::sin (carrier_phase));
90
+ }
47
91
}
0 commit comments