Metadata-Version: 2.4
Name: eopy-orbits
Version: 1.0.1
Summary: Fast Python Earth orbit propagation kernels with NumPy/SciPy
License-Expression: GPL-3.0-only
License-File: LICENSE
Project-URL: Repository, https://gitlab.irf.se/danielk/eopy
Project-URL: Issues, https://gitlab.irf.se/danielk/eopy/-/issues
Requires-Python: >=3.11
Requires-Dist: astropy>=6.0
Requires-Dist: numpy>=1.26
Requires-Dist: pyorb>=0.6.3
Requires-Dist: pymsis>=0.12
Requires-Dist: scipy>=1.11
Requires-Dist: spacecoords>=0.2.2
Provides-Extra: tests
Requires-Dist: pytest>=8; extra == "tests"
Requires-Dist: matplotlib>=3.8; extra == "tests"
Requires-Dist: sgp4>=2.23; extra == "tests"
Provides-Extra: develop
Requires-Dist: eopy-orbits[tests]; extra == "develop"
Requires-Dist: ruff>=0.9; extra == "develop"
Requires-Dist: mypy>=1.15; extra == "develop"
Requires-Dist: build>=1.2; extra == "develop"
Requires-Dist: twine>=6; extra == "develop"
Provides-Extra: examples
Requires-Dist: matplotlib>=3.8; extra == "examples"
Requires-Dist: sgp4>=2.23; extra == "examples"
Description-Content-Type: text/markdown

# eopy

Earth orbits in Python: a compact, fast propagation designed around NumPy arrays and function calls
so computationally heavy pieces can later move to low level implementations without changing the
public shape of the code.

eopy is licensed under the GNU General Public License version 3. The DTM2000 and isotropic
radiation-pressure implementations contain modified portions adapted from Apache-2.0-licensed
Orekit; the applicable upstream license and attribution notices are included in `eopy/assets/`.

## AI usage disclaimer

GPT-5.6-sol was used to produce an initial translation of most of the tests and data-reading
methods, which were then used as a basis for translating the code from Java to Python. It was also
used to check for discrepencies in implementation and to implement much of the boilerplate needed,
such as file downloading and visualization.

## What is implemented

- DOP853/Dormand-Prince 8(5,3) propagation through SciPy `solve_ivp`.
- Batch Cartesian propagation for states shaped `(N, 6)`.
- Central Earth gravity plus analytic J2.
- Fully normalized spherical-harmonic gravity through a native analytical-gradient kernel.
- DTM2000 density and MSIS 2.1 density through `pymsis`.
- Drag acceleration with co-rotating atmosphere and ballistic coefficient input.
- Isotropic solar radiation pressure with cylindrical Earth shadowing.
- Point-mass third-body perturbations with fixed or callable position providers, including a lazy
  Astropy-backed ephemeris helper.
- Basic propagation events through SciPy-compatible callables.
- On-demand data download and parsing helpers for external gravity, EOP and space-weather inputs.
- A C++ library for the most used functions loaded with `ctypes`, intended for the computationally
  heavy gravity parts.

Large data files are not bundled with the package. Use `EOPY_DATA_PATH` to choose a
cache directory, or let eopy use the platform cache directory. The `eopy.data` module can download
CelesTrak space-weather/EOP CSVs and arbitrary ICGEM-compatible gravity model files, and can parse
`.gfc` gravity coefficients into contiguous NumPy arrays.

Native C++ library is built as a shared library with a plain C ABI and loaded from Python with
`ctypes`. It falls back to Python when the library has not been built. Developers can point the
loader at an out-of-tree build with `EOPY_NATIVE_LIBRARY=/path/to/libeopykernels.so`.

For source-tree development, build the native library into the package directory
with:

```bash
cmake -S . -B build/native -DCMAKE_BUILD_TYPE=Release
cmake --build build/native --config Release
```

The native API is loaded through `ctypes`.

## Precision propagation

High-degree gravity models are defined in ITRS, while propagated Cartesian states are normally GCRS.
Build an Earth-orientation provider and pass it with the gravity field so tesseral harmonics and
atmospheric drag are evaluated in the correct rotating frame. Time-variable ICGEM 2.0 models also
require an evaluation epoch:

```python
from datetime import datetime, timezone

from eopy.data import read_icgem_gfc
from eopy.frames import interpolated_earth_orientation
from eopy.gravity import GravityField

epoch = datetime(2024, 7, 4, tzinfo=timezone.utc)
model = read_icgem_gfc(
    "EIGEN-6S4_v2.gfc", max_degree=120, max_order=120, epoch=epoch
)
orientation = interpolated_earth_orientation(epoch, 0.0, 86400.0)
field = GravityField.from_model(model, degree=120, order=120, backend="native")
```

`propagate(..., sample_times=epochs)` evaluates a single continuous DOP853 solution at requested
offsets.  Historical MSIS inputs can be loaded with `CelestrakSpaceWeather.from_csv("SW-All.csv")`.

The default atmosphere is the lightweight configurable exponential model. DTM2000 propagation must
be selected explicitly and supplied with both an `EarthOrientation` and an inertial `sun_position`
provider; this ensures its longitude, season, and local-solar-time terms are evaluated in the
correct Earth-fixed frame. CelesTrak space-weather files provide both the Ap history used by MSIS
and the Kp history used by DTM2000.

## Example

```python
import numpy as np

from eopy.constants import EARTH_MU
from eopy.gravity import GravityField
from eopy.integrators import Dop853Options
from eopy.propagator import propagate

r = 7000e3
v = np.sqrt(EARTH_MU / r)
states = np.array([
    [r, 0.0, 0.0, 0.0, v, 0.0],
    [r + 1000.0, 0.0, 0.0, 0.0, np.sqrt(EARTH_MU / (r + 1000.0)), 0.0],
])

t, propagated, stats = propagate(
    states,
    0.0,
    3600.0,
    gravity=GravityField(degree=2),
    options=Dop853Options(rtol=1e-10, atol=1e-3, max_step=60.0),
)
```

More runnable examples are in `examples/` and are covered by pytest so they
stay working across updates.

To print a slowest-first breakdown of propagation and force-model costs:

```bash
python examples/propagation_profile.py
```

For native gravity and external data workflows:

```bash
python examples/download_data_files.py /tmp/eopy-data \
  --no-space-weather \
  --no-eop

python examples/native_gravity_model.py \
  --gravity-model /tmp/eopy-data/EIGEN-6S4_v2.gfc \
  --native-library /path/to/libeopykernels.so \
  --degree 4 \
  --order 4
```

Both examples default to the ICGEM EIGEN-6S4 v2 `.gfc` URL when no gravity URL
or local gravity model path is supplied.

## Installation and development

Use Python 3.11 or newer. Linux x86_64 is the initial binary distribution target.
Install the `eopy-orbits` distribution and use `import eopy` in Python.

```bash
python -m pip install eopy-orbits
# From a checkout, with a C++17 compiler and CMake available:
pip install '.[develop]'
pytest --ignore=tests/precision_orbit
```

`propagate` accepts a single `(6,)` state or an `(N, 6)` batch, in metres and metres/second. Times
are seconds relative to the epoch supplied to frame, ephemeris, and atmosphere providers. Use
timezone-aware UTC epochs. Force providers must share those axes and epoch. History is `(T, 6)` or
`(T, N, 6)`; without history, the final state has the input shape. Built-in events apply to one
spacecraft; custom events receive the batch and return a scalar.

`sample_times` requests output along the integration direction, including for backward propagation.
A terminal event can leave an empty requested history; its state and time remain in the statistics.
Zero-duration integration returns the initial state without evaluating forces or events. For sampled
integrations, accepted/rejected internal step counts are unavailable; use `function_evals`.

Use `backend="native"` for high-degree gravity to require compiled kernels; `"auto"` prefers
"`native"` but falls back to Python and `"python"` uses Python. The Python harmonic implementation
is intended for low-degree validation.

Run `python examples/atmosphere_models.py` for MSIS/DTM2000 density and `examples/relativity.py`
relativity examples. See The [public interface reference](docs/api.md) describes force inputs,
callbacks, configuration, and return values.

### Remeber

Interpolated providers reject requests outside their coverage. Atmosphere altitude clipping, default
activity, and the exponential approximation should be considered when interpreting results.

