Skip to content
Snippets Groups Projects
Unverified Commit be2a14d6 authored by Oleg Alexandrov's avatar Oleg Alexandrov Committed by GitHub
Browse files

Fix for 0.5 pixel shift in the SAR model (#370)

* Bugfix for a 0.5 pixel offset in the SAR model

* Fix tests too

* Beautify the test

* Remove extra code from the test
parent c214d460
No related branches found
No related tags found
No related merge requests found
...@@ -374,7 +374,7 @@ csm::ImageCoord UsgsAstroSarSensorModel::groundToImage( ...@@ -374,7 +374,7 @@ csm::ImageCoord UsgsAstroSarSensorModel::groundToImage(
groundPt, time, slantRangeValue, groundTolerance); groundPt, time, slantRangeValue, groundTolerance);
double line = (time - m_startingEphemerisTime) / m_exposureDuration + 0.5; double line = (time - m_startingEphemerisTime) / m_exposureDuration + 0.5;
double sample = groundRange / m_scaledPixelWidth; double sample = groundRange / m_scaledPixelWidth + 0.5;
return csm::ImageCoord(line, sample); return csm::ImageCoord(line, sample);
} catch (std::exception& error) { } catch (std::exception& error) {
std::string message = "Could not calculate groundToImage, with error ["; std::string message = "Could not calculate groundToImage, with error [";
...@@ -504,7 +504,7 @@ csm::EcefCoord UsgsAstroSarSensorModel::imageToGround( ...@@ -504,7 +504,7 @@ csm::EcefCoord UsgsAstroSarSensorModel::imageToGround(
imagePt.line, height, desiredPrecision); imagePt.line, height, desiredPrecision);
double time = double time =
m_startingEphemerisTime + (imagePt.line - 0.5) * m_exposureDuration; m_startingEphemerisTime + (imagePt.line - 0.5) * m_exposureDuration;
double groundRange = imagePt.samp * m_scaledPixelWidth; double groundRange = (imagePt.samp - 0.5) * m_scaledPixelWidth;
std::vector<double> coeffs = getRangeCoefficients(time); std::vector<double> coeffs = getRangeCoefficients(time);
double slantRange = groundRangeToSlantRange(groundRange, coeffs); double slantRange = groundRangeToSlantRange(groundRange, coeffs);
...@@ -640,7 +640,7 @@ csm::EcefLocus UsgsAstroSarSensorModel::imageToProximateImagingLocus( ...@@ -640,7 +640,7 @@ csm::EcefLocus UsgsAstroSarSensorModel::imageToProximateImagingLocus(
// Compute the slant range // Compute the slant range
double time = double time =
m_startingEphemerisTime + (imagePt.line - 0.5) * m_exposureDuration; m_startingEphemerisTime + (imagePt.line - 0.5) * m_exposureDuration;
double groundRange = imagePt.samp * m_scaledPixelWidth; double groundRange = (imagePt.samp - 0.5) * m_scaledPixelWidth;
std::vector<double> coeffs = getRangeCoefficients(time); std::vector<double> coeffs = getRangeCoefficients(time);
double slantRange = groundRangeToSlantRange(groundRange, coeffs); double slantRange = groundRangeToSlantRange(groundRange, coeffs);
......
...@@ -43,14 +43,13 @@ TEST_F(SarSensorModel, State) { ...@@ -43,14 +43,13 @@ TEST_F(SarSensorModel, State) {
TEST_F(SarSensorModel, Center) { TEST_F(SarSensorModel, Center) {
csm::ImageCoord imagePt(500.0, 500.0); csm::ImageCoord imagePt(500.0, 500.0);
csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0); csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
EXPECT_NEAR(groundPt.x, 1737387.8590770673, 1e-3); EXPECT_NEAR(groundPt.x, 1737387.8671710272, 1e-3);
EXPECT_NEAR(groundPt.y, -5303.280537826621, 1e-3); EXPECT_NEAR(groundPt.y, -5300.6282306119301, 1e-3);
EXPECT_NEAR(groundPt.z, -3749.9796183814506, 1e-3); EXPECT_NEAR(groundPt.z, -3749.9796183814506, 1e-3);
} }
TEST_F(SarSensorModel, GroundToImage) { TEST_F(SarSensorModel, GroundToImage) {
csm::EcefCoord groundPt(1737387.8590770673, -5303.280537826621, csm::EcefCoord groundPt(1737387.8671710272, -5300.6282306119301, -3749.9796358514604);
-3749.9796183814506);
csm::ImageCoord imagePt = sensorModel->groundToImage(groundPt, 0.001); csm::ImageCoord imagePt = sensorModel->groundToImage(groundPt, 0.001);
EXPECT_NEAR(imagePt.line, 500.0, 1e-3); EXPECT_NEAR(imagePt.line, 500.0, 1e-3);
EXPECT_NEAR(imagePt.samp, 500.0, 1e-3); EXPECT_NEAR(imagePt.samp, 500.0, 1e-3);
...@@ -100,7 +99,7 @@ TEST_F(SarSensorModel, imageToProximateImagingLocus) { ...@@ -100,7 +99,7 @@ TEST_F(SarSensorModel, imageToProximateImagingLocus) {
0.001, 0.001,
&precision, &precision,
&warnings); &warnings);
EXPECT_NEAR(locus.point.x, 1737388.1260092105, 1e-2); EXPECT_NEAR(locus.point.x, 1737388.1411342232, 1e-2);
EXPECT_NEAR(locus.point.y, -5403.0102509726485, 1e-2); EXPECT_NEAR(locus.point.y, -5403.0102509726485, 1e-2);
EXPECT_NEAR(locus.point.z, -3749.9801945280433, 1e-2); EXPECT_NEAR(locus.point.z, -3749.9801945280433, 1e-2);
EXPECT_NEAR(locus.direction.x, 0.002701478402694769, 1e-5); EXPECT_NEAR(locus.direction.x, 0.002701478402694769, 1e-5);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment