Skip to content

Celestial Bodies

Celestial body definitions including physical properties and rotational elements.

Supported Bodies

Lox supports the standard NAIF/SPICE body identifiers for:

  • Planets (Mercury through Neptune)
  • Planetary barycenters
  • Natural satellites (major moons)
  • The Sun
  • Solar system barycenter

Quick Example

import lox_space as lox

# Create by name or ID
earth = lox.Origin("Earth")
moon = lox.Origin("Moon")
mars = lox.Origin(499)  # NAIF ID

# Access properties (returns unit types)
print(f"Earth radius: {earth.mean_radius().to_kilometers():.1f} km")
print(f"Earth GM: {earth.gravitational_parameter().to_km3_per_s2():.6e} km³/s²")

# Rotational elements at a given epoch
et = 0.0  # Ephemeris time (seconds from J2000)
ra, dec, w = earth.rotational_elements(et)
print(f"RA: {ra.to_degrees():.2f} deg")

Origin

Represents a celestial body (planet, moon, barycenter, etc.).

Origin objects represent celestial bodies using NAIF/SPICE identifiers. They provide access to physical properties such as gravitational parameters, radii, and rotational elements.

Parameters:

  • origin

    Body name (e.g., "Earth", "Moon") or NAIF ID (e.g., 399 for Earth).

Raises:

  • ValueError

    If the origin name or ID is not recognized.

  • TypeError

    If the argument is neither a string nor an integer.

Examples:

>>> earth = lox.Origin("Earth")
>>> moon = lox.Origin("Moon")
>>> mars = lox.Origin(499)  # NAIF ID

Methods:

declination

declination(et: float) -> Angle

Return the declination of the pole.

declination_rate

declination_rate(et: float) -> AngularRate

Return the rate of change of declination.

equatorial_radius

equatorial_radius() -> Distance

Return the equatorial radius.

gravitational_parameter

gravitational_parameter() -> GravitationalParameter

Return the gravitational parameter (GM).

id

id() -> int

Return the NAIF ID of this body.

mean_radius

mean_radius() -> Distance

Return the mean radius.

name

name() -> str

Return the name of this body.

polar_radius

polar_radius() -> Distance

Return the polar radius.

radii

Return the triaxial radii (x, y, z).

right_ascension

right_ascension(et: float) -> Angle

Return the right ascension of the pole.

right_ascension_rate

right_ascension_rate(et: float) -> AngularRate

Return the rate of change of right ascension.

rotation_angle

rotation_angle(et: float) -> Angle

Return the rotation angle (prime meridian).

rotation_rate

rotation_rate(et: float) -> AngularRate

Return the rotation rate.

rotational_element_rates

rotational_element_rates(et: float) -> tuple[AngularRate, AngularRate, AngularRate]

Return rotational element rates.

rotational_elements

rotational_elements(et: float) -> tuple[Angle, Angle, Angle]

Return rotational elements (right ascension, declination, rotation angle).