Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace cspice calls with spiceql and add api accessor function #5545

Draft
wants to merge 56 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
e7ea906
Added findspiceql to build system
AustinSanders Jul 12, 2024
cb14607
Added spiceql
AustinSanders Jul 12, 2024
972f7ef
Initial isis/spiceql wrapped functions
AustinSanders Jul 12, 2024
247a80e
added todo
AustinSanders Jul 12, 2024
0886b15
merge dev
AustinSanders Aug 5, 2024
8b76f4f
Replaced apollopaninit cspice calls with spiceql
AustinSanders Aug 8, 2024
5e09e3e
Updated local spice calls with searchkernels=true
AustinSanders Aug 8, 2024
3a3bb84
Replaced voyager2isis cspice calls with spiceql calls
AustinSanders Aug 8, 2024
75b0c53
Replaced vikcal calparameters cspice calls with spiceql calls
AustinSanders Aug 8, 2024
3915b69
Updated rosvirtis2isis cspice calls with spiceql calls
AustinSanders Aug 8, 2024
aa1c94b
Replaced newhorizons cspice calls with spiceql calls
AustinSanders Aug 8, 2024
394db88
Replaced lronaccal cspice calls with spiceql calls
AustinSanders Aug 8, 2024
79ab710
Replaced chan1m32isis cspice calls with spiceql calls
AustinSanders Aug 8, 2024
e563133
Replaced gllssical cspice calls with spiceql calls
AustinSanders Aug 8, 2024
5177066
Replaced lrowaccal cspice calls with spiceql calls
AustinSanders Aug 8, 2024
ead2f55
Replaced amicacal cspice calls with spiceql calls
AustinSanders Aug 8, 2024
2a4930e
Replaced hicalconf cspice calls with spiceql calls
AustinSanders Aug 8, 2024
e2494b5
Add spiceql to environment
AustinSanders Aug 8, 2024
b2df938
Replaced mical cspice calls with spiceql calls
AustinSanders Aug 8, 2024
5585fe7
Replaced moccal cspice calls with spiceql calls
AustinSanders Aug 8, 2024
b982070
Replaced moclabels cspice calls with spiceql calls
AustinSanders Aug 8, 2024
a0ba457
Replaced ctxcal cspice calls with spiceql calls
AustinSanders Aug 8, 2024
ab42c15
Replaced hijitcube cspice calls with spiceql calls
AustinSanders Aug 8, 2024
d1a8efe
Replaced sumfinder cspice calls with spiceql calls
AustinSanders Aug 9, 2024
320c937
Removed unused variables and added TODO
AustinSanders Aug 14, 2024
6014f91
Replaced hicrop cspice calls with spiceql calls
AustinSanders Aug 14, 2024
8fc3505
Added mission map
AustinSanders Aug 14, 2024
c98fa01
Updated getTargetStates vector to include velocities
AustinSanders Aug 14, 2024
a6c8f66
Replaced mdiscal cspice calls with spiceql calls
AustinSanders Aug 14, 2024
8734993
Removed unused variables
AustinSanders Aug 14, 2024
38e0184
Removed test couts
AustinSanders Aug 15, 2024
a66a37e
Added uri encoding function
AustinSanders Aug 15, 2024
2cb1164
Converted shadow cspice calls to spiceql calls
AustinSanders Aug 15, 2024
5e7c7fd
Converted spiceql ettosclk call to upstream version
AustinSanders Aug 15, 2024
19920c7
Removed useweb argument in favor of isis preference
AustinSanders Aug 23, 2024
e7e38fe
Changed functions with large param lists to POST
AustinSanders Aug 23, 2024
d3ec45e
Added useweb argument
AustinSanders Aug 23, 2024
2d2f21c
trigger build
chkim-usgs Dec 9, 2024
897fdd7
Capitalize SpiceQL
chkim-usgs Dec 9, 2024
70281f8
Update spiceql path_suffix
chkim-usgs Dec 9, 2024
9c49f15
Update spiceql library name
chkim-usgs Dec 9, 2024
67f7a6a
Change SpiceQL.h to spiceql.h
chkim-usgs Dec 9, 2024
7474fb2
Remove KernelPool
chkim-usgs Dec 9, 2024
579bb2b
Remove KernelPool
chkim-usgs Dec 9, 2024
f43f45d
Remove KernelPool in shadow
chkim-usgs Dec 9, 2024
dd4c67d
Remove false bools in apollopaninit
chkim-usgs Dec 9, 2024
8f4c340
Movie Isis import to top
chkim-usgs Dec 9, 2024
aef3de8
Replace furnsh_c with load
chkim-usgs Dec 10, 2024
b224fd3
Replace base in sumspice
chkim-usgs Dec 13, 2024
a4727bc
Replace post with get calls
chkim-usgs Dec 13, 2024
32b47dc
Lowercase mars
chkim-usgs Dec 13, 2024
8dfdcba
Turn off web spice for tests
chkim-usgs Dec 17, 2024
a44a2d9
Test fixes
chkim-usgs Jan 8, 2025
162f294
Lowercase in hicalconf
chkim-usgs Jan 8, 2025
124277c
Update apollopaninit getFrameInfo
chkim-usgs Jan 10, 2025
dfc48fa
Add post for getTargetStates
chkim-usgs Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ dependencies:
- qhull
- qt-main>=5.15.8, <5.16
- qwt <6.3.0
- spiceql
- sqlite >=3.46.0,<3.47
- suitesparse <7.7.0
- superlu
Expand Down
1 change: 1 addition & 0 deletions isis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ find_package(PCL REQUIRED)
find_package(Protobuf REQUIRED)
find_package(Qwt 6 REQUIRED)
find_package(SuperLU 4.3 REQUIRED)
find_package(SpiceQL REQUIRED)
find_package(TIFF 4.0.0 REQUIRED)
find_package(TNT 126 REQUIRED)
find_package(XercesC 3.1.2 REQUIRED)
Expand Down
11 changes: 11 additions & 0 deletions isis/IsisPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ Group = Plugins
"$HOME/.Isis/csm3.0.3/")
EndGroup

