Skip to content

SPICE Kernels

Native SPICE kernel registry: loading/unloading SPK and binary PCK kernels, and generic NAIF-ID ephemeris/orientation queries. For the per-body *_spice convenience functions, see the Ephemerides reference.

Kernel Registry

load_spice_kernel builtin

load_spice_kernel(name_or_path: str) -> Any

Load a SPICE kernel into the global registry.

Known kernel names are downloaded from NAIF and cached: the planetary (DE) ephemerides "de430", "de432s", "de435", "de438", "de440", "de440s", "de442", "de442s"; the satellite ephemeris kernels "mar099", "mar099s", "jup365", "sat441", "ura184", "nep097", "plu060"; and the binary PCK "moon_pa_de440". Any other argument is treated as a local file path. SPK (.bsp) and binary PCK (.bpc) kernels are detected automatically from the file header. Loading is idempotent; kernels stay resident until unloaded, and later loads take precedence for overlapping coverage.

Parameters:

Name Type Description Default
name_or_path str

Kernel name or filesystem path

required

Raises:

Type Description
RuntimeError

If the kernel cannot be downloaded, read, or parsed

Example
1
2
3
4
import brahe as bh

bh.load_spice_kernel("de440s")
print(bh.loaded_spice_kernels())

unload_spice_kernel builtin

unload_spice_kernel(name_or_path: str) -> Any

Unload a SPICE kernel from the global registry.

Parameters:

Name Type Description Default
name_or_path str

The name or path the kernel was loaded under

required

Raises:

Type Description
RuntimeError

If no kernel is loaded under that name

Example
1
2
3
4
import brahe as bh

bh.load_spice_kernel("de440s")
bh.unload_spice_kernel("de440s")

clear_spice_kernels builtin

clear_spice_kernels() -> Any

Remove all kernels from the global registry.

Example
1
2
3
4
import brahe as bh

bh.clear_spice_kernels()
assert bh.loaded_spice_kernels() == []

loaded_spice_kernels builtin

loaded_spice_kernels() -> list[str]

List the kernels currently loaded in the global registry, in load order.

Returns:

Type Description
list[str]

list[str]: Loaded kernel names/paths

Example
1
2
3
4
import brahe as bh

bh.load_common_spice_kernels()
assert "de440s" in bh.loaded_spice_kernels()

load_common_spice_kernels builtin

load_common_spice_kernels() -> Any

Load the kernels most applications need: "de440s" (planetary ephemeris) and "moon_pa_de440" (lunar principal-axes orientation).

~46 MB total on first download; cached thereafter. Each kernel load is idempotent, so calling this alongside other load_spice_kernel calls is safe.

Loading is not atomic: on error, kernels already loaded before the failure remain resident, so the call can be safely retried.

Raises:

Type Description
RuntimeError

If a kernel cannot be downloaded, read, or parsed

Example
1
2
3
4
import brahe as bh

bh.load_common_spice_kernels()
print(bh.loaded_spice_kernels())

load_all_spice_kernels builtin

load_all_spice_kernels() -> Any

Load every kernel brahe knows how to download: "de440s", "moon_pa_de440", and the satellite ephemeris kernels "mar099s", "jup365", "sat441", "ura184", "nep097", "plu060".

~2.5 GB total on first download; cached thereafter. Prefer load_common_spice_kernels unless outer-planet body centers or moons are needed.

Loading is not atomic: on error, kernels already loaded before the failure remain resident, so the call can be safely retried.

Raises:

Type Description
RuntimeError

If a kernel cannot be downloaded, read, or parsed

Example
1
2
3
4
import brahe as bh

bh.load_all_spice_kernels()
print(bh.loaded_spice_kernels())

Generic SPK Queries

spk_position builtin

spk_position(target: int, center: int, epc: Epoch) -> ndarray

Position of a target body relative to a center body from loaded SPK kernels.

