Commit f57b8189 authored by Kristin Berry's avatar Kristin Berry
Browse files

Updates to fix problems with calls to the MiniRF camera model from level 2...

Updates to fix problems with calls to the MiniRF camera model from level 2 cubes and set RAs/DECs in the camera model. Fixes #2400

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7042 41f8697f-d340-4b68-9986-7bafba869bb8
parent 3c5da104
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -328,6 +328,8 @@ namespace Isis {
        if(dp < 0.0 && p_lookDirection == Radar::Right) return false;
        if(dp == 0.0) return false;



        // Compute body fixed look direction
        std::vector<double> lookB;
        lookB.resize(3);
@@ -336,7 +338,7 @@ namespace Isis {
        lookB[2] = X[2] - Xsc[2];

        std::vector<double> lookJ = bodyFrame->J2000Vector(lookB);
        SpiceRotation *cameraFrame = p_camera->instrumentRotation();
        SpiceRotation *cameraFrame = p_camera->instrumentRotation(); //this is the pointer to the camera's SpiceRotation/instrumentatrotation object
        std::vector<double> lookC = cameraFrame->ReferenceVector(lookJ);

        SpiceDouble unitLookC[3];
@@ -346,7 +348,10 @@ namespace Isis {
        p_focalPlaneX = p_slantRange * 1000.0 / p_rangeSigma; // km to meters and scaled to focal plane
        p_focalPlaneY = 0.0;
        p_camera->target()->shape()->setSurfacePoint(surfacePoint); // Added 2-11-2013 by DAC
        return true;

        // set the sensor's ground point and also makes it possible to calculate m_ra & m_dec

        return p_camera->Sensor::SetGround(surfacePoint, true);
      }
    }

+3 −1
Original line number Diff line number Diff line
@@ -101,7 +101,9 @@ namespace Isis {
   *  @history 2012-07-06 Debbie A. Cook, Updated Spice members to be more compliant with Isis 
   *                      coding standards. References #972.
   * @history 2013-02-11 Debbie A. Cook, Fixed SetGround method by adding call to set the surface point 
                           in the ShapeModel so that photometric angles can be calculated.  References #775
   *                       in the ShapeModel so that photometric angles can be calculated.  References #775
   * @history 2016-07-19 Kristin Berry, Updated SetGround to call p_camera->Sensor::SetGround so that 
   *                       RA, DEC values will be set on level 2 images. References #2400.  
   */
  class RadarGroundMap : public CameraGroundMap {
    public:
+331 −256
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@
#include "iTime.h"
#include "PvlSequence.h"

using namespace std;

namespace Isis {
  /** Radar ground to slant range map constructor
   *
@@ -50,12 +52,13 @@ namespace Isis {
    // allow for solving for coordinates that are slightly outside of
    // the actual image area. Use S=-0.25*p_camera->Samples() and
    // S=1.25*p_camera->Samples().
    p_initialMinGroundRangeGuess = (-0.25 * p_camera->Samples() - 1.0)
                                   * groundRangeResolution;
    p_initialMaxGroundRangeGuess = (1.25 * p_camera->Samples() - 1.0)
                                   * groundRangeResolution;
    // The above approach works nicely for a level 1 image but the
    // sensor model at level2 doesn't have access to the level 1 
    // number of samples. Instead, we will calculate initial guesses
    // on the fly in SetUndistortedFocalPlane.
    p_tolerance = 0.1; // Default tolerance is a tenth of a meter
    p_maxIterations = 30;

  }

  /** Set the ground range and compute a slant range
@@ -85,20 +88,92 @@ namespace Isis {

    if(p_et != p_camera->time().Et()) ComputeA();

    // Evaluate the ground range at the 2 extremes of the image
    double slant = p_undistortedFocalPlaneX;
    // First trap the case where no iteration is needed. Since this occurs at
    // the first pixel of the image, it's a real possibility to encounter.
    if (fabs(slant-p_a[0]) < p_tolerance) {
      p_focalPlaneX = 0.0;
      p_focalPlaneY = 0.0;
      return true;
    }
    // Now calculate two guesses by the first and second iterations of
    // Newton's method, where the zeroth iteration is at ground range = 0.
    // The nature of the slant range function is such that, in the region
    // of validity (including all image data) the Newton approximations are
    // always too high, but the second one is within a few meters.  We therefore
    // add 10 m of “windage” to it to bracket the root.
    // Performing a third Newton iteration would give a satisfactory solution in
    // the data area but raises the problem of trapping errors outside this region
    // where the polynomial is not so well behaved.
    // Use the “min” variables temporarily to hold the first approximation
    p_initialMinGroundRangeGuess = (slant - p_a[0]) / p_a[1];
    double minGroundRangeGuess = slant - (p_a[0] + p_initialMinGroundRangeGuess *
                                          (p_a[1] + p_initialMinGroundRangeGuess * (p_a[2] +
                                              p_initialMinGroundRangeGuess * p_a[3])));
       (p_a[1] + p_initialMinGroundRangeGuess * (p_a[2] + p_initialMinGroundRangeGuess * p_a[3])));
    // Now the max is the second approximation
    p_initialMaxGroundRangeGuess = p_initialMinGroundRangeGuess + minGroundRangeGuess /
       (p_a[1] + p_initialMinGroundRangeGuess * (2.0 * p_a[2] + p_initialMinGroundRangeGuess *
       3.0 * p_a[3]));
    double maxGroundRangeGuess = slant - (p_a[0] + p_initialMaxGroundRangeGuess *
                                          (p_a[1] + p_initialMaxGroundRangeGuess * (p_a[2] +
                                              p_initialMaxGroundRangeGuess * p_a[3])));
    // Finally, apply the “windage” to bracket the root.
    p_initialMinGroundRangeGuess = p_initialMaxGroundRangeGuess - 10.0;
    minGroundRangeGuess = slant - (p_a[0] + p_initialMinGroundRangeGuess *
       (p_a[1] + p_initialMinGroundRangeGuess * (p_a[2] + p_initialMinGroundRangeGuess * p_a[3])));

    // If both guesses are on the same side of zero, we need to expand the bracket range
    // to include a zero-crossing. 
    if ((minGroundRangeGuess < 0.0 && maxGroundRangeGuess < 0.0) ||
        (minGroundRangeGuess > 0.0 && maxGroundRangeGuess > 0.0)) {

      int maxBracketIters = 10; 
      
      float xMin = p_initialMinGroundRangeGuess;
      float xMax = p_initialMaxGroundRangeGuess;

      float funcMin = minGroundRangeGuess;
      float funcMax = maxGroundRangeGuess; 

      for (int j=0; j<maxBracketIters; j++) {

        //distance between guesses
        float dist = abs(abs(xMin) - abs(xMax));
        
        // move move the x-value of the closest root twice as far away from the other root as it was
        // before to extend the bracket range. 
        if (abs(funcMin) <= abs(funcMax)) {
          //min is closer
          xMin = xMax - 2*dist; 
          xMax = xMax; //doesn't change
        }
        else {
          //max is closer
          xMax = xMin + 2*dist;
          xMin = xMin; //doesn't change
        }

        funcMin = slant -(p_a[0]+ xMin *(p_a[1] + xMin * (p_a[2] + xMin * p_a[3])));
        funcMax = slant - (p_a[0] + xMax *(p_a[1] + xMax * (p_a[2] + xMax * p_a[3])));
        
        // if we've successfully bracketed the root, we can break. 
        if((funcMin <= 0.0 && funcMax >= 0.0) || (funcMin >= 0.0 && funcMax <= 0.0)){
          p_initialMinGroundRangeGuess = xMin;
          p_initialMaxGroundRangeGuess = xMax;
          minGroundRangeGuess = funcMin;
          maxGroundRangeGuess = funcMax; 
          break; 
        }
      }
    }
    
    // If the ground range guesses at the 2 extremes of the image are equal
    // or they have the same sign, then the ground range cannot be solved for.
    // The only case where they are equal should be at zero, which we already trapped.
    if((minGroundRangeGuess == maxGroundRangeGuess) ||
        (minGroundRangeGuess < 0.0 && maxGroundRangeGuess < 0.0) ||
        (minGroundRangeGuess > 0.0 && maxGroundRangeGuess > 0.0)) return false;
       (minGroundRangeGuess > 0.0 && maxGroundRangeGuess > 0.0)) {
      return false;
    }

    // Use Wijngaarden/Dekker/Brent algorithm to find a root of the function:
    // g(groundRange) = slantRange - (p_a[0] + groundRange * (p_a[1] +
+7 −1
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@ namespace Isis {
   *                      known range coefficients.
   *  @history 2012-07-06 Debbie A. Cook, Updated Spice members to be more compliant with Isis 
   *                      coding standards. References #972.
   *  @history 2016-02-24 Randy Kirk and Janet Barrett - Fixed an issue that caused
   *                      the sensor model for LRO and Chandrayaan's MiniRF to not be able to 
   *                      calculate and report lat/lon in the LXB mode. References #2400.
   *  @history 2016-08-01 Kristin Berry - Added the ability to extend the range of the initial root
   *                      bracket in SetUndistortedFocalPlan if the initial range was too narrow.
   *                      Also added RAs & DECs to the camera model.References #2400. 
   *                      
   */
  class RadarSlantRangeMap : public CameraDistortionMap {
+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ namespace Isis {
   *   @history 2015-10-16 Ian Humphrey - Removed declarations of spacecraft and instrument 
   *                           members and methods and removed implementation of these methods
   *                           since Camera now handles this. References #2335.
   *   @history 2016-08-01 Kristin Berry - Added to unitTest to test camera model performance on
   *                           level 2 cubes and to test RA/DEC values. References #2400. 
   */
  class Chandrayaan1M3Camera : public LineScanCamera {
    public:
Loading