Commit 3aad7e19 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by Jesse Mapel
Browse files

updated with new isd format (#3839)

* updated with new isd format

* removed missed debug prints

* changed header stuff for ale

* updated env
parent 4d8f64fc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ channels:
  - defaults

dependencies:
  - ale<0.8.0
  - ale >=0.8.0
  - boost=1.68.0
  - armadillo
  - blas
+9 −10
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@

#include <getSpkAbCorrState.hpp>

#include <ale.h>
#include <ale/Load.h>

#include <nlohmann/json.hpp>
using json = nlohmann::json;
@@ -120,8 +120,8 @@ namespace Isis {
  void Spice::init(Pvl &lab, bool noTables, json isd) {
    NaifStatus::CheckErrors();
    // Initialize members
    
    m_solarLongitude = new Longitude;
    
    m_et = NULL;
    m_kernels = new QVector<QString>;

@@ -197,7 +197,7 @@ namespace Isis {
          isd = ale::load(lab.fileName().toStdString(), props.dump(), "isis");
        }
        
        json aleNaifKeywords = isd["NaifKeywords"];
        json aleNaifKeywords = isd["naif_keywords"];
        m_naifKeywords = new PvlObject("NaifKeywords", aleNaifKeywords);
        
        // Still need to load clock kernels for now 
@@ -379,8 +379,8 @@ namespace Isis {
    // Check to see if we have nadir pointing that needs to be computed &
    // See if we have table blobs to load 
    if (m_usingAle) {
      m_sunPosition->LoadCache(isd["SunPosition"]);
      m_bodyRotation->LoadCache(isd["BodyRotation"]);
      m_sunPosition->LoadCache(isd["sun_position"]);
      m_bodyRotation->LoadCache(isd["body_rotation"]);
      solarLongitude();
    }
    else if (kernels["TargetPosition"][0].toUpper() == "TABLE") {
@@ -421,7 +421,7 @@ namespace Isis {
      m_instrumentRotation = new SpiceRotation(*m_ikCode, *m_spkBodyCode);
    }
    else if (m_usingAle) {
     m_instrumentRotation->LoadCache(isd["InstrumentPointing"]);
     m_instrumentRotation->LoadCache(isd["instrument_pointing"]);
    }
    else if (kernels["InstrumentPointing"][0].toUpper() == "TABLE") {
      Table t("InstrumentPointing", lab.fileName(), lab);
@@ -436,7 +436,7 @@ namespace Isis {
    }
    
    if (m_usingAle) {
      m_instrumentPosition->LoadCache(isd["InstrumentPosition"]);
      m_instrumentPosition->LoadCache(isd["instrument_position"]);
    }
    else if (kernels["InstrumentPosition"][0].toUpper() == "TABLE") {
      Table t("InstrumentPosition", lab.fileName(), lab);
@@ -965,8 +965,7 @@ namespace Isis {


  /**
   * This returns the PvlObject that stores all of the requested Naif data
   *   and can be a replacement for furnishing text kernels.
   * This returns the PvlObject that stores all of the requested Naif data  *   and can be a replacement for furnishing text kernels.
   */
  PvlObject Spice::getStoredNaifKeywords() const {
    return *m_naifKeywords;
+7 −7
Original line number Diff line number Diff line
@@ -354,22 +354,22 @@ namespace Isis {
    }

    // Load the full cache time information from the label if available
    p_fullCacheStartTime = isdPos["SpkTableStartTime"].get<double>();
    p_fullCacheEndTime = isdPos["SpkTableEndTime"].get<double>();
    p_fullCacheSize = isdPos["SpkTableOriginalSize"].get<double>();
    p_cacheTime = isdPos["EphemerisTimes"].get<std::vector<double>>();
    p_fullCacheStartTime = isdPos["spk_table_start_time"].get<double>();
    p_fullCacheEndTime = isdPos["spk_table_end_time"].get<double>();
    p_fullCacheSize = isdPos["spk_table_original_size"].get<double>();
    p_cacheTime = isdPos["ephemeris_times"].get<std::vector<double>>();

    for (auto it = isdPos["Positions"].begin(); it != isdPos["Positions"].end(); it++) {
    for (auto it = isdPos["positions"].begin(); it != isdPos["positions"].end(); it++) {
      std::vector<double> pos = {it->at(0).get<double>(), it->at(1).get<double>(), it->at(2).get<double>()};
      p_cache.push_back(pos);
    }

    p_cacheVelocity.clear();

    bool hasVelocityKey = isdPos.find("Velocities") != isdPos.end();
    bool hasVelocityKey = isdPos.find("velocities") != isdPos.end();

    if (hasVelocityKey) {
      for (auto it = isdPos["Velocities"].begin(); it != isdPos["Velocities"].end(); it++) {
      for (auto it = isdPos["velocities"].begin(); it != isdPos["velocities"].end(); it++) {
        std::vector<double> vel = {it->at(0).get<double>(), it->at(1).get<double>(), it->at(2).get<double>()};
        p_cacheVelocity.push_back(vel);
      }
+6 −6
Original line number Diff line number Diff line
@@ -296,11 +296,11 @@ int main(int argc, char *argv[]) {

  // Test loading cache from an ALE ISD without velocities
  cout << "Test loading cache from an ALE ISD with velocities" << endl;
  json aleIsd = {{"SpkTableStartTime"    , -10.0},
                 {"SpkTableEndTime"      , 10.0},
                 {"SpkTableOriginalSize" , 3},
                 {"EphemerisTimes"       , {-10.0, 0.0, 10.0}},
                 {"Positions"            , {{-10.0, -10.0, -10.0},
  json aleIsd = {{"spk_table_start_time"    , -10.0},
                 {"spk_table_end_time"      , 10.0},
                 {"spk_table_original_size" , 3},
                 {"ephemeris_times"       , {-10.0, 0.0, 10.0}},
                 {"positions"            , {{-10.0, -10.0, -10.0},
                                            {0.0,  0.0,  0.0},
                                            {10.0,  10.0,  10.0}}}};
  SpicePosition alePos(-94, 499);
@@ -319,7 +319,7 @@ int main(int argc, char *argv[]) {
  // Test loading cache from an ALE ISD with velocities
  cout << "Test loading cache from an ALE ISD with velocities" << endl;
  json aleVelIsd = aleIsd;
  aleVelIsd["Velocities"] = {{1.0, 1.0, 1.0},
  aleVelIsd["velocities"] = {{1.0, 1.0, 1.0},
                             {1.0, 1.0, 1.0},
                             {1.0, 1.0, 1.0}};
  SpicePosition aleVelPos(-94, 499);
+11 −11
Original line number Diff line number Diff line
@@ -429,32 +429,32 @@ namespace Isis {
    m_frameType = CK;

    // Load the full cache time information from the label if available
    p_fullCacheStartTime = isdRot["CkTableStartTime"].get<double>();
    p_fullCacheEndTime = isdRot["CkTableEndTime"].get<double>();
    p_fullCacheSize = isdRot["CkTableOriginalSize"].get<double>();
    p_cacheTime = isdRot["EphemerisTimes"].get<std::vector<double>>();
    p_timeFrames = isdRot["TimeDependentFrames"].get<std::vector<int>>();
    p_fullCacheStartTime = isdRot["ck_table_start_time"].get<double>();
    p_fullCacheEndTime = isdRot["ck_table_end_time"].get<double>();
    p_fullCacheSize = isdRot["ck_table_original_size"].get<double>();
    p_cacheTime = isdRot["ephemeris_times"].get<std::vector<double>>();
    p_timeFrames = isdRot["time_dependent_frames"].get<std::vector<int>>();

    for (auto it = isdRot["Quaternions"].begin(); it != isdRot["Quaternions"].end(); it++) {
    for (auto it = isdRot["quaternions"].begin(); it != isdRot["quaternions"].end(); it++) {
        std::vector<double> quat = {it->at(0).get<double>(), it->at(1).get<double>(), it->at(2).get<double>(), it->at(3).get<double>()};
        Quaternion q(quat);
        std::vector<double> CJ = q.ToMatrix();
        p_cache.push_back(CJ);
    }

    if (isdRot["AngularVelocity"].size() != 0) {
      for (auto it = isdRot["AngularVelocity"].begin(); it != isdRot["AngularVelocity"].end(); it++) {
    if (isdRot["angular_velocity"].size() != 0) {
      for (auto it = isdRot["angular_velocity"].begin(); it != isdRot["angular_velocity"].end(); it++) {
          std::vector<double> av = {it->at(0).get<double>(), it->at(1).get<double>(), it->at(2).get<double>()};
          p_cacheAv.push_back(av);
      }
      p_hasAngularVelocity = true;
    }

    bool hasConstantFrames = isdRot.find("ConstantFrames") != isdRot.end();
    bool hasConstantFrames = isdRot.find("constant_frames") != isdRot.end();

    if (hasConstantFrames) {
      p_constantFrames = isdRot["ConstantFrames"].get<std::vector<int>>();
      p_TC = isdRot["ConstantRotation"].get<std::vector<double>>();
      p_constantFrames = isdRot["constant_frames"].get<std::vector<int>>();
      p_TC = isdRot["constant_rotation"].get<std::vector<double>>();

    }
    else {
Loading