Skip to main content

About

Spherapy is a convenience wrapper around the fantastic libraries skyfield, spacetrack, and hapsira (a maintained poliastro fork). It provides a consistent and straightforward method to create/propagate orbits without worrying about the implementation details of each library:

  • historical TLEs for known satellites (skyfield)
  • propagated orbital parameters hypothetical satellites (skyfield)
  • analytical orbital parameters (hapsira)
  • list of positions

Addtionaly, it provides a straightforward interface for updating used TLEs via spacetrack

Created orbits contain commonly used state variables:

  • satellite positions in various frames
  • velocities
  • etc.

Installation

  1. install the package
pip install spherapy
  1. configure. see Configuration

Usage

  • ensure spherapy has been configured, see Configuration
  • import the spherapy package
import spherapy.updater
import spherapy.timespan
import spherapy.orbit
  • if using real world satellites; update the desired TLEs (you can also use the TLEs supplied with the package, but these will be out of date).
updated_TLEs = spherapy.updater.updateTLEs([25544]) 	#ISS
TLE_paths = spherapy.updater.getTLEFilePaths([25544], use_packaged=True) 	#ISS
  • set up a timespan
t = spherapy.timespan.TimeSpan(datetime.datetime(2024,10,15,0,0,1),'1S','90M')
  • construct an orbit
    • from a TLE (good practice to update the TLE with the most recent)
o = spherapy.orbit.Orbit.fromTLE(t, TLE_paths[0])
  • from orbital parameters
o = spherapy.orbit.Orbit.fromAnalyticalOrbitalParam(timespan, body='Earth',
					 a=6978,
					 ecc=0,
					 inc=0,
					 raan=0,
					 argp=0,
					 true_nu=0,
					 name='My Analytical Orbit',
					 astrobodies=True)

Full TLE example (for copy paste)

import datetime
import spherapy.updater
import spherapy.timespan
import spherapy.orbit
TLE_paths = spherapy.updater.getTLEFilePaths([25544], use_packaged=True) 	#ISS
t = spherapy.timespan.TimeSpan(datetime.datetime(2024,10,15,0,0,1),'1S','90M')
o = spherapy.orbit.Orbit.fromTLE(t, TLE_paths[0])

Full Analytical exmaple (for copy paste)

import datetime
import spherapy.timespan
import spherapy.orbit
t = spherapy.timespan.TimeSpan(datetime.datetime(2024,10,15,0,0,1),'1S','90M')
o = spherapy.orbit.Orbit.fromAnalyticalOrbitalParam(timespan, body='Earth',
					 a=6978,
					 ecc=0,
					 inc=0,
					 raan=0,
					 argp=0,
					 true_nu=0,
					 name='My Analytical Orbit',
					 astrobodies=True)

SpaceTrack Credentials

In order to calculate the position of a historical satellite at any given time, spherapy requires TLE information for each satellite which is accurate for the given time period (or 'epoch').
TLE data can be obtained from either Celestrak or Spacetrack. Celestrak holds only the most recent TLE data for each satellite, while Spacetrack will provide historical TLE data. spherapy will fall back to using Celestrak if it cannot authenticate access to Spacetrack.
In order to use Spacetrack, you must provide your Spacetrack credentials to spherapy.

Configuration

Configuration for spherapy can either use the default settings, or settings specified in a spherapy.conf file.

Default settings

If the default settings are used, spherapy will use the system user data directory and expect spacetrack credentials to be stored in the system keyring.
The default data directories are listed in Directories

Custom settings

Custom settings can be specified in a spherapy.conf file.
This file can be located either in the system user's config file (described in Directories) or at a location specified by the environment variable SPHERAPY_CONFIG_DIR.

The fields of spherapy.conf are described below

[credentials]
SpacetrackUser = None 		# the spacetrack user, if left as "None" will source from system keyring
SpacetrackPasswd = None 	# the spacetrack password, if left as "None" will source from system keyring

[paths]
# relative paths are assumed to be relative to the location of this file
# do not quote path
TLE_path = ./spherapy/data/TLEs 	# the location where TLE files will be saved, if left empty (""), will default to system user's directory.

Directories

If SPHERAPY_CONFIG_DIR is not set or TLE_path is left empty in spherapy.conf, the spherapy default directories will be used:

Linux

  • TLE data dir:
/home/{username}/.local/share/spherapy/TLEs
  • config dir:
/home/{username}/.config/spherapy/spherapy/{spherapy_version}/

OSX

  • TLE data dir:
/Users/{username}/Library/Application Support/spherapy/TLEs
  • config dir:
/Users/{username}/Library/Application Support/spherapy/{spherapy_version}/

Windows

  • TLE data dir:
'C:\\Users\\{username}\\AppData\\Local\\spherapy\\TLEs'
  • config dir:
'C:\\Users\\{username}\\AppData\\Local\\spherapy\\{spherapy_version}'

Passwords

By default spherapy will use the system keyring to store the Spacetrack username and credentials (see SpaceTrack Credentials)
If a config file is supplied, the credentials in the file will be used.

Credentials can be added to the keyring by running the command (in the terminal, not the python shell)

spherapy-create-credentials

Configration File Format

The configuration file spherapy.conf should have the following format:

[credentials]
SpacetrackUser = None
SpacetrackPasswd = None

[paths]
# relative paths are assumed to be relative to the location of this file
# do not quote path
TLE_path =

Data Storage

  • TLEs
    • TLEs will be stored in the data directory, with a single file for each satellite ID. {sat_id}.tle, containing all historical TLEs for that satellite.
    • If celestrak is used instead, the file will be saved as a temporary file {sat_id}.temptle, which will be overwritten on each fetch from celestrak.

Metadata

Release files for spherapy 0.3.2

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

Source distribution (sdist)

Source distribution for spherapy 0.3.2
File Size Uploaded Provenance Actions
spherapy-0.3.2.tar.gz 2.0 MB Without provenance Details for spherapy-0.3.2.tar.gz

Built distribution (wheel)

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

Total release size: 4.1 MB

Release files / spherapy-0.3.2.tar.gz

Download URL spherapy-0.3.2.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
b0e7d23c5943637a61879990becd427f7f8f0255f53f3b6c25c58166a0d0fe6d
BLAKE2b-256 checksum
How to use checksums
326e9f1d1e90e64a2977810a0ba8a8083068ab9e20fcac831f0c62308a4ffbb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / spherapy-0.3.2-py3-none-any.whl

Download URL spherapy-0.3.2-py3-none-any.whl
Size 2.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
fcd2853aea7d5bdf05e2d0f60e889ec9d94e40fa57502bf2fcf833f7a32e8611
BLAKE2b-256 checksum
How to use checksums
754c82726efd00295bbab2594f01eef90ee5b0b9edf200bece73be10eb6fde53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for spherapy 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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