Skip to main content

License-GPL3 License-Apache License-BSD3

PyPI tag PyPI - Downloads

conda-forge platforms: Version on conda-forge conda-forge platforms: linux-64, osx-64, win-64 conda-forge downloads

  • Version: 0.4.0

  • Lead author/package maintainer: Benjamin Winkel

  • Contributor(s): Gyula I.G. Józsa, Boris Sorokin

  • Repository: on GitHub

  • Bug tracker: on GitHub

  • User manual: stable | developer

Project Status

cysgp4's Azure Pipelines Status

Purpose

The cysgp4 package is a Cython-powered wrapper of the sgp4lib library (by Daniel Warner) to compute satellite positions from two-line elements (TLE).

It provides similar functionality as the well-known sgp4 Python package (by Brandon Rhodes), which uses Numba internally to speed-up the calculations. In contrast to sgp4, cysgp4 can work well with arrays of TLEs and/or times and make use of multi-core platforms (via OpenMP) to boost processing times a lot.

Installation

We highly recommend to use cysgp4 with the Anaconda Python distribution, in which case installiation is as easy as

conda install -c conda-forge cysgp4

Otherwise, you should install cysgp4 via pip:

python -m pip install cysgp4

The installation is also possible from source. Detailed installation instructions can be found in the user manual.

Dependencies

We kept the dependencies as minimal as possible. The following packages are required:

  • Python 3.10 or later

  • numpy 2.0 or later (older numpy version may work)

If you want to run the notebooks yourself, you will also need the Jupyter server and install matplotlib. To run the tests, you’ll need sgp4.

Note, for compiling the C-extension, OpenMP is used for parallelization. If you use gcc, for example, you should have at least version 4.8 otherwise the setup-script may fail. Again, see Detailed installation instructions for more information.

Usage

Using cysgp4 is possible via an object-oriented interface or with a fast numpy-array functional approach. The former works like this:

import cysgp4

# Define a date/time and an observer
pydt = cysgp4.PyDateTime.from_mjd(58805.57)
lon_deg, lat_deg = 6.88375, 50.525
alt_km = 0.366
obs = cysgp4.PyObserver(lon_deg, lat_deg, alt_km)

# Define satellite properties/orbit via two-line element string (TLE)
hst_tle = cysgp4.PyTle(
    'HST',
    '1 20580U 90037B   19321.38711875  .00000471  00000-0  17700-4 0  9991',
    '2 20580  28.4699 288.8102 0002495 321.7771 171.5855 15.09299865423838',
    )

# Create a satellite object for querying coordinates
sat = cysgp4.Satellite(hst_tle, obs, pydt)
sat.eci_pos().loc  # ECI cartesian position, km
(5879.5931344459295, 1545.7455647032068, 3287.4155452595)
sat.eci_pos().vel  # ECI cartesian velocity, km/s
(-1.8205895517672226, 7.374044252723081, -0.20697960810978586)
sat.geo_pos()  # geographic (geodetic) position, lon/lat/alt
<PyCoordGeodetic: 112.2146d, 28.5509d, 538.0186km>
sat.topo_pos()  # topocentric position, az/el/dist/dist_rate
<PyCoordTopocentric: 60.2453d, -35.6844d, 8314.5683km, 3.5087km/s>

# One can change time to determine positions at another moment
sat.mjd += 1 / 720.  # one minute later
sat.topo_pos()
<PyCoordTopocentric: 54.8446d, -38.2749d, 8734.9195km, 3.4885km/s>

In many cases, however, one probably wants to calculate coordinates for a (large) number of satellites, observer locations, and/or observing times. For this, the function ~cysgp4.propagate_many is useful. This is an array interface to the sgp4 calculations, which allows to perform calculations for different satellite TLEs, observers and times in a parallelized manner. ~numpy broadcasting rules apply:

import requests
import numpy as np
from cysgp4 import PyTle, PyObserver, propagate_many

# Download many TLEs from a website
url = 'http://celestrak.com/NORAD/elements/science.txt'
ctrak_science = requests.get(url)
all_lines = ctrak_science.text.split('\\r\\n')

# Need to convert them to a list of tuples (each tuple consisting
# of the three TLE strings)
tle_list = list(zip(*tuple(
    all_lines[idx::3] for idx in range(3)
    )))
# Create an array of PyTle and PyObserver objects, and MJDs
tles = np.array([
    PyTle(*tle) for tle in tle_list
    ])[np.newaxis, np.newaxis, :20]  # use first 20 TLEs
observers = np.array([
    PyObserver(6.88375, 50.525, 0.366),
    PyObserver(16.88375, 50.525, 0.366),
    ])[np.newaxis, :, np.newaxis]
mjds = np.linspace(
    58805.5, 58806.5, 1000  # 1000 time steps
    )[:, np.newaxis, np.newaxis]

# The result is a dictionary
result = propagate_many(mjds, tles, observers)
print(result.keys())
dict_keys(['eci_pos', 'eci_vel', 'geo', 'topo'])

# Returned array shapes are as follows; last array dimension
# contains the coordinate pairs.
print(np.broadcast(mjds, tles, observers).shape)
(1000, 2, 20)
print(result['eci_pos'].shape, result['topo'].shape)
(1000, 2, 20, 3) (1000, 2, 20, 4)

# One can also skip over coordinate frames.
result = propagate_many(
    mjds, tles, observers,
    do_eci_pos=False, do_eci_vel=False, do_geo=False, do_topo=True
    )
print(result.keys())
dict_keys(['topo'])

More use-cases and tutorials

Check out the user manual or the Jupyter tutorial notebooks in the repository for further examples of how to use cysgp4. Note that you can only view the notebooks on GitHub, if you want to edit something it is necessary to clone the repository or download a notebook to run it on your machine.

