Loading SpiceQL/include/spice_types.h +14 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,20 @@ namespace SpiceQL { */ double doubleSclkToEt(int frameCode, double sclk, std::string mission, bool searchKernels=true); /** * @brief Converts a given double ephemeris time to an sclk string * * * @param frameCode int Frame id to use * @param et ephemeris time * @param mission string Mission name as it relates to the config files * @param searchKernels bool Whether to search the kernels for the user * @return string */ std::string doubleEtToSclk(int frameCode, double et, std::string mission, bool searchKernels); /** * @brief Get the center, class id, and class of a given frame * Loading SpiceQL/include/utils.h +1 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,7 @@ namespace SpiceQL { **/ std::vector<std::vector<int>> frameTrace(double et, int initialFrame, std::string mission="", std::string ckQuality="reconstructed", bool searchKernels=true); /** * @brief finds key:values in kernel pool * Loading SpiceQL/src/spice_types.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,26 @@ namespace SpiceQL { return et; } string doubleEtToSclk(int frameCode, double et, string mission, bool searchKernels) { Config missionConf; json sclks; if (searchKernels) { sclks = loadSelectKernels("sclk", mission); } KernelSet sclkSet(sclks); SpiceChar sclk[100]; checkNaifErrors(); sce2s_c(frameCode, et, 100, sclk); checkNaifErrors(); SPDLOG_DEBUG("strsclktoet({}, {}, {}) -> {}", frameCode, mission, sclk, et); return string(sclk); } json findMissionKeywords(string key, string mission, bool searchKernels) { json translationKernels = {}; Loading SpiceQL/src/utils.cpp +7 −11 Original line number Diff line number Diff line Loading @@ -399,33 +399,30 @@ namespace SpiceQL { // First try getting the entire state matrix (6x6), which includes CJ and the angular velocity checkNaifErrors(); frmchg_((int *) &refFrame, (int *) &toFrame, &et, (doublereal *) stateCJ); checkNaifErrors(); SpiceBoolean ckfailure = failed_c(); reset_c(); // Reset Naif error system to allow caller to recover if (!failed_c()) { if (!ckfailure) { // Transpose and isolate CJ and av checkNaifErrors(); xpose6_c(stateCJ, stateCJ); xf2rav_c(stateCJ, CJ_spice, av_spice); checkNaifErrors(); // Convert to std::array for output for(int i = 0; i < 3; i++) { orientation.push_back(av_spice[i]); } } else { // TODO This case is untested // Recompute CJ_spice ignoring av checkNaifErrors(); reset_c(); // reset frmchg_ failure refchg_((int *) &refFrame, (int *) &toFrame, &et, (doublereal *) CJ_spice); xpose_c(CJ_spice, CJ_spice); checkNaifErrors(); has_av = false; } checkNaifErrors(); // Translate matrix to std:array quaternion m2q_c(CJ_spice, quat_spice); Loading Loading @@ -610,8 +607,8 @@ namespace SpiceQL { json findKeywords(string keytpl) { // Define gnpool i/o const SpiceInt START = 0; const SpiceInt ROOM = 50; const SpiceInt LENOUT = 100; const SpiceInt ROOM = 200; const SpiceInt LENOUT = 200; ConstSpiceChar *cstr = keytpl.c_str(); SpiceInt nkeys; SpiceChar kvals [ROOM][LENOUT]; Loading Loading @@ -664,7 +661,6 @@ namespace SpiceQL { if (!gdfound) { gipool_c(fkey, START, ROOM, &nvals, ivals, &gifound); checkNaifErrors(); } if (gifound) { Loading fastapi/app/main.py +29 −5 Original line number Diff line number Diff line Loading @@ -6,7 +6,11 @@ from fastapi import FastAPI, Query from pydantic import BaseModel, Field from starlette.responses import RedirectResponse import numpy as np import os import pyspiceql import logging logger = logging.getLogger('uvicorn.error') SEARCH_KERNELS_BOOL = True Loading @@ -32,11 +36,16 @@ app = FastAPI() async def root(): return RedirectResponse(url="/docs") @app.post("/customMessage") async def message( message_item: MessageItem ): return {"message": message_item.message} @app.get("/healthCheck") async def message(): try: data_dir_exists = os.path.exists(pyspiceql.getDataDirectory()) return {"data_content": os.listdir(pyspiceql.getDataDirectory()), "data_dir_exists": data_dir_exists, "is_healthy": data_dir_exists} except Exception as e: logger.error(f"ERROR: {e}") return {"is_healthy": False} # SpiceQL endpoints Loading Loading @@ -125,6 +134,21 @@ async def doubleSclkToEt( body = ErrorModel(error=str(e)) return ResponseModel(statusCode=500, body=body) @app.get("/doubleEtToSclk") async def strSclkToEt( frameCode: int, et: float, mission: str): try: result = pyspiceql.doubleEtToSclk(frameCode, et, mission, SEARCH_KERNELS_BOOL) body = ResultModel(result=result) return ResponseModel(statusCode=200, body=body) except Exception as e: body = ErrorModel(error=str(e)) return ResponseModel(statusCode=500, body=body) @app.get("/utcToEt") async def utcToEt( utc: str): Loading Loading
SpiceQL/include/spice_types.h +14 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,20 @@ namespace SpiceQL { */ double doubleSclkToEt(int frameCode, double sclk, std::string mission, bool searchKernels=true); /** * @brief Converts a given double ephemeris time to an sclk string * * * @param frameCode int Frame id to use * @param et ephemeris time * @param mission string Mission name as it relates to the config files * @param searchKernels bool Whether to search the kernels for the user * @return string */ std::string doubleEtToSclk(int frameCode, double et, std::string mission, bool searchKernels); /** * @brief Get the center, class id, and class of a given frame * Loading
SpiceQL/include/utils.h +1 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,7 @@ namespace SpiceQL { **/ std::vector<std::vector<int>> frameTrace(double et, int initialFrame, std::string mission="", std::string ckQuality="reconstructed", bool searchKernels=true); /** * @brief finds key:values in kernel pool * Loading
SpiceQL/src/spice_types.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,26 @@ namespace SpiceQL { return et; } string doubleEtToSclk(int frameCode, double et, string mission, bool searchKernels) { Config missionConf; json sclks; if (searchKernels) { sclks = loadSelectKernels("sclk", mission); } KernelSet sclkSet(sclks); SpiceChar sclk[100]; checkNaifErrors(); sce2s_c(frameCode, et, 100, sclk); checkNaifErrors(); SPDLOG_DEBUG("strsclktoet({}, {}, {}) -> {}", frameCode, mission, sclk, et); return string(sclk); } json findMissionKeywords(string key, string mission, bool searchKernels) { json translationKernels = {}; Loading
SpiceQL/src/utils.cpp +7 −11 Original line number Diff line number Diff line Loading @@ -399,33 +399,30 @@ namespace SpiceQL { // First try getting the entire state matrix (6x6), which includes CJ and the angular velocity checkNaifErrors(); frmchg_((int *) &refFrame, (int *) &toFrame, &et, (doublereal *) stateCJ); checkNaifErrors(); SpiceBoolean ckfailure = failed_c(); reset_c(); // Reset Naif error system to allow caller to recover if (!failed_c()) { if (!ckfailure) { // Transpose and isolate CJ and av checkNaifErrors(); xpose6_c(stateCJ, stateCJ); xf2rav_c(stateCJ, CJ_spice, av_spice); checkNaifErrors(); // Convert to std::array for output for(int i = 0; i < 3; i++) { orientation.push_back(av_spice[i]); } } else { // TODO This case is untested // Recompute CJ_spice ignoring av checkNaifErrors(); reset_c(); // reset frmchg_ failure refchg_((int *) &refFrame, (int *) &toFrame, &et, (doublereal *) CJ_spice); xpose_c(CJ_spice, CJ_spice); checkNaifErrors(); has_av = false; } checkNaifErrors(); // Translate matrix to std:array quaternion m2q_c(CJ_spice, quat_spice); Loading Loading @@ -610,8 +607,8 @@ namespace SpiceQL { json findKeywords(string keytpl) { // Define gnpool i/o const SpiceInt START = 0; const SpiceInt ROOM = 50; const SpiceInt LENOUT = 100; const SpiceInt ROOM = 200; const SpiceInt LENOUT = 200; ConstSpiceChar *cstr = keytpl.c_str(); SpiceInt nkeys; SpiceChar kvals [ROOM][LENOUT]; Loading Loading @@ -664,7 +661,6 @@ namespace SpiceQL { if (!gdfound) { gipool_c(fkey, START, ROOM, &nvals, ivals, &gifound); checkNaifErrors(); } if (gifound) { Loading
fastapi/app/main.py +29 −5 Original line number Diff line number Diff line Loading @@ -6,7 +6,11 @@ from fastapi import FastAPI, Query from pydantic import BaseModel, Field from starlette.responses import RedirectResponse import numpy as np import os import pyspiceql import logging logger = logging.getLogger('uvicorn.error') SEARCH_KERNELS_BOOL = True Loading @@ -32,11 +36,16 @@ app = FastAPI() async def root(): return RedirectResponse(url="/docs") @app.post("/customMessage") async def message( message_item: MessageItem ): return {"message": message_item.message} @app.get("/healthCheck") async def message(): try: data_dir_exists = os.path.exists(pyspiceql.getDataDirectory()) return {"data_content": os.listdir(pyspiceql.getDataDirectory()), "data_dir_exists": data_dir_exists, "is_healthy": data_dir_exists} except Exception as e: logger.error(f"ERROR: {e}") return {"is_healthy": False} # SpiceQL endpoints Loading Loading @@ -125,6 +134,21 @@ async def doubleSclkToEt( body = ErrorModel(error=str(e)) return ResponseModel(statusCode=500, body=body) @app.get("/doubleEtToSclk") async def strSclkToEt( frameCode: int, et: float, mission: str): try: result = pyspiceql.doubleEtToSclk(frameCode, et, mission, SEARCH_KERNELS_BOOL) body = ResultModel(result=result) return ResponseModel(statusCode=200, body=body) except Exception as e: body = ErrorModel(error=str(e)) return ResponseModel(statusCode=500, body=body) @app.get("/utcToEt") async def utcToEt( utc: str): Loading