Fast astronomical calculations in Rust with Python bindings. Built for telescope control, sky surveys, and astronomical data processing.
Add to your Cargo.toml
:
[dependencies]
astro-math = "0.2"
chrono = "0.4"
pip install astro-math
Or build from source with maturin:
cd astro-math-py
maturin develop
use astro_math::{Location, ra_dec_to_alt_az};
use chrono::Utc;
// Parse observer location from various formats
let location = Location::parse("40.7128 N", "74.0060 W", 10.0)?;
// Convert celestial coordinates to horizon coordinates
let (alt, az) = ra_dec_to_alt_az(279.23, 38.78, Utc::now(), &location)?;
println!("Altitude: {:.2}°, Azimuth: {:.2}°", alt, az);
The examples/
directory contains working code for common tasks:
basic_transforms.rs
- Convert between coordinate systems (RA/Dec ↔ Alt/Az)location_parsing.rs
- Parse coordinates from strings in 25+ formatsproper_motion.rs
- Apply stellar proper motion over timerise_set_times.rs
- Calculate when objects rise and setmoon_phases.rs
- Moon position, phase, and illuminationprecession.rs
- Precess coordinates between epochsgalactic_coords.rs
- Convert between equatorial and galactic coordinatestelescope_pointing.rs
- Real-time telescope coordinate conversionbatch_processing.rs
- Process large coordinate datasets efficiently
Run any example:
cargo run --example basic_transforms
- Coordinate Transformations: RA/Dec ↔ Alt/Az, Galactic, Ecliptic
- Location Parsing: Handles DMS, HMS, decimal degrees, and mixed formats
- Time Systems: Proper UTC/TT conversion with leap second tables
- Stellar Motion: Proper motion, precession, nutation, aberration
- Solar System: Sun/Moon positions, phases, rise/set times
- Performance: Parallel batch processing, optimized algorithms
Tested against AstroPy to ensure accuracy:
- Coordinate transformations: Sub-arcsecond agreement
- Time calculations: Microsecond precision
- Performance benchmarks: See
benchmarks/
notebooks for detailed comparisons
The Jupyter notebooks in benchmarks/
show comprehensive testing against AstroPy across thousands of test cases.
astro-math/
- Core Rust libraryastro-math-py/
- Python bindings via PyO3examples/
- Rust usage examplesbenchmarks/
- Performance analysis notebooks
Built using the IAU SOFA algorithms and Jean Meeus formulations. See individual module documentation for implementation details and references.
MIT OR Apache-2.0