Skip to main content

Python bindings for astroz - high-performance astrodynamics library

Project description

astroz Python Bindings

High-performance SGP4 satellite propagation, powered by Zig with SIMD acceleration (AVX512/AVX2).

Platforms: macOS, Linux | Requires: Python 3.10+

Quick Start

python-sgp4 Compatible API (Recommended)

Drop-in replacement for python-sgp4:

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

# Single satellite (same syntax as python-sgp4)
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(satrecs)
e, r, v = sat_array.sgp4(jd, fr)  # Scalars or arrays

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

High-Level API

from astroz import propagate
import numpy as np

# Load and propagate - automatically optimized for 300M+ props/sec
positions = propagate("starlink", np.arange(1440))  # 1 day at 1-min intervals
# positions: (1440, num_satellites, 3) in km, ECEF coordinates

Loading Sources

from astroz import propagate, Constellation

# CelesTrak groups
positions = propagate("starlink", times)
positions = propagate("iss", times)
positions = propagate("gps", times)
positions = propagate("all", times)  # ~13k active satellites

# By NORAD ID
positions = propagate(None, times, norad_id=25544)  # ISS
positions = propagate(None, times, norad_id=[25544, 48274])  # Multiple

# Local file or URL
positions = propagate("satellites.tle", times)
positions = propagate("https://example.com/tles.txt", times)

# For repeated propagation, pre-parse to avoid overhead
c = Constellation("starlink")
positions1 = propagate(c, times1)
positions2 = propagate(c, times2)

Groups: all, starlink, oneweb, planet, spire, gps, glonass, galileo, beidou, stations/iss, weather, geo

Propagation

from astroz import propagate, Constellation
from datetime import datetime, timezone
import numpy as np

times = np.arange(1440)  # 1 day at 1-min intervals

# Simple (defaults: now UTC, ECEF output)
positions = propagate("starlink", times)

# With options
positions = propagate(
    "starlink",
    np.arange(14 * 1440),  # 2 weeks
    start_time=datetime(2024, 6, 1, tzinfo=timezone.utc),
    output="geodetic",  # "ecef" (default), "teme", or "geodetic"
)

# With velocities
positions, velocities = propagate("starlink", times, velocities=True)

Conjunction Screening

from astroz import screen
import numpy as np

times = np.arange(1440)

# Single target (fastest - uses fused propagate+screen, no full position array)
min_dists, min_t_indices = screen("starlink", times, threshold=50.0, target=0)
# Returns per-satellite minimum distance to target and time index

# All-vs-all screening
pairs, t_indices = screen("starlink", times, threshold=10.0)
# Returns all conjunction events within threshold

Migrating from python-sgp4

Step 1: Change the Import (2x faster)

# Before
from sgp4.api import Satrec, SatrecArray, jday

# After
from astroz.api import Satrec, SatrecArray, jday

That's it. Your existing code works unchanged and runs 2x faster.

Step 2: Use Batch Methods (5-12x faster)

If you have loops, switch to batch methods:

# Before: loop (1.3M props/sec)
results = []
for jd, fr in zip(jd_list, fr_list):
    e, r, v = sat.sgp4(jd, fr)
    results.append(r)

# After: batch (15M props/sec) - 12x faster
jd_array = np.array(jd_list)
fr_array = np.array(fr_list)
e, r, v = sat.sgp4_array(jd_array, fr_array)

Step 3: Use SatrecArray for Multiple Satellites (100x faster)

# Before: loop over satellites (1.3M props/sec)
for sat in satellites:
    e, r, v = sat.sgp4_array(jd, fr)

# After: batch all satellites (290M props/sec) - 100x faster
sat_array = SatrecArray(satellites)
e, r, v = sat_array.sgp4(jd, fr)

Step 4: Skip Velocities If Not Needed (30% faster)

# If you only need positions
e, r, _ = sat_array.sgp4(jd, fr, velocities=False)

Performance Summary

Pattern 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

Compatibility Notes

astroz supports the core python-sgp4 API for satellite propagation. Some rarely-used attributes are not implemented:

  • TLE metadata: classification, intldesg, elnum, revnum, ephtype
  • Intermediate elements: Om, am, em, im, mm, nm, om (osculating elements after propagation)
  • Element rates: argpdot, mdot, nodedot
  • Gravity constants: j2, j3, j4, mu, etc. (available via astroz.constants)

