SPICE Interface¶
-
namespace spice¶
SPICE ephemeris and time interface for huira.
Provides wrappers for CSPICE kernel loading, time conversion, and state/rotation queries. All units are SI unless otherwise noted. Functions are thread-safe and handle SPICE error management.
Functions
-
inline void furnsh(const fs::path &file_path)¶
Load a SPICE kernel file.
- Parameters:
file_path – Path to kernel file
-
inline void furnsh_relative_to_file(const fs::path &kernel_path)¶
Load a SPICE kernel file, resolving relative to its parent directory.
- Parameters:
kernel_path – Path to kernel file
-
inline fs::path get_default_lsk_path()¶
Get the default LSK (leap seconds kernel) path.
- Returns:
fs::path Path to default LSK
-
inline void ensure_lsk_loaded()¶
Ensure the default LSK is loaded.
-
inline fs::path get_default_pck_path()¶
Get the default PCK (planetary constants kernel) path.
- Returns:
fs::path Path to default PCK
-
inline void load_default_pck()¶
Load the default PCK.
-
inline double str2et(const std::string &time_string)¶
Convert a time string to ephemeris time (ET, seconds past J2000).
- Parameters:
time_string – Time string (e.g., “2000-001T12:00:00”)
- Returns:
double Ephemeris time (seconds past J2000)
-
inline double deltet(double epoch, const std::string &eptype)¶
Compute delta ET for a given epoch and type.
- Parameters:
epoch – Epoch (seconds past J2000)
eptype – Type of delta (e.g., “DELTET”)
- Returns:
double Delta ET
-
inline double unitim(double epoch, const std::string &insys, const std::string &outsys)¶
Convert an epoch from one time system to another.
- Parameters:
epoch – Epoch (seconds)
insys – Input time system
outsys – Output time system
- Returns:
double Converted epoch
-
inline std::string timout(double et, const std::string &pictur, int lenout)¶
Format ephemeris time as a string.
- Parameters:
et – Ephemeris time (seconds past J2000)
pictur – Output format string
lenout – Output string length
- Returns:
std::string Formatted time string
-
template<huira::IsFloatingPoint T>
inline std::tuple<Vec3<T>, Vec3<T>, double> spkezr(const std::string &TARGET, const huira::Time &time, const std::string &FRAME, const std::string &ABCORR, const std::string &OBSERVER)¶ returns the state (position and velocity) of a target body relative to an observer.
- Parameters:
TARGET – The name of the target body.
time – The time of observation.
FRAME – The reference frame relative to which the output vectors are expressed.
ABCORR – Aberration correction flag.
OBSERVER – The name of the observing body.
- Returns:
std::tuple<Vec3<T>, Vec3<T>, double> {Position, Velocity, LightTime}
Position is in km (SPICE default).
Velocity is in km/s (SPICE default).
-
template<huira::IsFloatingPoint T>
inline huira::Rotation<T> pxform(const std::string &FROM, const std::string &TO, const huira::Time &time)¶ Get the rotation from one frame to another at a given time.
- Template Parameters:
T – Floating point type
- Parameters:
FROM – Source frame
TO – Destination frame
time – Observation time
- Returns:
huira::Rotation<T> Rotation object
-
template<huira::IsFloatingPoint T>
inline std::pair<huira::Rotation<T>, huira::Vec3<T>> sxform(const std::string &FROM, const std::string &TO, const huira::Time &time)¶ Get the rotation and angular velocity from one frame to another at a given time.
- Template Parameters:
T – Floating point type
- Parameters:
FROM – Source frame
TO – Destination frame
time – Observation time
- Returns:
std::pair<huira::Rotation<T>, huira::Vec3<T>> {rotation, angular velocity}
-
template<huira::IsFloatingPoint T>
inline std::pair<Vec3<T>, Vec3<T>> conics(const std::array<double, 8> &elements, const huira::Time &time)¶ Compute the state (position and velocity) of an object in a conic orbit at a given time.
- Template Parameters:
T – Floating point type
- Parameters:
elements – Array of 8 orbital elements: [a, e, i, Ω, ω, M0, epoch, mu]
a: Semi-major axis (km)
e: Eccentricity
i: Inclination (radians)
Ω: Longitude of ascending node (radians)
ω: Argument of periapsis (radians)
M0: Mean anomaly at epoch (radians)
epoch: Epoch of the elements (seconds past J2000)
mu: Gravitational parameter of the central body (km^3/s^2)
time – Observation time
- Returns:
std::pair<Vec3<T>, Vec3<T>> {position, velocity} in meters and meters per second
-
inline void check_spice_error()¶
-
inline void furnsh(const fs::path &file_path)¶