Unverified Commit db9177c2 authored by Kristin's avatar Kristin Committed by GitHub
Browse files

Spice rotation update to use ALE (#3977)

Updated SpiceRotation to use ale::Orientations
parent d2938696
Loading
Loading
Loading
Loading
+35 −5
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
#include <cmath>
#include <iomanip>

#include<ale/Rotation.h>

#include "Cube.h"
#include "LineScanCameraRotation.h"
#include "Quaternion.h"
@@ -121,6 +123,7 @@ namespace Isis {
    SpiceRotation *prot = p_spi->bodyRotation();
    SpiceRotation *crot = p_spi->instrumentRotation();

    std::vector<ale::Rotation> rotationCache;
    for(std::vector<double>::iterator i = p_cacheTime.begin(); i < p_cacheTime.end(); i++) {
      double et = *i;

@@ -155,8 +158,23 @@ namespace Isis {

      // Put CI into parent cache to use the parent class methods on it
      mxmt_c((SpiceDouble( *)[3]) &CI[0], (SpiceDouble( *)[3]) &IB[0], (SpiceDouble( *)[3]) &CI[0]);
      p_cache.push_back(CI);
      rotationCache.push_back(ale::Rotation(CI));
    }

    if (m_orientation) {
      delete m_orientation;
      m_orientation = NULL;
    }

    if (ConstantRotation().size() > 1) {
      m_orientation = new ale::Orientations(rotationCache, p_cacheTime, std::vector<ale::Vec3d>(),
                                            ale::Rotation(ConstantMatrix()), ConstantFrameChain(), TimeFrameChain());
    }
    else {
      m_orientation = new ale::Orientations(rotationCache, p_cacheTime, std::vector<ale::Vec3d>(),
                                            ale::Rotation(1,0,0,0), ConstantFrameChain(), TimeFrameChain());
    }

    p_cachesLoaded = true;
    SetSource(Memcache);

@@ -185,9 +203,6 @@ namespace Isis {
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    // Clear existing matrices from cache
    p_cache.clear();

    // Create polynomials fit to angles & use to reload cache
    Isis::PolynomialUnivariate function1(p_degree);
    Isis::PolynomialUnivariate function2(p_degree);
@@ -218,6 +233,7 @@ namespace Isis {
    std::vector<double> CJ;
    CJ.resize(9);

    std::vector<ale::Rotation> rotationCache;
    for(std::vector<double>::size_type pos = 0; pos < p_cacheTime.size(); pos++) {
      double et = p_cacheTime.at(pos);
      rtime = (et - GetBaseTime()) / GetTimeScale();
@@ -242,7 +258,21 @@ namespace Isis {
      mxm_c((SpiceDouble( *)[3]) & (p_cacheIB.at(pos))[0], (SpiceDouble( *)[3]) & (prot->Matrix())[0], IJ);
      mxm_c(CI, IJ, (SpiceDouble( *)[3]) &CJ[0]);

      p_cache.push_back(CJ);   // J2000 to constant frame
      rotationCache.push_back(ale::Rotation(CJ));
    }

    if (m_orientation) {
      delete m_orientation;
      m_orientation = NULL;
    }

    if (ConstantRotation().size() > 1) {
      m_orientation = new ale::Orientations(rotationCache, p_cacheTime, std::vector<ale::Vec3d>(),
                                            ale::Rotation(ConstantMatrix()), ConstantFrameChain(), TimeFrameChain());
    }
    else {
      m_orientation = new ale::Orientations(rotationCache, p_cacheTime, std::vector<ale::Vec3d>(),
                                            ale::Rotation(1,0,0,0), ConstantFrameChain(), TimeFrameChain());
    }

    // Set source to cache to get updated values
+0 −2
Original line number Diff line number Diff line
@@ -103,11 +103,9 @@ namespace Isis {
  class LineScanCameraRotation : public Isis::SpiceRotation {
    public:
      //! Constructors
//      LineScanCameraRotation( int frameCode, SpiceRotation *crot, SpiceRotation *prot, SpicePosition *spos );
      LineScanCameraRotation(int frameCode,  Isis::Cube &cube, std::vector<double> timeCache, double tol);

      //! Destructor
//      virtual ~LineScanCameraRotation() { };
      virtual ~LineScanCameraRotation();

      void LoadCache();
+6 −6
Original line number Diff line number Diff line
@@ -6,8 +6,8 @@ Group = GroundPoint
  Declination                = 67.288137235407 <DEGREE>
  PlanetocentricLatitude     = -85.539935681585 <DEGREE>
  PlanetographicLatitude     = -85.539935681585 <DEGREE>
  PositiveEast360Longitude   = 27.089555271673 <DEGREE>
  PositiveEast180Longitude   = 27.089555271673 <DEGREE>
  PositiveEast360Longitude   = 27.089555271672 <DEGREE>
  PositiveEast180Longitude   = 27.089555271672 <DEGREE>
  PositiveWest360Longitude   = 332.91044472833 <DEGREE>
  PositiveWest180Longitude   = -27.089555271672 <DEGREE>
  BodyFixedCoordinate        = (120.6493939079, 61.711663528734,
@@ -21,13 +21,13 @@ Group = GroundPoint
  ObliqueSampleResolution    = 187.44583818806 <meters>

  # Spacecraft Information
  SpacecraftPosition         = (216.77599432924, 54.260221515166,
  SpacecraftPosition         = (216.77599432924, 54.260221515165,
                                -2462.1104393388) <km>
  SpacecraftAzimuth          = 38.331 <DEGREE>
  SlantDistance              = 731.11938668312 <km>
  TargetCenterDistance       = 2472.2305351357 <km>
  SubSpacecraftLatitude      = -84.813985589411 <DEGREE>
  SubSpacecraftLongitude     = 14.052715974499 <DEGREE>
  SubSpacecraftLongitude     = 14.052715974498 <DEGREE>
  SpacecraftAltitude         = 735.29826910549 <km>
  OffNadirAngle              = 3.124 <DEGREE>
  SubSpacecraftGroundAzimuth = 296.906 <DEGREE>
@@ -84,13 +84,13 @@ Group = GroundPoint
  ObliqueSampleResolution    = 187.61662252249 <meters>

  # Spacecraft Information
  SpacecraftPosition         = (216.77599432924, 54.260221515166,
  SpacecraftPosition         = (216.77599432924, 54.260221515165,
                                -2462.1104393388) <km>
  SpacecraftAzimuth          = 284.604 <DEGREE>
  SlantDistance              = 733.84767049682 <km>
  TargetCenterDistance       = 2472.2305351357 <km>
  SubSpacecraftLatitude      = -84.813985589411 <DEGREE>
  SubSpacecraftLongitude     = 14.052715974499 <DEGREE>
  SubSpacecraftLongitude     = 14.052715974498 <DEGREE>
  SpacecraftAltitude         = 735.29826910549 <km>
  OffNadirAngle              = 0.773 <DEGREE>
  SubSpacecraftGroundAzimuth = 195.221 <DEGREE>
+216 −112

File changed.

Preview size limit exceeded, changes collapsed.

+10 −14
Original line number Diff line number Diff line
@@ -25,18 +25,16 @@
#include <string>
#include <vector>

//#include <SpiceUsr.h>
//#include <SpiceZfc.h>
//#include <SpiceZmc.h>

#include <nlohmann/json.hpp>

#include <ale/Orientations.h>

#include "Angle.h"
#include "Table.h"
#include "PolynomialUnivariate.h"
#include "Quaternion.h"



#define J2000Code    1

namespace Isis {
@@ -426,7 +424,10 @@ namespace Isis {
      void checkForBinaryPck();

      int cacheSize() {
        return p_cache.size();
        if (m_orientation) {
          return m_orientation->getRotations().size(); 
        }
        return 0;
      }

    protected:
@@ -438,15 +439,11 @@ namespace Isis {
      void setEphemerisTimePolyFunctionOverSpice();
      void setEphemerisTimePckPolyFunction();
      std::vector<double> p_cacheTime;  //!< iTime for corresponding rotation
      std::vector<std::vector<double> > p_cache; /**< Cached rotations, stored as
                                                      rotation matrix from J2000
                                                      to 1st constant frame (CJ) or
                                                      coefficients of polynomial
                                                      fit to rotation angles.*/
      int p_degree;                     //!< Degree of fit polynomial for angles
      int p_axis1;                      //!< Axis of rotation for angle 1 of rotation
      int p_axis2;                      //!< Axis of rotation for angle 2 of rotation
      int p_axis3;                      //!< Axis of rotation for angle 3 of rotation
      ale::Orientations *m_orientation; //! Cached orientation information
                                       
    private:
      // method
@@ -494,8 +491,6 @@ namespace Isis {
                                           J2000 to target) to the target frame*/
      std::vector<double> p_CJ;           /**< Rotation matrix from J2000 to first constant
                                               rotation*/
      std::vector<std::vector<double> > p_cacheAv;
      //!< Cached angular velocities for corresponding rotactions in p_cache
      std::vector<double> p_av;           //!< Angular velocity for rotation at time p_et
      bool p_hasAngularVelocity;          /**< Flag indicating whether the rotation
                                               includes angular velocity*/
@@ -603,6 +598,7 @@ namespace Isis {
      static const double m_centScale;
      //! Seconds per day for scaling time in seconds to get target body w
      static const double m_dayScale;

  };
};

Loading