Skip to content
/ astroz Public

Astrodynamics and Spacecraft Toolkit Written in Zig! Features orbit prop, celestial precession, CCSDS parsing, RF parsing, fits image parsing, and more!

License

Notifications You must be signed in to change notification settings

ATTron/astroz

Repository files navigation

CI CD DC

Astronomical and Spacecraft Toolkit Written in Zig

Featuring the fastest CPU based open source SGP4 propagator

Orbital Mechanics Spacecraft Ops Astronomy
SGP4 propagation CCSDS packets FITS parsing
TLE parsing VITA49 packets WCS coordinates
Orbital maneuvers Attitude determination Star precession
Monte Carlo sims Celestial bodies

Performance

Sub-meter accuracy validated against reference implementations. Uses SIMD (AVX512/AVX2) to process 8 satellites simultaneously, with multithreaded constellation propagation across all available cores.

Single-Threaded (1.2M propagations, single satellite)

Implementation Props/sec Speedup vs python-sgp4
astroz 30.8M 11x
Rust sgp4 5.1M 1.8x
heyoka 3.8M 1.3x
satkit 3.5M 1.2x
python-sgp4 2.8M 1x

Multi-Threaded Constellation (13,478 satellites × 1,440 times)

Implementation 1 Thread 16 Threads
astroz 37.7M/s 303M/s
heyoka 15.7M/s 155.6M/s
Rust sgp4 (rayon) 4.4M/s 47.9M/s
satkit 3.5M/s 3.5M/s
python-sgp4 2.7M/s 2.7M/s

Benchmarked on AMD Ryzen 7 7840U (16 threads). All implementations using their optimal configurations (SIMD, pre-allocated outputs, batch mode).

Uses SIMD (AVX512 for 8-wide, AVX2/SSE for 4-wide) with multithreaded time-major iteration. Validated against Vallado AIAA 2006-6753 reference vectors (< 10m position error, < 1µm/s velocity error). Set ASTROZ_THREADS environment variable to control thread count (defaults to all available cores).

The Cesium visualization example propagates the entire active satellite catalog (~13,000 satellites) at interactive rates. Try the live demo →

Python

pip install astroz

python-sgp4 Compatible API (Recommended)

Drop-in replacement for python-sgp4. Just change the import for instant speedup:

# Before                                    # After
from sgp4.api import Satrec, jdayfrom astroz.api import Satrec, jday
Your Code python-sgp4 astroz Speedup
sat.sgp4() loop 1.3M/s 2.5M/s 2x
sat.sgp4_array() 2.7M/s 15M/s 5x
SatrecArray.sgp4() 3M/s 290M/s 100x

See migration guide for optimization tips.

from astroz.api import Satrec, SatrecArray, jday, WGS72
import numpy as np

# Single satellite (same syntax as python-sgp4)
line1 = "1 25544U 98067A   24127.82853009  .00015698  00000+0  27310-3 0  9995"
line2 = "2 25544  51.6393 160.4574 0003580 140.6673 205.7250 15.50957674452123"
sat = Satrec.twoline2rv(line1, line2, WGS72)

jd, fr = jday(2024, 5, 6, 12, 0, 0.0)
error, position, velocity = sat.sgp4(jd, fr)

# Batch propagation (270-330M props/sec with SIMD)
sat_array = SatrecArray([sat1, sat2, ...])  # List of Satrec objects

# Single time point (scalars)
e, r, v = sat_array.sgp4(2460000.5, 0.5)

# Multiple time points (arrays)
jd = np.full(1440, 2460000.5)
fr = np.linspace(0, 1, 1440)
e, r, v = sat_array.sgp4(jd, fr)  # (n_sats, n_times, 3)

# Skip velocities for 30% faster propagation
e, r, _ = sat_array.sgp4(jd, fr, velocities=False)

High-Level API

Convenience functions for common workflows:

from astroz import propagate, Constellation
import numpy as np

# Load and propagate - automatically optimized for maximum performance
positions = propagate("starlink", np.arange(1440))  # 1 day at 1-min intervals
# shape: (1440, num_satellites, 3) in km, ECEF coordinates

# With options
from datetime import datetime, timezone
positions = propagate(
    "starlink",
    np.arange(1440),
    start_time=datetime(2024, 6, 15, tzinfo=timezone.utc),
    output="geodetic",  # "ecef" (default), "teme", or "geodetic"
)

# With velocities
positions, velocities = propagate("starlink", np.arange(1440), velocities=True)

# For repeated propagation, pre-parse to avoid overhead
c = Constellation("starlink")
positions = propagate(c, np.arange(1440))

Usage

  • Add astroz as a dependency in your build.zig.zon.
zig fetch --save https://github.com/ATTron/astroz/archive/<git_tag_or_commit_hash>.tar.gz
#or
zig fetch --save git+https://github.com/ATTron/astroz/#HEAD
  • Use astroz as a module in your build.zig.
const astroz_dep = b.dependency("astroz", .{
    .target = target,
    .optimize = optimize,
});
const astroz_mod = astroz_dep.module("astroz");
exe.root_module.addImport("astroz", astroz_mod);

Examples

Orbital Mechanics

  • Demonstrates interplanetary transfers with mission planning (Hohmann vs Bi-Elliptic comparison) and trajectory propagation.

  • Comprehensive example showing TLE-based orbit propagation with various maneuver types: impulse, plane change, and phase change.

  • Statistical analysis for mission planning with uncertainty.

  • Analytical orbit propagation using SGP4 with TLE input. Demonstrates both direct SGP4 usage and the modular propagator interface.

  • Interactive 3D visualization of the entire near-earth satellite catalog (~13,000 satellites) using Cesium. Features multithreaded SGP4 propagation at ~300M props/sec, constellation filtering, search, and satellite tracking.

Spacecraft Operations

Telemetry & Data Handling

Astronomy & Astrometry

sample fits image as png

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •