Solar and lunar eclipse lookup from NASA's full Saros catalog (Saros 1–180)
Project description
saros-eclipse
Solar and lunar eclipse lookup from NASA's full Saros catalog.
Covers all 180 solar and 180 lunar Saros series — 13 206 solar and 12 223 lunar eclipses spanning several millennia. Data is read from pre-built binary files bundled with the package; no network access or C compilation is required.
Installation
pip install saros-eclipse
Requires Python ≥ 3.11.
Quick start
from datetime import datetime, timezone
import saros
now = datetime.now(timezone.utc)
# Next solar eclipse, plus its Saros-series neighbours
result = saros.find_next_solar_eclipse(now)
if result.eclipse:
e = result.eclipse
print(f"Next solar: {e.time:%Y-%m-%d %H:%M} UTC")
print(f" type={e.type} saros={e.saros_number}[{e.saros_pos}]")
print(f" lat={e.latitude:.1f}° lon={e.longitude:.1f}°")
if e.central_duration is not None:
print(f" central duration={e.central_duration}s")
if result.saros_next:
print(f" next in series: {result.saros_next.time:%Y-%m-%d}")
# Saros 145 window (the series that produced the Aug 2017 eclipse)
window = saros.find_solar_saros_window(now, 145)
if window.past:
print(f"Saros 145 was last: {window.past.time:%Y-%m-%d}")
if window.future:
print(f"Saros 145 next: {window.future.time:%Y-%m-%d}")
# Nearest lunar eclipse
lunar = saros.find_closest_lunar_eclipse(now)
if lunar.eclipse:
e = lunar.eclipse
print(f"Closest lunar: {e.time:%Y-%m-%d} type={e.type} "
f"saros={e.saros_number}")
if e.total_duration is not None:
print(f" totality={e.total_duration}s ({e.total_duration//60} min)")
API
All functions accept a timestamp as a datetime (aware or naive-UTC), or an
int/float Unix timestamp.
Solar
saros.find_next_solar_eclipse(ts) -> EclipseResult[SolarEclipse]
saros.find_past_solar_eclipse(ts) -> EclipseResult[SolarEclipse]
saros.find_closest_solar_eclipse(ts) -> EclipseResult[SolarEclipse]
saros.find_solar_saros_window(ts, saros_number: int) -> SarosWindow[SolarEclipse]
Lunar
saros.find_next_lunar_eclipse(ts) -> EclipseResult[LunarEclipse]
saros.find_past_lunar_eclipse(ts) -> EclipseResult[LunarEclipse]
saros.find_closest_lunar_eclipse(ts) -> EclipseResult[LunarEclipse]
saros.find_lunar_saros_window(ts, saros_number: int) -> SarosWindow[LunarEclipse]
Return types
EclipseResult[T]
| Field | Type | Description |
|---|---|---|
eclipse |
T | None |
The matched eclipse, None if out of dataset range |
saros_prev |
T | None |
Previous eclipse in the same Saros series |
saros_next |
T | None |
Next eclipse in the same Saros series |
SarosWindow[T]
| Field | Type | Description |
|---|---|---|
saros_number |
int |
The queried Saros series |
past |
T | None |
Most recent eclipse in the series before ts |
future |
T | None |
Next eclipse in the series at or after ts |
SolarEclipse
| Field | Type | Description |
|---|---|---|
time |
datetime |
Greatest-eclipse moment (UTC) |
global_index |
int |
Flat index in the dataset |
saros_number |
int |
Saros series (1–180) |
saros_pos |
int |
0-based position within the series |
type |
SolarEclipseType |
Eclipse type |
latitude |
float |
Geographic latitude of greatest eclipse (°N) |
longitude |
float |
Geographic longitude of greatest eclipse (°E) |
central_duration |
int | None |
Central-path duration in seconds; None if n/a |
sun_altitude |
int |
Sun altitude above horizon at greatest eclipse (°) |
LunarEclipse
| Field | Type | Description |
|---|---|---|
time |
datetime |
Greatest-eclipse moment (UTC) |
global_index |
int |
Flat index in the dataset |
saros_number |
int |
Saros series (1–180) |
saros_pos |
int |
0-based position within the series |
type |
LunarEclipseType |
Eclipse type |
penumbral_duration |
int | None |
Penumbral phase duration in seconds |
partial_duration |
int | None |
Partial phase duration in seconds |
total_duration |
int | None |
Total phase duration in seconds |
Eclipse types
Solar (SolarEclipseType): A, Aplus (A+), Aminus (A-), Am, An, As,
H, H2, H3, Hm, P, Pb, Pe, T, Tplus (T+), Tminus (T-), Tm, Tn, Ts
Lunar (LunarEclipseType): N, Nb, Ne, Nx, P, Pb, Pe,
T, Tplus (T+), Tminus (T-), Tm, Tn, Ts
str(eclipse_type) returns the canonical NASA code (e.g. "T+", "A-").
Data source
Fred Espenak, NASA/GSFC (retired) — Solar Saros Series / Lunar Saros Series
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saros_eclipse-0.1.1.tar.gz.
File metadata
- Download URL: saros_eclipse-0.1.1.tar.gz
- Upload date:
- Size: 392.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b049384bf01dadfe2f865e8249b8b409d5eeb1cafbefb2381cd25270be6e60a6
|
|
| MD5 |
4c6b5ab95988dc451f776d3943855c3e
|
|
| BLAKE2b-256 |
ee0f1465ccba919223bf2c991c913342030e93d5c4664e3652cd05e23ff91161
|
File details
Details for the file saros_eclipse-0.1.1-py3-none-any.whl.
File metadata
- Download URL: saros_eclipse-0.1.1-py3-none-any.whl
- Upload date:
- Size: 386.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb708fc9dba8ed817bbc1ac764b01da3553ca0f98692c4ac8be16a6e6357a4ef
|
|
| MD5 |
8a3e8c645766de82827f639827336d88
|
|
| BLAKE2b-256 |
d09a62079401bcbe768a081909398b2dd80a3eef4b96f688cb32048f5ae2474e
|