The result is expressed in the kernel's inertial frame (ICRF axes; NAIF labels this "J2000"). If no kernels are loaded, DE440s is loaded automatically.

Parameters:

Name Type Description Default
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: Position of target relative to center. Units: (m)

Raises:

Type Description
RuntimeError

If no ephemeris path exists between the bodies or the epoch is outside kernel coverage

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
r = bh.spk_position(bh.NAIFId.MOON, bh.NAIFId.EARTH, epc)

spk_velocity builtin

spk_velocity(target: int, center: int, epc: Epoch) -> ndarray

Velocity of a target body relative to a center body from loaded SPK kernels.

The result is expressed in the kernel's inertial frame (ICRF axes; NAIF labels this "J2000"). If no kernels are loaded, DE440s is loaded automatically.

Parameters:

Name Type Description Default
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: Velocity of target relative to center. Units: (m/s)

Raises:

Type Description
RuntimeError

If no ephemeris path exists between the bodies or the epoch is outside kernel coverage

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
v = bh.spk_velocity(bh.NAIFId.MOON, bh.NAIFId.EARTH, epc)

spk_state builtin

spk_state(target: int, center: int, epc: Epoch) -> ndarray

State (position and velocity) of a target body relative to a center body from loaded SPK kernels.

The result is expressed in the kernel's inertial frame (ICRF axes; NAIF labels this "J2000"). Computing the state shares a single record lookup between position and velocity. If no kernels are loaded, DE440s is loaded automatically.

Parameters:

Name Type Description Default
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: State [x, y, z, vx, vy, vz] of target relative to center. Units: (m, m/s)

Raises:

Type Description
RuntimeError

If no ephemeris path exists between the bodies or the epoch is outside kernel coverage

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
x = bh.spk_state(bh.NAIFId.SUN, bh.NAIFId.EARTH, epc)

spk_acceleration builtin

spk_acceleration(target: int, center: int, epc: Epoch) -> ndarray

Acceleration of a target body relative to a center body from loaded SPK kernels.

The result is expressed in the kernel's inertial frame (ICRF axes), evaluated by analytically differentiating the kernel's Chebyshev polynomials (twice for Type 2 segments; once, of the stored velocity polynomials, for Type 3). If no kernels are loaded, DE440s is loaded automatically.

Parameters:

Name Type Description Default
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: Acceleration [ax, ay, az] of target relative to center. Units: (m/s^2)

Raises:

Type Description
RuntimeError

If no ephemeris path exists between the bodies or the epoch is outside kernel coverage

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
a = bh.spk_acceleration(bh.NAIFId.MOON, bh.NAIFId.EARTH, epc)

Kernel-Scoped SPK Queries

spk_position_from_kernel builtin

spk_position_from_kernel(kernel_name: str, target: int, center: int, epc: Epoch) -> ndarray

Position of a target body relative to a center body, queried from a single named kernel.

Queries that kernel only — no cross-kernel chaining is performed and the registry's last-loaded-wins precedence semantics do not apply. The kernel is auto-loaded by name or path if not already loaded.

Parameters:

Name Type Description Default
kernel_name str

A known DE kernel name (e.g. "de440s", "de440"), or a path to a .bsp file

required
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: Position of target relative to center in the kernel's inertial frame (ICRF axes). Units: (m)

Raises:

Type Description
RuntimeError

If the kernel cannot be loaded, does not contain the requested bodies, or does not cover the epoch

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
r = bh.spk_position_from_kernel("de440s", bh.NAIFId.MOON, bh.NAIFId.EARTH, epc)

spk_velocity_from_kernel builtin

spk_velocity_from_kernel(kernel_name: str, target: int, center: int, epc: Epoch) -> ndarray

Velocity of a target body relative to a center body, queried from a single named kernel.

Queries that kernel only — no cross-kernel chaining is performed and the registry's last-loaded-wins precedence semantics do not apply. The kernel is auto-loaded by name or path if not already loaded.

