CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-spiceypy

A Python wrapper for the NAIF CSPICE Toolkit providing essential tools for spacecraft navigation and planetary science calculations

Overview
Eval results
Files

physical-constants.mddocs/

Physical Constants and Bodies

Functions for retrieving physical constants, body properties, and solar system object information. These functions provide access to fundamental astronomical and physical data needed for space calculations.

Capabilities

Body Properties

Retrieve physical characteristics of solar system bodies.

def bodvrd(bodynm: str, item: str, maxn: int) -> Tuple[int, ndarray]:
    """
    Fetch values from kernel pool for a body.
    
    Parameters:
    - bodynm: str, body name
    - item: str, property name ("RADII", "GM", "J2", etc.)
    - maxn: int, maximum number of values to return
    
    Returns:
    Tuple[int, ndarray]: (n, values) - number of values and array of values
    """

def bodn2c(name: str) -> int:
    """
    Translate body name to NAIF integer ID code.
    
    Parameters:
    - name: str, body name
    
    Returns:
    int: NAIF ID code
    """

def bodc2n(code: int) -> str:
    """
    Translate NAIF integer ID code to body name.
    
    Parameters:
    - code: int, NAIF ID code
    
    Returns:
    str: body name
    """

Mathematical Constants

Fundamental mathematical and physical constants.

def spd() -> float:
    """
    Return seconds per day.
    
    Returns:
    float: 86400.0 (seconds per day)
    """

def rpd() -> float:
    """
    Return radians per degree.
    
    Returns:
    float: π/180 (radians per degree)
    """

def dpr() -> float:
    """
    Return degrees per radian.
    
    Returns:
    float: 180/π (degrees per radian)
    """

def pi() -> float:
    """
    Return the value of pi.
    
    Returns:
    float: π
    """

def halfpi() -> float:
    """
    Return the value of pi/2.
    
    Returns:
    float: π/2
    """

def twopi() -> float:
    """
    Return the value of 2*pi.
    
    Returns:
    float: 2π
    """

Common Usage Patterns

Get Planet Properties

import spiceypy as spice

spice.furnsh("pck00010.tpc")  # Load planetary constants kernel

# Get Earth's radii
n, radii = spice.bodvrd("EARTH", "RADII", 3)
print(f"Earth radii: {radii} km")

# Get Mars GM (gravitational parameter)
n, gm = spice.bodvrd("MARS", "GM", 1) 
print(f"Mars GM: {gm[0]} km^3/s^2")

spice.kclear()

Body Name/ID Conversion

# Convert names to NAIF IDs
earth_id = spice.bodn2c("EARTH")
mars_id = spice.bodn2c("MARS")
print(f"Earth ID: {earth_id}, Mars ID: {mars_id}")

# Convert IDs back to names
earth_name = spice.bodc2n(399)
print(f"Body 399: {earth_name}")

Install with Tessl CLI

npx tessl i tessl/pypi-spiceypy

docs

ck-orientation.md

coordinate-systems.md

data-structures.md

dsk-shape-models.md

e-kernels.md

ephemeris-trajectories.md

error-handling.md

event-finding.md

geometry-surface.md

index.md

kernel-management.md

low-level-file-access.md

physical-constants.md

reference-frames.md

spacecraft-clock.md

time-systems.md

vector-matrix.md

tile.json