For typical satellite tracking and visualization, astroz is a full drop-in replacement.

Performance

Constellation (13,478 sats x 1,440 steps) Throughput
1 thread 37.7M props/sec
16 threads 303M props/sec

Benchmarked on AMD Ryzen 7 7840U with AVX512.

Set ASTROZ_THREADS to control thread count (defaults to all cores).

Building

Requires Zig and Python 3.10+.

cd bindings/python
pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astroz-0.7.1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

astroz-0.7.1-cp312-cp312-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

astroz-0.7.1-cp312-cp312-macosx_15_0_universal2.whl (418.2 kB view details)

Uploaded CPython 3.12macOS 15.0+ universal2 (ARM64, x86-64)

astroz-0.7.1-cp311-cp311-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

astroz-0.7.1-cp311-cp311-macosx_15_0_universal2.whl (418.5 kB view details)

Uploaded CPython 3.11macOS 15.0+ universal2 (ARM64, x86-64)

astroz-0.7.1-cp310-cp310-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

Details for the file astroz-0.7.1.tar.gz.

File metadata

  • Download URL: astroz-0.7.1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for astroz-0.7.1.tar.gz
Algorithm Hash digest
SHA256 2898d848888c973a2c059ce06e1cab625afff4b4d25b6b57765329053d13f410
MD5 6bf3d44d2efd39d39d2a5580e11bc1d9
BLAKE2b-256 8491c2425f9e24ec69dd535672a9b729b9079b104393b203dc4b3cdffbd39b25

See more details on using hashes here.

Provenance

The following attestation bundles were made for astroz-0.7.1.tar.gz:

Publisher: python.yaml on ATTron/astroz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file astroz-0.7.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for astroz-0.7.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 31d90f4abeb61842dbc3d2145dccbb6208663dc224f34489bf98c97c00520912
MD5 2991fedcfc1d334628628de357e3d168
BLAKE2b-256 25c3dc0e48009690c5033b97529e0bfe9bd733416530129dc30faf521a618873

See more details on using hashes here.

Provenance

The following attestation bundles were made for astroz-0.7.1-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: python.yaml on ATTron/astroz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file astroz-0.7.1-cp312-cp312-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for astroz-0.7.1-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 1cc9a1a24d176ecc0c7af449f81250108fcdec1f21141b1b788bf59f5b2e3ae7
MD5 07eeaf64b1104eadd0a01b68739b6ad4
BLAKE2b-256 980a968e0d4f42ae2f8af44733ef31963cd035e6c4b12e22d429ac2cb32e3b82

See more details on using hashes here.

Provenance

The following attestation bundles were made for astroz-0.7.1-cp312-cp312-macosx_15_0_universal2.whl:

Publisher: python.yaml on ATTron/astroz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file astroz-0.7.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for astroz-0.7.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 aa455c6bd9c9992a37bc76672367358c9d38276826d153ecbde2b9f587a2f7c3
MD5 5af56144e9689338f12a880abcd4b98e
BLAKE2b-256 0e9038dd81ff68ec53b3f6045d7631e0e7ebb86fe848ffc064deb083a8132dc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for astroz-0.7.1-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: python.yaml on ATTron/astroz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file astroz-0.7.1-cp311-cp311-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for astroz-0.7.1-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 9278a88ab549ab663373e24095c9213c97846b6f5437ebc0dec856f34c4b52f4
MD5 5498339d40e6a5a2128b2ea815677763
BLAKE2b-256 4c338bcb15e6756608118cb172fc170821a5448ff22da39ca5e08bac2d34ed2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for astroz-0.7.1-cp311-cp311-macosx_15_0_universal2.whl:

Publisher: python.yaml on ATTron/astroz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file astroz-0.7.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for astroz-0.7.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 20bfa35636d5dbef32933fe1be53cfee60cf78a70d7f0c15c618d5c18e8a2f8d
MD5 06a63709fa95a375c83a2acc47df0dec
BLAKE2b-256 e1bf4e9440087f25b2571aad4f905fbb41b0e5fea8aa9666108cdbc5b9dcc63d

See more details on using hashes here.

Provenance

The following attestation bundles were made for astroz-0.7.1-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: python.yaml on ATTron/astroz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page