Parameters:

Name Type Description Default
kernel_name str

A known DE kernel name (e.g. "de440s", "de440"), or a path to a .bsp file

required
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: Velocity of target relative to center in the kernel's inertial frame (ICRF axes). Units: (m/s)

Raises:

Type Description
RuntimeError

If the kernel cannot be loaded, does not contain the requested bodies, or does not cover the epoch

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
v = bh.spk_velocity_from_kernel("de440s", bh.NAIFId.MOON, bh.NAIFId.EARTH, epc)

spk_state_from_kernel builtin

spk_state_from_kernel(kernel_name: str, target: int, center: int, epc: Epoch) -> ndarray

State (position and velocity) of a target body relative to a center body, queried from a single named kernel.

Queries that kernel only — no cross-kernel chaining is performed and the registry's last-loaded-wins precedence semantics do not apply. The kernel is auto-loaded by name or path if not already loaded.

Parameters:

Name Type Description Default
kernel_name str

A known DE kernel name (e.g. "de440s", "de440"), or a path to a .bsp file

required
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: State [x, y, z, vx, vy, vz] of target relative to center in the kernel's inertial frame (ICRF axes). Units: (m, m/s)

Raises:

Type Description
RuntimeError

If the kernel cannot be loaded, does not contain the requested bodies, or does not cover the epoch

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
x = bh.spk_state_from_kernel("de440s", bh.NAIFId.SUN, bh.NAIFId.EARTH, epc)

spk_acceleration_from_kernel builtin

spk_acceleration_from_kernel(kernel_name: str, target: int, center: int, epc: Epoch) -> ndarray

Acceleration of a target body relative to a center body, queried from a single named kernel.

Queries that kernel only — no cross-kernel chaining is performed and the registry's last-loaded-wins precedence semantics do not apply. The kernel is auto-loaded by name or path if not already loaded.

Parameters:

Name Type Description Default
kernel_name str

A known DE kernel name (e.g. "de440s", "de440"), or a path to a .bsp file

required
target int

NAIF ID of the target body (e.g. bh.NAIFId.MOON)

required
center int

NAIF ID of the center body (e.g. bh.NAIFId.EARTH)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: Acceleration [ax, ay, az] of target relative to center in the kernel's inertial frame (ICRF axes). Units: (m/s^2)

Raises:

Type Description
RuntimeError

If the kernel cannot be loaded, does not contain the requested bodies, or does not cover the epoch

Example
1
2
3
4
import brahe as bh

epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
a = bh.spk_acceleration_from_kernel("de440s", bh.NAIFId.MOON, bh.NAIFId.EARTH, epc)

PCK Orientation Queries

pck_euler_angles builtin

pck_euler_angles(frame_id: int, epc: Epoch) -> Tuple

3-1-3 Euler angles and rates of a PCK body-fixed frame relative to ICRF.

PCKs are never auto-initialized; a PCK kernel must be explicitly loaded via bh.load_spice_kernel(...) first.

Parameters:

Name Type Description Default
frame_id int

Body-frame class ID (e.g. 31008 for MOON_PA_DE440)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
Tuple

tuple[np.ndarray, np.ndarray]: (angles [phi, delta, w] in rad, rates in rad/s)

Raises:

Type Description
RuntimeError

If no loaded binary PCK provides the frame at the epoch

Example
1
2
3
4
5
import brahe as bh

bh.load_spice_kernel("moon_pa_de440")
epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
angles, rates = bh.pck_euler_angles(31008, epc)

pck_euler_angle builtin

pck_euler_angle(frame_id: int, epc: Epoch) -> EulerAngle

3-1-3 Euler angle of a PCK body-fixed frame relative to ICRF.

PCKs are never auto-initialized; a PCK kernel must be explicitly loaded via bh.load_spice_kernel(...) first.

Parameters:

Name Type Description Default
frame_id int

Body-frame class ID (e.g. 31008 for MOON_PA_DE440)

required
epc Epoch

Epoch of the query

required

Returns:

Name Type Description
EulerAngle EulerAngle

ICRF to body-fixed orientation (order ZXZ, radians)

Raises:

Type Description
RuntimeError

If no loaded binary PCK provides the frame at the epoch

Example
1
2
3
4
5
import brahe as bh

bh.load_spice_kernel("moon_pa_de440")
epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
e = bh.pck_euler_angle(31008, epc)

pck_euler_rates builtin

pck_euler_rates(frame_id: int, epc: Epoch) -> ndarray

Time derivatives of the 3-1-3 Euler angles of a PCK body-fixed frame.

PCKs are never auto-initialized; a PCK kernel must be explicitly loaded via bh.load_spice_kernel(...) first.

Parameters:

Name Type Description Default
frame_id int

Body-frame class ID (e.g. 31008 for MOON_PA_DE440)

required
epc Epoch

Epoch of the query

required

Returns:

Type Description
ndarray

np.ndarray: [phi_dot, delta_dot, w_dot] in rad/s

Raises:

Type Description
RuntimeError

If no loaded binary PCK provides the frame at the epoch

Example
1
2
3
4
5
import brahe as bh

bh.load_spice_kernel("moon_pa_de440")
epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
rates = bh.pck_euler_rates(31008, epc)

pck_euler_angle_and_rates builtin

pck_euler_angle_and_rates(frame_id: int, epc: Epoch) -> Tuple

Typed Euler angle and its rates for a PCK body-fixed frame, from a single shared segment lookup.

PCKs are never auto-initialized; a PCK kernel must be explicitly loaded via bh.load_spice_kernel(...) first.

Parameters:

Name Type Description Default
frame_id int

Body-frame class ID (e.g. 31008 for MOON_PA_DE440)

required
epc Epoch

Epoch of the query

required

Returns:

Name Type Description
tuple Tuple

(EulerAngle, np.ndarray) — orientation (order ZXZ, radians) and rates [phi_dot, delta_dot, w_dot] in rad/s

Raises:

Type Description
RuntimeError

If no loaded binary PCK provides the frame at the epoch

Example
1
2
3
4
5
import brahe as bh

bh.load_spice_kernel("moon_pa_de440")
epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
angle, rates = bh.pck_euler_angle_and_rates(31008, epc)

pck_quaternion builtin

pck_quaternion(frame_id: int, epc: Epoch) -> Quaternion

Orientation of a PCK body-fixed frame relative to ICRF, as a unit quaternion.

PCKs are never auto-initialized; a PCK kernel must be explicitly loaded via bh.load_spice_kernel(...) first.

Parameters:

Name Type Description Default
frame_id int

Body-frame class ID (e.g. 31008 for MOON_PA_DE440)

required
epc Epoch

Epoch of the query

required

Returns:

Name Type Description
Quaternion Quaternion

Unit quaternion (ICRF to body-fixed). Dimensionless.

Raises:

Type Description
RuntimeError

If no loaded binary PCK provides the frame at the epoch

Example
1
2
3
4
5
import brahe as bh

bh.load_spice_kernel("moon_pa_de440")
epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
q = bh.pck_quaternion(31008, epc)

pck_rotation_matrix builtin

pck_rotation_matrix(frame_id: int, epc: Epoch) -> RotationMatrix

Rotation matrix from ICRF to a PCK body-fixed frame.

PCKs are never auto-initialized; a PCK kernel must be explicitly loaded via bh.load_spice_kernel(...) first.

Parameters:

Name Type Description Default
frame_id int

Body-frame class ID (e.g. 31008 for MOON_PA_DE440)

required
epc Epoch

Epoch of the query

required

Returns:

Name Type Description
RotationMatrix RotationMatrix

3x3 rotation matrix (ICRF to body-fixed). Dimensionless.

Raises:

