Skip to main content

Cysgp4: a wrapper around the SGP4 package, for sat TLE calculations

Project description

PyPI tag License-GPL3 License-Apache License-BSD3

Project Status

cysgp4's Azure Pipelines Status cysgp4's Coveralls 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:

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.5 or later

  • numpy 1.13 or later

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.

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

cysgp4-0.3.2.tar.gz (572.6 kB view details)

Uploaded Source

Built Distributions

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

cysgp4-0.3.2-cp37-cp37m-win_amd64.whl (239.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

cysgp4-0.3.2-cp37-cp37m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl (262.5 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

cysgp4-0.3.2-cp36-cp36m-win_amd64.whl (238.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

cysgp4-0.3.2-cp36-cp36m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.2-cp36-cp36m-macosx_10_9_x86_64.whl (271.0 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

cysgp4-0.3.2-cp35-cp35m-win_amd64.whl (226.5 kB view details)

Uploaded CPython 3.5mWindows x86-64

cysgp4-0.3.2-cp35-cp35m-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.2-cp35-cp35m-macosx_10_9_x86_64.whl (289.8 kB view details)

Uploaded CPython 3.5mmacOS 10.9+ x86-64

File details

Details for the file cysgp4-0.3.2.tar.gz.

File metadata

  • Download URL: cysgp4-0.3.2.tar.gz
  • Upload date:
  • Size: 572.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.2.tar.gz
Algorithm Hash digest
SHA256 b4f58bc19a50e54a27a57d4b66b31af47805bb408f2f8665548ae4c08fef1db3
MD5 71da12b088991b8da809731fbe683646
BLAKE2b-256 2cc001981c217759e8d588b2369e28e4c7d129de4ffb8666bec8814f2e4f5aed

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 239.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5aab855dc0957e75ff482fbc6d37f04ece4d4b351b38f3905aa315f1db325f4f
MD5 93323156c9bbede59560e2b6a06800f1
BLAKE2b-256 00481616532958d10f3f71d3124f8dfe77457bf7f8c6cc8c6f72d97c0e8b1085

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 669d1673a0dcd335e9b5384b463d4ca1cc1976042f588c79b2189058b5457a21
MD5 865927856eb299046d901508b3536a1a
BLAKE2b-256 c633b459c6fb949ca87e54ccb5065d37c5231a42ea7f57d3cec67c352efccbc5

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 262.5 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a0419eaed256d6c58c0c8dbce9c0225c39cd980a6714fc570eda78c3f90cb45c
MD5 e65b447dfe5c49f5f7a73d5e1c120d5e
BLAKE2b-256 46b9b7e96f57cbde0161e78de8265d976944e0432fd01bbb32f609ee8bb1705c

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 238.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 8dcada27434ae30fb2ac92d3f77db151cb4fca5e676f17c434e95f33e1cbee54
MD5 07f48c2dfd6e90d01c159417c1d7c8d3
BLAKE2b-256 224ba3377e79f152ab2aa978694bf91ee15c33572215148603a7a28f9f38209b

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1ee021c9a6deb934314c1bb911ad12d621972f7b714f880a7154afbeeb3da246
MD5 7ed1254d40fd5a9b65b1e75da619fe50
BLAKE2b-256 0a908b2f5433cb8337e42cf69f2272ce72a0180ab4c291f4c7d3709498bcd2f1

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 271.0 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e4615b4b33320f7ad82f40ba95c61ebbd532a5ae992396f5d0636dcc00540501
MD5 2ec33b2cadc73563b7a26d845fcd0238
BLAKE2b-256 6ffd5c76314967a81ed89eefa45eaba7ec6875f352024208985c7152831542aa

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 226.5 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.2-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 9cbfbf9da6bf7cf7503dfcf15c076deae1d15671eedb5725b87d08e70df1b904
MD5 ea241e0d54d99955bf890c875347c06b
BLAKE2b-256 b963f4255ef35879f5401ddec33e6b20f23c1448ca2742bd5741918b260da767

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.2-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 13dcc165cdcf68d4b87285979ac13e600108cd03dee47b62a66e649569fc5c3e
MD5 0e93fa31913cbd7bca837f227fe22b2b
BLAKE2b-256 ee21d88a16674307a61f94d22e26ead7cd75e36a79274f7859203a05fd5482fb

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.2-cp35-cp35m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cysgp4-0.3.2-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 289.8 kB
  • Tags: CPython 3.5m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.2-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2af38b9da683da35d86214fcc7fad2a393b978b416bc30dda2d6812ff4382bb9
MD5 538d8f9c01204e6a7c46a8e941f18d16
BLAKE2b-256 c4638a36554a298ac118c457d77961e8bc3e69a815b49d3086a6a0d1a54d4c60

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