Skip to content

Commit

Permalink
Bugfixes (#39)
Browse files Browse the repository at this point in the history
* some fixes

* Update spk search for getTargetStates

* Update more noquality

* Update schema json
  • Loading branch information
chkim-usgs authored Oct 24, 2024
1 parent b9d6c38 commit a793fdb
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 19 deletions.
4 changes: 3 additions & 1 deletion SpiceQL/db/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"kernels" : ["naif[0-9]{4}.tls"]
},
"spk" : {
"kernels" : ["^de[0-9]{3}.bsp$", "^mar[0-9]{3}.bsp$", "^nep[0-9]{3}.bsp$", "^sat[0-9]{3}.bsp$", "^ura[0-9]{3}.bsp$"]
"noquality" : {
"kernels" : ["^de[0-9]{3}.bsp$", "^mar[0-9]{3}.bsp$", "^nep[0-9]{3}.bsp$", "^sat[0-9]{3}.bsp$", "^ura[0-9]{3}.bsp$"]
}
},
"pck" : {
"kernels" : ["pck0000[0-9].tpc"]
Expand Down
2 changes: 1 addition & 1 deletion SpiceQL/db/galileo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"smithed" : {
"kernels" : "pck00010_msgr_v[0-9]{2}.tpc"
},
"na" : {
"noquality" : {
"kernels" : "pck0000[0-9].tpc"
}
}
Expand Down
2 changes: 1 addition & 1 deletion SpiceQL/db/juno.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"kernels" : "junoAddendum[0-9]{3}.ti$"
},
"pck" : {
"na": {
"noquality": {
"kernels" : "pck000[0-9]{2}.tpc$"
}
},
Expand Down
2 changes: 1 addition & 1 deletion SpiceQL/db/mess.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"kernels" : "mdisAddendum[0-9]{3}.ti"
},
"pck" : {
"na" : {
"noquality" : {
"kernels" : "pck00010_msgr_v[0-9]{2}.tpc"
}
},
Expand Down
2 changes: 1 addition & 1 deletion SpiceQL/db/schema/spiceMissionSchmea.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"quality_kernels": {
"type": "object",
"patternProperties": {
"^(reconstructed|na|deps|smithed|predicted)$": {
"^(reconstructed|noquality|deps|smithed|predicted)$": {
"required": [
"kernels"
],
Expand Down
4 changes: 2 additions & 2 deletions SpiceQL/include/spice_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ namespace SpiceQL {
* @brief Enumeration representing the different possible kernel qualities
**/
enum class Quality {
NOQUALITY=0, // Either Quaility doesn't apply (e.g. text kernels) -or-
// we dont care about quality (e.g. CK of any quality)
NADIR = 1, // Assumes Nadir pointing
PREDICTED = 2, // Based on predicted future location of the spacecraft/body
RECONSTRUCTED = 3, // Supplemented by real spacecraft/body data
SMITHED = 4, // Controlled Kernels
NA = SMITHED // Either Quaility doesn't apply (e.g. text kernels) -or-
// we dont care about quality (e.g. CK of any quality)
};

/**
Expand Down
6 changes: 1 addition & 5 deletions SpiceQL/src/inventoryimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ namespace SpiceQL {
for (auto &[mission, kernels] : json_kernels.items()) {
fmt::print("mission: {}\n", mission);

if (mission == "Base") {
continue;
}

for(auto &[kernel_type, kernel_obj] : kernels.items()) {
if (kernel_type == "ck" || kernel_type == "spk") {
// we need to log the times
Expand Down Expand Up @@ -255,7 +251,7 @@ namespace SpiceQL {
}

// iterate down the qualities
for(int i = (int)quality; i > 0 && !found; i--) {
for(int i = (int)quality; i >= 0 && !found; i--) {
string key = instrument+"/"+Kernel::translateType(type)+"/"+Kernel::QUALITIES.at(i)+"/"+"kernels";
SPDLOG_DEBUG("Key: {}", key);
quality = (Kernel::Quality)i;
Expand Down
2 changes: 1 addition & 1 deletion SpiceQL/src/spice_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace SpiceQL {
"iak", "ik", "fk",
"dsk", "pck", "ek"};

const std::vector<std::string> Kernel::QUALITIES = { "na",
const std::vector<std::string> Kernel::QUALITIES = { "noquality",
"predicted",
"nadir",
"reconstructed",
Expand Down
22 changes: 18 additions & 4 deletions SpiceQL/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,25 @@ namespace SpiceQL {

json ephemKernels = {};
json lskKernels = {};
json pckKernels = {};
json spkKernels = {};

if (searchKernels) {
ephemKernels = Inventory::search_for_kernelset(mission, {"sclk", "ck", "spk", "pck", "tspk"}, ets.front(), ets.back(), ckQuality, spkQuality);
lskKernels = Inventory::search_for_kernelset("base", {"lsk"});
pckKernels = Inventory::search_for_kernelset("base", {"pck"});
spkKernels = Inventory::search_for_kernelset("base", {"spk"});
SPDLOG_DEBUG("LSK Kernels : {}", lskKernels.dump(4));
SPDLOG_DEBUG("{} Kernels : {}", mission, ephemKernels.dump(4));
SPDLOG_DEBUG("{} Kernels : {}", mission, ephemKernels.dump(4));
SPDLOG_DEBUG("PCK Kernels : {}", pckKernels.dump(4));
SPDLOG_DEBUG("SPK Kernels : {}", spkKernels.dump(4));
}

auto start = high_resolution_clock::now();
KernelSet ephemSet(ephemKernels);
KernelSet lskSet(lskKernels);
KernelSet pckSet(pckKernels);
KernelSet spkSet(spkKernels);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
SPDLOG_INFO("Time in microseconds to furnish kernel sets: {}", duration.count());
Expand Down Expand Up @@ -250,7 +258,7 @@ namespace SpiceQL {


if (searchKernels) {
ephemKernels = Inventory::search_for_kernelset(mission, {"ck", "sclk"}, observStart, observEnd, ckQuality, "na");
ephemKernels = Inventory::search_for_kernelset(mission, {"ck", "sclk"}, observStart, observEnd, ckQuality, "noquality");
lskKernels = Inventory::search_for_kernelset("base", {"lsk"});
}

Expand Down Expand Up @@ -455,15 +463,18 @@ namespace SpiceQL {

json ephemKernels = {};
json lskKernels = {};
json pckKernels = {};

if (searchKernels) {
ephemKernels = Inventory::search_for_kernelset(mission, {"sclk", "ck", "pck", "fk", "tspk"}, ets.front(), ets.back(), ckQuality, "na");
ephemKernels = Inventory::search_for_kernelset(mission, {"sclk", "ck", "pck", "fk", "tspk"}, ets.front(), ets.back(), ckQuality, "noquality");
lskKernels = Inventory::search_for_kernelset("base", {"lsk"});
pckKernels = Inventory::search_for_kernelset("base", {"pck"});
}

auto start = high_resolution_clock::now();
KernelSet ephemSet(ephemKernels);
KernelSet lskSet(lskKernels);
KernelSet pckSet(pckKernels);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
SPDLOG_INFO("Time in microseconds to furnish kernel sets: {}", duration.count());
Expand All @@ -489,14 +500,17 @@ namespace SpiceQL {
// json missionJson;
json ephemKernels;
json lskKernels;
json pckKernels;

if (searchKernels) {
ephemKernels = Inventory::search_for_kernelset(mission, {"sclk", "ck", "pck", "fk", "tspk"}, et, et, ckQuality, "na");
ephemKernels = Inventory::search_for_kernelset(mission, {"sclk", "ck", "pck", "fk", "tspk"}, et, et, ckQuality, "noquality");
lskKernels = Inventory::search_for_kernelset("base", {"lsk"});
pckKernels = Inventory::search_for_kernelset("base", {"pck"});
}

KernelSet ephemSet(ephemKernels);
KernelSet lskSet(lskKernels);
KernelSet pckSet(pckKernels);

checkNaifErrors();
// The code for this method was extracted from the Naif routine rotget written by N.J. Bachman &
Expand Down
4 changes: 2 additions & 2 deletions SpiceQL/tests/QueryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ TEST_F(KernelDataDirectories, FunctionalTestListMissionKernelsAllMess) {
EXPECT_EQ(SpiceQL::getKernelsAsVector(res["mdis"]["fk"]["kernels"]).size(), 2);
EXPECT_EQ(SpiceQL::getKernelsAsVector(res["mdis"]["ik"]["kernels"]).size(), 2);
EXPECT_EQ(SpiceQL::getKernelsAsVector(res["mdis"]["iak"]["kernels"]).size(), 2);
EXPECT_EQ(SpiceQL::getKernelsAsVector(res["mdis"]["pck"]["na"]["kernels"]).size(), 2);
EXPECT_EQ(SpiceQL::getKernelsAsVector(res["mdis"]["pck"]["noquality"]["kernels"]).size(), 2);

EXPECT_EQ(SpiceQL::getKernelsAsVector(res["mdis_att"]["ck"]["reconstructed"]["kernels"]).size(), 4);

Expand Down Expand Up @@ -172,7 +172,7 @@ TEST_F(KernelDataDirectories, FunctionalTestListMissionKernelsGalileo) {
ASSERT_EQ(SpiceQL::getKernelsAsVector(res["galileo"]["spk"]["reconstructed"]["kernels"]).size(), 2);
ASSERT_EQ(SpiceQL::getKernelsAsVector(res["galileo"]["iak"]["kernels"]).size(), 1);
ASSERT_EQ(SpiceQL::getKernelsAsVector(res["galileo"]["pck"]["smithed"]["kernels"]).size(), 2);
ASSERT_EQ(SpiceQL::getKernelsAsVector(res["galileo"]["pck"]["na"]["kernels"]).size(), 1);
ASSERT_EQ(SpiceQL::getKernelsAsVector(res["galileo"]["pck"]["noquality"]["kernels"]).size(), 1);
ASSERT_EQ(SpiceQL::getKernelsAsVector(res["galileo"]["sclk"]["kernels"]).size(), 1);
}

Expand Down

0 comments on commit a793fdb

Please sign in to comment.