rust-ephem Documentation

rust-ephem logo Python 3.10 + Rust 2021

High-performance satellite and planetary ephemeris calculations for Python

rust-ephem is a Python library powered by Rust that provides fast, accurate ephemeris calculations for satellites, spacecraft, and ground observatories. It integrates seamlessly with astropy and achieves 10-20 meter accuracy for LEO satellites.

Key Features

πŸš€ Performance

Up to 84x faster than pure-Python solutions for coordinate conversions. Vectorized batch constraint evaluation provides 3-50x speedup over single-target loops.

🎯 Accuracy

10-20 meter position accuracy with UT1 and polar motion corrections. Sub-arcsecond Moon positions using SPICE kernels.

πŸ”— Astropy Integration

Direct SkyCoord output for GCRS, ITRS, Sun, Moon, and Earth frames. Compatible with astropy’s coordinate transformation ecosystem.

πŸ“‘ Multiple Ephemeris Types
  • TLEEphemeris: Satellite tracking from Two-Line Elements (SGP4)

  • SPICEEphemeris: Spacecraft ephemeris from SPICE kernel (SPK) files

  • GroundEphemeris: Fixed ground station positions

  • OEMEphemeris: CCSDS Orbit Ephemeris Message files

  • FileEphemeris: Generic simulator output files (offset-based, ISO 8601, CSV, …)

  • ParquetEphemeris: Parquet state-vector files via DuckDB (local, S3, Spaces, GCS, R2, HTTPS)

πŸŽ›οΈ Flexible Constraints

Evaluate observational constraints (Sun/Moon avoidance, Earth limb, eclipses) with logical operators (AND, OR, NOT, XOR) for observation planning.

Quick Start

Installation

pip install rust-ephem

Basic Usage

import rust_ephem
from datetime import datetime, timezone

# Define time range
begin = datetime(2024, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
end = datetime(2024, 1, 1, 1, 0, 0, tzinfo=timezone.utc)

# Create satellite ephemeris from TLE
ephem = rust_ephem.TLEEphemeris(
    norad_id=25544,  # ISS
    begin=begin,
    end=end,
    step_size=60
)

# Get positions as astropy SkyCoord
satellite = ephem.gcrs  # Satellite position in GCRS frame
sun = ephem.sun         # Sun position from satellite's perspective
moon = ephem.moon       # Moon position from satellite's perspective

# Access raw position/velocity data
print(f"Position: {ephem.gcrs_pv.position[0]} km")
print(f"Velocity: {ephem.gcrs_pv.velocity[0]} km/s")

Constraint Evaluation

Constraints are created by instantiating constraint classes and can be combined using logical operators. The example below creates a constraint that requires a target to be at least 45 degrees from the Sun or at least 10 degrees from the Moon. Python logical operators are overloaded to allow combining constraints. As we are evaluating constraints, and not visibilities, we combined constraints with β€œor” (|), if we used β€œand” (&), the target would only be constrained if it violated both Sun and Moon constraints simultaneously.

from rust_ephem.constraints import SunConstraint, MoonConstraint

rust_ephem.ensure_planetary_ephemeris()

# Create combined constraint, not the use of or operator, this means a
# target is constrained if it's too close to either the Sun or the Moon.
constraint = SunConstraint(min_angle=45.0) | MoonConstraint(min_angle=10.0)

# Evaluate for a target (Crab Nebula)
result = constraint.evaluate(ephem, target_ra=83.63, target_dec=22.01)

print(f"Visibility windows: {len(result.visibility)}")
for window in result.visibility:
    print(f"  {window.start_time} to {window.end_time}")

Documentation Contents

Indices and Tables