Skip to content
Snippets Groups Projects
Commit 08b12027 authored by kelvinrr's avatar kelvinrr
Browse files

more bug fixes

parent 1cbbed75
Branches bug_squashing
No related tags found
No related merge requests found
{ {
"lro" : { "lro" : {
"ik" : {
"kernels" : ["lro_instruments_v[0-9]{2}.ti$"]
},
"iak" : { "iak" : {
"kernels" : ["lro_instrumentAddendum_v[0-9]{2}.ti$"] "kernels" : ["lro_instrumentAddendum_v[0-9]{2}.ti$"]
}, },
...@@ -16,12 +13,12 @@ ...@@ -16,12 +13,12 @@
"moc" : { "moc" : {
"ck" : { "ck" : {
"reconstructed" : { "reconstructed" : {
"kernels": ["moc42r?_[0-9]{7}_[0-9]{7}_v[0-9]{2}.bc$"] "kernels": ["moc42r_[0-9]{7}_[0-9]{7}_v[0-9]{2}.bc$"]
} }
}, },
"spk" : { "spk" : {
"reconstructed" : { "reconstructed" : {
"kernels" : ["fdf29r?_[0-9]{7}_[0-9]{7}_[nbv][0-9]{2}.bsp$"] "kernels" : ["fdf29r_[0-9]{7}_[0-9]{7}_[nbv][0-9]{2}.bsp$"]
}, },
"smithed" : { "smithed" : {
"kernels" : ["LRO_.*_GRGM660.*.bsp$", "LRO_.*_GRGM900C.*.BSP$"] "kernels" : ["LRO_.*_GRGM660.*.bsp$", "LRO_.*_GRGM900C.*.BSP$"]
...@@ -39,7 +36,7 @@ ...@@ -39,7 +36,7 @@
} }
}, },
"tspk" : { "tspk" : {
"kernels" : ["de421.bsp$", "moon_pa_de421_1900-2050.bpc$"] "kernels" : ["^de421.bsp$", "moon_pa_de421_1900-2050.bpc$"]
}, },
"ik" : { "ik" : {
"kernels" : ["lro_lroc_v[0-9]{2}.ti$"] "kernels" : ["lro_lroc_v[0-9]{2}.ti$"]
......
...@@ -42,7 +42,9 @@ namespace SpiceQL { ...@@ -42,7 +42,9 @@ namespace SpiceQL {
string DB_START_TIME_KEY = "starttime"; string DB_START_TIME_KEY = "starttime";
string DB_STOP_TIME_KEY = "stoptime"; string DB_STOP_TIME_KEY = "stoptime";
string DB_TIME_FILES_KEY = "path_index"; string DB_TIME_FILES_KEY = "path_index";
string DB_SS_TIME_INDICES_KEY = "ss_index"; string DB_START_TIME_INDICES_KEY = "start_kindex";
string DB_STOP_TIME_INDICES_KEY = "stop_kindex";
string getCacheDir() { string getCacheDir() {
static std::string CACHE_DIRECTORY = ""; static std::string CACHE_DIRECTORY = "";
...@@ -141,15 +143,19 @@ namespace SpiceQL { ...@@ -141,15 +143,19 @@ namespace SpiceQL {
json json_kernels = getLatestKernels(config.get()); json json_kernels = getLatestKernels(config.get());
// load time kernels for creating the timed kernel DataBase // load time kernels for creating the timed kernel DataBase
json sclk_json = getLatestKernels(config.getRecursive("sclk")); json lsk_json = getLatestKernels(config["base"].getRecursive("lsk"));
json lsk_json = getLatestKernels(config.getRecursive("lsk"));
SPDLOG_TRACE("InventoryImpl LSKs: {}", lsk_json.dump(4));
m_required_kernels.load(sclk_json);
m_required_kernels.load(lsk_json); m_required_kernels.load(lsk_json);
for (auto &[mission, kernels] : json_kernels.items()) { for (auto &[mission, kernels] : json_kernels.items()) {
fmt::print("mission: {}\n", mission); fmt::print("mission: {}\n", mission);
json sclk_json = getLatestKernels(config[mission].getRecursive("sclk"));
SPDLOG_TRACE("{} SCLKs: {}", mission, sclk_json.dump(4));
KernelSet sclks_ks(sclk_json);
for(auto &[kernel_type, kernel_obj] : kernels.items()) { for(auto &[kernel_type, kernel_obj] : kernels.items()) {
if (kernel_type == "ck" || kernel_type == "spk") { if (kernel_type == "ck" || kernel_type == "spk") {
// we need to log the times // we need to log the times
...@@ -272,15 +278,18 @@ namespace SpiceQL { ...@@ -272,15 +278,18 @@ namespace SpiceQL {
vector<double> start_times_v = getKey<vector<double>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_START_TIME_KEY); vector<double> start_times_v = getKey<vector<double>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_START_TIME_KEY);
vector<double> stop_times_v = getKey<vector<double>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_STOP_TIME_KEY); vector<double> stop_times_v = getKey<vector<double>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_STOP_TIME_KEY);
vector<size_t> file_index_v = getKey<vector<size_t>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_SS_TIME_INDICES_KEY); vector<size_t> start_file_index_v = getKey<vector<size_t>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_START_TIME_INDICES_KEY);
vector<size_t> stop_file_index_v = getKey<vector<size_t>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_STOP_TIME_INDICES_KEY);
vector<string> file_paths_v = getKey<vector<string>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_TIME_FILES_KEY); vector<string> file_paths_v = getKey<vector<string>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_TIME_FILES_KEY);
time_indices->file_paths = file_paths_v; time_indices->file_paths = file_paths_v;
SPDLOG_TRACE("Index, start time, stop time sizes: {}, {}, {}", file_index_v.size(), start_times_v.size(), stop_times_v.size()); SPDLOG_TRACE("Index, start time, stop time sizes: {}, {}, {}", start_file_index_v.size(), start_times_v.size(), stop_times_v.size());
// load start_times // load start_times
for(size_t i = 0; i < start_times_v.size(); i++) { for(size_t i = 0; i < start_times_v.size(); i++) {
time_indices->start_times[start_times_v[i]] = file_index_v[i]; time_indices->start_times[start_times_v[i]] = start_file_index_v[i];
time_indices->stop_times[stop_times_v[i]] = file_index_v[i]; }
for(size_t i = 0; i < stop_times_v.size(); i++) {
time_indices->stop_times[stop_times_v[i]] = stop_file_index_v[i];
} }
} }
catch (runtime_error &e) { catch (runtime_error &e) {
...@@ -313,6 +322,7 @@ namespace SpiceQL { ...@@ -313,6 +322,7 @@ namespace SpiceQL {
} }
for(auto it = time_indices->start_times.begin() ;it != start_upper_bound; it++) { for(auto it = time_indices->start_times.begin() ;it != start_upper_bound; it++) {
iterations++; iterations++;
SPDLOG_TRACE("Inserting {} with the start time {}", time_indices->file_paths.at(it->second), it->first);
start_time_kernels.insert(it->second); start_time_kernels.insert(it->second);
} }
...@@ -320,15 +330,15 @@ namespace SpiceQL { ...@@ -320,15 +330,15 @@ namespace SpiceQL {
// Get everything stopping after the start_time; // Get everything stopping after the start_time;
auto stop_lower_bound = time_indices->stop_times.lower_bound(start_time); auto stop_lower_bound = time_indices->stop_times.lower_bound(start_time);
SPDLOG_TRACE("IS {} in the array? {}", stop_lower_bound->second, start_time_kernels.contains(stop_lower_bound->second));
if(time_indices->stop_times.end() == stop_lower_bound && stop_lower_bound->first >= stop_time && start_time_kernels.contains(stop_lower_bound->second)) { if(time_indices->stop_times.end() == stop_lower_bound && stop_lower_bound->first >= stop_time && start_time_kernels.contains(stop_lower_bound->second)) {
SPDLOG_TRACE("Is {} in the array? {}", stop_lower_bound->second, start_time_kernels.contains(stop_lower_bound->second));
final_time_kernels.push_back(time_indices->file_paths.at(stop_lower_bound->second)); final_time_kernels.push_back(time_indices->file_paths.at(stop_lower_bound->second));
} }
else { else {
for(auto &it = stop_lower_bound;it != time_indices->stop_times.end(); it++) { for(auto it = stop_lower_bound;it != time_indices->stop_times.end(); it++) {
// if it's also in the start_time set, add it to the list // if it's also in the start_time set, add it to the list
iterations++; iterations++;
SPDLOG_TRACE("IS {} in the array? {}", it->second, start_time_kernels.contains(it->second)); SPDLOG_TRACE("Is {} with stop time {} in the array? {}", time_indices->file_paths.at(it->second), it->first, start_time_kernels.contains(it->second));
if (start_time_kernels.contains(it->second)) { if (start_time_kernels.contains(it->second)) {
final_time_kernels.push_back(data_dir / time_indices->file_paths.at(it->second)); final_time_kernels.push_back(data_dir / time_indices->file_paths.at(it->second));
} }
...@@ -394,21 +404,26 @@ namespace SpiceQL { ...@@ -394,21 +404,26 @@ namespace SpiceQL {
start_times_v.reserve(kernels->start_times.size()); start_times_v.reserve(kernels->start_times.size());
vector<double> stop_times_v; vector<double> stop_times_v;
stop_times_v.reserve(kernels->stop_times.size()); stop_times_v.reserve(kernels->stop_times.size());
vector<size_t> indices_v; vector<size_t> start_indices_v;
indices_v.reserve(kernels->start_times.size()); start_indices_v.reserve(kernels->start_times.size());
vector<size_t> stop_indices_v;
stop_indices_v.reserve(kernels->stop_times.size());
for (const auto &[k, v] : kernels->start_times) { for (const auto &[k, v] : kernels->start_times) {
start_times_v.push_back(k); start_times_v.push_back(k);
indices_v.push_back(v); start_indices_v.push_back(v);
} }
for (const auto &[k, v] : kernels->stop_times) { for (const auto &[k, v] : kernels->stop_times) {
stop_times_v.push_back(k); stop_times_v.push_back(k);
stop_indices_v.push_back(v);
} }
H5Easy::dump(file, DB_SPICE_ROOT_KEY + "/"+kernel_key+"/"+DB_START_TIME_KEY, start_times_v, H5Easy::DumpMode::Overwrite); H5Easy::dump(file, DB_SPICE_ROOT_KEY + "/"+kernel_key+"/"+DB_START_TIME_KEY, start_times_v, H5Easy::DumpMode::Overwrite);
H5Easy::dump(file, DB_SPICE_ROOT_KEY + "/"+kernel_key+"/"+DB_STOP_TIME_KEY, stop_times_v, H5Easy::DumpMode::Overwrite); H5Easy::dump(file, DB_SPICE_ROOT_KEY + "/"+kernel_key+"/"+DB_STOP_TIME_KEY, stop_times_v, H5Easy::DumpMode::Overwrite);
H5Easy::dump(file, DB_SPICE_ROOT_KEY + "/"+kernel_key+"/"+DB_SS_TIME_INDICES_KEY, indices_v, H5Easy::DumpMode::Overwrite); H5Easy::dump(file, DB_SPICE_ROOT_KEY + "/"+kernel_key+"/"+DB_START_TIME_INDICES_KEY, start_indices_v, H5Easy::DumpMode::Overwrite);
H5Easy::dump(file, DB_SPICE_ROOT_KEY + "/"+kernel_key+"/"+DB_STOP_TIME_INDICES_KEY, stop_indices_v, H5Easy::DumpMode::Overwrite);
} }
} }
......
...@@ -230,6 +230,13 @@ namespace SpiceQL { ...@@ -230,6 +230,13 @@ namespace SpiceQL {
} }
if (pointers.empty() && kernels.is_object()) { if (pointers.empty() && kernels.is_object()) {
// Assume it's in the format {"sclk" : ["path1", "path2"], "ck" : ["path1"], ...} // Assume it's in the format {"sclk" : ["path1", "path2"], "ck" : ["path1"], ...}
json iaks = {};
// we want to furnish them last
if(kernels.contains("iak")) {
iaks = kernels["iak"];
kernels.erase("iak");
}
for (auto& [key, val] : kernels.items()) { for (auto& [key, val] : kernels.items()) {
SPDLOG_TRACE("Getting Kernels of Type: {}", key); SPDLOG_TRACE("Getting Kernels of Type: {}", key);
if(!val.empty()) { if(!val.empty()) {
...@@ -240,6 +247,16 @@ namespace SpiceQL { ...@@ -240,6 +247,16 @@ namespace SpiceQL {
} }
} }
} }
// add iaks at the end
if(!iaks.empty()) {
vector<string> ks = jsonArrayToVector(iaks);
for (auto &kernel : ks) {
SPDLOG_TRACE("Adding: {}", kernel);
kernelVect.push_back(kernel);
}
}
} }
else { else {
for (auto & p : pointers) { for (auto & p : pointers) {
......
...@@ -176,6 +176,8 @@ namespace SpiceQL { ...@@ -176,6 +176,8 @@ namespace SpiceQL {
vector<double> getTargetState(double et, string target, string observer, string frame, string abcorr) { vector<double> getTargetState(double et, string target, string observer, string frame, string abcorr) {
SPDLOG_TRACE("getTargetState(et={}, target={}, observer={}, frame={}, abcorr={})", et, target, observer, frame, abcorr);
// convert params to spice types // convert params to spice types
ConstSpiceChar *target_spice = target.c_str(); // better way to do this? ConstSpiceChar *target_spice = target.c_str(); // better way to do this?
ConstSpiceChar *observer_spice = observer.c_str(); ConstSpiceChar *observer_spice = observer.c_str();
...@@ -185,7 +187,6 @@ namespace SpiceQL { ...@@ -185,7 +187,6 @@ namespace SpiceQL {
// define outputs // define outputs
SpiceDouble lt; SpiceDouble lt;
SpiceDouble starg_spice[6]; SpiceDouble starg_spice[6];
checkNaifErrors(); checkNaifErrors();
spkezr_c( target_spice, et, frame_spice, abcorr_spice, observer_spice, starg_spice, &lt ); spkezr_c( target_spice, et, frame_spice, abcorr_spice, observer_spice, starg_spice, &lt );
checkNaifErrors(); checkNaifErrors();
...@@ -208,26 +209,19 @@ namespace SpiceQL { ...@@ -208,26 +209,19 @@ namespace SpiceQL {
} }
json ephemKernels = {}; json ephemKernels = {};
json lskKernels = {}; json baseKernels = {};
json pckKernels = {};
json spkKernels = {};
if (searchKernels) { if (searchKernels) {
ephemKernels = Inventory::search_for_kernelset(mission, {"sclk", "ck", "spk", "pck", "tspk"}, ets.front(), ets.back(), ckQuality, spkQuality); ephemKernels = Inventory::search_for_kernelset(mission, {"sclk", "ck", "spk", "pck", "tspk", "fk"}, ets.front(), ets.back(), ckQuality, spkQuality);
lskKernels = Inventory::search_for_kernelset("base", {"lsk"}); baseKernels = Inventory::search_for_kernelset("base", {"lsk", "pck", "spk"});
pckKernels = Inventory::search_for_kernelset("base", {"pck"}); SPDLOG_DEBUG("Base Kernels : {}", baseKernels.dump(4));
spkKernels = Inventory::search_for_kernelset("base", {"spk"}, ets.front(), ets.back(), "noquality", "noquality");
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(); auto start = high_resolution_clock::now();
KernelSet baseSet(baseKernels);
KernelSet ephemSet(ephemKernels); KernelSet ephemSet(ephemKernels);
KernelSet lskSet(lskKernels);
KernelSet pckSet(pckKernels);
KernelSet spkSet(spkKernels);
auto stop = high_resolution_clock::now(); auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start); auto duration = duration_cast<microseconds>(stop - start);
SPDLOG_INFO("Time in microseconds to furnish kernel sets: {}", duration.count()); SPDLOG_INFO("Time in microseconds to furnish kernel sets: {}", duration.count());
...@@ -1102,7 +1096,7 @@ namespace SpiceQL { ...@@ -1102,7 +1096,7 @@ namespace SpiceQL {
ssize_c(200000, &cover); ssize_c(200000, &cover);
// A SPICE SEGMENT is composed of SPICE INTERVALS // A SPICE SEGMENT is composed of SPICE INTERVALS
ckcov_c(kpath.c_str(), body, SPICEFALSE, "SEGMENT", 0.0, "TDB", &cover); ckcov_c(kpath.c_str(), body, SPICEFALSE, "INTERVAL", 0.0, "TDB", &cover);
getStartStopFromInterval(cover); getStartStopFromInterval(cover);
} }
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include <vector> #include <vector>
%} %}
%template(DoublePair) std::pair<double, double>;
%typemap(in) nlohmann::json { %typemap(in) nlohmann::json {
if (PyDict_Check($input) || PyList_Check($input)) { if (PyDict_Check($input) || PyList_Check($input)) {
PyObject* module = PyImport_ImportModule("json"); PyObject* module = PyImport_ImportModule("json");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment