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.1.tar.gz (144.0 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.1-cp37-cp37m-win_amd64.whl (233.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

cysgp4-0.3.1-cp37-cp37m-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.1-cp37-cp37m-macosx_10_9_x86_64.whl (258.1 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

cysgp4-0.3.1-cp36-cp36m-win_amd64.whl (233.1 kB view details)

Uploaded CPython 3.6mWindows x86-64

cysgp4-0.3.1-cp36-cp36m-manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.1-cp36-cp36m-macosx_10_9_x86_64.whl (267.2 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

cysgp4-0.3.1-cp35-cp35m-win_amd64.whl (221.1 kB view details)

Uploaded CPython 3.5mWindows x86-64

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

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.1-cp35-cp35m-macosx_10_9_x86_64.whl (284.5 kB view details)

Uploaded CPython 3.5mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: cysgp4-0.3.1.tar.gz
  • Upload date:
  • Size: 144.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200102 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.7

File hashes

Hashes for cysgp4-0.3.1.tar.gz
Algorithm Hash digest
SHA256 ee8fa7e89bb01aff209ce85cd48e6f575d14618f5d9e71e8cd3a7fcc04ea6188
MD5 12c1f3aa8bc1a363b91e264eb96cfd0f
BLAKE2b-256 374563923d3f2d2c2836d33642a9341f84f089b2b6e0a386c236e25b0b62219e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 233.5 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 91f4b0fbeb6747050b40f3b99b0235d318963fc2003c3cc68196090a58f03a42
MD5 9ae41e141cb9c7a0f52d24b0ed773f87
BLAKE2b-256 87284be24eb851d59f1880a9b725700a39d4f232c96e94e7003e5c7cab02116d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 48997ba8eab270c50c5ffa98f74017df3f4e85c470a9ef6d261ddb73a80639fb
MD5 4da792c961c1627a36e18d578925303a
BLAKE2b-256 bcc82475f96a043df0c6efe9cc4801f83ffcc1f9e07a733d93b1a97d3b6cd030

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 258.1 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fdbd15e5142dc53ce56570cba65c850bb46ab883a4df70a60adc19b65094804a
MD5 4c0a39c8146708e8af20adcb6d5ccec3
BLAKE2b-256 d49f11bfc930592ebad7237f7f00dc71102db8405906fc107ae9b579e8c26efa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 233.1 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d793e7323027b7443a343c5534108c733290eaf17dce8bafbc0d20c951a1583c
MD5 80b6c2bb86154f805710d803af9d0a91
BLAKE2b-256 2c454118c5dea3beba5c28c9114ad5e932a0a87ca490adae64dd8b951f8545bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.5 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 24aaee1c51e9a6b483ee8498877793852ae4c1446551b004250b5e94ac9e22e7
MD5 cf3141a49e875ac3482a01d30a6278b5
BLAKE2b-256 d5bad44b1668ee768d8bccb8b15de7028fe5747d58ecedab77af37e3195cf769

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 267.2 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0d0e154b7f0eef3b7e4044bee0be43df339976d6ab81a01aa8637205cd0c3565
MD5 c64326b4aec1f60a1e3a3a924207977c
BLAKE2b-256 18296bec80a070bc33d176bbf9b60f9ede5481a3e60b0e64deee1af1a7852258

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 221.1 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 03818dc08aaf0f170a4d21c159cab12a4ec991760beeecf09ec09f36da940781
MD5 3e393ec512ffac7659497643e07c94ae
BLAKE2b-256 14574bafb3876d30787607701e7d8cf979b68974aa40b47387e3be090d187579

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e3cb00fe7d6ceac203cb1cdd4f79bd35df079834e1c500215f055890b7e514ce
MD5 620bb064451bffcfb69a50635ea6bf62
BLAKE2b-256 3c5810f1ff4228cf1d342f2510e8d9a141c148410969848b175b3b2817859f70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.1-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 284.5 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.1-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dd1d2456418f8b7c0d8f776a9dcf652f35c34a89c8ab04a5683a9eb029896d86
MD5 d0c1db10bd38c86aa134ab4647529bb2
BLAKE2b-256 0dac8362cd47ffe1028fd291ed3855fdedd14ac8e8b5b7e84ecdeea4b0fa6b42

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