Who do I talk to?

If you encounter any problems or have questions, do not hesitate to raise an issue or make a pull request. Moreover, you can contact the devs directly:

Licenses

cysgp4 itself is published under GPL v3, an open-source license. The package is a Cython-powered wrapper of the sgp4lib library (by Daniel Warner) to compute satellite positions from two-line elements (TLE). The sgp4lib source code is licensed under Apache-2.0 license

The package is partly based on the Astropy-affiliated package template, which is under BSD 3-clause license.

Metadata

Release files for cysgp4 0.4.0

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

Source distribution (sdist)

Source distribution for cysgp4 0.4.0
File Size Uploaded
cysgp4-0.4.0.tar.gz 955.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cysgp4 0.4.0
File
cysgp4-0.4.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
cysgp4-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
cysgp4-0.4.0-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
cysgp4-0.4.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
cysgp4-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
cysgp4-0.4.0-cp311-cp311-macosx_10_13_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.13+ x86-64 Details
cysgp4-0.4.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
cysgp4-0.4.0-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
cysgp4-0.4.0-cp310-cp310-macosx_10_13_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.13+ x86-64 Details

Total release size: 13.0 MB

Release files / cysgp4-0.4.0.tar.gz

Download URL cysgp4-0.4.0.tar.gz
Size 955.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bb38659db575bddd8aae30c8e1cb8060a278ac06f867b2bd18e1b4ce483d8182
BLAKE2b-256 checksum
How to use checksums
6f333baf022b61f80f24995c74effff0f711c34707a6447f3f4538548cd18e26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / cysgp4-0.4.0-cp312-cp312-win_amd64.whl

Download URL cysgp4-0.4.0-cp312-cp312-win_amd64.whl
Size 689.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d132e073821691ddbc1f38a926f9ba7ff2e025b2a058c42850cb3a6019a97a73
BLAKE2b-256 checksum
How to use checksums
21a693f11894350520a10c5f90ffad1de4402c296dd1e1f314a4e2dcecf0437c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / cysgp4-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL cysgp4-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 2.6 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fb0fcc4ed822c6577a331f9a7411aee218cd244e36cd9717ff46f559754e7941
BLAKE2b-256 checksum
How to use checksums
bb23f97162e0f38b4ee48e1ad278f4370e87eb7fd42f5e142200e9ae57b2e2b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / cysgp4-0.4.0-cp312-cp312-macosx_10_13_x86_64.whl

Download URL cysgp4-0.4.0-cp312-cp312-macosx_10_13_x86_64.whl
Size 741.8 kB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
f0726c30321e266e70329c65ca38ecc66c812af511a1d96ae2b4243e021b5975
BLAKE2b-256 checksum
How to use checksums
f43034a1f0bbc43386e14167bcd85ae7c9ecb86dc0f91e4e910b1d61e6ac5fbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / cysgp4-0.4.0-cp311-cp311-win_amd64.whl

Download URL cysgp4-0.4.0-cp311-cp311-win_amd64.whl
Size 691.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
9e7170f87b1c169d60d839fb16e0d8e29319657574d0b928c4bfffe8e6753393
BLAKE2b-256 checksum
How to use checksums
a291feea64494b17f0880e7adaaf0a25b263e29f71257bcb032e7748ebefdab1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / cysgp4-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL cysgp4-0.4.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 2.6 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a2f18f125726d25297df9579b8a7716b27c4489e0828e16a5a6097133b94695a
BLAKE2b-256 checksum
How to use checksums
638a640de6c8e9f1e16ef46686c4ce7e2ce809582955c345be4df7ec17a4296d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / cysgp4-0.4.0-cp311-cp311-macosx_10_13_x86_64.whl

Download URL cysgp4-0.4.0-cp311-cp311-macosx_10_13_x86_64.whl
Size 738.9 kB
Tags CPython 3.11 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
b1498e474be500dddb2f9c439fe954f6ea579eea506ea34bfbc88230993eb9b4
BLAKE2b-256 checksum
How to use checksums
31bbb64df373622967849e0d3a6f8664a7f45054c7c9cae870a61e9396be5fbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / cysgp4-0.4.0-cp310-cp310-win_amd64.whl

Download URL cysgp4-0.4.0-cp310-cp310-win_amd64.whl
Size 691.2 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
d91c847ea779bb235125866c6569255a7215fdd5da5f7920a83537748e6593b2
BLAKE2b-256 checksum
How to use checksums
8e549b63ba4f6231680e918892128a49f914eb76790df6d50c5c605412ea0e7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / cysgp4-0.4.0-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL cysgp4-0.4.0-cp310-cp310-manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
85ce63de2e8556ccb2f97c669bd4c8aea02ebaa7f5ab5e8b4eeba46e1f3d3241
BLAKE2b-256 checksum
How to use checksums
ac69cb2a024ab55dcb61b837734f16cf1f272abca52e9abb3704ad26761e7cc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / cysgp4-0.4.0-cp310-cp310-macosx_10_13_x86_64.whl

Download URL cysgp4-0.4.0-cp310-cp310-macosx_10_13_x86_64.whl
Size 743.8 kB
Tags CPython 3.10 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
007ba2d07ceb6e371e3ecfbe7c5ab84524497011f7f27de1740e8cbea47f87c9
BLAKE2b-256 checksum
How to use checksums
39163bff5611da06502e847438191b7cfded15d8bf86d324d2a5402213960dc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.4.0 This release

10 release files

0.3.6

16 release files

0.3.5

10 release files

0.3.4

9 release files

0.3.3

10 release files

0.3.2

10 release files

0.3.0

10 release files

0.2.15

5 release files

0.2.13

1 release file

0.2.12

1 release file

0.2.6

1 release file

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