adam_core.utils.spice module

adam_core.utils.spice.clear_spkez_cache() None[source]

Clear the in-process SPICE state cache.

This is primarily intended for testing and benchmarking.

adam_core.utils.spice.setup_SPICE(kernels: List[str] | None = None, force: bool = False)[source]

Load SPICE kernels.

This function checks to see if SPICE has already been initialized for the current process. If it has, then it does nothing. If it has not, then it loads the desired kernels into SPICE. If force is set to True, then the kernels will be loaded regardless of whether or not SPICE has already been initialized. SPICE has a limit on the number of kernels that can be loaded at once, so it is recommended to only load the kernels that are needed for the current calculation (calling sp.furnsh multiple times will load the same kernel multiple times, which will cause an error.)

The default kernels loaded are those provided by the NAIF data packages:

Parameters:

kernels – List of SPICE kernels to load into SPICE. If None, then the default kernels will be loaded.

adam_core.utils.spice.get_perturber_state(perturber: OriginCodes, times: Timestamp, frame: Literal['ecliptic', 'equatorial', 'itrf93'] = 'ecliptic', origin: OriginCodes = OriginCodes.SUN) CartesianCoordinates[source]

Query the JPL ephemeris files loaded in SPICE for the state vectors of desired perturbers.

Parameters:
  • perturber (OriginCodes) – The NAIF ID of the perturber.

  • times (Timestamp (N)) – Times at which to get state vectors.

  • frame ({'equatorial', 'ecliptic', 'itrf93'}) – Return perturber state in the equatorial or ecliptic J2000 frames.

  • origin (OriginCodes) – The NAIF ID of the origin.

Returns:

states – The state vectors of the perturber in the desired frame and measured from the desired origin.

Return type:

~adam_core.coordinates.cartesian.CartesianCoordinates

adam_core.utils.spice.list_registered_kernels() Set[str][source]

Get the set of currently registered custom SPICE kernels.

Returns:

kernels – Set of kernel file paths that are currently registered

Return type:

set[str]

adam_core.utils.spice.register_spice_kernel(kernel_path: str) None[source]

Register and load a custom SPICE kernel.

Parameters:

kernel_path (str) – Path to the SPICE kernel file

adam_core.utils.spice.unregister_spice_kernel(kernel_path: str) None[source]

Unregister and unload a custom SPICE kernel.

Parameters:

kernel_path (str) – Path to the SPICE kernel file

adam_core.utils.spice.get_spice_body_state(body_id: int, times: Timestamp, frame: Literal['ecliptic', 'equatorial', 'itrf93'] = 'ecliptic', origin: OriginCodes = OriginCodes.SUN) CartesianCoordinates[source]

Get state vectors for a body using its SPICE ID.

Parameters:
  • body_id (int) – The SPICE ID of the body

  • times (Timestamp) – Times at which to get state vectors

  • frame ({'equatorial', 'ecliptic', 'itrf93'}) – Reference frame for returned state vectors

  • origin (OriginCodes) – The origin for the state vectors

Returns:

states – The state vectors in the desired frame

Return type:

CartesianCoordinates

Raises:

ValueError – If the body ID is not found in any loaded kernel or if state data cannot be retrieved for the requested times