Skip to main content

besselian2shape

Generate ESRI Shapefiles and Google Earth KML/KMZ files describing a solar eclipse's visibility from NASA's Besselian elements dataset: the central line, the umbral/antumbral path of totality or annularity, and the penumbral region from which at least a partial eclipse is visible.

Besselian elements are downloaded once from NASA's Five Millennium Canon of Solar Eclipses and cached locally.

Installation

pip install besselian2shape

Requires Python 3.11+.

CLI usage

besselian2shape YEAR MONTH DAY [options]

YEAR uses astronomical numbering for BCE dates (1 BCE is year 0, 2 BCE is year -1, etc.).

# Shapefiles (default) for the 2024 total eclipse, written to ./eclipse_2024-04-08
besselian2shape 2024 4 8

# KMZ file in a custom directory
besselian2shape 2017 8 21 -o out/ -f kmz

# Every format at once
besselian2shape 2024 10 2 -f all

Options:

Flag Default Description
-o, --output DIR ./eclipse_YYYY-MM-DD Output directory
-f, --format {shp,kml,kmz,all} shp Output format; may be repeated
--step-minutes MINUTES 0.5 Time resolution for sampling the central line and umbral path
--penumbral-resolution DEGREES 0.25 Grid resolution for the penumbral visibility boundary
--penumbral-step-minutes MINUTES 1.5 Time step for the penumbral visibility raster scan
--refresh-cache Re-download the Besselian elements dataset even if already cached

Negative-year (BCE) example:

besselian2shape -1999 6 12 -f kml

Shapefile output writes up to three layers into the output directory:

  • penumbral_path.shp -- polygon (all eclipse types)
  • central_line.shp -- polyline (total/annular/hybrid only)
  • umbral_path.shp -- polygon (total/annular/hybrid only)

KML/KMZ output writes a single file (eclipse.kml or eclipse.kmz) containing the same layers as separate placemarks.

Python API

from besselian2shape import generate_eclipse_shapefiles, generate_eclipse_kml

# Shapefiles
written = generate_eclipse_shapefiles(2024, 4, 8, "output_dir")
# {"penumbral_path": Path(...), "central_line": Path(...), "umbral_path": Path(...)}

# KML/KMZ (format is inferred from the output path's suffix)
generate_eclipse_kml(2024, 4, 8, "output_dir/eclipse.kmz")

Both functions raise LookupError if no eclipse occurred on the given date. Both accept the same optional keyword arguments:

  • csv_path: use a specific Besselian elements CSV instead of the cached download.
  • step_minutes (default 0.5): sampling density along the central line/umbral path.
  • penumbral_resolution_deg / penumbral_step_minutes (defaults 0.25, 1.5): grid resolution and time step for the penumbral coverage raster -- lower values are more accurate but slower.
  • elements: an already-looked-up BesselianElements instance, to avoid parsing the CSV twice when generating more than one format for the same eclipse:
from besselian2shape import find_by_date, generate_eclipse_shapefiles, generate_eclipse_kml

e = find_by_date(2024, 4, 8)
generate_eclipse_shapefiles(2024, 4, 8, "output_dir", elements=e)
generate_eclipse_kml(2024, 4, 8, "output_dir/eclipse.kmz", elements=e)

Other public functions

  • find_by_date(year, month, day, csv_path=None) -> BesselianElements
  • load_all(csv_path=None) -> list[BesselianElements]
  • download_besselian_csv(force=False) -> Path
  • get_cache_dir() -> Path
  • get_cached_csv_path() -> Path

BesselianElements is a frozen dataclass holding one eclipse's metadata (date, Saros number, gamma, magnitude, path width, etc.) and its raw Besselian polynomial coefficients (x0..x3, y0..y3, d0..d2, mu0..mu2, l10..l12, l20..l22, tan_f1, tan_f2, t0, tmin, tmax), as published in NASA's dataset.

Development

uv sync
uv run pytest

Release files for besselian2shape 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 besselian2shape 0.1.0
File Size Uploaded
besselian2shape-0.1.0.tar.gz 24.2 kB Details

Built distribution (wheel)

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

Total release size: 53.6 kB

Release files / besselian2shape-0.1.0.tar.gz

Download URL besselian2shape-0.1.0.tar.gz
Size 24.2 kB
Tags Source
SHA-256 checksum
How to use checksums
868ab61fabf7461b19b11507cba1f6e1e0dbd31fdb0d25993cfc5708c186902e
BLAKE2b-256 checksum
How to use checksums
ca16cd75a717ed82a8ced6d3bf2faf6197ef4eec69c9b78d00f6c4d0ed4a61e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

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

Download URL besselian2shape-0.1.0-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2f3e3b375046f87bf2249ef2a70b49fe78d587b44797c622cfccf571e3a1643
BLAKE2b-256 checksum
How to use checksums
4bdab0c06c5c94fcaf2237b774cadcdc207a62a2991b163219c7a5dc3f667d26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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