Skip to main content

astraeos-astro

The Sun's position in pure Python, ported from libastro, the C core of PyEphem.

It needs nothing but the Python standard library, so it installs anywhere Python runs, with no compiler. It matches PyEphem to within a few thousandths of an arcsecond. Helios, a Home Assistant integration, computes the Sun with it.

Read this in: English | Français

English

Install

pip install astraeos-astro

Python 3.10 or later.

Usage

from datetime import datetime, timezone
import astraeos_astro as astro

jd = astro.julian_day(datetime(2024, 6, 21, 12, 0, tzinfo=timezone.utc))
seen = astro.observe_sun(jd, latitude=48.8566, longitude=2.3522, elevation_m=35)
print(f"altitude {seen.altitude:.4f}°, azimuth {seen.azimuth:.4f}°")
# altitude 64.5363°, azimuth 183.9972°

position = seen.position
code = astro.constellation(
    position.astrometric_right_ascension,
    position.astrometric_declination,
    position.jd_tt,
)
print(code, astro.CONSTELLATION_NAMES[code])
# Gem Gemini
  • Angles are in degrees, longitudes positive east, and times in Julian days.
  • observe_sun takes Universal Time and applies ΔT itself; sun_position takes Terrestrial Time.
  • Altitude and azimuth are topocentric (parallax included) and without refraction. Azimuth is 0° north, 90° east.

What it computes

Module Port of Contents
timescales mjd.c, deltat.c, utc_gst.c Julian dates, ΔT, Greenwich mean sidereal time (IAU 1982)
vsop87 vsop87.c The Earth from VSOP87D (406 terms, as libastro keeps them), FK5
nutation obliq.c, nutation.c Mean obliquity, IAU 1980 nutation (106 terms)
frames eq_ecl.c, aberration.c, precess.c, parallax.c, aa_hadec.c Ecliptic to equator, nutation, aberration, precession, parallax, altitude and azimuth
sun sun.c, circum.c sun_position(jd_tt) and observe_sun(jd, latitude, longitude, elevation_m)
constellations constel.c IAU boundaries at B1875.0 (Roman's method), all 88 constellations

Accuracy against PyEphem 4.2.1

Value Largest difference
Altitude / azimuth 0.012″ / 0.05″
Apparent right ascension and declination < 0.001″
Distance < 10⁻⁷ AU (15 km)
ΔT identical
Constellation identical

Measured on 3,000 random moments and places from 1900 to 2100. The remaining differences come from PyEphem itself, which stores altitude, azimuth and distance in single precision.

Data tables

The _*_data.py modules hold libastro's tables: VSOP87, nutation, ΔT and constellation boundaries. scripts/extract_libastro.py regenerates them from the libastro folder of a PyEphem source distribution, byte for byte:

python scripts/extract_libastro.py path/to/ephem-4.2.1/libastro

Tests

pip install -e ".[test]"
pytest

PyEphem is only the reference the tests compare against; the tests that need it are skipped without it.

License

MIT. astraeos-astro ports libastro (Elwood Downey) and PyEphem (Brandon Rhodes), both under the MIT license, and Craig Counterman's precession routine. Their notices are in src/astraeos_astro/LICENSE.txt, which ships with the package.

Français

astraeos-astro calcule la position du soleil en Python pur, à partir d'une traduction de libastro, le cœur en C de PyEphem. Il ne dépend que de la bibliothèque standard de Python et s'installe partout sans compilateur. Il rejoint PyEphem à quelques millièmes de seconde d'arc près. Helios, une intégration Home Assistant, s'en sert pour calculer le soleil.

pip install astraeos-astro

Python 3.10 ou plus récent.

  • Les angles sont en degrés, les longitudes positives vers l'est et les dates en jours juliens.
  • observe_sun prend le temps universel et applique ΔT lui-même ; sun_position prend le temps terrestre.
  • La hauteur et l'azimut sont topocentriques (parallaxe comprise) et sans réfraction. L'azimut vaut 0° au nord, 90° à l'est.

L'exemple, le détail des modules et les mesures de précision sont dans la section en anglais. Les tables de données se régénèrent avec scripts/extract_libastro.py, et les tests se lancent avec pip install -e ".[test]" puis pytest.

Licence MIT. astraeos-astro traduit libastro (Elwood Downey) et PyEphem (Brandon Rhodes), tous deux sous licence MIT, ainsi que la routine de précession de Craig Counterman. Leurs mentions figurent dans src/astraeos_astro/LICENSE.txt, livré avec le paquet.

Metadata

Release files for astraeos-astro 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for astraeos-astro 0.1.0
File Size Uploaded Provenance Actions
astraeos_astro-0.1.0.tar.gz 25.8 kB With provenance Details for astraeos_astro-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for astraeos-astro 0.1.0
File Interpreter ABI Platform Actions
astraeos_astro-0.1.0-py3-none-any.whl Python 3 none any Details for astraeos_astro-0.1.0-py3-none-any.whl

Total release size: 53.3 kB

Release files / astraeos_astro-0.1.0.tar.gz

Download URL astraeos_astro-0.1.0.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ac7b9813e5766f344e8ef5540f406a0ae4432ea47635ce087859e3fe8feb4ab0
BLAKE2b-256 checksum
How to use checksums
19d10ab38795f5f138f02271eda041f592437b392405a812fce34901b19dac4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / astraeos_astro-0.1.0-py3-none-any.whl

Download URL astraeos_astro-0.1.0-py3-none-any.whl
Size 27.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdb500fb62ee76bc67f7964253d2cb4a9c71a72647e50168fea6579c487959ca
BLAKE2b-256 checksum
How to use checksums
597d7e000ebf0c321c070af26f6edeb677eb8a33ac61184a13027eec67c0bf54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for astraeos-astro 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for astraeos_astro-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page