Celestial
Celestial is a set of Rust crates for astronomy software: time scales, the IAU coordinate chain, ephemerides, images, WCS, telescope pointing models, a star catalog and a plate solver.
Everything runs in pure Rust, with no C or Fortran underneath. The IAU precession, nutation and Earth orientation models are tested against ERFA output with exact equality. For those models you get the same numbers as ERFA, in a binary you can cross-compile without a C toolchain and step through in a debugger.
A first example
Here’s a star going from its catalog position to azimuth and elevation at Keck:
use celestial_coords::eop::EopProvider;
use celestial_coords::frames::cirs::CIRSPosition;
use celestial_coords::frames::icrs::ICRSPosition;
use celestial_coords::transforms::CoordinateFrame;
use celestial_core::constants::MJD_ZERO_POINT;
use celestial_core::location::Location;
use celestial_time::julian::JulianDate;
use celestial_time::scales::conversions::{ToTAI, ToTT};
use celestial_time::scales::utc::UTC;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// EOP tables are indexed by UTC MJD; precession and nutation take TT.
let mjd = 60000.35;
let utc = UTC::from_julian_date(JulianDate::new(MJD_ZERO_POINT, mjd));
let epoch = utc.to_tai()?.to_tt()?;
let eop = EopProvider::bundled()?.get(mjd)?;
let keck = Location::from_degrees(19.8283, -155.4783, 4145.0)?;
let sirius = ICRSPosition::from_hours_degrees(6.7525, -16.716)?;
let cirs = CIRSPosition::from_icrs(&sirius, &epoch)?;
let hour_angle = cirs.to_hour_angle(&keck, &eop)?;
let horizon = hour_angle.to_topocentric()?;
println!(
"HA = {:.3} h, az = {:.2}°, el = {:.2}°",
hour_angle.hour_angle().hours(),
horizon.azimuth().degrees(),
horizon.elevation().degrees()
); // HA = 1.595 h, az = 214.36°, el = 46.53°
Ok(())
}
Each step takes the input its physics needs. Precession and nutation need a TT epoch, the Earth’s rotation needs Earth orientation parameters, and the horizon needs a site. Each frame is its own type, so you can’t skip a step by accident. EopProvider::bundled() reads the IERS tables that ship with celestial-coords, so this works offline.
The crates
| Crate | Use it to |
|---|---|
celestial-core | work with angles, vectors and rotation matrices, and run the IAU precession, nutation and Earth orientation models |
celestial-time | convert between UTC, TAI, TT, UT1, GPS, TDB, TCB and TCG, and compute sidereal time |
celestial-coords | move positions through ICRS, GCRS, CIRS, TIRS and ITRS to hour angle and azimuth/elevation |
celestial-ephemeris | compute Sun, Moon and planet positions from VSOP2013 and ELP/MPP02, or read JPL SPK kernels |
celestial-wcs | convert between pixel and sky coordinates with FITS WCS headers |
celestial-images | read and write FITS, XISF, SER, PNG and TIFF |
celestial-catalog | run cone searches on a Gaia DR3 and Hipparcos star catalog |
celestial-solver | plate-solve an image and write the WCS solution back to its header |
celestial-pointing | fit and apply pointing models for equatorial mounts |
celestial-core depends on no other crate in the workspace. time and wcs build on core, and the rest build on those. The plate solver uses the most: coords, wcs, images and catalog.
What this book covers
Each section starts with the problem its crate solves. Each crate’s README has a short example and the API details.
- To use angles, vectors and rotation matrices, read Angles and Vectors & Rotation Matrices.
- To understand why catalog coordinates need precession and nutation, and how the CIO-based and equinox-based chains relate, read Precession, Nutation & Obliquity and The CIO and the Equinox. Ecliptic Coordinates and Observer Locations cover the other frames and the observer.
- To pick the right time scale, handle leap seconds or compute sidereal time, start with Time Scales.
- To turn a catalog position into where a star appears in your sky, read From Catalog to Horizon, or go straight to Find the Altitude and Azimuth of a Star.
- To find where a planet, the Sun or the Moon is, start with Planets, Sun and Moon. Accuracy says how close the built-in series come to the JPL ephemerides, and JPL SPK Kernels covers reading a kernel when you need more.
- To convert between pixels and sky coordinates with a FITS WCS, read Pixels and Sky Coordinates.
- To read or write FITS, XISF or SER files, start with Open and Save Images.
- To find the stars around a sky position, or to choose and download a catalog file, start with Star Catalog.
- To find where an image points, follow Solve Your First Image.
- To build a pointing model from a night of observations, start with Pointing Models. The pointing crate is still experimental.