siderust-py
Astrometry and astrodynamics for Python, powered by the siderust Rust library through PyO3.
siderust-py provides Python-native access to observation planning,
coordinate queries, ephemerides, solar-system bodies, stellar targets,
moon-phase calculations, and related astronomy utilities while keeping the
numerical implementation in Rust.
The Crates.io and docs.rs badges above refer to the siderust-py Rust crate,
which exposes the supported cross-extension interoperability API. The Python
package is imported as siderust.
Features
- Rust-backed astronomy with Python orchestration and Pythonic result types
- Observers and observing sites, including predefined major observatories
- Solar-system bodies and stars with altitude and azimuth queries
- Coordinate types including directions, positions, and spherical positions
- Observation events such as threshold crossings and culminations
- Visibility windows above or below configurable altitude thresholds
- Twilight thresholds for horizon, civil, nautical, and astronomical twilight
- Moon phase geometry and events
- Targets and proper motion for epoch-aware stellar tracking
- Orbit, comet, and runtime ephemeris bindings
- PyO3 interoperability for exchanging canonical
ObserverandDirectionobjects across independently compiled Rust extensions
Installation
Install the Python package with pip:
To build from source, install a Rust toolchain and Maturin:
Quick Start
# Pick an observatory.
=
# Find sunrise and sunset over one day (MJD 60 000).
=
=
# Check a star altitude.
=
=
Core API
| Area | Main API |
|---|---|
| Observers | Observer, predefined observatories |
| Solar system | Body, Orbit, Comet, RuntimeEphemeris |
| Stars and targets | Star, Target, ProperMotion, apply_proper_motion() |
| Coordinates | Direction, Position, SphericalPosition |
| Altitude / azimuth | altitude_at(), azimuth_at() |
| Visibility | above_threshold(), below_threshold() |
| Events | crossings(), culminations(), intersect_periods() |
| Moon phase | moon_phase(), find_moon_phases() |
| Twilight | TWILIGHT_HORIZON, TWILIGHT_CIVIL, TWILIGHT_NAUTICAL, TWILIGHT_ASTRONOMICAL |
Observer
=
=
=
=
=
Bodies and stars
=
=
=
=
Visibility and events
=
=
=
=
target arguments accepted by the common observing functions can be a
Body, Star, or Direction.
Examples
The repository includes runnable examples covering the larger API surface:
- Basic coordinates
- Coordinate transformations
- Reference-frame conversions
- Reference-center conversions
- Target tracking
- Night events
- Moon properties
- Solar-system calculations
- Star observability
- Time periods
- Serialization
- Runtime ephemerides
- Coordinate operations
Rust / PyO3 interoperability
The project also builds an rlib so downstream Rust/PyO3 extensions can
exchange canonical Python siderust.Observer and siderust.Direction
objects without relying on duplicate PyO3 class registrations.
Add the published interoperability crate to a Rust extension:
[]
= "0.29"
= "0.2"
The public bridge lives under siderust_py::interop and uses a versioned,
primitive-only protocol across extension boundaries.
See Cross-extension interoperability for the compatibility contract, Cargo setup, and complete examples.
Relationship with siderust
siderust-py is the Python interface to the
siderust Rust library. Core
astronomy and astrodynamics algorithms remain implemented in Rust; this
repository focuses on Python bindings, Python-facing ergonomics, and safe
cross-extension interoperability.
- Rust core crate: crates.io/crates/siderust
- Rust core API: docs.rs/siderust
- Python/Rust interop crate: crates.io/crates/siderust-py
- Interop API docs: docs.rs/siderust-py
Development
Prerequisites:
- Rust stable toolchain
- Python 3.8+
- Maturin 1.9.4 or newer
- pytest
- Ruff
Local setup:
Common checks used by CI:
# Python tests
# Rust tests
# Formatting
# Linting
The CI matrix validates Python 3.8 through 3.14 and also exercises the cross-extension bridge contract on Linux, macOS, and Windows.
Changelog
See CHANGELOG.md for release notes.
License
AGPL-3.0 — see LICENSE.