Skip to main content

Library to provide planetary constants

Project description

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.

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

planets-0.9.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

planets-0.9.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file planets-0.9.1.tar.gz.

File metadata

  • Download URL: planets-0.9.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for planets-0.9.1.tar.gz
Algorithm Hash digest
SHA256 c86abe021e221b27bf262c718c56c9e2223455129f7b8979dae0166c999cc7eb
MD5 76537bfba60bff7ea31a3f1af0c21dcb
BLAKE2b-256 35fc64e5c1a054f59798bad35d3e7190491c7648516542900ecbb849c06b5d39

See more details on using hashes here.

File details

Details for the file planets-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: planets-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for planets-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b57a654018f3806ab283796aaa3e87194d7f729a69970fb3ee3fcaefbb3b92e
MD5 1f589dbd171aabd4a3d5021eeba8dcec
BLAKE2b-256 f98d42f8cfc523c1feba01928c8fd39fcf2eeb446a84586c9b9b74effe798dc3

See more details on using hashes here.

Supported by

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