Skip to content

Commit

Permalink
updated with new isd format (#3839)
Browse files Browse the repository at this point in the history
* updated with new isd format

* removed missed debug prints

* changed header stuff for ale

* updated env
  • Loading branch information
Kelvin Rodriguez authored Apr 17, 2020
1 parent 4e0ace3 commit e926548
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 256 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- defaults

dependencies:
- ale >=0.7.1
- ale >=0.8.0
- boost=1.68.0
- armadillo
- blas
Expand Down
2 changes: 1 addition & 1 deletion isis/cmake/Findale.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# ALE_LIBRARY

find_path(ALE_INCLUDE_DIR
NAMES ale.h
NAMES Isd.h
PATH_SUFFIXES ale
)

Expand Down
19 changes: 9 additions & 10 deletions isis/src/base/objs/Spice/Spice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <getSpkAbCorrState.hpp>

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

#include <nlohmann/json.hpp>
using json = nlohmann::json;
Expand Down Expand Up @@ -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>;

Expand Down Expand Up @@ -197,9 +197,9 @@ 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
load(kernels["LeapSecond"], noTables);
if ( kernels.hasKeyword("SpacecraftClock")) {
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions isis/src/base/objs/SpicePosition/SpicePosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions isis/src/base/objs/SpicePosition/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
22 changes: 11 additions & 11 deletions isis/src/base/objs/SpiceRotation/SpiceRotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions isis/src/base/objs/SpiceRotation/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,12 +620,12 @@ int main(int argc, char *argv[]) {
// [-90, 0, 0],
// [-90, 180, 0],
// [-90, 180, 90]
json aleQuatIsd = {{"CkTableStartTime" , 0.0},
{"CkTableEndTime" , 3.0},
{"CkTableOriginalSize" , 4},
{"EphemerisTimes" , {0.0, 1.0, 2.0, 3.0}},
{"TimeDependentFrames" , {-94031, 10014, 1}},
{"Quaternions" , {{0.0, 0.0, 0.0, 1.0},
json aleQuatIsd = {{"ck_table_start_time" , 0.0},
{"ck_table_end_time" , 3.0},
{"ck_table_original_size" , 4},
{"ephemeris_times" , {0.0, 1.0, 2.0, 3.0}},
{"time_dependent_frames" , {-94031, 10014, 1}},
{"quaternions" , {{0.0, 0.0, 0.0, 1.0},
{-1.0 / sqrt(2), 0.0, 0.0, 1.0 / sqrt(2)},
{0.0, 1.0 / sqrt(2), 1.0 / sqrt(2), 0.0},
{-0.5, -0.5, 0.5, 0.5}}}};
Expand Down Expand Up @@ -664,7 +664,7 @@ int main(int argc, char *argv[]) {
cout << endl << endl << "Testing loading cache from ALE ISD with time dependent quaternions and AV ..." << endl;
SpiceRotation aleQuatAVRot(-94031);
json aleQuatAVIsd(aleQuatIsd);
aleQuatAVIsd["AngularVelocity"] = {{-Isis::PI / 2, 0.0, 0.0},
aleQuatAVIsd["angular_velocity"] = {{-Isis::PI / 2, 0.0, 0.0},
{0.0, Isis::PI, 0.0},
{0.0, 0.0, Isis::PI / 2},
{0.0, 0.0, Isis::PI / 2}};
Expand All @@ -675,9 +675,9 @@ int main(int argc, char *argv[]) {
cout << endl << endl << "Testing loading cache from ALE ISD with time dependent quaternions and constant rotation ..." << endl;
SpiceRotation aleQuatConstRot(-94031);
json aleQuatConstIsd(aleQuatIsd);
aleQuatConstIsd["TimeDependentFrames"] = {-94030, 10014, 1};
aleQuatConstIsd["ConstantFrames"] = {-94031, -94030};
aleQuatConstIsd["ConstantRotation"] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0};
aleQuatConstIsd["time_dependent_frames"] = {-94030, 10014, 1};
aleQuatConstIsd["constant_frames"] = {-94031, -94030};
aleQuatConstIsd["constant_rotation"] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0};
aleQuatConstRot.LoadCache(aleQuatConstIsd);
timeDepChain = aleQuatConstRot.TimeFrameChain();
cout << "Time dependent frame chain = { ";
Expand Down
72 changes: 36 additions & 36 deletions isis/tests/CubeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ TEST(CubeTest, TestCubeAttachSpiceFromIsd) {


json isd = json::parse(R"(
{"CameraVersion": 2,
"NaifKeywords": {
{"isis_camera_version": 2,
"naif_keywords": {
"BODY_CODE" : 499,
"BODY499_RADII" : [3396.19, 3396.19, 3376.2],
"BODY_FRAME_CODE" : 10014,
Expand All @@ -131,75 +131,75 @@ TEST(CubeTest, TestCubeAttachSpiceFromIsd) {
"INS-27002_ITRANSS" : [0.0, 85.0, 0.0],
"INS-27002_ITRANSL" : [0.0, 0.0, 85.0]
},
"InstrumentPointing": {
"TimeDependentFrames": [-85600, -85000, 1],
"CkTableStartTime": 100,
"CkTableEndTime": 100.1,
"CkTableOriginalSize": 2,
"EphemerisTimes": [
"instrument_pointing": {
"time_dependent_frames": [-85600, -85000, 1],
"ck_table_start_time": 100,
"ck_table_end_time": 100.1,
"ck_table_original_size": 2,
"ephemeris_times": [
100,
100.1
],
"Quaternions": [
"quaternions": [
[0.0, -0.660435174378928, 0, 0.750883067090392],
[0.0, -0.660435174378928, 0, 0.750883067090392]
],
"AngularVelocity": [
"angular_velocity": [
[0, 0, 0],
[0, 0, 0]
],
"ConstantFrames": [-85600],
"ConstantRotation": [1, 0, 0, 0, 1, 0, 0, 0, 1]
"constant_frames": [-85600],
"constant_rotation": [1, 0, 0, 0, 1, 0, 0, 0, 1]
},
"BodyRotation": {
"TimeDependentFrames": [31006, 1],
"CkTableStartTime": 100,
"CkTableEndTime": 100.1,
"CkTableOriginalSize": 2,
"EphemerisTimes": [
"body_rotation": {
"time_dependent_frames": [31006, 1],
"ck_table_start_time": 100,
"ck_table_end_time": 100.1,
"ck_table_original_size": 2,
"ephemeris_times": [
100,
100.1
],
"Quaternions": [
"quaternions": [
[ 0, 0.8509035, 0, 0.525322 ],
[ 0, 0.8509035, 0, 0.525322 ]
],
"AngularVelocity": [
"angular_velocity": [
[0, 0, 0],
[0, 0, 0]
],
"ConstantFrames": [31001, 31007, 31006],
"ConstantRotation": [-0.4480736, 0, 0.8939967, 0, 1, 0, -0.8939967, 0, -0.4480736]
"constant_frames": [31001, 31007, 31006],
"constant_rotation": [-0.4480736, 0, 0.8939967, 0, 1, 0, -0.8939967, 0, -0.4480736]
},
"InstrumentPosition": {
"SpkTableStartTime": 100,
"SpkTableEndTime": 100.1,
"SpkTableOriginalSize": 2,
"EphemerisTimes": [
"instrument_position": {
"spk_table_start_time": 100,
"spk_table_end_time": 100.1,
"spk_table_original_size": 2,
"ephemeris_times": [
100,
100.1
],
"Positions": [
"positions": [
[1000, 0, 0],
[1000, 0, 0]
],
"Velocities": [
"velocities": [
[0, 0, 0],
[0, 0, 0]
]
},
"SunPosition": {
"SpkTableStartTime": 100,
"SpkTableEndTime": 100.1,
"SpkTableOriginalSize": 2,
"EphemerisTimes": [
"sun_position": {
"spk_table_start_time": 100,
"spk_table_end_time": 100.1,
"spk_table_original_size": 2,
"ephemeris_times": [
100,
100.1
],
"Positions": [
"positions": [
[0, 20, 0]
],
"Velocities": [
"velocities": [
[10,10,10]
]
}
Expand Down
Loading

0 comments on commit e926548

Please sign in to comment.