########################################################
#
# Set whether spice calls use the SpiceQL web API or
# local kernels.
#
########################################################

Group = WebSpice
UseWebSpice = "true"
EndGroup

########################################################
# Customize the location of mission specific data
# files (calibration and spice kernels). Usually this
Expand Down
12 changes: 12 additions & 0 deletions isis/TestPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ Group = Plugins
"$HOME/.Isis/csm3.0.3/")
EndGroup

########################################################
#
# Set whether spice calls use the SpiceQL web API or
# local kernels.
#
########################################################

Group = WebSpice
UseWebSpice = "false"
EndGroup


########################################################
# Customize the location of mission specific data
# files (calibration and spice kernels). Usually this
Expand Down
23 changes: 23 additions & 0 deletions isis/cmake/FindSpiceQL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# CMake module for find_package(SpiceQL)
# Finds include directory and all applicable libraries
#
# Sets the following:
# SpiceQL_INCLUDE_DIR
# SpiceQL_LIBRARY

find_path(SPICEQL_INCLUDE_DIR
NAME spiceql.h
PATH_SUFFIXES "SpiceQL"
)

find_library(SPICEQL_LIBRARY
NAMES SpiceQL
)

get_filename_component(SUPERLU_ROOT_INCLUDE_DIR "${SUPERLU_INCLUDE_DIR}" DIRECTORY)


message(STATUS "SPICEQL INCLUDE DIR: " ${SPICEQL_INCLUDE_DIR} )
message(STATUS "SPICEQL LIB: " ${SPICEQL_LIBRARY} )

get_filename_component(SPICEQL_ROOT_INCLUDE_DIR "${SPICEQL_INCLUDE_DIR}" DIRECTORY)
30 changes: 18 additions & 12 deletions isis/src/apollo/apps/apollopaninit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ find files of those names at the top level of this repository. **/
#include "PvlKeyword.h"
#include "PvlObject.h"
#include "PvlTranslationTable.h"
#include "RestfulSpice.h"
#include "Spice.h"
#include "SpicePosition.h"
#include "SpiceRotation.h"
#include "Table.h"
#include "UserInterface.h"
#include "spiceql.h"


