#astronomy #iau #sofa

sofars

Pure Rust implementation of the IAU SOFA library

22 unstable releases (5 breaking)

Uses new Rust 2024

new 0.6.0 Feb 27, 2026
0.5.1 Feb 26, 2026
0.4.5 Feb 25, 2026
0.3.3 Jul 7, 2025
0.1.7 Mar 24, 2025

#133 in Date and time

MIT license

1MB
21K SLoC

Sofars

Build Status Crates.io Downloads Documentation Rust

中文

sofars is a pure Rust implementation of the International Astronomical Union's (IAU) official Standards of Fundamental Astronomy (SOFA). It provides a comprehensive, efficient, and industry-standard set of astronomical calculation tools for high-precision time scale transformations, coordinate system conversions, and fundamental astronomical modeling.

Key Features

  • Standard Compliance: Strictly follows IAU 2000/2006 models, ensuring numerical consistency with the original SOFA C library.
  • Pure Rust: No C compiler required. Enjoy Rust's memory safety, concurrency, and performance.
  • Comprehensive Coverage:
    • Time Scales (ts): Precise transformations between UTC, TAI, TT, TDB, TCG, TCB, and more.
    • Precession, Nutation & Polar Motion (pnp): Full implementation of IAU precession and nutation series.
    • Fundamental Astrometry (astro): Core algorithms for apparent star positions, refraction, etc.
    • Coordinate Systems (coords): Conversions between geocentric, heliocentric, and spherical systems.
    • Vector & Matrix Operations (vm): 3D vector and rotation matrix utilities optimized for astronomy.
    • Calendars (cal): Transformations between Julian Dates and Gregorian calendar dates.

Installation

Add the following to your Cargo.toml:

[dependencies]
sofars = "0.5.0"

Quick Start

The following example shows how to calculate the Earth Rotation Angle (ERA) for a given Julian Date:

use sofars::consts::DJ00;
use sofars::ts::era00;

fn main() {
    // 2000 January 1, 12:00 (TT)
    let tt1 = DJ00;
    let tt2 = 0.5; 
    
    let era = era00(tt1, tt2);
    println!("Earth Rotation Angle: {} radians", era);
}

Documentation

For detailed API documentation and function lists, please visit docs.rs/sofars.

License & SOFA Terms of Use

This project is licensed under the MIT License.

Important Note: Since the core algorithms are derived from the IAU SOFA source code, any use of this project must also comply with the SOFA license terms.

  • Any published work or commercial product that includes results obtained using sofars should acknowledge the use of algorithms provided by the IAU SOFA Board.
  • Please refer to the LICENSE file for full details.

No runtime deps