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.3.tar.gz (572.3 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.3-cp37-cp37m-win_amd64.whl (239.1 kB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.3-cp37-cp37m-macosx_10_9_x86_64.whl (262.1 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

cysgp4-0.3.3-cp36-cp36m-win_amd64.whl (238.7 kB view details)

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.3-cp36-cp36m-macosx_10_9_x86_64.whl (270.6 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

cysgp4-0.3.3-cp35-cp35m-win_amd64.whl (226.4 kB view details)

Uploaded CPython 3.5mWindows x86-64

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

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.3-cp35-cp35m-macosx_10_9_x86_64.whl (289.4 kB view details)

Uploaded CPython 3.5mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: cysgp4-0.3.3.tar.gz
  • Upload date:
  • Size: 572.3 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.2.0.post20200511 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.3.tar.gz
Algorithm Hash digest
SHA256 76c83ee090cd097248c18bbbebe6891288e9b8e6185292ab8e7893f3492aac66
MD5 b2bac4ed81e6348f7c4cf69a41c7a619
BLAKE2b-256 45e557eca797fb795fe4f040e4bd410f7260ec28e4271048cbdcad88790b0010

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 239.1 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.46.0 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 cf37b6f46e3f1f5b11f992d97f96270283327a4c46adf4ad9875f63ef069534d
MD5 55b52e72dd6d089d13e4e5bc80d3e0f4
BLAKE2b-256 e54c4fe252a752b8d5f6111a7d6fcc23da5a97707f4d1e78205c0a687118dd70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-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.46.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4e9ef1cfc4195dc44be27bc7437a5e7f5972d62b50b44edcf4b6b0f5b27f050e
MD5 041c7d5641b14b8c269d0dab71cb3aa8
BLAKE2b-256 941a0c3cc2a5baac561a28c892418d03352273e956aba128b3a6768a6b333f2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 262.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.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b576437cdd7e01631bfd16e3a721aa07c45586adb7c2a38d32e0bd5f53b3ff60
MD5 5fb041302671c19389789c985694c8d1
BLAKE2b-256 f389570b945babdb2c7eb649b735686a6a19e41749b3643f251ae819880f9e9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 238.7 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.46.0 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f9a77886d7198e01f82c5300ca36b592cef34b4c1c067293c73dec0e98ffcb1f
MD5 74f32291f5b5ed731c133313bde09d43
BLAKE2b-256 ed270173d02726bea1ccdaf7e81fd7513c0259c3d1e94b78141ff8bb4b1470d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-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.46.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d27cb1203a0d99ca435fca0514ceb0cc3244c3197c01fca2793736bf26d7c078
MD5 61a475580eddaf7f1e7f963e85de2096
BLAKE2b-256 018bfd015bd4a4bb22a58dc6c1336730199e60fd61e7d535111c64b070d2ab66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 270.6 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.46.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 12a2a6e283dfa204019699cc3861486944c44f61a5e664fe34874262db1f8ef9
MD5 35cf02877642341b344bb0ae1517ed55
BLAKE2b-256 eb94543681a637868063e3220ac178836e1349ad3e762ecdfd8be0756ec75192

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 226.4 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.46.0 CPython/3.6.8

File hashes

Hashes for cysgp4-0.3.3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 826af351a17f1711fce88ef9d649832230eb6a1e95c84728fb1de95c11231f8e
MD5 1331f1e3946d9d2bbeedd0215fc54e28
BLAKE2b-256 345721ca622e82e6e36220487bfca4f3d0ab1878cfa39a4d4f58e5a200ee3484

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-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.46.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.3-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 fc16d03e677bf455c93d049a62e41ffff5f819cecee461c03e71517e241d3c8d
MD5 ac77973a548e13bf8ff14d785b7b2e83
BLAKE2b-256 b4707f5ff2bbb0a0de0ab8d25c0144887cb7160b6f6820b464c928da4c3c65c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.3-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 289.4 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.46.0 CPython/3.6.10

File hashes

Hashes for cysgp4-0.3.3-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3afa983fd4df009e2b0d8f9f235db017dc8e6dfa7ff0ae3db1efe61fc8f66e55
MD5 c8df51d7c9f3e01d1ea648b160e4c625
BLAKE2b-256 0b7b5a523cd343653218b3e3199142cf8824c8c73bbf6489e8a4ee6e24c3aaa3

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