SpiceManager#
- class SpiceManager#
Bases:
objectUnified interface to NASA SPICE via SpiceyPy.
Provides static utility methods for loading/unloading SPICE kernels, querying body states and positions, converting between time systems, resolving body and frame identifiers, and computing geometric quantities (light time, ground-station visibility, etc.).
All methods that return physical quantities wrap their output in
ArrayWUnitsorArrayWFrameto carry units and frames explicitly.Notes
SpiceManageris a pure-static class; it holds no instance state. Configuration is done through class-level attributes:kernel_list— list of currently loaded kernel paths.kernel_folder— default folder scanned for scenario kernels.poly_interp_deg— polynomial degree for state interpolation.
References
[1]Annex et al., (2020). SpiceyPy: a Pythonic Wrapper for the SPICE Toolkit. Journal of Open Source Software, 5(46), 2050. https://doi.org/10.21105/joss.02050
[2]Acton, C.H.; “Ancillary Data Services of NASA’s Navigation and Ancillary Information Facility;” Planetary and Space Science, Vol. 44, No. 1, pp. 65–70, 1996. DOI 10.1016/0032-0633(95)00107-7
[3]Acton, C.; Bachman, N.; Semenov, B.; Wright, E.; “A look toward the future in the handling of space science mission geometry;” Planetary and Space Science (2017). DOI 10.1016/j.pss.2017.02.013
- Attributes:
- kernel_folder
Methods
YDS2et(year, doy, sec)Method to convert a year, DOY, seconds into ephemeris times.
cal2et(cal)Convert a calendar UTC string to ephemeris time.
check_kernel_status_in_pool(kernel_filename)Check if a Spice kernel is loaded in the kernel pool.
ckbrief(ck_file[, tol, disp])Extracts ID and interval information from a given C-kernel.
Unload all SPICE kernels from the kernel pool.
def_new_body(name, spiceId)Define a new celestial body in the SPICE kernel.
et2YDS(et_list)Method to convert a list of ephemeris times into (year, DOY, seconds) format.
et2cal(et)Convert ephemeris time to a calendar UTC string.
et2jd(et[, form, prec, utclen])Convert ephemeris time to a Julian Date string (JDUTC).
et2sclk(scId, et[, lenout])Convert ephemeris time to a spacecraft clock string.
et2utc(et[, form, prec, utclen])Convert ephemeris time to a UTC string.
frame_id_to_frame_name(frame_id)Return the SPICE frame name for a given integer frame ID.
frame_name_to_frame_id(frame_name)Return the SPICE integer frame ID for a given frame name.
generate_metakernel(directory[, output_file])List all files in a directory and write them into a SPICE metakernel.
get_STMs(trgt_bdy, epoch_time, ...[, ...])Retrieve or interpolate the State Transition Matrix (STM) at a given epoch.
get_attitude(trgt_bdy, epoch_time, ...)Get the attitude of a target body at a specified epoch time.
get_elevation_angle(target, et[, station, ...])Compute the elevation angle of a target body as seen from a DSN ground station using SPICE.
get_frame_w_spice_id(id_number)Return the frame code and name associated with a NAIF body ID.
get_id_from_string(name_string)Return the NAIF integer ID for a body given its SPICE name.
get_intervals(spkFile, objID)Return the coverage interval of a body in an SPK file as JD strings.
get_lighttime(trgt_bdy, epoch_time, ...[, ...])Calculate the light time between a target and an origin at a given epoch time.
get_name_from_id(spice_id)Return the SPICE body name for a given NAIF integer ID.
Determine the visibility windows between an observer and a target within a specified time range.
get_parameters(trgt_bdy, epoch_time, ...[, ...])Retrieve and interpolate estimated parameters from a companion JSON file.
get_pos(trgt_bdy, epoch_time, ...[, ab_correct])Get the position of a target body relative to an observer body at a given epoch.
get_propagator_settings(trgt_bdy, ...[, ...])Retrieves the propagator settings for a given target, reference frame, and origin from JSON files.
get_sep_angle(target, et[, station, abcorr])Compute the Sun–Earth–Probe (SEP) angle of a target body as seen from a DSN ground station.
get_state(trgt_bdy, epoch_time, ...[, ...])Retrieve the state (position and velocity) of a target body relative to an origin body at a specified epoch time.
get_state_antenna(trgt_bdy, epoch_time, ...)Retrieve the state (position and velocity) of the antenna on a target spacecraft relative to an origin body at a specified epoch time.
get_state_precise(trgt_bdy, epoch_time_high, ...)Retrieve the state (position and velocity) of a target body relative to an origin body at a specified epoch time.
get_vel(trgt_bdy, epoch_time, ...[, ab_correct])Calculates the velocity of a target body relative to an observer body at a specified epoch time and reference frame.
get_xfrm(frame_from, frame_to, epoch)Computes the direction cosine matrix (DCM) to transform coordinates from one reference frame to another at a given epoch.
id2name(id)Convert given SPICE ID to the name of the associated body.
increase_kernel_priority(kernel_filename)This function increases the priority of kernel to the top of the pool for kernels of the same type by unloading then loading it.
jd2et(jd)Convert a Julian Date (JDTDB) to ephemeris time.
list_all_ck_ids(ck_file)Return all NAIF IDs present in a C-kernel file.
list_all_frames([max_id])List all SPICE reference frames currently detectable in the pool.
load_kernel(kernel_filenames)Load SPICE kernels into the SPICE system.
load_kernel_from_mkfile(furnshKernelFilename)Load a SPICE kernel from a given MK file.
matrix_times_vector(matrix, vector)Multiply a \(3 \times 3\) matrix by a 3-vector via SPICE.
name_to_ID(name)Converts a given name to its corresponding ID in the kernel pool.
Print the source and type of every currently loaded SPICE kernel.
sce2c(sc, et)Convert ephemeris time to encoded spacecraft clock ticks.
sclk2et(scId, sclk)Convert a spacecraft clock string to ephemeris time.
str2et(s)Convert a time string to ephemeris time (TDB seconds past J2000).
unload_kernel_from_pool(kernel_filename)Unload a kernel from the pool.
utc2et(utc)Convert a UTC time string to ephemeris time (TDB seconds past J2000).
utc2tdb(utc)Convert a UTC time string to TDB seconds past J2000.
write_ck_type3(ck_path, inst_id, ref_frame, ...)Write a CK type 3 segment (discrete pointing) to a new CK file.
write_spk_metadata_json(SPK_name, body, ...)Write ONLY the JSON sidecars associated with an SPK (parameters/STMs/settings/mass profile).
write_spk_segment_type9(SPK_name, ...[, ...])Write a segment of type 9 to an SPK file.
test
- classmethod ckbrief(ck_file: str, tol: int = 0, disp: bool = False) list[dict]#
Extracts ID and interval information from a given C-kernel.
- Parameters:
- Returns:
brief – A list containing information about each frame in the C-kernel. Each element of the list is a dict containing the following keys:
'ID': the NAIF integer code of the frame.'SCLK_INTERVAL': the interval or intervals for which the frame is defined in the C-kernel, represented as encoded SCLK ticks by floats.'TDB_INTERVAL': the interval or intervals for which the frame is defined in the C-kernel, represented as ephemeris time (TDB) EpochArray objects.
- Return type:
- classmethod clear_kernels()#
Unload all SPICE kernels from the kernel pool.
Calls
spice.kclear()to flush every kernel currently held in memory.- Return type:
- classmethod get_STMs(trgt_bdy: str | Body, epoch_time: float, reference_frame: str | Frame, obsvr_bdy: str | Body, folder_path_override: str = None) ndarray#
Retrieve or interpolate the State Transition Matrix (STM) at a given epoch.
Searches the scenario kernel folder for a
*_stms.jsonfile whosebody_ID,origin_ID, andreference_framefields match the supplied arguments. If epoch_time coincides (within floating-point tolerance) with a stored epoch the corresponding STM is returned directly. Otherwise element-wise linear interpolation is performed between the two bracketing epochs.- Parameters:
trgt_bdy (
strorBody) – Target body whose STMs are requested.epoch_time (
float) – TDB epoch (seconds past J2000) at which to retrieve/interpolate the STM.reference_frame (
strorFrame) – Reference frame recorded in the STM JSON file.obsvr_bdy (
strorBody) – Observer (origin) body recorded in the STM JSON file.
- Returns:
STM – Shape
(6, 6)State Transition Matrix evaluated at epoch_time.- Return type:
- Raises:
ValueError – If no matching STM JSON file is found, or if epoch_time lies outside the stored time span.
- classmethod get_attitude(trgt_bdy: str | Body, epoch_time: float | EpochArray, reference_frame: str | Frame, tol: int)#
Get the attitude of a target body at a specified epoch time. :param trgt_bdy: The target body for which the attitude is to be determined. Can be an instance of Body or a string representing the body’s name. :type trgt_bdy:
strorBody:param epoch_time: The epoch time at which the attitude is to be determined. Can be an instance of EpochArray or a float representing the time. :type epoch_time:floatorEpochArray:param reference_frame: The reference frame in which the attitude is to be determined. Can be a string or an instance of Frame. :type reference_frame:strorFrame:param tol: The tolerance value for the attitude determination. :type tol:int- Returns:
A tuple containing: - ArrayWUnits: The state vector of the target body. - ArrayWUnits: The angular velocity of the target body. - ArrayWUnits: The angular acceleration of the target body.
- Return type:
- classmethod get_elevation_angle(target: str, et, station: str = 'DSS-14', abcorr: str = 'LT+S') float#
Compute the elevation angle of a target body as seen from a DSN ground station using SPICE.
This method uses the SPICE toolkit to calculate the elevation angle of a target relative to a Deep Space Network (DSN) ground station. The calculation is performed in the station’s local topocentric frame (e.g.,
DSS-14_TOPO), where the convention is X = East, Y = North, and Z = Up.- Parameters:
target (
str) – The name or NAIF ID of the target body. Examples:"MRO"or"-74".et (
float) – Ephemeris time at which to compute the elevation angle.station (
str) – The DSN ground station name or NAIF ID used as the observer. Must match the identifiers defined in the loaded SPICE kernels. Defaults to"DSS-14".abcorr (
str, optional) – Aberration correction to apply when computing the geometry. Examples: -"NONE": No corrections. -"LT": Light-time correction only. -"LT+S": Light-time + stellar aberration correction (default).
- Returns:
elevation_angle – The elevation angle of the target relative to the local horizon at the specified DSN station, expressed in radians (or the units defined by
cls._spc_angle_units). Positive values indicate the target is above the horizon, while negative values indicate it is below.- Return type:
Notes
The station’s topocentric frame (e.g.,
DSS-14_TOPO) must be defined in the
loaded SPICE kernels. - The axis convention for topocentric frames is assumed to be: X = East, Y = North, Z = Up. - To obtain azimuth as well, use
atan2(East, North)in the same frame. - Requires SPICE kernels for:DSN station locations and frames.
Target body ephemerides.
Leapseconds (LSK).
- classmethod get_lighttime(trgt_bdy: str | Body, epoch_time: float | EpochArray, reference_frame: str | Frame, obsvr_bdy: str | Body, aberration_correction: str = 'None')#
Calculate the light time between a target and an origin at a given epoch time.
- Parameters:
trgt_bdy (
strorBody) – The target body or its name as a string.epoch_time (
EpochArrayorfloat) – The epoch time at which to calculate the light time.reference_frame (
strorFrame) – The reference frame or its name as a string.origin (
strorBody) – The origin body or its name as a string.aberration_correction (
str, optional) – The aberration correction to apply. Defaults toNone.
- Returns:
light_time – The light time as an array with units.
- Return type:
- classmethod get_parameters(trgt_bdy: str | Body, epoch_time: float | EpochArray, reference_frame: str | Frame, obsvr_bdy: str | Body, folder_path_override: str = None)#
Retrieve and interpolate estimated parameters from a companion JSON file.
Searches the scenario kernel folder for a
*_parameters.jsonfile whosebody_ID,origin_ID, andreference_framefields match the supplied arguments. If the file contains a multi-leg sequence, the leg whoseepochsTDBinterval contains epoch_time is selected. Within each leg (or in the flat, non-sequence case) the stored parameter time series is fitted with a polynomial of degreecls.poly_interp_par_degand evaluated at epoch_time.- Parameters:
trgt_bdy (
strorBody) – Target body whose parameters are requested.epoch_time (
floatorEpochArray) – TDB epoch (seconds past J2000) at which to evaluate the parameters.reference_frame (
strorFrame) – Reference frame recorded in the JSON file.obsvr_bdy (
strorBody) – Observer (origin) body recorded in the JSON file.folder_path_override (
str, optional) – Absolute path to the folder that contains the JSON files. WhenNone(default),cls.kernel_folderis used if set; otherwise falls back to<cwd>/data/kernels/scenario.
- Returns:
parameters – Interpolated parameter vector with units reconstructed from the
unitsPower/unitsScalefields stored in the JSON.- Return type:
- Raises:
ValueError – If no matching JSON file is found, or if epoch_time does not fall within any leg’s time span.
RuntimeWarning – If more than one matching JSON file is found; the most recently modified file is used.
- classmethod get_pos(trgt_bdy: str | Body, epoch_time: float | EpochArray, reference_frame: str | Frame, obsvr_bdy: str | Body, ab_correct: str = 'None')#
Get the position of a target body relative to an observer body at a given epoch. This method computes the position vector of a target body as observed from an observer body at a specified epoch time, in a given reference frame.
- Parameters:
trgt_bdy (
str | Body) – The target body whose position is to be computed. Can be specified as a string (body name) or a Body object.epoch_time (
float | EpochArray) – The epoch time(s) at which to compute the position. Can be a single float value or an EpochArray for multiple time points.reference_frame (
str | Frame) – The reference frame in which to express the position vector. Can be specified as a string (frame name) or a Frame object.obsvr_bdy (
str | Body) – The observer body from which the target position is measured. Can be specified as a string (body name) or a Body object.ab_correct (
str, optional) – Aberration correction specification. Defaults to “None”. Common values include “NONE”, “LT”, “LT+S”, “CN”, “CN+S”, “XLT”, “XLT+S”, “XCN”, “XCN+S”.
- Returns:
The position vector(s)ofthe target body relativetothe observer body.The exact return type depends on the implementationof_get_pos_core.
Notes
This method is a wrapper around _get_pos_core and delegates the actual computation to that core method.
- classmethod get_propagator_settings(trgt_bdy: str | Body, reference_frame: str | Frame, obsvr_bdy: str | Body, folder_path_override: str = None)#
Retrieves the propagator settings for a given target, reference frame, and origin from JSON files. :param trgt_bdy: The target body or its name. :type trgt_bdy:
strorBody:param reference_frame: The reference frame or its name. :type reference_frame:strorFrame:param obsvr_bdy: The origin body or its name. :type obsvr_bdy:strorBody- Returns:
The propagator settings data from the corresponding JSON file.
- Return type:
- Raises:
ValueError – If the settings JSON file could not be located.
- classmethod get_sep_angle(target: str, et, station: str = 'DSS-14', abcorr: str = 'LT+S') float#
Compute the Sun–Earth–Probe (SEP) angle of a target body as seen from a DSN ground station.
The SEP angle is defined as the angle at the observer (DSN station) between the vector pointing to the Sun and the vector pointing to the spacecraft (target). This is the standard “solar elongation angle” used in mission operations to assess geometry for radiometric tracking and solar corona effects.
- Parameters:
target (
str) – The name or NAIF ID of the target body. Examples:"OSIRIS-REX"or"-64".et (
float) – Ephemeris Time (seconds past J2000 TDB) at which to compute the SEP angle.station (
str, optional) – DSN ground station name or NAIF ID used as the observer. Must match the identifiers defined in the loaded SPICE kernels. Default is"DSS-14".abcorr (
str, optional) – Aberration correction to apply when computing the geometry. Examples: -"NONE": No corrections. -"LT": Light-time correction only. -"LT+S": Light-time + stellar aberration correction (default).
- Returns:
sep_angle – The SEP angle in radians (or converted via
cls._spc_angle_units). Larger angles correspond to better tracking geometry (target farther from the Sun as seen from Earth).- Return type:
Notes
- Requires SPICE kernels for:
DSN station locations (SPK + topocentric frame definitions).
Target body ephemerides (SPK).
Solar system ephemerides (SPK).
Leapseconds (LSK).
This angle is distinct from elevation angle (target above station horizon). SEP measures angular separation from the Sun, not from the horizon.
Often used to set operational limits during solar conjunctions.
Examples
et = scb.SpiceManager.utc2et("2017-09-22T16:52:00") # OSIRIS-REx EGA sep = MyClass.get_sep_angle("OSIRIS-REX", et, station="DSS-14") print(sep.to("deg"))
- classmethod get_state(trgt_bdy: str | Body, epoch_time: float | EpochArray, reference_frame: str | Frame, obsvr_bdy: str | Body, aberration_correction: str = 'None')#
Retrieve the state (position and velocity) of a target body relative to an origin body at a specified epoch time.
- Parameters:
trgt_bdy (
strorBody) – The target body for which the state is to be retrieved. Can be a string name or a Body object.epoch_time (
floatorEpochArray) – The epoch time at which the state is to be retrieved. Can be an EpochArray object or a float representing the time.reference_frame (
strorFrame) – The reference frame in which the state is to be retrieved. Can be a Frame object or a string name.obsvr_bdy (
strorBody) – The observing body relative to which the state is to be retrieved. Can be a string name or a Body object.aberration_correction (
str, optional) – The aberration correction to be applied. Defaults toNone.
- Returns:
state – An array containing the state (position and velocity) of the target body with associated units.
- Return type:
- classmethod get_state_antenna(trgt_bdy: Body, epoch_time: float, reference_frame: Frame, obsvr_bdy: Body, antenna_offset: ndarray, offset_reference_frame: Frame, ab_correct: str = 'None')#
Retrieve the state (position and velocity) of the antenna on a target spacecraft relative to an origin body at a specified epoch time.
- Parameters:
trgt_bdy (
str) – The target body for which the position is to be determined. Can be a string or a Body object.epoch_time (
float) – The epoch time at which the position is to be determined. Can be a float or an EpochArray object.reference_frame (
Frame) – The reference frame in which the position is to be determined. Can be a string or a Frame object.obsvr_bdy (
str) – The observing body from which the position is to be measured. Can be a string or a Body object.antenna_offset (
np.ndarray) – The antenna-CoM offset vector, expressed in the “spacecraft_body_frame” reference frame.offset_reference_frame (
Frame) – The spaceraft body-fixed reference frame. The origin of this frame is used to account for the antenna offset vector.ab_correct (
str, optional) – Aberration correction to be applied. Defaults toNone.
- Returns:
state – The State of the antenna relative to the origin body, expressed in units of km and km/sec
- Return type:
np.ndarra()
- classmethod get_state_precise(trgt_bdy: str | Body, epoch_time_high: float | EpochArray, reference_frame: str | Frame, obsvr_bdy: str | Body, aberration_correction: str = 'None', epoch_time_low: float | EpochArray = None)#
Retrieve the state (position and velocity) of a target body relative to an origin body at a specified epoch time.
- Parameters:
trgt_bdy (
strorBody) – The target body for which the state is to be retrieved. Can be a string name or a Body object.epoch_time_high (
floatorEpochArray) – The epoch time at which the state is to be retrieved. Can be an EpochArray object or a float representing the time. This is the high componentreference_frame (
strorFrame) – The reference frame in which the state is to be retrieved. Can be a Frame object or a string name.obsvr_bdy (
strorBody) – The observing body relative to which the state is to be retrieved. Can be a string name or a Body object.aberration_correction (
str, optional) – The aberration correction to be applied. Defaults toNone.epoch_time_low (
floatorEpochArray) – The epoch time at which the state is to be retrieved. Can be an EpochArray object or a float representing the time. This is the low component
- Returns:
state – An array containing the state (position and velocity) of the target body with associated units.
- Return type:
- classmethod get_vel(trgt_bdy: str | Body, epoch_time: float | EpochArray, reference_frame: str | Frame, obsvr_bdy: str | Body, ab_correct: str = 'None')#
Calculates the velocity of a target body relative to an observer body at a specified epoch time and reference frame.
- Parameters:
trgt_bdy (
str | Body) – The target body for which the velocity is to be computed. Can be a string identifier or a Body object.epoch_time (
float | EpochArray) – The epoch time(s) at which to compute the velocity. Can be a single float or an array of epochs.reference_frame (
str | Frame) – The reference frame in which the velocity is expressed. Can be a string or a Frame object.obsvr_bdy (
str | Body) – The observer body relative to which the velocity is computed. Can be a string identifier or a Body object.ab_correct (
str, optional) – Aberration correction flag. Defaults to “None”.
- Returns:
The computed velocity of the target body relative to the observer in the specified reference frame.
- Return type:
Velocityorarray-like
- classmethod get_xfrm(frame_from: str, frame_to: str, epoch)#
Computes the direction cosine matrix (DCM) to transform coordinates from one reference frame to another at a given epoch.
- Parameters:
- Returns:
The direction cosine matrix (DCM) representing the transformation from frame_from to frame_to at the specified epoch.
- Return type:
- classmethod print_kernels()#
Print the source and type of every currently loaded SPICE kernel.
Iterates over all kernels tracked by
spice.ktotaland prints each entry’s file path and kernel type to stdout.- Return type:
- classmethod write_ck_type3(ck_path: str, inst_id: int, ref_frame: str, sclk_id: int, et_list: list[float] | ndarray, quats: ndarray | None = None, avvs: ndarray | None = None, dcm_cb=None, segid: str = 'SCB GENERATED CK TYPE 3', make_intervals: str = 'per_sample', load_after: bool = True)#
Write a CK type 3 segment (discrete pointing) to a new CK file.
- Parameters:
ck_path (
str) – Output CK file path (.bc or .ck).inst_id (
int) – NAIF instrument/frame ID for the CK segment (the CK “INST” id).ref_frame (
str) – Base/reference frame name (usually ‘J2000’).sclk_id (
int) – NAIF spacecraft clock ID code used by sce2c().et_list (
array-like) – ET (TDB seconds past J2000) sample times.quats (
ndarray, optional) – Quaternions rotating vectors from ref_frame to inst frame. Shape (N,4) or (4,N). If None, must provide dcm_cb.avvs (
ndarray, optional) – Angular velocities expressed in ref_frame. Shape (N,3) or (3,N). If None, AVFLAG=0 and zeros are written (or FD-estimated if dcm_cb provided and you want).dcm_cb (
callable, optional) – Function et -> (3,3) DCM C_ref_to_inst. If provided and quats is None, quats are built via spice.m2q(C). spice.m2q uses SPICE quaternion convention. :contentReference[oaicite:2]{index=2}segid (
str) – Segment ID (<= 40 chars recommended).make_intervals (
{'per_sample','single'}) –‘per_sample’: NINTS=N-1, STARTS=sclkdp[:-1]
’single’ : NINTS=1, STARTS=[sclkdp[0]]
load_after (
bool) – If True, furnsh() the CK after writing.
- Returns:
ck_path – Path to the written CK file.
- Return type:
Notes
CKW03 requirements include monotonically increasing SCLKDP and descriptor times containing the data range. :contentReference[oaicite:3]{index=3}
- classmethod write_spk_metadata_json(SPK_name: str, body: Body, origin_ID: float, ref_frame: Frame, epochs_TDB: list, degree_poly: float, parameters_JSON: list = None, STMs_JSON: list = None, state_definition: list = None, sequence_definition: list = None, leg_data: dict = None, propagator_settings: dict = None, mass_profile: SCBPolynomial = None)#
Write ONLY the JSON sidecars associated with an SPK (parameters/STMs/settings/mass profile).
This avoids writing any additional SPK segments (no dummy segments), and avoids SPICE descriptor-time errors.
Notes
epochs_TDB is included so JSON has a time reference; for sequences it can be the concatenated full epochs list or the global seq.total_epochsTDB list.
For sequence_definition != None, epochs_TDB is not directly used for legs epochs; _prepare_sequence_data uses sequence_definition.epochs_vec.
- classmethod write_spk_segment_type9(SPK_name: str, SPK_SEG_ID: str, body: Body, origin_ID: float, ref_frame: Frame, epochs_TDB: list, degree_poly: float, state_SPICE: list, parameters_JSON: list = None, STMs_JSON: list = None, state_definition: list = None, sequence_definition: list = None, leg_data: dict = None, propagator_settings: dict = None, mass_profile: SCBPolynomial = None)#
Write a segment of type 9 to an SPK file.
- Parameters:
SPK_name (
str) – The name of the SPK file.SPK_SEG_ID (
str) – The segment ID.body (
object) – The body object.origin_ID (
int) – The ID of the origin.ref_frame (
frame) – The reference frame.epochs_TDB (
list) – The array of epochs in TDB format.degree_poly (
int) – The degree of the polynomial.state_SPICE (
list) – The array of states in SPICE format.parameters_JSON (
list, optional) – The array of parameters in JSON format.STMs_JSON (
list, optional) – The array of state transition matrices in JSON format.state_definition (
list, optional) – The state definition.sequence_definition (
object, optional) – The sequence definition.leg_data (
dict, optional) – The body, origin, and reference frame data for each leg.propagator_settings (
dict, optional) – The propagator settings.mass_profile (
SCBPolynomial, optional) – The mass profile.
- Return type:
- static YDS2et(year, doy, sec)#
Method to convert a year, DOY, seconds into ephemeris times.
- static cal2et(cal: str) float#
Convert a calendar UTC string to ephemeris time.
Alias for
str2et(); accepts any time string format recognised by SPICE.
- static check_kernel_status_in_pool(kernel_filename: str) bool#
Check if a Spice kernel is loaded in the kernel pool.
- static def_new_body(name, spiceId)#
Define a new celestial body in the SPICE kernel.
- static et2YDS(et_list)#
Method to convert a list of ephemeris times into (year, DOY, seconds) format.
- static et2cal(et: float | ndarray[tuple[Any, ...], dtype[_ScalarT]])#
Convert ephemeris time to a calendar UTC string.
Accepts scalar floats, 0-D arrays, or N-D arrays and preserves the input shape in the output.
- Parameters:
et (
floatornumpy.ndarray) – TDB seconds past J2000. May be scalar or array-valued.- Returns:
cal – Calendar UTC string(s) in
"C"(civil) format. A scalar et returns a singlestr; a 1-D array returns a 1-D array of strings; a higher-dimensional array is reshaped back to the original shape.- Return type:
strornumpy.ndarrayofstr
- static et2jd(et: float, form: str = 'J', prec: int = 27, utclen: int = 27) str#
Convert ephemeris time to a Julian Date string (JDUTC).
- Parameters:
- Returns:
jd – Julian Date string. The returned value is always JDUTC.
- Return type:
- static et2sclk(scId: int, et: float, lenout: int = 30) str#
Convert ephemeris time to a spacecraft clock string.
Thin wrapper around
spice.sce2s.
- static et2utc(et: float, form: str = 'ISOC', prec: int = 27, utclen: int = 27) str#
Convert ephemeris time to a UTC string.
- Parameters:
et (
float) – TDB seconds past J2000.form (
str, optional) – Output format code passed tospice.et2utc. Common values:"ISOC"(ISO calendar, default),"ISOD"(ISO day-of-year),"C"(calendar),"D"(day-of-year),"J"(Julian date).prec (
int, optional) – Number of digits of precision for fractional seconds. Default 27.utclen (
int, optional) – Length of the output string buffer. Default 27.
- Returns:
utc – UTC time string in the requested format.
- Return type:
- static frame_id_to_frame_name(frame_id: int) str#
Return the SPICE frame name for a given integer frame ID.
Results are cached with
functools.lru_cache()for performance.- Parameters:
frame_id (
int) – SPICE integer frame ID to resolve.- Returns:
frame_name – SPICE name of the reference frame.
- Return type:
Notes
The frame ID is distinct from the body NAIF ID used in SPK/PCK kernels.
- static frame_name_to_frame_id(frame_name: str) int#
Return the SPICE integer frame ID for a given frame name.
- Parameters:
frame_name (
str) – SPICE name of the reference frame (e.g."J2000").- Returns:
frame_id – SPICE integer frame ID corresponding to frame_name.
- Return type:
Notes
The frame ID is distinct from the body NAIF ID used in SPK/PCK kernels.
- static generate_metakernel(directory: str, output_file: str = 'output_metakernel.tm')#
List all files in a directory and write them into a SPICE metakernel.
- static get_frame_w_spice_id(id_number: int)#
Return the frame code and name associated with a NAIF body ID.
- Parameters:
id_number (
int) – NAIF integer body ID to look up (e.g.499for Mars).- Returns:
result –
(frame_code, frame_name)where frame_code is the integer SPICE frame ID and frame_name is its string identifier.- Return type:
tupleof(int,str)- Raises:
ValueError – If id_number has no associated frame in the kernel pool.
- static get_id_from_string(name_string: str) int#
Return the NAIF integer ID for a body given its SPICE name.
- static get_intervals(spkFile: str, objID: int) list[str]#
Return the coverage interval of a body in an SPK file as JD strings.
Retrieves the first (and typically only) time window for objID from the SPK coverage window and converts the endpoints to Julian Date strings.
- Parameters:
- Returns:
interval –
[start_jd, end_jd]where each element is a Julian Date string produced byspice.timout.- Return type:
- static get_observer_target_visibility_windows(obsvr_bdy: str | Body, trgt_bdy: str | Body, epoch_start: float | EpochArray, epoch_end: float | EpochArray, step_size: float = 300.0, angle_limit: float = 10.0, inframe: str = 'obs', abcorr: str = 'None', crdsys: str = 'LATITUDINAL', coord: str = 'LATITUDE', relate: str = '>', adjust: float = 0.0, num_intervals: int = 1000)#
Determine the visibility windows between an observer and a target within a specified time range.
- Parameters:
obsvr_bdy (
Union[str,scb.Body]) – The observer, either as a string name or a scb.Body object.trgt_bdy (
Union[str,scb.Body]) – The target, either as a string name or a scb.Body object.epoch_start (
Union[float,scb.EpochArray]) – The start time of the observation window.epoch_end (
Union[float,scb.EpochArray]) – he end time of the observation window.step_size (
float, optional) – The step size in seconds for the search. Default is 300.0.angle_limit (
float, optional) – The angular limit for visibility in degrees. Default is 10.0.inframe (
str, optional) – The reference frame for the observation. Default is “obs”.abcorr (
str, optional) – Aberration correction. Default is “None”.crdsys (
str, optional) – Coordinate system. Default is “LATITUDINAL”.coord (
str, optional) – Coordinate type. Default is “LATITUDE”.relate (
str, optional) – Relational operator for the coordinate comparison. Default is “>”.adjust (
float, optional) – Adjustment value for the search. Default is 0.0.num_intervals (
int, optional) – Maximum number of intervals for the search. Default is 1000.
- Returns:
A tuple containing the number of visibility windows and a list of visibility windows.
- Return type:
- static increase_kernel_priority(kernel_filename: str)#
This function increases the priority of kernel to the top of the pool for kernels of the same type by unloading then loading it.
Note: this is the method recommended by the Spice documentation.
- Parameters:
kernel_filename (
str) – Filename of the
- static jd2et(jd: float) float#
Convert a Julian Date (JDTDB) to ephemeris time.
- Parameters:
jd (
float) – Julian Date in the TDB time scale.- Returns:
et – TDB seconds past J2000.
- Return type:
Notes
A leap-second correction (
spice.deltet) is added to account for the drift between JD and ET.
- static list_all_frames(max_id: int = 100000) list#
List all SPICE reference frames currently detectable in the pool.
Scans integer frame IDs in \([-\texttt{max\_id},\,+\texttt{max\_id})\) and collects every ID for which SPICE returns a non-empty name.
- Parameters:
max_id (
int, optional) – Half-range of the frame-ID scan window. Defaults to100000.- Returns:
frames_list – Names of all reference frames found.
- Return type:
Notes
Frame IDs are distinct from body NAIF IDs used in SPK/PCK kernels.
- static load_kernel(kernel_filenames)#
Load SPICE kernels into the SPICE system.
- static load_kernel_from_mkfile(furnshKernelFilename)#
Load a SPICE kernel from a given MK file.
- static matrix_times_vector(matrix, vector)#
Multiply a \(3 \times 3\) matrix by a 3-vector via SPICE.
Computes \(\mathbf{w} = \mathbf{M}\,\mathbf{v}\) using
spice.mxv(CSPICEmxv_c).- Parameters:
matrix (
numpy.ndarray) – Shape(3, 3)double-precision matrix (e.g. a rotation matrix).vector (
numpy.ndarray) – Shape(3,)double-precision vector.
- Returns:
result – Shape
(3,)product \(\mathbf{M}\mathbf{v}\).- Return type:
- static name_to_ID(name)#
Converts a given name to its corresponding ID in the kernel pool.
- static sce2c(sc: int, et: float) float#
Convert ephemeris time to encoded spacecraft clock ticks.
Thin wrapper around
spice.sce2c.
- static sclk2et(scId: int, sclk: str) float#
Convert a spacecraft clock string to ephemeris time.
Thin wrapper around
spice.scs2e.
- static str2et(s: str) float#
Convert a time string to ephemeris time (TDB seconds past J2000).
Thin wrapper around
spice.str2et. Accepts a wide range of formats (ISO calendar, DOY, JD, etc.).
- static test(file)#
- static unload_kernel_from_pool(kernel_filename: str)#
Unload a kernel from the pool. If the kernel is not in the pool then no action is taken.
- Parameters:
kernel_filename (
str) – Filename of the Spice kernel being unloaded.
- static utc2et(utc: str) float#
Convert a UTC time string to ephemeris time (TDB seconds past J2000).
Thin wrapper around
spice.utc2et.
- static utc2tdb(utc: str) float#
Convert a UTC time string to TDB seconds past J2000.
Alias for
utc2et().
- kernel_folder = None#
- kernel_list = []#
- poly_interp_deg = 3#
- poly_interp_par_deg = 1#