Commit b398bb44 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez
Browse files

Added Celestial North Clock Angle computation to skypt through new function in...

Added Celestial North Clock Angle computation to skypt through new function in Camera class. Fixes #2365

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6919 41f8697f-d340-4b68-9986-7bafba869bb8
parent 686c6988
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ void IsisMain() {
  b.SetBasePosition(intSamp, intLine, 1);
  cube.read(b);

  double rot = cam->CelestialNorthClockAngle();

  // Create group with sky position
  PvlGroup sp("SkyPoint");
  {
@@ -58,7 +60,9 @@ void IsisMain() {
    sp += PvlKeyword("Declination", toString(cam->Declination()));
    sp += PvlKeyword("EphemerisTime", toString(cam->time().Et()));
    sp += PvlKeyword("PixelValue", PixelToString(b[0]));
    sp += PvlKeyword("CelestialNorthClockAngle", toString(rot), "degrees");
  }

  //Write the group to the screen
  Application::Log(sp);

+12 −9
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@
    <change name="Debbie A. Cook" date="2012-07-06">
       Updated Spice members to be more compliant with Isis coding standards. References #972.
    </change>
    <change name="Kelvin Rodriguez" date="2016-06-27">
       Added functionality to compute celestial north clock angle, References #2365.
    </change>
  </history>

  <groups>
+1 −6
Original line number Diff line number Diff line
@@ -25,12 +25,7 @@ void IsisMain() {
  double centerDec = cam->Declination();

  // Compute the rotation
  cam->SetRightAscensionDeclination(centerRa, centerDec + 2.0 * res);
  double x = cam->Sample() - icube->sampleCount() / 2.0;
  double y = cam->Line() - icube->lineCount() / 2.0;
  double rot = atan2(-y, x) * 180.0 / Isis::PI;
  rot = 90.0 - rot;
  if(rot < 0.0) rot += 360.0;
  double rot = cam->CelestialNorthClockAngle();

  // Setup and log results
  PvlGroup results("Range");
+5 −1
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@
    <change name="Steven Lambright" date="2008-05-12">
      Removed references to CubeInfo
    </change>
    <change name="Kelvin Rodriguez" date="2016-06-27">
      Changed rotation computation to the function call Camera::celestialNorthClockAngle.
      References #2365.
    </change>
  </history>

  <groups>
+206 −155
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
#include <cfloat>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <stdint.h>

#include <QDebug>
#include <QList>
@@ -1464,21 +1466,11 @@ namespace Isis {
   * @param mindec Minimum declination value
   * @param maxdec Maximum declination value
   *
   * @throw iException::Programmer - "Camera::RaDecRange can not calculate a
   *  right ascension, declination range for projected images which are not
   *  projected to sky"
   * @return @b bool Returns true if the range computation was successful and false
   *              if it was not
   */
  bool Camera::RaDecRange(double &minra, double &maxra,
                          double &mindec, double &maxdec) {
    TProjection *tproj = (TProjection *) p_projection;
    if (p_projection != NULL && !tproj->IsSky()) {
      IString msg = "Camera::RaDecRange can not calculate a right ascension, declination range";
      msg += " for projected images which are not projected to sky";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    bool computed = p_pointComputed;
    double originalSample = Sample();
    double originalLine = Line();
@@ -1618,13 +1610,6 @@ namespace Isis {
   * @return @b double The resutant RaDec resolution
   */
  double Camera::RaDecResolution() {
    TProjection *tproj = (TProjection *) p_projection;
    if (p_projection != NULL && !tproj->IsSky()) {
      IString msg = "Camera::RaDecResolution can not calculate a right ascension, declination resolution";
      msg += " for projected images which are not projected to sky";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    bool computed = p_pointComputed;
    double originalSample = Sample();
    double originalLine = Line();
@@ -1701,6 +1686,7 @@ namespace Isis {
    return ComputeAzimuth(LocalRadius(lat, lon), lat, lon);
  }


  /**
   * Return the Spacecraft Azimuth
   *
@@ -1714,6 +1700,7 @@ namespace Isis {
    return ComputeAzimuth(LocalRadius(lat, lon), lat, lon);
  }


  /**
   * Computes the image azimuth value from your current position (origin) to a point of interest
   * specified by the lat/lon input to this method. (NOTE: This azimuth is different from a Ground
@@ -1964,6 +1951,7 @@ namespace Isis {
    return azimuth;
  }


  /**
   * Return the off nadir angle in degrees.
   *
@@ -1989,6 +1977,7 @@ namespace Isis {
    return c;
  }


  /**
   * Computes and returns the ground azimuth between the ground point and
   * another point of interest, such as the subspacecraft point or the
@@ -2116,6 +2105,7 @@ namespace Isis {
    p_distortionMap = map;
  }


  /**
   * Sets the Focal Plane Map. This object will take ownership of the focal plane
   * map pointer.
@@ -2130,6 +2120,7 @@ namespace Isis {
    p_focalPlaneMap = map;
  }


  /**
   * Sets the Detector Map. This object will take ownership of the detector map
   * pointer.
@@ -2144,6 +2135,7 @@ namespace Isis {
    p_detectorMap = map;
  }


  /**
   * Sets the Ground Map. This object will take ownership of the ground map
   * pointer.
@@ -2158,6 +2150,7 @@ namespace Isis {
    p_groundMap = map;
  }


  /**
   * Sets the Sky Map. This object will take ownership of the sky map pointer.
   *
@@ -2171,6 +2164,7 @@ namespace Isis {
    p_skyMap = map;
  }


  /**
   * This loads the spice cache big enough for this image. The default cache size
   *   is the number of lines in the cube if the ephemeris time changes in the
@@ -2266,6 +2260,7 @@ namespace Isis {
    return ephemerisTimes;
  }


  /**
   * This method calculates the spice cache size. This method finds the number
   * of lines in the beta cube and adds 1, since we need at least 2 points for
@@ -2350,6 +2345,7 @@ namespace Isis {
    p_geometricTilingEndSize = endSize;
  }


  /**
   * This will get the geometric tiling hint; these values are typically used for
   * ProcessRubberSheet::SetTiling(...).
@@ -2383,6 +2379,7 @@ namespace Isis {
    return true;
  }


  /**
   * Checks to see if the camera object has a projection
   *
@@ -2393,6 +2390,7 @@ namespace Isis {
    return p_projection != 0;
    }


  /**
   * Virtual method that checks if the band is independent
   *
@@ -2403,6 +2401,7 @@ namespace Isis {
    return true;
  }


  /**
   * Returns the reference band
   *
@@ -2412,6 +2411,7 @@ namespace Isis {
    return p_referenceBand;
  }


  /**
   * Checks to see if the Camera object has a reference band
   *
@@ -2422,6 +2422,7 @@ namespace Isis {
    return p_referenceBand != 0;
  }


  /**
   * Virtual method that sets the band number
   *
@@ -2431,6 +2432,7 @@ namespace Isis {
    p_childBand = band;
  }


  /**
   * Returns the current sample number
   *
@@ -2440,6 +2442,7 @@ namespace Isis {
    return p_childSample;
  }


  /**
   * Returns the current band
   *
@@ -2449,6 +2452,7 @@ namespace Isis {
    return p_childBand;
  }


  /**
   * Returns the current line number
   *
@@ -2457,6 +2461,8 @@ namespace Isis {
   double Camera::Line() {
    return p_childLine;
  }


  /**
   * Returns the resolution of the camera
   *
@@ -2465,6 +2471,8 @@ namespace Isis {
  double Camera::resolution() {
    return PixelResolution();
  }


  /**
   * Returns the focal length
   *
@@ -2474,6 +2482,7 @@ namespace Isis {
    return p_focalLength;
  }


  /**
   * Returns the pixel pitch
   *
@@ -2483,6 +2492,7 @@ namespace Isis {
    return p_pixelPitch;
  }


  /**
   * Returns the pixel ifov offsets from center of pixel, which defaults to the
   * (pixel pitch * summing mode ) / 2.  If an instrument has a non-square ifov, it must implement
@@ -2514,6 +2524,7 @@ namespace Isis {
    return p_samples;
  }


  /**
   * Returns the number of lines in the image
   *
@@ -2523,6 +2534,7 @@ namespace Isis {
    return p_lines;
  }


  /**
   * Returns the number of bands in the image
   *
@@ -2532,6 +2544,7 @@ namespace Isis {
    return p_bands;
  }


  /**
   * Returns the number of lines in the parent alphacube
   *
@@ -2541,6 +2554,7 @@ namespace Isis {
    return p_alphaCube->AlphaLines();
  }


  /**
   * Returns the number of samples in the parent alphacube
   *
@@ -2549,6 +2563,8 @@ namespace Isis {
   int Camera::ParentSamples() const {
    return p_alphaCube->AlphaSamples();
  }


  /**
   * Returns a pointer to the CameraDistortionMap object
   *
@@ -2558,6 +2574,7 @@ namespace Isis {
    return p_distortionMap;
  }


  /**
   * Returns a pointer to the CameraFocalPlaneMap object
   *
@@ -2567,6 +2584,7 @@ namespace Isis {
    return p_focalPlaneMap;
  }


  /**
   * Returns a pointer to the CameraDetectorMap object
   *
@@ -2576,6 +2594,7 @@ namespace Isis {
    return p_detectorMap;
  }


  /**
   * Returns a pointer to the CameraGroundMap object
   *
@@ -2585,6 +2604,7 @@ namespace Isis {
    return p_groundMap;
  }


  /**
   * Returns a pointer to the CameraSkyMap object
   *
@@ -2740,5 +2760,36 @@ namespace Isis {
  void Camera::SetPixelPitch(double v) {
    p_pixelPitch = v;
  }

  /**
   * Computes the celestial north clock angle at the current
   * line/sample or ra/dec. The reference vector is a vecor from the
   * current pixel pointed directly "upward". Celetial North
   * is a vector from the current pixel poiting towards celetial north.
   * The Celestial North Clock Angle is the angle between these two vectors
   * on the image.
   *
   * @return @b double The resultant Celestial North Clock Angle
   */
  double Camera::CelestialNorthClockAngle() {
    double orgLine = Line();
    double orgSample = Sample();
    double orgDec = Declination();
    double orgRa = RightAscension();

    SetRightAscensionDeclination(orgRa, orgDec + (2 * RaDecResolution()));
    double y = Line() - orgLine;
    double x = Sample() - orgSample;
    double celestialNorthClockAngle = atan2(-y, x) * 180.0 / Isis::PI;
    celestialNorthClockAngle = 90.0 - celestialNorthClockAngle;

    if (celestialNorthClockAngle < 0.0) {
       celestialNorthClockAngle += 360.0;
    }

    SetImage(orgSample, orgLine);
    return celestialNorthClockAngle;
  }

// end namespace isis
}
Loading