Commit d984c1dc authored by Jesse Mapel's avatar Jesse Mapel Committed by Trent Hare
Browse files

Fixed look vectors with fractional lines (#29)

* Added subpixel test for genericls

* Added sub-pixel look vector calculations for fractional lines.

* Removed extra test

* Added documentation to line scan ground to image iteration.

* Fixed error with namespace scoping on Mac.

* more documentation of the iteration calculations.
parent 3467d668
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -204,10 +204,11 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage(
   //  Computes line and sample given the ground coordinates in ECF cs.
   //  The solution is iterative and repeatedly calls the routine
   //  imageToPlane. If convergence is not achieved, a warning is issued.
   //  This method uses Newton-Raphson method on planes to iterate.

   // Initialize variables
   const int MKTR = 10;
   const double DELTA_IMAGE = 1.0;
   const int MKTR = 20;
   const double DELTA_IMAGE = 0.1;
   double preSquare = desired_precision * desired_precision;
   int mode = -1;

@@ -251,6 +252,8 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage(
      mode = -1;
      ktr++;

      // Compute the approximate Jacobian using finite differences on planes.

      // Compute partial of ground coordinates w.r.t. line

      xLine = xSeed;
@@ -282,6 +285,9 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage(
      // Therefore, one of dx, dy, dz must be = 0.0 exactly.
      // The following if else if should work just fine.

      // Compute the adjustment step by multiplying the ground delta by the
      // inverse of the (approximate) Jacobian.

      if (0.0 == dx)
      {
         det = yPLine * zPSamp - yPSamp * zPLine;
@@ -317,8 +323,16 @@ csm::ImageCoord UsgsAstroLsSensorModel::groundToImage(
            "Divide by zero.",
            "UsgsAstroLsSensorModel::groundToImage");
      }
      lineTemp += (dLine / det / DELTA_IMAGE);
      sampleTemp += (dSamp / det / DELTA_IMAGE);

      // We have to divide by the determinant of the Jacobian here as part of
      // the inverse calculation.
      // The multiplication by DELTA_IMAGE is because the calculation of the
      // ground partials with respect to sample and line does not divide by
      // DELTA_IMAGE. This also means the determinant of the Jacobian should
      // be divided by DELTA_IMAGE^2. So, dLine and dSamp should be multiplied
      // by DELTA_IMAGE^2/DELTA_IMAGE, which is just DELTA_IMAGE.
      lineTemp += (dLine / det * DELTA_IMAGE);
      sampleTemp += (dSamp / det * DELTA_IMAGE);

      // Update ground delta

@@ -1347,6 +1361,7 @@ void UsgsAstroLsSensorModel::losToEcf(

   double sampleCSMFull = sample + _data.m_OffsetSamples;
   double sampleUSGSFull = sampleCSMFull + 0.5;
   double fractionalLine = line - floor(line) - 0.5;

   // Compute distorted image coordinates in mm

@@ -1356,7 +1371,8 @@ void UsgsAstroLsSensorModel::losToEcf(
   double m12 = _data.m_ITransL[2];
   double m21 = _data.m_ITransS[1];
   double m22 = _data.m_ITransS[2];
   double t1 = _data.m_DetectorLineOffset - _data.m_DetectorLineOrigin - _data.m_ITransL[0];
   double t1 = fractionalLine + _data.m_DetectorLineOffset
               - _data.m_DetectorLineOrigin - _data.m_ITransL[0];
   double t2 = isisDetSample - _data.m_DetectorSampleOrigin - _data.m_ITransS[0];
   double determinant = m11 * m22 - m12 * m21;
   double p11 = m11 / determinant;
+9 −9
Original line number Diff line number Diff line
@@ -67,9 +67,9 @@ class TestHRSCNadir:
    def test_image_to_ground(self, hrsc_nadir_model, image, ground):
        gx, gy, gz = ground
        x, y, z = hrsc_nadir_model.imageToGround(*image)
        assert x == pytest.approx(gx, abs=100)
        assert y == pytest.approx(gy, abs=100)
        assert z == pytest.approx(gz, abs=100)
        assert x == pytest.approx(gx, abs=20)
        assert y == pytest.approx(gy, abs=20)
        assert z == pytest.approx(gz, abs=20)

    @pytest.mark.parametrize('image, ground',[
          ((0.5, 0.5, 0), (985377.89225802, 3243484.7261571, 206009.0045894)),
@@ -82,8 +82,8 @@ class TestHRSCNadir:
        y, x = hrsc_nadir_model.groundToImage(*ground)
        iy, ix, _ = image

        assert x == pytest.approx(ix, abs=0.5)
        assert y == pytest.approx(iy, abs=0.5)
        assert x == pytest.approx(ix, abs=1)
        assert y == pytest.approx(iy, abs=1)

class TestHRSCStereo1:

@@ -112,8 +112,8 @@ class TestHRSCStereo1:
        y, x = hrsc_stereo_1_model.groundToImage(*ground)
        iy, ix, _ = image

        assert x == pytest.approx(ix, abs=0.5)
        assert y == pytest.approx(iy, abs=0.5)
        assert x == pytest.approx(ix, abs=1)
        assert y == pytest.approx(iy, abs=1)

class TestHRSCStereo2:

@@ -142,5 +142,5 @@ class TestHRSCStereo2:
        y, x = hrsc_stereo_2_model.groundToImage(*ground)
        iy, ix, _ = image

        assert x == pytest.approx(ix, abs=0.5)
        assert y == pytest.approx(iy, abs=0.5)
        assert x == pytest.approx(ix, abs=1)
        assert y == pytest.approx(iy, abs=1)