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:
-
–originBody 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–Return the declination of the pole.
-
declination_rate–Return the rate of change of declination.
-
equatorial_radius–Return the equatorial radius.
-
gravitational_parameter–Return the gravitational parameter (GM).
-
id–Return the NAIF ID of this body.
-
mean_radius–Return the mean radius.
-
name–Return the name of this body.
-
polar_radius–Return the polar radius.
-
radii–Return the triaxial radii (x, y, z).
-
right_ascension–Return the right ascension of the pole.
-
right_ascension_rate–Return the rate of change of right ascension.
-
rotation_angle–Return the rotation angle (prime meridian).
-
rotation_rate–Return the rotation rate.
-
rotational_element_rates–Return rotational element rates.
-
rotational_elements–Return rotational elements (right ascension, declination, rotation angle).
declination_rate
declination_rate(et: float) -> AngularRate
Return the rate of change of declination.
gravitational_parameter
gravitational_parameter() -> GravitationalParameter
Return the gravitational parameter (GM).
right_ascension_rate
right_ascension_rate(et: float) -> AngularRate
Return the rate of change of right ascension.
rotational_element_rates
rotational_element_rates(et: float) -> tuple[AngularRate, AngularRate, AngularRate]
Return rotational element rates.