Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5a4d58c
added --download-base
Kelvinrr Apr 4, 2025
4db36f3
added overwrite flag
Kelvinrr May 9, 2025
9e57898
merge conflicts
Kelvinrr May 9, 2025
ec3af8b
merge conflicts
Kelvinrr May 9, 2025
8222902
udpated script
Kelvinrr May 12, 2025
4e362a4
added auto as default
Kelvinrr May 14, 2025
e11c33e
added :325
Kelvinrr May 14, 2025
ad82606
pi
Kelvinrr May 14, 2025
bd4ebad
fixed some things
Kelvinrr May 20, 2025
ef75db1
fixed bug
Kelvinrr May 20, 2025
f98d0e4
syntax error
Kelvinrr May 20, 2025
94f59c3
Merge branch 'dev' of github.com:USGS-Astrogeology/ISIS3
Kelvinrr May 23, 2025
448227f
removed some itime spice calls
Kelvinrr Jun 4, 2025
8813615
added working web spoice
Kelvinrr Jun 17, 2025
0d5ebc4
removed couts
Kelvinrr Jun 17, 2025
9654246
bump spiceql to 1.2.0
chkim-usgs Jun 24, 2025
530d4ae
fix lrowaccal
chkim-usgs Jun 24, 2025
0dfc112
fix mical
chkim-usgs Jun 24, 2025
992fa2e
Fix iTime UTC and dayOfYear functions
acpaquette Jul 2, 2025
ad23206
bump spiceql to 1.2.1
chkim-usgs Jul 9, 2025
a692b34
Merge branch 'dev' into spice
chkim-usgs Jul 9, 2025
1ed31e9
trigger build
chkim-usgs Jul 9, 2025
c5766f3
accommodating spiceql 1.2.1 changes
chkim-usgs Jul 9, 2025
160af6d
Add function in ISIS Preference class to read UseWebSpice option
acpaquette Jul 11, 2025
4e7df95
Updated all places that need to check if web spice is enabled
acpaquette Jul 11, 2025
3af3972
merge conflicts
Kelvinrr Jan 9, 2026
88933ee
added isis.h changes
Kelvinrr Jan 14, 2026
31a1b3e
removed verbose
Kelvinrr Jan 15, 2026
3e7a1fa
removed table check
Kelvinrr Jan 16, 2026
19e62ae
merge conflcits
Kelvinrr Feb 9, 2026
1bad556
updated to use ALE for spiceinit
Kelvinrr Feb 19, 2026
1fdbc47
merge conflicts
Kelvinrr Mar 30, 2026
4f32f17
Enforced camera loading happen through the camera factory in spiceinint
acpaquette Apr 9, 2026
201cd76
Exposed a couple functions from KernelDb
acpaquette Apr 9, 2026
46fdf71
Removed direct spice calls from missed calls in camera models
acpaquette Apr 9, 2026
026f893
Removed missed debug print
acpaquette Apr 9, 2026
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
2 changes: 1 addition & 1 deletion isis/src/apollo/apps/apollopaninit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void IsisMain() {


//////////////////////////////////////////attach a target rotation table
bool useWeb = QString(Preference::Preferences().findGroup("SpiceQL")["UseSpiceQL"]).toUpper() == "TRUE";
bool useWeb = Preference::Preferences().useWebSpice();
std::string frameName;
SpiceInt frameCode = 0;
try {
Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/apps/shadow/shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace Isis {
userKernels = true;
}

bool useWeb = QString(Preference::Preferences().findGroup("SpiceQL")["UseSpiceQL"]).toUpper() == "TRUE";
bool useWeb = Preference::Preferences().useWebSpice();

if (userKernels) {
auto [output, kernels] = SpiceQL::getTargetStates(etStart, "sun", observer, bff, "NONE", "base", {"reconstructed"}, {"reconstructed"}, useWeb, true);
Expand Down
166 changes: 133 additions & 33 deletions isis/src/base/apps/spiceinit/spiceinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@
#include "Table.h"
#include "UserInterface.h"
#include "spiceinit.h"
#include <ale/Load.h>
#include <nlohmann/json.hpp>

using json = nlohmann::json;
using namespace std;

namespace Isis {

void getUserEnteredKernel(UserInterface &ui, const QString &param, Kernel &kernel);
bool tryKernels(Cube *icube, Process &p, UserInterface &ui, Pvl *log,
Kernel lk, Kernel pck,
Kernel targetSpk, Kernel ck,
Kernel fk, Kernel ik,
Kernel sclk, Kernel spk,
Kernel iak, Kernel dem,
Kernel exk);

PvlGroup createKernelGroup(const PvlGroup &currentKernels, UserInterface &ui,
Kernel lk, Kernel pck,
Kernel targetSpk, Kernel ck,
Kernel fk, Kernel ik,
Kernel sclk, Kernel spk,
Kernel iak, Kernel dem,
Kernel exk);
bool tryKernels(Cube *icube, UserInterface &ui, Pvl *log, PvlGroup &currentKernels);
void requestSpice(Cube *icube, UserInterface &ui, Pvl *log, Pvl &labels, QString missionName);

/**
Expand Down Expand Up @@ -111,6 +114,66 @@ namespace Isis {
if (ui.GetBoolean("WEB")) {
requestSpice(icube, ui, log, *icube->label(), mission);
}
else if (Preference::Preferences().useWebSpice()) {
PvlGroup currentKernels = icube->group("Kernels");
std::vector<QString> keywordsToRemove = {"CameraVersion",
"ShapeModel",
"Source",
"LeapSecond",
"TargetAttitudeShape",
"TargetPosition",
"InstrumentPointing",
"Instrument",
"SpacecraftClock",
"InstrumentPosition",
"InstrumentAddendum",
"ShapeModel",
"InstrumentPositionQuality",
"InstrumentPointingQuality",
"Extra"};
for (QString keyword : keywordsToRemove) {
if (currentKernels.hasKeyword(keyword))
currentKernels.deleteKeyword(keyword);
}

if (ui.GetBoolean("CKNADIR")) {
PvlKeyword instPointing("InstrumentPointing");
instPointing.addValue("Nadir");
currentKernels += instPointing;
}

// Get shape kernel
Kernel dem;
if (ui.GetString("SHAPE") == "USER") {
getUserEnteredKernel(ui, "MODEL", dem);
}
else if (ui.GetString("SHAPE") == "SYSTEM") {
KernelDb baseKernels(0);

// Get the base DataDirectory
PvlGroup &dataDir = Preference::Preferences().findGroup("DataDirectory");
QString baseDir = dataDir["Base"];
baseKernels.loadKernelDbFiles(dataDir, baseDir + "/dems", lab);
baseKernels.readKernelDbFiles();
dem = baseKernels.dem(lab);
}
PvlKeyword demKeyword("ShapeModel");
if (ui.GetString("SHAPE") == "RINGPLANE") {
demKeyword.addValue("RingPlane");
}
else {
for (int i = 0; i < dem.size(); i++) {
demKeyword.addValue(dem[i]);
}
}
currentKernels += demKeyword;
bool kernelSuccess = tryKernels(icube, ui, log, currentKernels);
if (!kernelSuccess) {
throw IException(IException::Unknown,
"Unable to initialize camera model",
_FILEINFO_);
}
}
else {
// Get system base kernels
unsigned int allowed = 0;
Expand Down Expand Up @@ -253,8 +316,11 @@ namespace Isis {

realCkKernel.setKernels(ckKernelList);

kernelSuccess = tryKernels(icube, p, ui, log, lk, pck, targetSpk,
PvlGroup currentKernels = createKernelGroup(icube->group("kernels"), ui,
lk, pck, targetSpk,
realCkKernel, fk, ik, sclk, spk, iak, dem, exk);

kernelSuccess = tryKernels(icube, ui, log, currentKernels);
}
if (!kernelSuccess) {
throw IException(IException::Unknown,
Expand Down Expand Up @@ -293,9 +359,8 @@ namespace Isis {
* @param(in/out) icube The Cube to create the camera from. If attach is true
* in the options, then the SPICE data will be written
* to the Cube's file.
* @param p The process object that the Cube belongs to
* @param options The spiceinit options
* @param(out) log The Application log
* @param originalKernels The cubes kernels group to use as a base for the output kernels group
* @param ui Userinterface from the spiceinit app
* @param lk The leap second kernels
* @param pck The planetary constant kernels
* @param targetspk The target state kernels
Expand All @@ -308,14 +373,22 @@ namespace Isis {
* @param dem The digital elevation model
* @param exk The extra kernels
*
* @return If a camera model was successfully created
* @return New kernels group with updated kernels from input
*/
bool tryKernels(Cube *icube, Process &p, UserInterface &ui, Pvl *log,
Kernel lk, Kernel pck,
Kernel targetSpk, Kernel ck,
Kernel fk, Kernel ik, Kernel sclk,
Kernel spk, Kernel iak,
Kernel dem, Kernel exk) {
PvlGroup createKernelGroup(const PvlGroup &originalKernels,
UserInterface &ui,
Kernel lk,
Kernel pck,
Kernel targetSpk,
Kernel ck,
Kernel fk,
Kernel ik,
Kernel sclk,
Kernel spk,
Kernel iak,
Kernel dem,
Kernel exk)
{
// Add the new kernel files to the existing kernels group
PvlKeyword lkKeyword("LeapSecond");
PvlKeyword pckKeyword("TargetAttitudeShape");
Expand Down Expand Up @@ -365,7 +438,6 @@ namespace Isis {
exkKeyword.addValue(exk[i]);
}

PvlGroup originalKernels = icube->group("Kernels");
PvlGroup currentKernels = originalKernels;
currentKernels.addKeyword(lkKeyword, Pvl::Replace);
currentKernels.addKeyword(pckKeyword, Pvl::Replace);
Expand All @@ -377,15 +449,6 @@ namespace Isis {
currentKernels.addKeyword(iakKeyword, Pvl::Replace);
currentKernels.addKeyword(demKeyword, Pvl::Replace);

// Save off the CSM State so it can be restored if spiceinit fails
Blob csmState("CSMState", "String");
if (icube->hasBlob("CSMState", "String")) {
icube->read(csmState);
}

// Delete the CSM State blob so that CameraFactory doesn't try to instantiate a CSMCamera
icube->deleteBlob("CSMState", "String");

// report qualities
PvlKeyword spkQuality("InstrumentPositionQuality");
spkQuality.addValue(Kernel::typeEnum(spk.type()));
Expand All @@ -402,6 +465,24 @@ namespace Isis {
currentKernels.deleteKeyword("EXTRA");
}

return currentKernels;
}

/**
* Attempt to create a camera model from a set of kernels.
*
* @param(in/out) icube The Cube to create the camera from. If attach is true
* in the options, then the SPICE data will be written
* to the Cube's file.
* @param icube The process object that the Cube belongs to
* @param ui The spiceinit options
* @param log(out) log The Application log
* @param currentKernels kernel set to attempt to load
*
* @return If a camera model was successfully created
*/
bool tryKernels(Cube *icube, UserInterface &ui, Pvl *log, PvlGroup &currentKernels) {

// Get rid of old keywords from previously inited cubes
if (currentKernels.hasKeyword("Source"))
currentKernels.deleteKeyword("Source");
Expand Down Expand Up @@ -451,14 +532,26 @@ namespace Isis {
PvlKeyword("CameraVersion", toString(CameraFactory::CameraVersion(*icube))),
Pvl::Replace);

// Save off the old kernels group so it can be restored if spiceinit fails
PvlGroup originalKernels = icube->group("Kernels");

// Save off the CSM State so it can be restored if spiceinit fails
Blob csmState("CSMState", "String");
if (icube->hasBlob("CSMState", "String")) {
icube->read(csmState);
}

// Add the modified Kernels group to the input cube labels
icube->putGroup(currentKernels);

// Delete the CSM State blob so that CameraFactory doesn't try to instantiate a CSMCamera
icube->deleteBlob("CSMState", "String");

// Create the camera so we can get blobs if necessary
try {
Camera *cam;
try {
cam = icube->camera();
cam = CameraFactory::Create(*icube);
currentKernels = icube->group("Kernels");

PvlKeyword source("Source");
Expand All @@ -484,7 +577,9 @@ namespace Isis {
icube->putGroup(originalKernels);

// restore CSM State blob if spiceinit failed
icube->write(csmState);
if (csmState.Size() > 0) {
icube->write(csmState);
}

throw IException(e);
}
Expand All @@ -494,6 +589,11 @@ namespace Isis {
ckTable.Label() += PvlKeyword("Description", "Created by spiceinit");
ckTable.Label() += PvlKeyword("Kernels");

const PvlKeyword &ckKeyword = currentKernels.findKeyword("InstrumentPointing");
const PvlKeyword &spkKeyword = currentKernels.findKeyword("InstrumentPosition");
const PvlKeyword &pckKeyword = currentKernels.findKeyword("TargetAttitudeShape");
const PvlKeyword &targetSpkKeyword = currentKernels.findKeyword("TargetPosition");

for (int i = 0; i < ckKeyword.size(); i++)
ckTable.Label()["Kernels"].addValue(ckKeyword[i]);

Expand Down Expand Up @@ -587,7 +687,7 @@ namespace Isis {
}
}
}
catch(IException &) {
catch(IException &e) {
icube->putGroup(originalKernels);
return false;
}
Expand Down Expand Up @@ -718,4 +818,4 @@ namespace Isis {
delete sunPosTable;
sunPosTable = NULL;
}
}
}
3 changes: 0 additions & 3 deletions isis/src/base/objs/Cube/Cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,14 +1724,12 @@ namespace Isis {
ckTable.Label()["Kernels"].addValue(ckKeyword[i]);

this->write(ckTable);

Table spkTable = spice.instrumentPosition()->Cache("InstrumentPosition");
spkTable.Label() += PvlKeyword("Kernels");
for (int i = 0; i < spkKeyword.size(); i++)
spkTable.Label()["Kernels"].addValue(spkKeyword[i]);

this->write(spkTable);

Table bodyTable = spice.bodyRotation()->Cache("BodyRotation");
bodyTable.Label() += PvlKeyword("Kernels");
for (int i = 0; i < targetSpkKeyword.size(); i++)
Expand All @@ -1743,7 +1741,6 @@ namespace Isis {
bodyTable.Label() += PvlKeyword("SolarLongitude",
toString(spice.solarLongitude().degrees()));
this->write(bodyTable);

Table sunTable = spice.sunPosition()->Cache("SunPosition");
sunTable.Label() += PvlKeyword("Kernels");
for (int i = 0; i < targetSpkKeyword.size(); i++)
Expand Down
7 changes: 7 additions & 0 deletions isis/src/base/objs/Isis/Isis.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ find files of those names at the top level of this repository. **/

#include <QCoreApplication>

#include <spiceql.h>

#include "Application.h"

#ifndef APPLICATION
Expand Down Expand Up @@ -97,7 +99,12 @@ int main(int argc, char *argv[]) {
}

Isis::Application::p_applicationForceGuiApp = false;
if (getenv("ISISDATA") != NULL && QString(getenv("ISISDATA")) != "") {
SpiceQL::Inventory::setDbFilePath(std::string(getenv("ISISDATA")) + "/base/", true);
}


SpiceQL::addAliasKey("Mars_Reconnaissance_Orbiter", "MRO");
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to add more into SpiceQL

#ifdef USE_GUI_QAPP
Isis::Application::p_applicationForceGuiApp = true;
#endif
Expand Down
Loading
Loading