diff --git a/include/usgscsm/UsgsAstroLsSensorModel.h b/include/usgscsm/UsgsAstroLsSensorModel.h index b2d0a9b4b62b84f27cc1fdbe443cceb4764f7a20..687f34f0f1f522ba86b19ae46c522ea71e93912e 100644 --- a/include/usgscsm/UsgsAstroLsSensorModel.h +++ b/include/usgscsm/UsgsAstroLsSensorModel.h @@ -111,6 +111,7 @@ public: std::vector<double> m_currentParameterValue; std::vector<csm::param::Type> m_parameterType; csm::EcefCoord m_referencePointXyz; + int m_downtrackLines; double m_gsd; double m_flyingHeight; double m_halfSwath; diff --git a/src/UsgsAstroLsSensorModel.cpp b/src/UsgsAstroLsSensorModel.cpp index 5fc142b7a3257a3111448c0873204e4e35718723..99a53c548710a796ecd156fc67f02ad2f6662ec8 100644 --- a/src/UsgsAstroLsSensorModel.cpp +++ b/src/UsgsAstroLsSensorModel.cpp @@ -240,6 +240,8 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string &stateString ) j["m_referencePointXyz"][1].dump(), j["m_referencePointXyz"][2].dump()) + m_downtrackLines = j["m_downtrackLines"]; + m_gsd = j["m_gsd"]; m_flyingHeight = j["m_flyingHeight"]; m_halfSwath = j["m_halfSwath"]; @@ -425,6 +427,8 @@ std::string UsgsAstroLsSensorModel::getModelState() const { state["m_currentParameterValue"] = m_currentParameterValue; state["m_parameterType"] = m_parameterType; + state["m_downtrackLines"] = m_downtrackLines; + state["m_gsd"] = m_gsd; state["m_flyingHeight"] = m_flyingHeight; state["m_halfSwath"] = m_halfSwath; @@ -527,6 +531,8 @@ void UsgsAstroLsSensorModel::reset() m_sunPosition = std::vector<double>(3, 0.0); m_sunVelocity = std::vector<double>(3, 0.0); + m_downtrackLines = 1; + m_gsd = 1.0; m_flyingHeight = 1000.0; m_halfSwath = 1000.0; @@ -609,6 +615,23 @@ void UsgsAstroLsSensorModel::updateState() MESSAGE_LOG(m_logger, "updateState: half time duration set to {}", m_halfTime) + // Compute if downtrack is increasing or decreasing lines + // so that we know which direction to iterate during groundToImage + // This requires that all of the other parameters be set first! + csm::ImageCoord nextLinePoint((lineCtr+m_nLines)/2, sampCtr); + double nextLineTime = getImageTime(nextLinePoint); + std::vector<double> refView = computeDetectorView(nextLineTime, + m_referencePointXyz, + _no_adjustment); + double refDetectorLine = m_iTransL[0] + + m_iTransL[1] * refView[0] + + m_iTransL[2] * refView[1]; + if (refDetectorLine > 0.0) { + m_downtrackLines = -1; + } + MESSAGE_LOG(m_logger, "updateState: down track line direction set to {}", + m_downtrackLines) + // Parameter covariance, hardcoded accuracy values int num_params = NUM_PARAMETERS; int num_paramsSquare = num_params * num_params; @@ -661,9 +684,13 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage( // This method first uses a linear approximation to get an initial point. // Then the detector offset for the line is continuously computed and // applied to the line until we achieve the desired precision. + MESSAGE_LOG(m_logger, "Computing groundToImage for {}, {}, {}, with desired precision {}", + groundPt.x, groundPt.y, groundPt.z, desiredPrecision); csm::ImageCoord approxPt; computeLinearApproximation(groundPt, approxPt); + MESSAGE_LOG(m_logger, "Approximate image point {}, {}", + approxPt.line, approxPt.samp); std::vector<double> detectorView; double detectorLine = m_nLines; @@ -673,6 +700,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage( while(abs(detectorLine) > desiredPrecision && ++count < 15) { timei = getImageTime(approxPt); detectorView = computeDetectorView(timei, groundPt, adj); + MESSAGE_LOG(m_logger, "Computed detector view {}, {}", + detectorView[0], detectorView[1]); // Convert to detector line detectorLine = m_iTransL[0] @@ -680,16 +709,22 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage( + m_iTransL[2] * detectorView[1]; // Convert to image line - approxPt.line += detectorLine; + approxPt.line += m_downtrackLines * detectorLine; + MESSAGE_LOG(m_logger, "Updated image point {}, {}", + approxPt.line, approxPt.samp); } timei = getImageTime(approxPt); detectorView = computeDetectorView(timei, groundPt, adj); + MESSAGE_LOG(m_logger, "Computed detector view {}, {}", + detectorView[0], detectorView[1]); // Invert distortion double distortedFocalX, distortedFocalY; applyDistortion(detectorView[0], detectorView[1], distortedFocalX, distortedFocalY, m_opticalDistCoeffs, m_distortionType, desiredPrecision); + MESSAGE_LOG(m_logger, "Distorted detector view {}, {}", + distortedFocalX, distortedFocalY); // Convert to detector line and sample detectorLine = m_iTransL[0] @@ -700,7 +735,7 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage( + m_iTransS[2] * distortedFocalY; // Convert to image sample line - approxPt.line += detectorLine; + approxPt.line += m_downtrackLines * detectorLine; approxPt.samp = (detectorSample + m_detectorSampleOrigin - m_startingSample) / m_detectorSampleSumming; @@ -2676,6 +2711,7 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(const std::string imag state["m_sunVelocity"]= getSunVelocities(isd, parsingWarnings); // leave these be for now. + state["m_downtrackLines"] = 1.0; state["m_gsd"] = 1.0; state["m_flyingHeight"] = 1000.0; state["m_halfSwath"] = 1000.0; diff --git a/tests/Fixtures.h b/tests/Fixtures.h index 5b89d9d7d33aebc3b4eb0b161bcf97b5d5838263..ba0c6f5841109498234bf874f2cd08277c371094 100644 --- a/tests/Fixtures.h +++ b/tests/Fixtures.h @@ -268,5 +268,4 @@ class OrbitalLineScanSensorModel : public ::testing::Test { }; - #endif diff --git a/tests/data/orbitalLineScan.json b/tests/data/orbitalLineScan.json index f101451cedfaee24b47248435c9518f387f9ddb7..ee15df51900c94623c1ae156e74ce385f5afc845 100644 --- a/tests/data/orbitalLineScan.json +++ b/tests/data/orbitalLineScan.json @@ -13,7 +13,7 @@ "dt_ephemeris": 0.1, "t0_quaternion": -0.8, "dt_quaternion": 0.1, - "focal2pixel_lines": [0.0, -10.0, 0.0], + "focal2pixel_lines": [0.0, 10.0, 0.0], "focal2pixel_samples": [0.0, 0.0, 10.0], "focal_length_model": { "focal_length": 50