Skip to main content

dSGP4 ($\partial\textrm{SGP4}$)

build codecov Anaconda-Server Badge Anaconda-Server Badge

Differentiable SGP4 in PyTorch.

Logo

This repository contains the implementation described in:

Acciarini, Baydin, Izzo, Closing the gap between SGP4 and high-precision propagation via differentiable programming, Acta Astronautica (2025), https://doi.org/10.1016/j.actaastro.2024.10.063.

What dSGP4 provides

  • A PyTorch implementation of SGP4 with autograd support.
  • Gradients of propagated states with respect to time and TLE-derived parameters.
  • Single-object and batched propagation APIs.
  • A hybrid model (mldsgp4) for learning corrections around SGP4 dynamics.

Primary use cases include state transition matrix estimation, covariance transformation/propagation, gradient-based orbit estimation, and ML-augmented orbit prediction.

Installation

From PyPI:

pip install dsgp4

From conda-forge:

conda install conda-forge::dsgp4
# or
mamba install dsgp4

From source:

git clone https://github.com/esa/dSGP4.git
cd dSGP4
pip install -e .

Quick start

1. Parse a TLE and propagate

import torch
import dsgp4

tle = dsgp4.TLE([
    "1 25544U 98067A   24060.50000000  .00016717  00000-0  30134-3 0  9990",
    "2 25544  51.6403 124.7938 0005102 220.2782 248.4427 15.50010353440289",
])

# Initialize once, then reuse for multiple propagations.
dsgp4.initialize_tle(tle, gravity_constant_name="wgs-84")

# tsince is in minutes from TLE epoch.
tsince = torch.tensor([0.0, 10.0, 20.0])
state = dsgp4.propagate(tle, tsince)

# state shape: (N, 2, 3) when tsince has N elements
# state[:, 0, :] -> position [km], state[:, 1, :] -> velocity [km/s]
print(state.shape)

2. Differentiate through propagation

import torch
import dsgp4

tle = dsgp4.TLE([
    "1 25544U 98067A   24060.50000000  .00016717  00000-0  30134-3 0  9990",
    "2 25544  51.6403 124.7938 0005102 220.2782 248.4427 15.50010353440289",
])

time_min = torch.tensor(15.0, requires_grad=True)
state = dsgp4.propagate(tle, time_min, initialized=False)

# Example scalar objective: x-position at time_min.
loss = state[0, 0]
loss.backward()
print(time_min.grad)

3. Batched propagation

import torch
import dsgp4

tles = [
    dsgp4.TLE([
        "1 25544U 98067A   24060.50000000  .00016717  00000-0  30134-3 0  9990",
        "2 25544  51.6403 124.7938 0005102 220.2782 248.4427 15.50010353440289",
    ]),
    dsgp4.TLE([
        "1 40967U 15058A   24060.50000000  .00000033  00000-0  00000+0 0  9992",
        "2 40967   0.0187  89.2881 0002035  82.1068 220.3980  1.00270014 30754",
    ]),
]

times = torch.tensor([5.0, 30.0])
states = dsgp4.propagate_batch(tles, times, initialized=False)
print(states.shape)  # (2, 2, 3)

Technical notes and limitations

  • Time input (tsince) is in minutes from the TLE epoch.
  • Output units are km (position) and km/s (velocity).
  • Supported gravity models: wgs-72, wgs-84, wgs-72old.
  • Deep-space propagation is supported.
  • Default torch dtype is set to float64 when importing dsgp4.

Development

Run tests:

pytest -q

Documentation and notebooks

Citation

If you use dsgp4, please cite:

@article{acciarini2024closing,
  title = {Closing the gap between SGP4 and high-precision propagation via differentiable programming},
  journal = {Acta Astronautica},
  volume = {226},
  pages = {694-701},
  year = {2025},
  issn = {0094-5765},
  doi = {https://doi.org/10.1016/j.actaastro.2024.10.063},
  url = {https://www.sciencedirect.com/science/article/pii/S0094576524006374},
  author = {Giacomo Acciarini and Atılım Güneş Baydin and Dario Izzo},
  keywords = {SGP4, Orbital propagation, Differentiable programming, Machine learning, Spacecraft collision avoidance, Kessler, Kessler syndrome, AI for space, Applied machine learning for space}
}

Authors

The project originated from work at the University of Oxford AI4Science Lab.

Acknowledgements

We thank Dr. T.S. Kelso for support and validation guidance against the official Space-Track SGP4 release: https://www.space-track.org/documentation#/sgp4.

License

dSGP4 is distributed under GNU GPL v3. Contact the authors for alternative licensing options.

Contact

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsgp4-1.2.1.tar.gz (239.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsgp4-1.2.1-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

Details for the file dsgp4-1.2.1.tar.gz.

File metadata

  • Download URL: dsgp4-1.2.1.tar.gz
  • Upload date:
  • Size: 239.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for dsgp4-1.2.1.tar.gz
Algorithm Hash digest
SHA256 b02b70e49373bb1ff4e48e0d946aa9ec6a57ae48dbd998556df6374a89f25b5e
MD5 e8780baaaf97e526df323dd0653a7ce5
BLAKE2b-256 c57ac2c55d666c8ac04a29138d2d8ac18774bf2d114989e6fc639092defd4952

See more details on using hashes here.

File details

Details for the file dsgp4-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: dsgp4-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 51.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for dsgp4-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2fc9d20ae4e594b7e3c17be1d73ba9ed7cc078ce8bf89b256894afa24f2e063
MD5 2bb5be0cc3a4b51b29ac701d840ad0bd
BLAKE2b-256 9917ddcb204db73efdb05cf70775ca4909c4b7d811a85b75449504250c4498be

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.0

2 files

This release

1.2.1 This release

2 files

1.2.0

2 files

1.1.5

2 files

1.1.3

2 files

1.1.2

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.1.2

2 files

0.1.0

2 files

0.0.3

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page