Astro Math
Astronomy library for Rust implementing algorithms from Jean Meeus and ERFA. Built for telescope control, observation planning, and celestial mechanics.
Core Capabilities
This library provides everything needed for astronomical calculations:
Time Systems
- [
time] — Julian Date conversions, J2000 epoch calculations - [
time_scales] — UTC ↔ TT conversions with proper leap second handling - [
sidereal] — Greenwich Mean Sidereal Time (GMST), Local Mean/Apparent Sidereal Time
Observer Location
- [
location] — Earth coordinates with flexible parsing (27+ formats) - Support for decimal degrees, DMS, HMS, aviation formats, Unicode symbols
Coordinate Transformations
- [
transforms] — RA/Dec ↔ Alt/Az conversions with spherical trigonometry - [
galactic] — Equatorial ↔ Galactic coordinate system conversions - [
projection] — Gnomonic/TAN projection for astrometry and plate solving
Precision Corrections
- [
precession] — Convert coordinates between epochs (J2000 ↔ current date) - [
nutation] — Earth's axis wobble corrections (±18.6" longitude, ±9.2" obliquity) - [
aberration] — Annual stellar aberration corrections (±20.5 arcseconds) - [
proper_motion] — Linear and rigorous 3D space motion calculations - [
parallax] — Diurnal and annual parallax corrections
Solar System Objects
- [
moon] — Lunar position, phase, illumination, distance calculations - [
sun] — Solar position and rise/set calculations - [
rise_set] — Rise, set, and meridian transit times for any object
Atmospheric Effects
- [
refraction] — Multiple atmospheric refraction models (Bennett, Saemundsson, radio) - [
airmass] — Various airmass formulas for extinction calculations
High Performance
- Parallel batch processing with Rayon for coordinate transformations
- ERFA (Essential Routines for Fundamental Astronomy) integration
- Input validation and clear error messages
Architecture Overview
The library is structured around these core concepts:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Observer │ │ Celestial │ │ Corrections │
│ Location │───▶│ Coordinates │───▶│ & Effects │
│ │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
1. Observer Location ([Location])
Earth-based observer coordinates with flexible coordinate parsing supporting 27+ formats (decimal degrees, DMS, HMS, aviation, Unicode symbols). Handles local sidereal time calculations and coordinate validation.
2. Time Systems ([time], [time_scales], [sidereal])
- Julian Date conversions and J2000 epoch calculations
- UTC ↔ TT conversions with proper leap second handling
- Greenwich Mean Sidereal Time (GMST) and Local Sidereal Time (LST)
3. Coordinate Systems ([transforms], [galactic], [projection])
- RA/Dec ↔ Alt/Az transformations using spherical trigonometry
- Equatorial ↔ Galactic coordinate system conversions
- Gnomonic/TAN projection for astrometry and plate solving
4. Astrometric Corrections
- [
precession] — Convert coordinates between epochs (J2000 ↔ current date) - [
nutation] — Earth's axis wobble (±18.6" longitude, ±9.2" obliquity) - [
aberration] — Annual stellar aberration (±20.5 arcseconds) - [
proper_motion] — Linear and rigorous 3D space motion calculations - [
parallax] — Diurnal and annual parallax corrections - [
refraction] — Atmospheric refraction (Bennett, Saemundsson, radio models)
5. Solar System Objects ([sun], [moon], [rise_set])
- Solar and lunar position calculations
- Rise, set, and meridian transit times for any celestial object
- Moon phase, illumination, and distance calculations
Accuracy & Standards
This library implements algorithms from:
- Jean Meeus: Astronomical Algorithms (2nd edition)
- IAU SOFA: Standards of Fundamental Astronomy
- ERFA: Essential Routines for Fundamental Astronomy
- USNO: US Naval Observatory references
Quick Example: Compute LST and Alt/Az for Vega
use ;
use ;
let dt = Utc.with_ymd_and_hms.unwrap;
let loc = Location ;
let jd = julian_date;
let lst = loc.local_sidereal_time;
let = ra_dec_to_alt_az.unwrap;
println!;
println!;
println!;
This computes the Julian Date, sidereal time, and sky position of Vega from Kitt Peak at 06:00 UTC on August 4, 2024.
You can verify this output against Astropy using:
=
=
=