Skip to main content

planets

PyPI Version Build Status Documentation Status Updates

Library to provide planetary constants

Package Structure

This package uses modern Python packaging with pyproject.toml for configuration and Hatch for build management. See the changelog file for more information about changes.

  • Version: 0.9
  • Python 3.7+ compatible

Development with Hatch

This project uses Hatch for build management, testing, and publishing:

# Install Hatch
pip install hatch

# Activate development environment
hatch shell

# Run tests
hatch run test:pytest

# Build package
hatch build

# Install in development mode
pip install -e .

Features

  • Provides planetary constants for all major solar system bodies
  • Includes complete radii information from SPICE PCK kernels
  • Easy access to body properties by name or NAIF ID

API Usage

You can access planetary data programmatically in your Python code:

# Import specific planets
from planets import Earth, Mars, Jupiter

# Access planetary properties
print(f"Earth's radius: {Earth.R} meters")
print(f"Mars' gravity: {Mars.g} m/s²")
print(f"Jupiter's sidereal length of year [s]: {Jupiter.year} seconds")

# Get list of all available bodies (new helper function)
from planets import get_all_bodies

available_bodies = get_all_bodies()
print(f"Available bodies: {available_bodies}")

# Retrieve body attributes with units
radius_km = Earth.R / 1000
orbit_years = Earth.year / (365.25 * 24 * 3600)
print(f"Earth's radius: {radius_km:.1f} km")
print(f"Earth's orbital period: {orbit_years:.2f} years")

Command Line Interface

The package includes a command-line interface for quick access to planetary data:

# List all available planetary bodies
planets --list

# Show all attributes for a specific body with units
planets --body Earth

# Show version information
planets --version

# Show help information
planets --help

Example output for planets --body Mars:

Attributes for Mars:
-------------------
S               = 589.2 W/m²
Tsavg           = 210.0 K
Tsmax           = 290.0 K
albedo          = 0.25 fraction
day             = 88775.244147 seconds
eccentricity    = 0.0934
emissivity      = 0.95 fraction
g               = 3.71 m/s²
name            = Mars
obliquity       = 25.19 radians
psurf           = 636.0 Pa
rAU             = 1.52366231 AU
rsm             = 2.27939366e+11 meters
year            = 59354294.4 seconds

Data Sources

Since version 0.6, planetary radii data is read directly from the official NASA SPICE Planetary Constants Kernel (PCK) version 0.11. This ensures that all radius values are consistent with the most widely used planetary constants in the scientific community. The package automatically downloads and parses the necessary SPICE kernel files using the pooch library.

SPICE PCK data provides authoritative values for:

  • Equatorial radius
  • Polar radius
  • Mean radius
  • Other shape parameters

Credits

Planetary Database

Modified by Paul Hayne from the "planets.py" library by Raymond T. Pierrehumbert

Last modified: June, 2017

Sources:

  1. http://nssdc.gsfc.nasa.gov/planetary/factsheet/
  2. Lang, K. (2012). Astrophysical data: planets and stars. Springer Science & Business Media.

Python packaging

This package was created with Cookiecutter and the forked michaelaye/cookiecutter-pypackage-conda project template.

Metadata

Release files for planets 0.9.1

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

Source distribution (sdist)

Source distribution for planets 0.9.1
File Size Uploaded
planets-0.9.1.tar.gz 17.9 kB Details

Built distribution (wheel)

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

Total release size: 33.7 kB

Release files / planets-0.9.1.tar.gz

Download URL planets-0.9.1.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c86abe021e221b27bf262c718c56c9e2223455129f7b8979dae0166c999cc7eb
BLAKE2b-256 checksum
How to use checksums
35fc64e5c1a054f59798bad35d3e7190491c7648516542900ecbb849c06b5d39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / planets-0.9.1-py3-none-any.whl

Download URL planets-0.9.1-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b57a654018f3806ab283796aaa3e87194d7f729a69970fb3ee3fcaefbb3b92e
BLAKE2b-256 checksum
How to use checksums
f98d42f8cfc523c1feba01928c8fd39fcf2eeb446a84586c9b9b74effe798dc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

0.9.1 This release

2 release files

0.9

2 release files

0.8

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.1.0

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