#define FIDL 26.72093 //spacing between fiducial marks in mm
Expand Down Expand Up @@ -228,25 +230,29 @@ void IsisMain() {

panCube.putGroup(kernels_pvlG);

//Load all the kernels
// Load kernels
Load_Kernel(kernels_pvlG["TargetPosition"]);
Load_Kernel(kernels_pvlG["TargetAttitudeShape"]);
Load_Kernel(kernels_pvlG["LeapSecond"]);


//////////////////////////////////////////attach a target rotation table
char frameName[32];
SpiceInt frameCode;
SpiceBoolean found;
//get the framecode from the body code (301=MOON)
cidfrm_c(301, sizeof(frameName), &frameCode, frameName, &found);
if(!found) {
QString naifTarget = QString("IAU_MOOM");
namfrm_c(naifTarget.toLatin1().data(), &frameCode);
std::string frameName;
SpiceInt frameCode = 0;
try{
json output = Isis::RestfulSpice::getTargetFrameInfo(301, RestfulSpice::spiceql_mission_map[(panCube.camera()->instrumentId()).toStdString()]);
frameCode = output["frameCode"].get<SpiceInt>();
frameName = output["frameName"].get<std::string>();
}catch(std::invalid_argument){
std::string naifTarget = "IAU_MOON";
frameCode = Isis::RestfulSpice::translateNameToCode(naifTarget, mission.toLower().toStdString());
if(frameCode == 0) {
QString msg = "Can not find NAIF code for [" + naifTarget + "]";
QString msg = "Can not find NAIF code for [" + QString::fromStdString(naifTarget) + "]";
throw IException(IException::Io, msg, _FILEINFO_);
}
}


spRot = new SpiceRotation(frameCode);
//create a table from starttime to endtime (streched by 3%) with NODES entries
spRot->LoadCache(time0-0.015*(time1-time0), time1+0.015*(time1-time0), NODES);
Expand All @@ -267,7 +273,7 @@ void IsisMain() {
/////////////Finding the principal scan line position and orientation
//get the radii of the MOON
SpiceInt tempRadii = 0;
bodvcd_c(301,"RADII",3,&tempRadii,R_MOON); //units are km
//bodvcd_c(301,"RADII",3,&tempRadii,R_MOON); //units are km
double omega,phi,kappa;

std::vector<double> posSel; //Seleno centric position
Expand Down Expand Up @@ -808,7 +814,7 @@ void Load_Kernel(Isis::PvlKeyword &key) {
throw IException(IException::Io, msg, _FILEINFO_);
}
QString fileName(file.expanded());
furnsh_c(fileName.toLatin1().data());
SpiceQL::load(fileName.toLatin1().data());
}

NaifStatus::CheckErrors();
Expand Down
20 changes: 14 additions & 6 deletions isis/src/base/apps/appjit/LineScanCameraRotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "IString.h"
#include "iTime.h"
#include "IException.h"
#include "RestfulSpice.h"
#include "Table.h"
#include "NaifStatus.h"

Expand Down Expand Up @@ -54,8 +55,6 @@ namespace Isis {
p_ckKeyword = kernels["InstrumentPointing"];

p_cacheTime = timeCache;
// std::cout<<std::setprecision(24);
// std::cout<<timeCache.at(0)<<"-"<<timeCache.at(50000)<<std::endl;

InitConstantRotation(p_cacheTime[0]);

Expand Down Expand Up @@ -110,8 +109,6 @@ namespace Isis {
// *** May need to do a frame trace and load the frames (at least the constant ones) ***

// Loop and load the cache
double state[6];
double lt;
NaifStatus::CheckErrors();

double R[3]; // Direction of radial axis of line scan camera
Expand All @@ -124,15 +121,26 @@ namespace Isis {
SpiceRotation *crot = p_spi->instrumentRotation();

std::vector<ale::Rotation> rotationCache;

std::vector<std::vector<double>> sunLt = Isis::RestfulSpice::getTargetStates(p_cacheTime, "MRO", "mars", "IAU_MARS", "NONE", "mro", "reconstructed", "reconstructed");

double state[6];
for(std::vector<double>::iterator i = p_cacheTime.begin(); i < p_cacheTime.end(); i++) {
// Clear state array before copying new values
std::fill_n(state, 6, 0);

double et = *i;

// Get the index from the iterator
size_t idx = i - p_cacheTime.begin();

prot->SetEphemerisTime(et);
crot->SetEphemerisTime(et);

// The following code will be put into method LoadIBcache()
spkezr_c("MRO", et, "IAU_MARS", "NONE", "MARS", state, &lt);
NaifStatus::CheckErrors();

std::copy(sunLt[idx].begin(), sunLt[idx].begin()+6, state);


// Compute the direction of the radial axis (3) of the line scan camera
vscl_c(1. / vnorm_c(state), state, R); // vscl and vnorm only operate on first 3 members of state
Expand Down
44 changes: 31 additions & 13 deletions isis/src/base/apps/shadow/shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include "KernelDb.h"
#include "NaifStatus.h"
#include "ProcessByBrick.h"
#include "RestfulSpice.h"
#include "ShadowFunctor.h"
#include "SpicePosition.h"
#include "spiceql.h"

namespace Isis {
QStringList kernels(QString kernelType,
Expand Down Expand Up @@ -46,11 +48,12 @@ namespace Isis {
allKernelFiles.append(kernels("PCK", &KernelDb::targetAttitudeShape, *demCube->label(), ui));
allKernelFiles.append(kernels("SPK", &KernelDb::targetPosition, *demCube->label(), ui));


NaifStatus::CheckErrors();

foreach (QString kernelFile, allKernelFiles) {
kernelsUsed += kernelFile;
furnsh_c(FileName(kernelFile).expanded().toLatin1().data());
SpiceQL::load(FileName(kernelFile).expanded().toLatin1().data());
}

// Find the NAIF target code for the DEM's target
Expand All @@ -63,28 +66,43 @@ namespace Isis {

// Get actual sun position, relative to target
QString bodyFixedFrame = QString("IAU_%1").arg(name.toUpper());
spkpos_c("SUN", time.Et(), bodyFixedFrame.toLatin1().data(), "NONE",
name.toUpper().toLatin1().data(), sunPosition, &lightTime);
std::vector<double> etStart = {time.Et()};
std::string observer = name.toUpper().toLatin1().data();
std::string bff = bodyFixedFrame.toLatin1().data();
std::vector<std::vector<double>> sunLt;
// If kernels are specified
bool userKernels = false;

if (ui.WasEntered("PCK") || ui.WasEntered("SPK")){
userKernels = true;
}

if (userKernels){
sunLt = SpiceQL::getTargetStates(etStart, "sun", observer, bff, "NONE", "base", "reconstructed", "reconstructed", true);
}else{
sunLt = Isis::RestfulSpice::getTargetStates(etStart, "sun", observer, bff, "NONE", RestfulSpice::spiceql_mission_map[observer], "reconstructed", "reconstructed");
}

NaifStatus::CheckErrors();

// Adjusted for light time
spkpos_c("SUN", time.Et() - lightTime, bodyFixedFrame.toLatin1().data(), "NONE",
name.toUpper().toLatin1().data(), sunPosition, &lightTime);
// Adjust for light time
lightTime = sunLt[0][6];
etStart = {time.Et() - lightTime};

if (userKernels){
sunLt = SpiceQL::getTargetStates(etStart, "sun", observer, bff, "NONE", "base", "reconstructed", "reconstructed", true);
}else{
sunLt = Isis::RestfulSpice::getTargetStates(etStart, "sun", observer, bff, "NONE", RestfulSpice::spiceql_mission_map[observer], "reconstructed", "reconstructed");
}

std::copy(sunLt[0].begin(), sunLt[0].begin()+3, sunPosition);
NaifStatus::CheckErrors();



// Convert sun position units: KM -> M
sunPosition[0] *= 1000;
sunPosition[1] *= 1000;
sunPosition[2] *= 1000;

foreach (QString kernelFile, allKernelFiles) {
unload_c(FileName(kernelFile).expanded().toLatin1().data());
}

NaifStatus::CheckErrors();
functor.setSunPosition(sunPosition);
}

Expand Down
3 changes: 2 additions & 1 deletion isis/src/base/objs/Kernels/Kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ find files of those names at the top level of this repository. **/
#include "NaifStatus.h"
#include "PvlKeyword.h"
#include "Pvl.h"
#include "spiceql.h"

using namespace std;

Expand Down Expand Up @@ -776,7 +777,7 @@ namespace Isis {
if (!kfile.loaded) {
NaifStatus::CheckErrors();
try {
furnsh_c(kfile.fullpath.toLatin1().data());
SpiceQL::load(kfile.fullpath.toLatin1().data());
NaifStatus::CheckErrors();
kfile.loaded = true;
kfile.managed = true;
Expand Down
7 changes: 7 additions & 0 deletions isis/src/base/objs/RestfulSpice/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ifeq ($(ISISROOT), $(BLANK))
.SILENT:
error:
echo "Please set ISISROOT";
else
include $(ISISROOT)/make/isismake.apps
endif
Loading
Loading