Loading SpiceQL/include/inventory.h +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ namespace SpiceQL { nlohmann::json search_for_kernelset(std::string spiceql_mission, std::vector<std::string> types, double start_time=-std::numeric_limits<double>::max(), double stop_time=std::numeric_limits<double>::max(), std::string ckQuality="smithed", std::string spkQuality="smithed", bool enforce_quality=false); std::string getDbFilePath(); void create_database(); } } No newline at end of file SpiceQL/src/inventory.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ #include <nlohmann/json.hpp> #include <spdlog/spdlog.h> #include <ghc/fs_std.hpp> #include "inventory.h" #include "inventoryimpl.h" Loading @@ -27,6 +28,11 @@ namespace SpiceQL { return impl.search_for_kernelset(instrument, enum_types, start_time, stop_time, enum_ck_quality, enum_spk_quality, enforce_quality); } string getDbFilePath() { static std::string db_path = fs::path(getCacheDir()) / DB_HDF_FILE; return db_path; } void create_database() { // force generate the database InventoryImpl db(true); Loading SpiceQL/src/inventoryimpl.cpp +55 −49 Original line number Diff line number Diff line Loading @@ -106,8 +106,8 @@ namespace SpiceQL { fc::BTreePair<double, size_t> p; p.first = sstimes.first; p.second = index; if(kernel_times->start_times.contains(p.first)) { p.first-=0.0000001; while(kernel_times->start_times.contains(p.first)) { p.first-=0.001; } kernel_times->start_times.insert(p); Loading @@ -115,8 +115,8 @@ namespace SpiceQL { p2.first = sstimes.second; p2.second = index; if(kernel_times->stop_times.contains(p2.first)) { p2.first+=0.0000001; while(kernel_times->stop_times.contains(p2.first)) { p2.first+=0.001; } kernel_times->stop_times.insert(p2); Loading Loading @@ -280,14 +280,12 @@ namespace SpiceQL { vector<string> file_paths_v = getKey<vector<string>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_TIME_FILES_KEY); 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()); // load start_times 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->stop_times[stop_times_v[i]] = file_index_v[i]; } found = true; } catch (runtime_error &e) { // should probably replace with a more specific exception Loading @@ -295,8 +293,6 @@ namespace SpiceQL { continue; } } if (enforce_quality) break; // only interate once if quality is enforced } if (time_indices) { SPDLOG_TRACE("NUMBER OF KERNELS: {}", time_indices->file_paths.size()); Loading @@ -306,6 +302,7 @@ namespace SpiceQL { // no kernels found continue; } size_t iterations = 0; // init containers Loading @@ -314,6 +311,10 @@ namespace SpiceQL { // Get everything starting before the stop_time; auto start_upper_bound = time_indices->start_times.upper_bound(stop_time); if(start_upper_bound == time_indices->start_times.begin() && start_upper_bound->first <= start_time) { iterations++; start_time_kernels.insert(start_upper_bound->second); } for(auto it = time_indices->start_times.begin() ;it != start_upper_bound; it++) { iterations++; start_time_kernels.insert(it->second); Loading @@ -323,25 +324,30 @@ namespace SpiceQL { // Get everything stopping after the start_time; auto stop_lower_bound = time_indices->stop_times.lower_bound(start_time); if(time_indices->stop_times.end() == stop_lower_bound && 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)); if(time_indices->stop_times.end() == stop_lower_bound && stop_lower_bound->first >= stop_time && start_time_kernels.contains(stop_lower_bound->second)) { final_time_kernels.push_back(time_indices->file_paths.at(stop_lower_bound->second)); } else { 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 iterations++; SPDLOG_TRACE("IS {} in the array? {}", it->second, 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)); } } } if (final_time_kernels.size()) { found = true; kernels[Kernel::translateType(type)] = final_time_kernels; kernels[qkey] = Kernel::translateQuality(quality); } SPDLOG_TRACE("NUMBER OF ITERATIONS: {}", iterations); SPDLOG_TRACE("NUMBER OF KERNELS FOUND: {}", final_time_kernels.size()); if (enforce_quality) break; // only interate once if quality is enforced } } else { // text/non time based kernels SPDLOG_DEBUG("Trying to search time independant kernels"); Loading SpiceQL/tests/Fixtures.cpp +43 −3 Original line number Diff line number Diff line Loading @@ -54,9 +54,9 @@ void TempTestingFiles::SetUp() { void TempTestingFiles::TearDown() { if(!fs::remove_all(tempDir)) { throw runtime_error("Could not delete temporary files"); } // if(!fs::remove_all(tempDir)) { // throw runtime_error("Could not delete temporary files"); // } } Loading Loading @@ -171,6 +171,46 @@ void IsisDataDirectory::CompareKernelSets(vector<string> kVector, vector<string> } } void KernelsWithQualities::SetUp() { root = getenv("SPICEROOT"); fs::create_directory(root / "spk"); // we are using Mars odyssey here int bodyCode = -83000; std::string referenceFrame = "j2000"; std::vector<double> times1 = {110000000, 120000000}; std::vector<double> times2 = {130000000, 140000000}; // create predicted SPK std::vector<std::vector<double>> velocities = {{1,1,1}, {2,2,2}}; std::vector<std::vector<double>> positions = {{1, 1, 1}, {2, 2, 2}}; spkPathPredict = root / "spk" / "m01_map.bsp"; writeSpk(spkPathPredict, positions, times1, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); // create reconstructed SPK spkPathRecon = root / "spk" / "m01_ab_v2.bsp"; writeSpk(spkPathRecon, positions, times1, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); // create another reconstructed SPK with different times spkPathRecon2 = root / "spk" / "m01_map_rec.bsp"; writeSpk(spkPathRecon2, positions, times2, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); spkPathSmithed = root / "spk" / "themis_dayir_merged_2018Jul13_spk.bsp"; writeSpk(spkPathSmithed, positions, times1, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); Inventory::create_database(); } void KernelsWithQualities::TearDown() { } void LroKernelSet::SetUp() { root = getenv("SPICEROOT"); Loading SpiceQL/tests/Fixtures.h +12 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,18 @@ class LroKernelSet : public ::testing::Test { void TearDown() override; }; class KernelsWithQualities : public ::testing::Test { protected: fs::path root; string spkPathPredict; string spkPathRecon; string spkPathRecon2; string spkPathSmithed; void SetUp() override; void TearDown() override; }; class TestConfig : public KernelDataDirectories { protected: Loading Loading
SpiceQL/include/inventory.h +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ namespace SpiceQL { nlohmann::json search_for_kernelset(std::string spiceql_mission, std::vector<std::string> types, double start_time=-std::numeric_limits<double>::max(), double stop_time=std::numeric_limits<double>::max(), std::string ckQuality="smithed", std::string spkQuality="smithed", bool enforce_quality=false); std::string getDbFilePath(); void create_database(); } } No newline at end of file
SpiceQL/src/inventory.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ #include <nlohmann/json.hpp> #include <spdlog/spdlog.h> #include <ghc/fs_std.hpp> #include "inventory.h" #include "inventoryimpl.h" Loading @@ -27,6 +28,11 @@ namespace SpiceQL { return impl.search_for_kernelset(instrument, enum_types, start_time, stop_time, enum_ck_quality, enum_spk_quality, enforce_quality); } string getDbFilePath() { static std::string db_path = fs::path(getCacheDir()) / DB_HDF_FILE; return db_path; } void create_database() { // force generate the database InventoryImpl db(true); Loading
SpiceQL/src/inventoryimpl.cpp +55 −49 Original line number Diff line number Diff line Loading @@ -106,8 +106,8 @@ namespace SpiceQL { fc::BTreePair<double, size_t> p; p.first = sstimes.first; p.second = index; if(kernel_times->start_times.contains(p.first)) { p.first-=0.0000001; while(kernel_times->start_times.contains(p.first)) { p.first-=0.001; } kernel_times->start_times.insert(p); Loading @@ -115,8 +115,8 @@ namespace SpiceQL { p2.first = sstimes.second; p2.second = index; if(kernel_times->stop_times.contains(p2.first)) { p2.first+=0.0000001; while(kernel_times->stop_times.contains(p2.first)) { p2.first+=0.001; } kernel_times->stop_times.insert(p2); Loading Loading @@ -280,14 +280,12 @@ namespace SpiceQL { vector<string> file_paths_v = getKey<vector<string>>(DB_SPICE_ROOT_KEY+"/"+key+"/"+DB_TIME_FILES_KEY); 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()); // load start_times 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->stop_times[stop_times_v[i]] = file_index_v[i]; } found = true; } catch (runtime_error &e) { // should probably replace with a more specific exception Loading @@ -295,8 +293,6 @@ namespace SpiceQL { continue; } } if (enforce_quality) break; // only interate once if quality is enforced } if (time_indices) { SPDLOG_TRACE("NUMBER OF KERNELS: {}", time_indices->file_paths.size()); Loading @@ -306,6 +302,7 @@ namespace SpiceQL { // no kernels found continue; } size_t iterations = 0; // init containers Loading @@ -314,6 +311,10 @@ namespace SpiceQL { // Get everything starting before the stop_time; auto start_upper_bound = time_indices->start_times.upper_bound(stop_time); if(start_upper_bound == time_indices->start_times.begin() && start_upper_bound->first <= start_time) { iterations++; start_time_kernels.insert(start_upper_bound->second); } for(auto it = time_indices->start_times.begin() ;it != start_upper_bound; it++) { iterations++; start_time_kernels.insert(it->second); Loading @@ -323,25 +324,30 @@ namespace SpiceQL { // Get everything stopping after the start_time; auto stop_lower_bound = time_indices->stop_times.lower_bound(start_time); if(time_indices->stop_times.end() == stop_lower_bound && 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)); if(time_indices->stop_times.end() == stop_lower_bound && stop_lower_bound->first >= stop_time && start_time_kernels.contains(stop_lower_bound->second)) { final_time_kernels.push_back(time_indices->file_paths.at(stop_lower_bound->second)); } else { 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 iterations++; SPDLOG_TRACE("IS {} in the array? {}", it->second, 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)); } } } if (final_time_kernels.size()) { found = true; kernels[Kernel::translateType(type)] = final_time_kernels; kernels[qkey] = Kernel::translateQuality(quality); } SPDLOG_TRACE("NUMBER OF ITERATIONS: {}", iterations); SPDLOG_TRACE("NUMBER OF KERNELS FOUND: {}", final_time_kernels.size()); if (enforce_quality) break; // only interate once if quality is enforced } } else { // text/non time based kernels SPDLOG_DEBUG("Trying to search time independant kernels"); Loading
SpiceQL/tests/Fixtures.cpp +43 −3 Original line number Diff line number Diff line Loading @@ -54,9 +54,9 @@ void TempTestingFiles::SetUp() { void TempTestingFiles::TearDown() { if(!fs::remove_all(tempDir)) { throw runtime_error("Could not delete temporary files"); } // if(!fs::remove_all(tempDir)) { // throw runtime_error("Could not delete temporary files"); // } } Loading Loading @@ -171,6 +171,46 @@ void IsisDataDirectory::CompareKernelSets(vector<string> kVector, vector<string> } } void KernelsWithQualities::SetUp() { root = getenv("SPICEROOT"); fs::create_directory(root / "spk"); // we are using Mars odyssey here int bodyCode = -83000; std::string referenceFrame = "j2000"; std::vector<double> times1 = {110000000, 120000000}; std::vector<double> times2 = {130000000, 140000000}; // create predicted SPK std::vector<std::vector<double>> velocities = {{1,1,1}, {2,2,2}}; std::vector<std::vector<double>> positions = {{1, 1, 1}, {2, 2, 2}}; spkPathPredict = root / "spk" / "m01_map.bsp"; writeSpk(spkPathPredict, positions, times1, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); // create reconstructed SPK spkPathRecon = root / "spk" / "m01_ab_v2.bsp"; writeSpk(spkPathRecon, positions, times1, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); // create another reconstructed SPK with different times spkPathRecon2 = root / "spk" / "m01_map_rec.bsp"; writeSpk(spkPathRecon2, positions, times2, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); spkPathSmithed = root / "spk" / "themis_dayir_merged_2018Jul13_spk.bsp"; writeSpk(spkPathSmithed, positions, times1, bodyCode, 1, referenceFrame, "SPK ID 1", 1, velocities, "SPK 1"); Inventory::create_database(); } void KernelsWithQualities::TearDown() { } void LroKernelSet::SetUp() { root = getenv("SPICEROOT"); Loading
SpiceQL/tests/Fixtures.h +12 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,18 @@ class LroKernelSet : public ::testing::Test { void TearDown() override; }; class KernelsWithQualities : public ::testing::Test { protected: fs::path root; string spkPathPredict; string spkPathRecon; string spkPathRecon2; string spkPathSmithed; void SetUp() override; void TearDown() override; }; class TestConfig : public KernelDataDirectories { protected: Loading