Skip to main content

Spacecraft ephemeris made easy — auto-managed SPICE kernels for heliophysics missions

Project description

xhelio-spice

Spacecraft ephemeris made easy — auto-managed SPICE kernels for heliophysics missions.

xhelio-spice wraps SpiceyPy with automatic kernel download, caching, and loading. Ask for a spacecraft position and xhelio-spice handles the rest: downloading the right NAIF kernels, loading them in the correct order, and returning results as Python dicts or pandas DataFrames.

Installation

pip install xhelio-spice

For MCP server support (Claude Desktop, Claude Code, Cursor, etc.):

pip install xhelio-spice[mcp]

Quick Start

from xhelio_spice import get_position, get_trajectory

# Where is Parker Solar Probe right now?
pos = get_position("PSP", observer="SUN", time="2024-01-15", frame="ECLIPJ2000")
print(f"PSP is {pos['r_au']:.3f} AU from the Sun")

# Get a month of trajectory data as a DataFrame
df = get_trajectory(
    "PSP", observer="SUN",
    time_start="2024-01-01", time_end="2024-01-31",
    step="1h", frame="ECLIPJ2000",
)
print(df[["r_au"]].describe())

Kernels are automatically downloaded from NAIF on first use and cached in ~/.xhelio_spice/kernels/.

Supported Missions

With SPICE Kernels (auto-downloaded)

  • PSP (Parker Solar Probe) — 2018-2030
  • Solar Orbiter (SOLO) — 2020-2030
  • STEREO-A — 2017-2031
  • Juno — 2011-present (updated regularly)
  • Voyager 1/2 — 1981-2100 / 1989-2100
  • New Horizons — 2019-2030

NAIF IDs Only (no auto-download yet)

  • ACE, Wind, DSCOVR, MMS (1-4) — no public SPK kernels exist
  • Cassini, MAVEN — require multi-segment kernel loading (planned)
  • Galileo, Pioneer 10/11, Ulysses, MESSENGER, STEREO-B

Natural Bodies

Sun, Earth, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto

API Reference

Position & Trajectory

from xhelio_spice import get_position, get_trajectory, get_state

# Single position
pos = get_position("ACE", observer="EARTH", time="2024-06-01", frame="GSE")

# Full state (position + velocity)
state = get_state("PSP", observer="SUN", time="2024-01-15", frame="ECLIPJ2000")

# Trajectory timeseries (returns pandas DataFrame)
df = get_trajectory(
    "Cassini", observer="SATURN",
    time_start="2010-01-01", time_end="2010-12-31",
    step="6h", frame="ECLIPJ2000",
    include_velocity=True,
)

Coordinate Transforms

from xhelio_spice import transform_vector, list_available_frames

# J2000 to Ecliptic
v_ecl = transform_vector([1.0, 0.0, 0.0], "2024-01-15", "J2000", "ECLIPJ2000")

# RTN transform (requires spacecraft)
v_rtn = transform_vector(
    [5.0, -3.0, 1.0], "2024-01-15",
    from_frame="ECLIPJ2000", to_frame="RTN",
    spacecraft="PSP",
)

# List all frames
print(list_available_frames())

Mission Registry

from xhelio_spice import resolve_mission, list_supported_missions

# Resolve name aliases
naif_id, key = resolve_mission("Parker Solar Probe")  # -> (-96, "PSP")

# List all spacecraft
missions = list_supported_missions()

Kernel Management

from xhelio_spice import get_kernel_manager

km = get_kernel_manager()
km.ensure_mission_kernels("PSP")  # Download + load
print(km.get_cache_info())        # Cache stats
km.unload_all()                    # Free memory

Configuration

Method Description
XHELIO_SPICE_KERNEL_DIR env var Override kernel cache directory
KernelManager(kernel_dir=...) Per-instance override
Default ~/.xhelio_spice/kernels/

MCP Server

xhelio-spice includes an MCP server for LLM tool use:

# Run directly
xhelio-spice-mcp

# Or via Python
python -m xhelio_spice.server

Claude Desktop Configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "xhelio-spice": {
      "command": "xhelio-spice-mcp"
    }
  }
}

Available MCP Tools

Tool Description
get_ephemeris Position/velocity — single time (inline) or timeseries (CSV)
compute_distance Distance between two bodies
transform_coordinates Coordinate frame transform
list_spice_missions Supported missions
list_coordinate_frames Available frames with descriptions
manage_kernels Kernel cache management

License

MIT

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

xhelio_spice-0.5.0.tar.gz (6.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xhelio_spice-0.5.0-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file xhelio_spice-0.5.0.tar.gz.

File metadata

  • Download URL: xhelio_spice-0.5.0.tar.gz
  • Upload date:
  • Size: 6.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for xhelio_spice-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7162537684daa63dbb060e778ab89111dc9c4ebc2687215b0d82ebd76d3a29ca
MD5 8f87c9a3c8cd458698d21446af9d4502
BLAKE2b-256 f900d46f4889019122d58ae2c9b4abb12c1136328e06aa23c81bab66a12f4604

See more details on using hashes here.

File details

Details for the file xhelio_spice-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: xhelio_spice-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for xhelio_spice-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fb21f897f679e3358baa1c6093a8379387c535b122879386fdc111ca3195357
MD5 52a4fe41f712fc229f2be82a77c7e4a0
BLAKE2b-256 7d0b83de5741136c41227d17589f482be5fd585c32933e98f008929d037eae86

See more details on using hashes here.

Supported by

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