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.2.19.tar.gz (109.5 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.2.19-cp37-cp37m-win_amd64.whl (244.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

cysgp4-0.2.19-cp37-cp37m-macosx_10_9_x86_64.whl (279.4 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

cysgp4-0.2.19-cp36-cp36m-win_amd64.whl (244.2 kB view details)

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

cysgp4-0.2.19-cp36-cp36m-macosx_10_9_x86_64.whl (284.4 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

cysgp4-0.2.19-cp35-cp35m-win_amd64.whl (233.1 kB view details)

Uploaded CPython 3.5mWindows x86-64

cysgp4-0.2.19-cp35-cp35m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.5mmanylinux: glibc 2.12+ x86-64

cysgp4-0.2.19-cp35-cp35m-macosx_10_9_x86_64.whl (303.1 kB view details)

Uploaded CPython 3.5mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: cysgp4-0.2.19.tar.gz
  • Upload date:
  • Size: 109.5 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.2.19.tar.gz
Algorithm Hash digest
SHA256 130042f9d12c9b5820737c724d130564232a6f1624e18705af9dfc0d94085ca3
MD5 bfb17a63681f6c5f8584216107c3b1e2
BLAKE2b-256 ba400c709a22561c717b3264f93d5c22b4a5d2da7c5b16b08c9dc8b017cd2ab0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 244.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 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.2.19-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 7bad2a92aa06c21998e8c8b9d55d81e55c96aa3073f5b880f39fe4be4aa4f5f2
MD5 ae0ec36a9023a16e2fb7d134d18820b7
BLAKE2b-256 57ea78cdcd26d77d256ba6544b99759a4ac3daec293da96dd1dfb19572403cb6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-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.0 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.2.19-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ef90bdd21f711a30fdaf979f437b201ef4caade279d81351c06f49c2be4fbca9
MD5 1e6147251ef022e86494857481660685
BLAKE2b-256 bd0bde20506207dd253fbadc5c3249b4174ac84885c59edb32d1849239611d6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 279.4 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 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.2.19-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 516d1ea233e247ba05af726f5fa4da3f1ab309e5d7c720bb5a876a0e89d37015
MD5 3eeb92646c6bd7671edbb4826e44fc1b
BLAKE2b-256 7477ee4043a0134623ea22c120e9c8c971b682141901ebdc372b35b93e750d7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 244.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 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.2.19-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 6504f2c17fcaf40ce7e1e86e0ada09a6f62c0bf8bb2b659f98f116beb01f6734
MD5 1f620899917ade5eba21c39fc442134d
BLAKE2b-256 e2fa88f2a28e01b0fd4a6047052af2989f1d24cf588d868a184785d630b5dcd3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-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.0 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.2.19-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a00954381e617ed78d90f749fb938c5e1e2bdb228db679e4115649fa1d327b27
MD5 e2618c604b3a05470d48ea0ea6569ed0
BLAKE2b-256 559c81dba259216848f8d1fe1195ac8007caeb2cd2240050d16dbda6c09edcc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 284.4 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 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.2.19-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 542db0c3f83e7f3bd993956c0808fb3089fb1dbf2b253990554751ad2ce16407
MD5 10fc082253e57393c7b9214bcbbd3410
BLAKE2b-256 10bdae7859b7e20a02caaf6dfda586fff2861852d12c88e5144ec5c4a3ef39b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 233.1 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 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.2.19-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 dac2726b1a65ebc1155e2fdb3d8e304660fb262e674f14887c9f7764093335d6
MD5 ceeba4c50aa8466e61f1f5781bf59d84
BLAKE2b-256 c1e4a2677038ef3ebcbbcf9981d3b4a0e34f2beb770b52f7c6b60dacd24b1ea9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 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.2.19-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 84d3c355b69eba9bb591ff310aefec533e75d3f1eed152fc57d0f8e5cf145902
MD5 d44dcabc53faba38d9c5384fd90d5a38
BLAKE2b-256 8db19b5135e88dbbd484495a35754a45f44d45ecb73455004398487cb42c2324

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cysgp4-0.2.19-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 303.1 kB
  • Tags: CPython 3.5m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 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.2.19-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9fba871e83d347774b0c35faa9c8d8e4990d4bdeecf625ba6345d1af553b6ffe
MD5 18155a3470fc24c284866973c63bcd38
BLAKE2b-256 9041c47bdde29824f49930e0cdaf95ea0346a21e5fa00c97e747e81bafe9fba3

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