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.5.tar.gz (581.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.5-cp310-cp310-win_amd64.whl (240.6 kB view details)

Uploaded CPython 3.10Windows x86-64

cysgp4-0.3.5-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

cysgp4-0.3.5-cp310-cp310-macosx_10_9_x86_64.whl (295.1 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

cysgp4-0.3.5-cp39-cp39-win_amd64.whl (243.8 kB view details)

Uploaded CPython 3.9Windows x86-64

cysgp4-0.3.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

cysgp4-0.3.5-cp39-cp39-macosx_10_9_x86_64.whl (292.3 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

cysgp4-0.3.5-cp38-cp38-win_amd64.whl (243.8 kB view details)

Uploaded CPython 3.8Windows x86-64

cysgp4-0.3.5-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

cysgp4-0.3.5-cp38-cp38-macosx_10_9_x86_64.whl (294.2 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: cysgp4-0.3.5.tar.gz
  • Upload date:
  • Size: 581.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cysgp4-0.3.5.tar.gz
Algorithm Hash digest
SHA256 8447183c63c9800d329f5f6753400d50b286beddd49baa2d4df415ae20965e12
MD5 0f1adcf2325909e28c8bde400bf16c8e
BLAKE2b-256 e9a6d08dd8931edbe48746d31ce8d6b1950bfca91d078add07d0615f2b33100d

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: cysgp4-0.3.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 240.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cysgp4-0.3.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7f570c9dabcd5313f7ff39f82b0e9e5261da5ffcb5d57f5b587a05d71536a37b
MD5 6db9346b131e2e2da5720e5f598e84e6
BLAKE2b-256 dfd8bd2f976748dff4327136552eb1707b8535442250b239e9762d9ab4d04662

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for cysgp4-0.3.5-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5050fc40c4a9c019550f475e3d3718c2bb4d943f7adfa5517bb62fa6bb184612
MD5 7637a5ff4c2c3f8e57c8e60565d7bc37
BLAKE2b-256 e8f0638250718115429782040f49f10ffc3eb10c636527c7084d2511e3896240

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cysgp4-0.3.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3b35ff81bdcff38245e4ddef40ed6c93c7ba3ca9854252ad74496074c1f201db
MD5 0a2507db0f724824a7f654a848bc3d4a
BLAKE2b-256 214c33594cf5b2ce3f8fc7c5771ecdcb13c382e3486608beb5b49fd5ef590540

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: cysgp4-0.3.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 243.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cysgp4-0.3.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 034b7e69280948eac51e9e8f232657bd4c04faecadd5d4d7e9fb436814c26067
MD5 da7cbf77502e81cb1fcd3a8c0bf7eb5e
BLAKE2b-256 d67ec4fca29bc63f2e2098826e046b44b0dc0d70491a9945c78833d158a7e92c

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for cysgp4-0.3.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3e9d4feec064890c648ad4cacd88cb18ce8b978cb4c933c5f91345fc1e07c6f1
MD5 2ef91de647a39e4d3132c0ea4ae8e6c2
BLAKE2b-256 4786d4e9ed8f69d7224e0b120be9923249389ef20d483c90b2775743795c717b

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cysgp4-0.3.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6de91270f78ecd6840ad30a14aafb4f1b91155f41ca6d90e9175eaf11cffee95
MD5 e2be0afba1ff0b6bd719ea3d7f261080
BLAKE2b-256 dd709a8f988daf414dc6f5ed04c49dd2a34c7a9be5ed1a63e6aed97afce30fe3

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: cysgp4-0.3.5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 243.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cysgp4-0.3.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ea86b5fdf0516a3e747fea5c2f0fc8afc8d2dc347dd2a3192da62a8eb1584b62
MD5 cfcef4f14fb3beeebbcb5b4fa7f142a7
BLAKE2b-256 3aa8daade5561603cfd8f92ea53ed64e353a3f9edbe8204a88dce265c40b2251

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for cysgp4-0.3.5-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cce2ddec55e7501a17414c651b94c8e0dd17c55985b4aca34a47cd09b6791bda
MD5 a360d0b7761f7c2df9cd9d1927f897b2
BLAKE2b-256 93f3d44fec27ca1c868f8d527c8b8d710ce2dfa1a7ebef54e4ba5d1fd999d944

See more details on using hashes here.

File details

Details for the file cysgp4-0.3.5-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cysgp4-0.3.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8c23ad24a37b07881c42a0054b427f59b4185026cbc8d8ca4de5a37a80edc586
MD5 7d59f2082eb7530a42b98e70dec3317e
BLAKE2b-256 234e5dd64217ce972a496d7b7236a7c44e61969650693b3f81e5bb6ff2a5d4ba

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