Type Description
RuntimeError

If no loaded binary PCK provides the frame at the epoch

Example
1
2
3
4
5
import brahe as bh

bh.load_spice_kernel("moon_pa_de440")
epc = bh.Epoch.from_date(2025, 1, 1, bh.TimeSystem.UTC)
R = bh.pck_rotation_matrix(31008, epc)

NAIFId

Full NAIF integer ID listing: NAIF Integer ID Codes.

NAIFId

NAIF integer ID codes for solar-system bodies.

Values pass directly to any function taking a NAIF ID; arbitrary raw integer IDs are equally accepted by those functions. Full ID list: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html

SOLAR_SYSTEM_BARYCENTER class-attribute instance-attribute

SOLAR_SYSTEM_BARYCENTER = 0

MERCURY_BARYCENTER class-attribute instance-attribute

MERCURY_BARYCENTER = 1

VENUS_BARYCENTER class-attribute instance-attribute

VENUS_BARYCENTER = 2

EARTH_MOON_BARYCENTER class-attribute instance-attribute

EARTH_MOON_BARYCENTER = 3

MARS_BARYCENTER class-attribute instance-attribute

MARS_BARYCENTER = 4

JUPITER_BARYCENTER class-attribute instance-attribute

JUPITER_BARYCENTER = 5

SATURN_BARYCENTER class-attribute instance-attribute

SATURN_BARYCENTER = 6

URANUS_BARYCENTER class-attribute instance-attribute

URANUS_BARYCENTER = 7

NEPTUNE_BARYCENTER class-attribute instance-attribute

NEPTUNE_BARYCENTER = 8

PLUTO_BARYCENTER class-attribute instance-attribute

PLUTO_BARYCENTER = 9

SUN class-attribute instance-attribute

SUN = 10

MERCURY class-attribute instance-attribute

MERCURY = 199

VENUS class-attribute instance-attribute

VENUS = 299

EARTH class-attribute instance-attribute

EARTH = 399

MOON class-attribute instance-attribute

MOON = 301

MARS class-attribute instance-attribute

MARS = 499

JUPITER class-attribute instance-attribute

JUPITER = 599

SATURN class-attribute instance-attribute

SATURN = 699

URANUS class-attribute instance-attribute

URANUS = 799

NEPTUNE class-attribute instance-attribute

NEPTUNE = 899

PLUTO class-attribute instance-attribute

PLUTO = 999

PHOBOS class-attribute instance-attribute

PHOBOS = 401

DEIMOS class-attribute instance-attribute

DEIMOS = 402

IO class-attribute instance-attribute

IO = 501

EUROPA class-attribute instance-attribute

EUROPA = 502

GANYMEDE class-attribute instance-attribute

GANYMEDE = 503

CALLISTO class-attribute instance-attribute

CALLISTO = 504

TITAN class-attribute instance-attribute

TITAN = 606

ARIEL class-attribute instance-attribute

ARIEL = 701

UMBRIEL class-attribute instance-attribute

UMBRIEL = 702

TITANIA class-attribute instance-attribute

TITANIA = 703

OBERON class-attribute instance-attribute

OBERON = 704

MIRANDA class-attribute instance-attribute

MIRANDA = 705

TRITON class-attribute instance-attribute

TRITON = 801

CHARON class-attribute instance-attribute

CHARON = 901

Any other NAIF ID present in a loaded kernel (e.g. a spacecraft or minor body) also works — pass the raw integer directly. In Rust the equivalent catch-all is NAIFId::Id(i32).

FrameId

FrameId

PCK body-frame class IDs. Raw integer IDs are equally accepted.

MOON_PA_DE440 class-attribute instance-attribute

MOON_PA_DE440 = 31008

Any other frame class ID present in a loaded binary PCK also works — pass the raw integer directly. In Rust the equivalent catch-all is FrameId::Id(i32). Full frame reference: NAIF Frames Required Reading.

See Also