Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

CrateUse it to
celestial-corework with angles, vectors and rotation matrices, and run the IAU precession, nutation and Earth orientation models
celestial-timeconvert between UTC, TAI, TT, UT1, GPS, TDB, TCB and TCG, and compute sidereal time
celestial-coordsmove positions through ICRS, GCRS, CIRS, TIRS and ITRS to hour angle and azimuth/elevation
celestial-ephemeriscompute Sun, Moon and planet positions from VSOP2013 and ELP/MPP02, or read JPL SPK kernels
celestial-wcsconvert between pixel and sky coordinates with FITS WCS headers
celestial-imagesread and write FITS, XISF, SER, PNG and TIFF
celestial-catalogrun cone searches on a Gaia DR3 and Hipparcos star catalog
celestial-solverplate-solve an image and write the WCS solution back to its header
celestial-pointingfit 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.