celestial-coords
Type-safe astronomical coordinate transformations between reference frames.
Pure Rust implementation of coordinate frame transformations with full aberration, light deflection, and Earth orientation support. Each frame is a distinct type to prevent accidental mixing. ICRS serves as the pivot for all transformations.
Installation
[]
= "0.1"
Coordinate Frames
| Frame | Description |
|---|---|
ICRSPosition |
International Celestial Reference System (catalog positions, J2000) |
CIRSPosition |
Celestial Intermediate Reference System (precession + nutation + bias) |
GCRSPosition |
Geocentric Celestial Reference System |
TIRSPosition |
Terrestrial Intermediate Reference System |
ITRSPosition |
International Terrestrial Reference System (ECEF) |
GalacticPosition |
Galactic coordinates (l, b) with IAU standard pole |
EclipticPosition |
Ecliptic coordinates with IAU 2006 obliquity |
TopocentricPosition |
Observer-specific azimuth/elevation |
HourAnglePosition |
Hour angle + declination for a given observer |
HeliographicCarrington |
Solar surface coordinates (Carrington rotation) |
HeliographicStonyhurst |
Solar surface coordinates (fixed grid) |
SelenographicPosition |
Lunar surface coordinates |
Modules
| Module | Purpose |
|---|---|
frames |
Coordinate frame types and conversions |
transforms |
CoordinateFrame trait, Cartesian utilities |
distance |
Distance type with parsec/AU/ly/km conversions |
eop |
Earth Orientation Parameters (polar motion, UT1-UTC) |
aberration |
Stellar aberration and gravitational light deflection |
lighttime |
Light-time correction for proper motion and radial velocity |
solar |
Solar orientation (B0, L0, P angle, Carrington rotation) |
lunar |
Lunar libration and orientation |
Example
use ;
use CoordinateFrame;
use TT;
// Create a position in ICRS (catalog coordinates)
let sirius = from_hours_degrees?;
// Transform to Galactic coordinates
let epoch = TTj2000;
let galactic = sirius.to_galactic?;
println!;
// With distance (parallax-derived)
let distance = from_parallax_milliarcsec?;
let proxima = from_degrees_with_distance?;
println!;
Transformation Chain
ICRS (catalog)
↓ frame bias + precession + nutation (IAU 2006A)
↓ stellar aberration (~20.5")
↓ gravitational light deflection (~1.75" max)
CIRS (geocentric apparent)
↓ Earth rotation (GAST)
TIRS
↓ polar motion (EOP)
ITRS (terrestrial)
All transformations use ICRS as the pivot frame. The CoordinateFrame trait provides:
Earth Orientation Parameters
Required for CIRS to ITRS transformations (polar motion, UT1-UTC):
use ;
// Load embedded baseline data (1962-present)
let mut eop = default.build?;
// Get parameters for a specific MJD
let params = eop.get?;
println!;
println!;
Features
serde- Serialization for coordinate types and EOP recordseop-download- Network download of EOP data (requiresserde)
Topocentric Observations
use ;
use ;
use TT;
let observer = from_degrees?; // Keck
let epoch = TTj2000;
let moon_distance = from_kilometers?;
let moon = with_distance?;
// Airmass (Rozenberg formula)
println!;
// Atmospheric refraction (standard conditions)
let refraction = moon.atmospheric_refraction;
println!;
// Diurnal parallax
let parallax = moon.diurnal_parallax.unwrap;
println!;
Solar and Lunar Coordinates
use ;
use compute_optical_libration;
use TT;
let epoch = TTj2000;
// Solar orientation
let solar = compute_solar_orientation;
println!;
println!;
println!;
// Lunar libration
let = compute_optical_libration;
println!;
License
Licensed under either of:
- Apache License, Version 2.0
- MIT License
Contributing
See the repository for contribution guidelines.