Namespace SpiceQL
Namespaces
Type | Name |
---|---|
namespace | Inventory |
namespace | Memo |
Classes
Type | Name |
---|---|
class | CkSegment C++ object repersenting NAIF spice CK Segment and it's metadata. |
class | Config Object for interacting with SpiceQL target configs. |
class | InventoryImpl |
class | Kernel Base Kernel class. |
class | KernelSet Class for furnishing kernels in bulk. |
class | SpkSegment C++ object repersenting NAIF spice SPK Segment and it's metadata. |
class | TimeIndexedKernels |
Public Attributes
Type | Name |
---|---|
std::string | DB_HDF_FILE |
std::string | DB_SPICE_ROOT_KEY |
std::string | DB_SS_TIME_INDICES_KEY |
std::string | DB_START_TIME_KEY |
std::string | DB_STOP_TIME_KEY |
std::string | DB_TIME_FILES_KEY |
const std::vector< std::string > | KERNEL_QUALITIES |
const std::vector< std::string > | KERNEL_TYPES |
std::map< std::string, std::string > | spiceql_mission_map |
Public Functions
Type | Name |
---|---|
bool | checkNaifErrors (bool reset=true) raises a C++ exception if NAIF has an error buffered. |
std::vector< std::vector< double > > | concatStates (std::vector< std::vector< double > > statePositions, std::vector< std::vector< double > > stateVelocities) |
std::pair< std::string, nlohmann::json > | doubleEtToSclk (int frameCode, double et, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Converts a given double spacecraft clock time to an ephemeris time. |
std::pair< double, nlohmann::json > | doubleSclkToEt (int frameCode, double sclk, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Converts a given double spacecraft clock time to an ephemeris time. |
size_t | eraseAtPointer (nlohmann::json & j, nlohmann::json::json_pointer ptr) erase a part of a json object based on a json pointer |
std::pair< std::string, nlohmann::json > | etToUtc (double et, std::string format, double precision, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) convert et string to a UTC string |
std::pair< std::vector< double >, nlohmann::json > | extractExactCkTimes (double observStart, double observEnd, int targetFrame, std::string mission, std::vector< std::string > ckQualities={"smithed", "reconstructed"}, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Extracts all segment times between observStart and observeEnd. |
std::vector< nlohmann::json::json_pointer > | findKeyInJson (nlohmann::json in, std::string key, bool recursive=true) recursively search keys in json. |
nlohmann::json | findKeywords (std::string keytpl) finds key:values in kernel pool |
std::pair< nlohmann::json, nlohmann::json > | findMissionKeywords (std::string key, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) returns kernel values for a specific mission in the form of a json |
std::pair< nlohmann::json, nlohmann::json > | findTargetKeywords (std::string key, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) returns Target values in the form of a vector |
std::pair< std::vector< std::vector< int > >, nlohmann::json > | frameTrace (double et, int initialFrame, std::string mission, std::vector< std::string > ckQualities={"smithed", "reconstructed"}, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Given an ephemeris time and a starting frame, find the path from that starting frame to J2000 (1) |
std::string | gen_random (const int len) generate a random string |
std::vector< std::string > | getAvailableConfigFiles () Returns a vector of all the available configs. |
std::vector< nlohmann::json > | getAvailableConfigs () Get names of available config files as a json vector. |
std::string | getCacheDir () |
std::string | getConfigDirectory () Get the directory pointing to the db files. |
std::string | getDataDirectory () Returns std::vector<string> interpretation of a json array. |
std::pair< std::vector< int >, nlohmann::json > | getFrameInfo (int frame, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Get the center, class id, and class of a given frame. |
std::string | getHdfFile () |
std::pair< double, double > | getKernelStartStopTimes (std::string kpath) |
std::string | getKernelStringValue (std::string key) return's kernel value from key |
std::string | getKernelType (std::string kernelPath) get the Kernel type (CK, SPK, etc.) |
std::vector< std::string > | getKernelVectorValue (std::string key) return's kernel values in the form of a vector |
std::set< std::string > | getKernelsAsSet (nlohmann::json kernels) Get all the kernels in the json as a set. |
std::vector< std::string > | getKernelsAsVector (nlohmann::json kernels) Get all the kernels in the json as a vector. |
std::vector< std::string > | getLatestKernel (std::vector< std::string > kernels) get the latest kernel in a list |
nlohmann::json | getLatestKernels (nlohmann::json kernels) returns a JSON object of only the latest version of each kernel type |
nlohmann::json | getMissionConfig (std::string mission) Returns the path to the Mission specific Spice config file. |
std::string | getMissionConfigFile (std::string mission) Returns the path to the Mission specific Spice config file. |
std::string | getMissionKeys (nlohmann::json config) Returns a string of mission keys from the JSON config file. |
std::vector< std::vector< std::string > > | getPathsFromRegex (std::string root, std::vector< std::string > regexes) glob, but with json |
std::string | getRestUrl () Returns the REST URL. |
std::string | getRootDependency (nlohmann::json config, std::string pointer) Returns the root most dependency for a json pointer. |
std::pair< nlohmann::json, nlohmann::json > | getTargetFrameInfo (int targetId, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) returns frame name and frame code associated to the target ID. |
std::vector< double > | getTargetOrientation (double et, int toFrame, int refFrame=1) Gives quaternion and angular velocity for a given frame at a given ephemeris time. |
std::pair< std::vector< std::vector< double > >, nlohmann::json > | getTargetOrientations (std::vector< double > ets, int toFrame, int refFrame, std::string mission, std::vector< std::string > ckQualities={"smithed", "reconstructed"}, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Gives quaternion and angular velocity for a given frame at a set of ephemeris times. |
std::vector< double > | getTargetState (double et, std::string target, std::string observer, std::string frame="J2000", std::string abcorr="NONE") Gives the position and velocity for a given frame at some ephemeris time. |
std::pair< std::vector< std::vector< double > >, nlohmann::json > | getTargetStates (std::vector< double > ets, std::string target, std::string observer, std::string frame, std::string abcorr, std::string mission, std::vector< std::string > ckQualities={"smithed", "reconstructed"}, std::vector< std::string > spkQualities={"smithed", "reconstructed"}, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Gives the positions and velocities for a given frame given a set of ephemeris times. |
std::vector< std::pair< double, double > > | getTimeIntervals (std::string kpath) Get start and stop times a kernel. |
std::vector< std::string > | glob (std::string const & root, std::string const & reg=".*", bool recursive=false) glob, like python's glob.glob, except C++ |
std::string | globKernelStartStopTimes (std::string mission) |
nlohmann::json | globKernels (std::string root, nlohmann::json conf, std::string kernelType) acquire all kernels of a type according to a configuration JSON object |
std::string | globTimeIntervals (std::string mission) Get start and stop times for all kernels. |
std::vector< std::vector< std::string > > | json2DArrayTo2DVector (nlohmann::json arr) Returns std::vector<std::vector<string>> interpretation of a json array. |
std::vector< std::pair< double, double > > | json2DArrayToDoublePair (nlohmann::json arr) Returns std::vector<std::vector<string>> interpretation of a json array. |
std::vector< std::vector< double > > | json2DFloatArrayTo2DVector (nlohmann::json arr) Returns std::vector<std::vector<float>> interpretation of a json array. |
std::vector< std::vector< int > > | json2DIntArrayTo2DVector (nlohmann::json arr) Returns std::vector<std::vector<int>> interpretation of a json array. |
std::vector< std::string > | jsonArrayToVector (nlohmann::json arr) Returns std::vector<string> interpretation of a json array. |
std::vector< double > | jsonDoubleArrayToVector (nlohmann::json arr) Returns std::vector<double> interpretation of a json array. |
std::vector< int > | jsonIntArrayToVector (nlohmann::json arr) Returns std::vector<int> interpretation of a json array. |
nlohmann::json | listMissionKernels (std::string root, nlohmann::json conf) Returns all kernels available for a mission. |
void | load (std::string path, bool force_refurnsh=true) |
nlohmann::json | loadSelectKernels (std::string kernelType, std::string mission) Loads PCK kernels associated to mission name. |
nlohmann::json | loadTranslationKernels (std::string mission, bool loadFk=true, bool loadIk=true, bool loadIak=true) Loads translation kernels (fk, ik, and iaks) associated to mission name. |
std::vector< std::string > | ls (std::string const & root, bool recursive) ls, like in unix, kinda. Also it's a function. |
void | mergeConfigs (nlohmann::json & baseConfig, const nlohmann::json & mergingConfig) Merge two json configs. |
nlohmann::json | merge_json (nlohmann::json & j1, nlohmann::json & j2, bool overwrite=false) Merges the right json to the left json. |
std::string | replaceAll (std::string str, const std::string & from, const std::string & to) find and replace one substring with another |
void | resolveConfigDependencies (nlohmann::json & config, const nlohmann::json & dependencies) resolve the dependencies in a config in place |
nlohmann::json | spiceAPIQuery (std::string functionName, nlohmann::json args, std::string method="GET") |
std::pair< double, nlohmann::json > | strSclkToEt (int frameCode, std::string sclk, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Converts a given string spacecraft clock time to an ephemeris time. |
std::string | toLower (std::string s) force a string to lower case |
std::string | toUpper (std::string s) force a string to upper case |
std::pair< std::string, nlohmann::json > | translateCodeToName (int frame, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Switch between NAIF frame integer code to string frame name. |
std::pair< int, nlohmann::json > | translateNameToCode (std::string frame, std::string mission, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) Switch between NAIF frame string name to integer frame code. |
void | unload (std::string path) |
std::string | url_encode (const std::string & value) |
std::pair< double, nlohmann::json > | utcToEt (std::string utc, bool useWeb=false, bool searchKernels=true, std::vector< std::string > kernelList={}) convert a UTC string to an ephemeris time |
void | writeCk (std::string fileName, std::vector< std::vector< double > > quats, std::vector< double > times, int bodyCode, std::string referenceFrame, std::string segmentId, std::string sclk, std::string lsk, std::vector< std::vector< double > > angularVelocity={}, std::string comment="") Write CK segments to a file. |
void | writeCk (std::string fileName, std::string sclk, std::string lsk, std::vector< CkSegment > segments) Write CK segments to a file. |
void | writeComment (std::string fileName, std::string comment) |
void | writeSpk (std::string fileName, std::vector< SpkSegment > segments) Write SPK segments to a file. |
void | writeSpk (std::string fileName, std::vector< std::vector< double > > statePositions, std::vector< double > stateTimes, int bodyCode, int centerOfMotion, std::string referenceFrame, std::string segmentId, int polyDegree, std::vector< std::vector< double > > stateVelocities={}, std::string segmentComment="") Write SPK to path. |
void | writeTextKernel (std::string fileName, std::string type, nlohmann::json & keywords, std::string comment="") Write json key value pairs into a NAIF text kernel. |
Detailed Description
types
Public Attributes Documentation
variable DB_HDF_FILE
variable DB_SPICE_ROOT_KEY
variable DB_SS_TIME_INDICES_KEY
variable DB_START_TIME_KEY
variable DB_STOP_TIME_KEY
variable DB_TIME_FILES_KEY
variable KERNEL_QUALITIES
variable KERNEL_TYPES
variable spiceql_mission_map
Public Functions Documentation
function checkNaifErrors
raises a C++ exception if NAIF has an error buffered.
Parameters:
reset
true if NAIF status errors should be reset
function concatStates
std::vector< std::vector< double > > SpiceQL::concatStates (
std::vector< std::vector< double > > statePositions,
std::vector< std::vector< double > > stateVelocities
)
Combine the state positions and velocities into a single vector
Returns:
Single vector with {X1, Y1, Z1, dX1, dY1, dZ1, X2, Y2, Z2, dX2, dY2, dZ2, ...}
function doubleEtToSclk
Converts a given double spacecraft clock time to an ephemeris time.
std::pair< std::string, nlohmann::json > SpiceQL::doubleEtToSclk (
int frameCode,
double et,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Given a known frame code doubleSclkToEt converts a given spacecraft clock time as a double to an ephemeris time. Call this function if your clock time looks something like: 922997380.174174
Parameters:
frameCode
int Frame id to useet
double Spacecraft ephemeris time to convert to an SCLKmission
string Mission name as it relates to the config filessearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
double
function doubleSclkToEt
Converts a given double spacecraft clock time to an ephemeris time.
std::pair< double, nlohmann::json > SpiceQL::doubleSclkToEt (
int frameCode,
double sclk,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Given a known frame code doubleSclkToEt converts a given spacecraft clock time as a double to an ephemeris time. Call this function if your clock time looks something like: 922997380.174174
Parameters:
frameCode
int Frame id to usesclk
int Spacecraft Clock formatted as an intmission
string Mission name as it relates to the config filessearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
double
function eraseAtPointer
erase a part of a json object based on a json pointer
Parameters:
j
The json object ot erase part of. Modified in placeptr
The object to erase
Returns:
The number of objects removed
function etToUtc
convert et string to a UTC string
std::pair< std::string, nlohmann::json > SpiceQL::etToUtc (
double et,
std::string format,
double precision,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Basically a wrapper around NAIF's cspice et2utc_c function except it also temporarily loads the required kernels. See Also: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/et2utc_c.html
Parameters:
et
ephemeris timeprecision
number of decimalsearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
double precision ephemeris time
function extractExactCkTimes
Extracts all segment times between observStart and observeEnd.
std::pair< std::vector< double >, nlohmann::json > SpiceQL::extractExactCkTimes (
double observStart,
double observEnd,
int targetFrame,
std::string mission,
std::vector< std::string > ckQualities={"smithed", "reconstructed"},
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Givven an observation start and observation end, extract all times assocaited with segments in a CK file. The times returned are all times assocaited with concrete CK segment times with no interpolation.
Parameters:
observStart
Ephemeris time to start searching atobservEnd
Ephemeris time to stop searching attargetFrame
Target reference frame to get ephemeris data inckQualities
vector of string describing the quality of cks to try and obtainkernelList
vector<string> vector of additional kernels to load
Returns:
A list of times
function findKeyInJson
recursively search keys in json.
std::vector< nlohmann::json::json_pointer > SpiceQL::findKeyInJson (
nlohmann::json in,
std::string key,
bool recursive=true
)
Given a root and a regular expression, give all the files that match.
Parameters:
in
input json to searchkey
key to search forrecursive
recursively iterates through objects if true
Returns:
vector of refernces to matching json objects
function findKeywords
finds key:values in kernel pool
Given a key template, returns matching key:values from the kernel pool by using gnpool, gcpool, gdpool, and gipool
Parameters:
keytpl
input key template to search for
Returns:
json list of found key:values
function findMissionKeywords
returns kernel values for a specific mission in the form of a json
std::pair< nlohmann::json, nlohmann::json > SpiceQL::findMissionKeywords (
std::string key,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Takes in a kernel key and returns the value associated with the inputted mission as a json
Parameters:
key
key - Kernel to get values frommission
mission namesearchKernels
bool Whether to search the kernels for the user
Returns:
json of values
function findTargetKeywords
returns Target values in the form of a vector
std::pair< nlohmann::json, nlohmann::json > SpiceQL::findTargetKeywords (
std::string key,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Takes in a target and key and returns the value associated in the form of vector. Note: This function is mainly for obtaining target keywords. For obtaining other values, use findMissionKeywords.
Parameters:
key
keyword for desired valuesmission
mission name as it relates to the config filessearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
vector of values
function frameTrace
Given an ephemeris time and a starting frame, find the path from that starting frame to J2000 (1)
std::pair< std::vector< std::vector< int > >, nlohmann::json > SpiceQL::frameTrace (
double et,
int initialFrame,
std::string mission,
std::vector< std::string > ckQualities={"smithed", "reconstructed"},
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
This function uses NAIF routines and builds a path from the initalframe to J2000 making note of all the in between frames
Parameters:
et
ephemeris times at which you want to optain the frame traceinitialFrame
the initial frame's NAIF code.mission
Config subset as it relates to the missionckQualities
vector of strings describing the quality of cks to try and obtainsearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
A two element vector of vectors ints, where the first element is the sequence of time dependent frames and the second is the sequence of constant frames
function gen_random
generate a random string
Parameters:
len
length of the string
Returns:
new random alphanumeric string
function getAvailableConfigFiles
Returns a vector of all the available configs.
Returns the db files in either the installed or debug directory depending on whether or not SPICEQL_DEV_DB is set.
See also: getConfigDirectory
Returns:
std::vector<std::string>
function getAvailableConfigs
Get names of available config files as a json vector.
This iterates through all the configs in the db folder either installed or in the debug directory depending on whether or not SPICEQL_DEV_DB is set. Loads them as vector of json obects and returns the vector.
Returns:
std::vector<nlohmann::json>
function getCacheDir
function getConfigDirectory
Get the directory pointing to the db files.
Default behavior returns the installed DB files in $CONDA_PREFIX/etc/SpiceQL/db.
If the env var $SPICEQL_DEV_DB is set, this returns the local source path of _SOURCE_PREFIX/SpiceQL/db/
Returns:
std::string directory containing db files
function getDataDirectory
Returns std::vector<string> interpretation of a json array.
Attempts to convert the json array to a C++ array. Also handles strings in cases where one element arrays are stored as scalars. Throws exception if the json obj is not an array.
Parameters:
arr
input json arr
Returns:
string vector containing arr data
function getFrameInfo
Get the center, class id, and class of a given frame.
std::pair< std::vector< int >, nlohmann::json > SpiceQL::getFrameInfo (
int frame,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
See NAIF's Docs on frame codes for more information
Parameters:
frame
String frame name to translate to a NAIF codemission
Mission name as it relates to the config filessearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
3 element vector of the given frames center, class id, and class
function getHdfFile
function getKernelStartStopTimes
function getKernelStringValue
return's kernel value from key
Takes in a kernel key and returns the value associated with that kernel as a string Note: this function is for when the kernal has a single value associated with it, ie: INS-236800_FOV_REF_ANGLE = ( 5.27 )
Parameters:
key
key - Kernel to get values from
Returns:
string of value associated with key
function getKernelType
get the Kernel type (CK, SPK, etc.)
Parameters:
kernelPath
path to kernel
Returns:
Kernel type as a string
function getKernelVectorValue
return's kernel values in the form of a vector
Takes in a kernel key and returns the value associated with that kernel as a vector of string Note: This function is for when the kernel has more than 1 value associated with it, ie: INS-236800_FOV_REF_VECTOR = ( 1.0, 0.0, 0.0 )
Parameters:
key
key - Kernel to get values from
Returns:
vector of values in the form of a string
function getKernelsAsSet
Get all the kernels in the json as a set.
Recusively iterates all the kernel keys and flattens them in a vector.
Parameters:
kernels
json object with kernel query results
Returns:
set<string> set of kernels
function getKernelsAsVector
Get all the kernels in the json as a vector.
Recusively iterates all the kernel keys and flattens them in a vector.
Parameters:
kernels
json object with kernel query results
Returns:
vector<string> list of kernels
function getLatestKernel
get the latest kernel in a list
Returns the kernels with the latest version string (e.g. the highest v??? or similar sub-string in a kernel path name) in the input list and returns it as a path object. Given multiple different kernels, like de### and mar###, each will be evaluted on there own to return the highest version of each.
Parameters:
kernels
vector of strings, should be a list of kernel paths.
Returns:
std::vector<std::string> vector paths to latest Kernels
function getLatestKernels
returns a JSON object of only the latest version of each kernel type
Recursively iterates Kernel groups in the input JSON and gets the kernels with the latest version string (e.g. the highest v??? sub-string in a kernel path name).
New JSON is returned.
Parameters:
kernels
A Kernel JSON object
Returns:
A new Kernel JSON object with reduced kernel sets
function getMissionConfig
Returns the path to the Mission specific Spice config file.
Given a mission, search a prioritized list of directories for the json config file. This function checks in the order:
- The local build dir, i.e. $CMAKE_SOURCE_DIR
- The install dir, i.e. $CMAKE_PREFIX
Parameters:
mission
mission name of the config file
Returns:
path object of the config file
function getMissionConfigFile
Returns the path to the Mission specific Spice config file.
Given a mission, search a prioritized list of directories for the json config file. This function checks in the order:
- The local build dir, i.e. $CMAKE_SOURCE_DIR
- The install dir, i.e. $CMAKE_PREFIX
Parameters:
mission
mission name of the config file
Returns:
path object of the condig file
function getMissionKeys
Returns a string of mission keys from the JSON config file.
Parameters:
config
JSON config file
Returns:
string of mission keys
function getPathsFromRegex
glob, but with json
std::vector< std::vector< std::string > > SpiceQL::getPathsFromRegex (
std::string root,
std::vector< std::string > regexes
)
Lambda for globbing files from a regular expression stored in json. As they can be a single expression or a list, we need to massage the json a little.
Parameters:
root
root path to searchr
json list of regexes
Returns:
vector of paths
function getRestUrl
Returns the REST URL.
Returns:
SpiceQL's REST URL as string
function getRootDependency
Returns the root most dependency for a json pointer.
Given a config json, recursively find the root pointer for the given json pointer
Parameters:
config
unevaluated config jsonpointer
json pointer to get the root dependency for
Returns:
string vector containing arr data
function getTargetFrameInfo
returns frame name and frame code associated to the target ID.
std::pair< nlohmann::json, nlohmann::json > SpiceQL::getTargetFrameInfo (
int targetId,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Takes in a target id and returns the frame name and frame code in json format
Parameters:
targetId
target IDmission
mission name as it relates to the config filessearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
json of frame name and frame code
function getTargetOrientation
Gives quaternion and angular velocity for a given frame at a given ephemeris time.
Gets an orientation for an input frame in some reference frame. The orientations returned from this function can be used to transform a position in the source frame to the ref frame.
Parameters:
et
ephemeris time at which you want to optain the target pointingtoframe
the source frame's NAIF code.refframe
the reference frame's NAIF code, orientations are relative to this reference frame
Returns:
SPICE-style quaternions (w,x,y,z) and optional angular velocity (4 element without angular velocity, 7 element with)
function getTargetOrientations
Gives quaternion and angular velocity for a given frame at a set of ephemeris times.
std::pair< std::vector< std::vector< double > >, nlohmann::json > SpiceQL::getTargetOrientations (
std::vector< double > ets,
int toFrame,
int refFrame,
std::string mission,
std::vector< std::string > ckQualities={"smithed", "reconstructed"},
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Gets orientations for an input frame in some reference frame. The orientations returned from this function can be used to transform a position in the source frame to the ref frame.
Parameters:
ets
ephemeris times at which you want to optain the target pointingtoframe
the source frame's NAIF code.refframe
the reference frame's NAIF code, orientations are relative to this reference framemission
Config subset as it relates to the missionckQualities
vector of string describing the quality of cks to try and obtainsearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
See also: SpiceQL::getTargetOrientation
Returns:
Vector of SPICE-style quaternions (w,x,y,z) and optional angular velocity (4 element without angular velocity, 7 element with)
function getTargetState
Gives the position and velocity for a given frame at some ephemeris time.
std::vector< double > SpiceQL::getTargetState (
double et,
std::string target,
std::string observer,
std::string frame="J2000",
std::string abcorr="NONE"
)
Mostly a C++ wrap for NAIF's spkezr_c
Parameters:
et
ephemeris time at which you want to optain the target statetarget
NAIF ID for the target frameobserver
NAIF ID for the observing frameframe
The reference frame in which to get the positions inabcorr
aborration correction flag, default it NONE. This can set to: "NONE" - No correction For the "reception" case, i.e. photons from the target being recieved by the observer at the given time. "LT" - One way light time correction "LT+S" - Correct for one-way light time and stellar aberration correction "CN" - Converging Newtonian light time correction "CN+S" - Converged Newtonian light time correction and stellar aberration correction For the "transmission" case, i.e. photons emitted from the oberver hitting at target at the given time "XLT" - One-way light time correction using a newtonian formulation "XLT+S" - One-way light time and stellar aberration correction using a newtonian formulation "XCN" - converged Newtonian light time correction "XCN+S" - converged Newtonian light time correction and stellar aberration correction.
Returns:
A vector of 7 elements with a 0 - 5 index state vector of position and velocity in x,y,z,vx,vy,vz format followed by the light time adjustment at the 6th index.
function getTargetStates
Gives the positions and velocities for a given frame given a set of ephemeris times.
std::pair< std::vector< std::vector< double > >, nlohmann::json > SpiceQL::getTargetStates (
std::vector< double > ets,
std::string target,
std::string observer,
std::string frame,
std::string abcorr,
std::string mission,
std::vector< std::string > ckQualities={"smithed", "reconstructed"},
std::vector< std::string > spkQualities={"smithed", "reconstructed"},
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Mostly a C++ wrap for NAIF's spkezr_c
Parameters:
ets
ephemeris times at which you want to obtain the target statetarget
NAIF ID for the target frameobserver
NAIF ID for the observing frameframe
The reference frame in which to get the positions inabcorr
aborration correction flag, default it NONE. This can set to: "NONE" - No correction For the "reception" case, i.e. photons from the target being recieved by the observer at the given time. "LT" - One way light time correction "LT+S" - Correct for one-way light time and stellar aberration correction "CN" - Converging Newtonian light time correction "CN+S" - Converged Newtonian light time correction and stellar aberration correction For the "transmission" case, i.e. photons emitted from the oberver hitting at target at the given time "XLT" - One-way light time correction using a newtonian formulation "XLT+S" - One-way light time and stellar aberration correction using a newtonian formulation "XCN" - converged Newtonian light time correction "XCN+S" - converged Newtonian light time correction and stellar aberration correction.mission
Config subset as it relates to the missionckQualities
vector of strings describing the quality of cks to try and obtainspkQualities
string of strings describing the quality of spks to try and obtainsearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
See also: SpiceQL::getTargetState
See also: Kernel::Quality
Returns:
A vector of vectors with a Nx7 state vector of positions and velocities in x,y,z,vx,vy,vz format followed by the light time adjustment.
function getTimeIntervals
Get start and stop times a kernel.
For each segment in the kernel, get all start and stop times as a vector of double pairs. This gets all start and stop times regardless of the frame associated with it.
Input kernel is assumed to be a binary kernel with time dependant external orientation data.
Parameters:
kpath
Path to the kernel
Returns:
std::vector of start and stop times
function glob
glob, like python's glob.glob, except C++
std::vector< std::string > SpiceQL::glob (
std::string const & root,
std::string const & reg=".*",
bool recursive=false
)
Given a root and a regular expression, give all the files that match.
Parameters:
root
The root directory to searchreg
std::regex object to pattern to search, defaults to ".*", or match averything.recursive
recursively iterates through directories if true
Returns:
list of paths matching regex
function globKernelStartStopTimes
function globKernels
acquire all kernels of a type according to a configuration JSON object
nlohmann::json SpiceQL::globKernels (
std::string root,
nlohmann::json conf,
std::string kernelType
)
Given the root directotry with kernels, a JSON configuration object and a kernel type string (e.g. ck, fk, spk), return a JSON object containing kernels. The kernel config's regular expressions are replaced by a concrete kernel list located in the passed in root.
Parameters:
root
Directory with kernels somewhere in the directory or its subdirectoriesconf
JSON config file, usually this is a JSON object read from one of the db files that shipped with the librarykernelType
Some CK kernel type, see KERNEL_TYPES
function globTimeIntervals
Get start and stop times for all kernels.
Returns:
string json map of kernel names to list of time segments
function json2DArrayTo2DVector
Returns std::vector<std::vector<string>> interpretation of a json array.
Attempts to convert the json array to a C++ array. Also handles strings in cases where one element arrays are stored as scalars. Throws exception if the json obj is not an array.
Parameters:
arr
input json arr
Returns:
string vector containing arr data
function json2DArrayToDoublePair
Returns std::vector<std::vector<string>> interpretation of a json array.
Attempts to convert the json array to a C++ array. Throws exception if the json obj is not an Nx2 array of doubles.
Parameters:
arr
input json arr
Returns:
pair vector containing arr data
function json2DFloatArrayTo2DVector
Returns std::vector<std::vector<float>> interpretation of a json array.
Attempts to convert the json array to a C++ array. Also handles strings in cases where one element arrays are stored as scalars. Throws exception if the json obj is not an array.
Parameters:
arr
input json arr
Returns:
double vector containing arr data
function json2DIntArrayTo2DVector
Returns std::vector<std::vector<int>> interpretation of a json array.
Attempts to convert the json array to a C++ array. Also handles strings in cases where one element arrays are stored as scalars. Throws exception if the json obj is not an array.
Parameters:
arr
input json arr
Returns:
int vector containing arr data
function jsonArrayToVector
Returns std::vector<string> interpretation of a json array.
Attempts to convert the json array to a C++ array. Also handles strings in cases where one element arrays are stored as scalars. Throws exception if the json obj is not an array.
Parameters:
arr
input json arr
Returns:
string vector containing arr data
function jsonDoubleArrayToVector
Returns std::vector<double> interpretation of a json array.
Attempts to convert the json array to a C++ array. Also handles strings in cases where one element arrays are stored as scalars. Throws exception if the json obj is not an array.
Parameters:
arr
input json arr
Returns:
double containing arr data
function jsonIntArrayToVector
Returns std::vector<int> interpretation of a json array.
Attempts to convert the json array to a C++ array. Also handles strings in cases where one element arrays are stored as scalars. Throws exception if the json obj is not an array.
Parameters:
arr
input json arr
Returns:
int containing arr data
function listMissionKernels
Returns all kernels available for a mission.
Returns a structured json object containing all available kernels for a specified mission along with their dependencies.
TODO: Add a "See Also" on json format after the format matures a bit more.
Parameters:
root
root path to searchconf
json conf file
Returns:
list of paths matching ext
function load
function loadSelectKernels
Loads PCK kernels associated to mission name.
Parameters:
kernelType
kernelType to search for and loadmission
mission name of the config file
function loadTranslationKernels
Loads translation kernels (fk, ik, and iaks) associated to mission name.
nlohmann::json SpiceQL::loadTranslationKernels (
std::string mission,
bool loadFk=true,
bool loadIk=true,
bool loadIak=true
)
Parameters:
mission
mission name of the config file
function ls
ls, like in unix, kinda. Also it's a function.
Iterates the input path and returning a list of files. Optionally, recursively.
Parameters:
root
The root directory to searchrecursive
recursively iterates through directories if true
Returns:
list of paths
function mergeConfigs
Merge two json configs.
When arrays are merged, the values from the base config will appear first in the merged config.
Parameters:
baseConfig
The config to merge intomergingConfig
The config to merge into the base config
function merge_json
Merges the right json to the left json.
nlohmann::json SpiceQL::merge_json (
nlohmann::json & j1,
nlohmann::json & j2,
bool overwrite=false
)
Parameters:
j1
input json obj, this json is having it's values editedj2
input json obj to be merged into j1overwrite
if true, overwrites the keys in j1 in favors of those in j2. If overwrite=true, this is the same as nlohmann::json::merge_patch
Returns:
j1 with j2 keys + values
function replaceAll
find and replace one substring with another
std::string SpiceQL::replaceAll (
std::string str,
const std::string & from,
const std::string & to
)
Parameters:
str
input string to searchfrom
substring to findto
substring to replace "from" instances to
Returns:
std::string
function resolveConfigDependencies
resolve the dependencies in a config in place
void SpiceQL::resolveConfigDependencies (
nlohmann::json & config,
const nlohmann::json & dependencies
)
Given a config with "deps" keys in it and a second config to extract dependencies from, recursively resolve all of the deps into their actual values. Only allows up to 10 recurssions.
Parameters:
config
The config to populatedependencies
The config to pull dependencies from
Returns:
The full instrument config
function spiceAPIQuery
nlohmann::json SpiceQL::spiceAPIQuery (
std::string functionName,
nlohmann::json args,
std::string method="GET"
)
function strSclkToEt
Converts a given string spacecraft clock time to an ephemeris time.
std::pair< double, nlohmann::json > SpiceQL::strSclkToEt (
int frameCode,
std::string sclk,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Given a known frame code strSclkToEt converts a given spacecraft clock time as a string to an ephemeris time. Call this function if your clock time looks something like: 1/281199081:48971
Parameters:
frameCode
int Frame id to usesclk
string Spacecraft Clock formatted as a stringmission
string Mission name as it relates to the config filessearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
double
function toLower
force a string to lower case
Parameters:
s
input string
Returns:
copy of input string, in lower case
function toUpper
force a string to upper case
Parameters:
s
input string
Returns:
copy of input string, in upper case
function translateCodeToName
Switch between NAIF frame integer code to string frame name.
std::pair< std::string, nlohmann::json > SpiceQL::translateCodeToName (
int frame,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
See NAIF's Docs on frame codes for more information
Parameters:
frame
int NAIF frame code to translatesearchKernels
bool Whether to search the kernels for the usermission
Mission name as it relates to the config fileskernelList
vector<string> vector of additional kernels to load
Returns:
string Naif frame name
function translateNameToCode
Switch between NAIF frame string name to integer frame code.
std::pair< int, nlohmann::json > SpiceQL::translateNameToCode (
std::string frame,
std::string mission,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
See NAIF's Docs on frame codes for more information
Parameters:
frame
String frame name to translate to a NAIF codemission
Mission name as it relates to the config filessearchKernels
bool Whether to search the kernels for the userkernelList
vector<string> vector of additional kernels to load
Returns:
integer Naif frame code
function unload
function url_encode
function utcToEt
convert a UTC string to an ephemeris time
std::pair< double, nlohmann::json > SpiceQL::utcToEt (
std::string utc,
bool useWeb=false,
bool searchKernels=true,
std::vector< std::string > kernelList={}
)
Basically a wrapper around NAIF's cspice str2et function except it also temporarily loads the required kernels. See Also: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html
Parameters:
et
UTC string, e.g. "1988 June 13, 12:29:48 TDB"searchKernels
bool Whether to search the kernels for the user
Returns:
double precision ephemeris time
function writeCk
Write CK segments to a file.
void SpiceQL::writeCk (
std::string fileName,
std::vector< std::vector< double > > quats,
std::vector< double > times,
int bodyCode,
std::string referenceFrame,
std::string segmentId,
std::string sclk,
std::string lsk,
std::vector< std::vector< double > > angularVelocity={},
std::string comment=""
)
Given orientations, angular velocities, times, target and reference frames, write data as a segment in a CK kernel.
Parameters:
fileName
path to file to write the segment toquats
nx4 vector of orientations as quaternionstimes
nx1 vector of times matching the number of quatsbodyCode
NAIF body code identifying the orientations belong toreferenceFrame
NAIF string for the reference frame the orientations are insegmentId
Some ID to give the segmentsclk
path to S clock kernal to convert to and from ephemeris timelsk
path to leap second kernalangularVelocity
optional, nx3 array of angular velocitiescomment
optional, comment to be associated with the segment
function writeCk
Write CK segments to a file.
void SpiceQL::writeCk (
std::string fileName,
std::string sclk,
std::string lsk,
std::vector< CkSegment > segments
)
Given orientations, angular velocities, times, target and reference frames, write data as a segment in a CK kernel.
Parameters:
fileName
path to file to write the segment tosclk
path to SCLK kernel matching the segments' frame codelsk
path to LSK kernelsegments
spkSegments to be writte
function writeComment
function writeSpk
Write SPK segments to a file.
Given a vector of SPK segments, write them to the requested SPK file.
Parameters:
fileName
file specification to have the SPK segments written tosegments
spkSegments to be written
function writeSpk
Write SPK to path.
void SpiceQL::writeSpk (
std::string fileName,
std::vector< std::vector< double > > statePositions,
std::vector< double > stateTimes,
int bodyCode,
int centerOfMotion,
std::string referenceFrame,
std::string segmentId,
int polyDegree,
std::vector< std::vector< double > > stateVelocities={},
std::string segmentComment=""
)
Parameters:
fileName
full path to file to write the segment tostatePositions
Nx3 array of positions in X,Y,Z orderstateTimes
Nx1 array of timesbodyCode
NAIF integer code for the body the states belong tocenterOfMotion
is the NAIF integer code for the center of motion of the object identified by body.referenceFrame
The NAIF code the states are relative tosegmentId
ID for the segmentpolyDegree
degree of the hermite polynomials used for interpolationstateVelocities
Nx3 array of state velocities in VX, VY, VZ order, optionalsegmentComment
Comment associated with the segment, optional
function writeTextKernel
Write json key value pairs into a NAIF text kernel.
void SpiceQL::writeTextKernel (
std::string fileName,
std::string type,
nlohmann::json & keywords,
std::string comment=""
)
Parameters:
fileName
pull path to the text kerneltype
kernel type string, valid text kernel types: FK, IK, LSK, MK, PCK, SCLKcomment
the comment to add to the top of the kernelkeywords
json object containing key/value pairs to write to the text kernel
The documentation for this class was generated from the following file SpiceQL/include/api.h