Skip to main content

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

Project description

PyPI tag License

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:

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.0.tar.gz (117.1 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.0-cp37-cp37m-win_amd64.whl (237.3 kB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl (266.7 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

cysgp4-0.3.0-cp36-cp36m-win_amd64.whl (237.0 kB view details)

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.6mmacOS 10.9+ x86-64

cysgp4-0.3.0-cp35-cp35m-win_amd64.whl (226.0 kB view details)

Uploaded CPython 3.5mWindows x86-64

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

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

cysgp4-0.3.0-cp35-cp35m-macosx_10_9_x86_64.whl (290.4 kB view details)

Uploaded CPython 3.5mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: cysgp4-0.3.0.tar.gz
  • Upload date:
  • Size: 117.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1.post20191125 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.7

File hashes

Hashes for cysgp4-0.3.0.tar.gz
Algorithm Hash digest
SHA256 24bf9cdc2168c7fc6b6dd89a24849c09560b755d7268e97f6988c08aa09ff84e
MD5 36b9054325d5d53a48f02a7ed1bf650e
BLAKE2b-256 188900f17fde87acc0951a956c42db9fd399055175333a1507e9ef83b1d22e94

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cysgp4-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a542f3c3e205f484e7929611543c79d5ca2159cfe1b7424cbd266b9f81f43fc2
MD5 35b4761ec40df5ea167b22b17c3a5f5c
BLAKE2b-256 4e1680524d5d5f9eb6215dda7179c116d50ed6787bc043a2d73be7c6343d75ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.0-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.39.0 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ef0a1930c81654b04dfed98cb95d4229540ee97d8561439401acf40361ab5145
MD5 0799b2357c20585ff1f02346ce912ebf
BLAKE2b-256 15ac0eb47079c599d92f3820dd97ecbaa4b05b34013ac7324065b5877e2dbc2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 266.7 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.39.0 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b56ee1b08a77829e6c30aeda9bed216257f305238b5df335b264700c784a3b3d
MD5 1b18389022ea6a6471aa23fb65b77a2a
BLAKE2b-256 ade133a659fe0b8c60cd3ddd50e4b7690f962a0a2f20cd66e5d59293f3be771d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cysgp4-0.3.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 82ef32bb4c8fd95578d7b3ee961f56870396f3b75a6d0aebf025733950a97749
MD5 69696271445b7d13c866baa0c09a415f
BLAKE2b-256 0a4733795ce8f2fba4964518f2ae2c1f0b072d42378641ae44f55292e5eaf17c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.0-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.39.0 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 04e05e8c7ca92b11e8c3eea5c9631440f9568b380828929c536ea06b3039df22
MD5 b83c80460f94a04cb2b37291f4536bc5
BLAKE2b-256 af3b911db9f9dd979ac3365373e4be82187cbc6592721a67c27a5639ac312b0d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cysgp4-0.3.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 af56d32a83508520ebd4347b93ba9d1855d6698c1e2387dfcb4aef50afcbd647
MD5 bd02bc5b2e40144a05f21cad666cacc4
BLAKE2b-256 d47a06ce74b0b6224eb3f32ddf4ada5938f1f994886e7ae874678b333021ff1f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cysgp4-0.3.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 17a720c4faf6421f32bce5520692b8f568acddf63ceea471395dbb101a265f4d
MD5 fe6364528953bb0bde644b394fdd0145
BLAKE2b-256 4cd03a0bc887d0d8240aadfceb8ed1a74c7840c3056f4f5f01c1c497f15e1479

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.3.0-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.39.0 CPython/3.6.9

File hashes

Hashes for cysgp4-0.3.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b8552112119dc11e5644150996febf4f3f4868987bed9b8013c5e40f2a707704
MD5 0dc304dfa3582daf445bdf53c8d5d0f0
BLAKE2b-256 e4017a0fc9bff59a880bb05112fd3df0b0f62f904ed73003f80e216db591a53c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cysgp4-0.3.0-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 106df9c7089b18911d2baa16a15fe9961b11920d0160f4ee6e3fff5811a3394e
MD5 ad49d83a60c8dea119874295650d957b
BLAKE2b-256 a1626670bf26531ea02fbcf6057d048d3611b00d9cb23ec001eb0f3683c72d37

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