Unverified Commit a51d9a51 authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Added check for downtrack line direction (#268)

* Added check for downtrack

* Added test for flipped downtrack

* Moved downtrack check down the image

* Added groundtoimage logging

* Fixed typo

* Added more logging

* Added line direction to sensor state

* Missed a state thing

* Test updates

* Removed extra test

* Added a litte more docs
parent 0bddf1da
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+38 −2
Original line number Diff line number Diff line
@@ -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;
+0 −1
Original line number Diff line number Diff line
@@ -268,5 +268,4 @@ class OrbitalLineScanSensorModel : public ::testing::Test {
};



#endif
+1 −1
Original line number Diff line number Diff line
@@ -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