neuromorphicsystems / sgp4

A Rust implementation of the SGP4 satellite propagation algorithm
https://crates.io/crates/sgp4
MIT License
68 stars 19 forks source link

Support converting `Prediction` from TEME reference frame to J2000 #4

Closed vegardgs-ksat closed 1 year ago

vegardgs-ksat commented 2 years ago

This may be out of scope for this crate.

Currently, the Prediction output produces Cartesian coordinates in the TEME reference frame, whilst most other calculation and interfaces surrounding space calculations work with the J2000 earth centered inertial (commonly known as EME2000) reference frame.

It would be desirable to have a rust-equivalent implementation of performing the correct reference frame conversion. As stated, this may be out of scope for this crate.

A reference to this conversion and applicability of it is discussion in AIAA 2006 rev 3, Appendix C

aMarcireau commented 2 years ago

I agree that this conversion would be very useful. I think it is out of scope in the long run but a short term filler might be convenient.

In the long run, I have in mind an architecture similar to that of Astropy + SGP4 (https://docs.astropy.org/en/stable/coordinates/satellites.html), with another crate (or crates) for astronomy calculations and this crate solely for SGP4 propagation. The closest thing to a full-fledged astronomy crate is probably https://github.com/saurvs/astro-rust but I don't know whether it already implements TEME.

In the short term, adding a function to this crate would be quite nice even if the function is ultimately removed. I won't have time to look into it in the coming months but would happily review a pull request. According to Orekit's documentation, GCRS has superseded EME2000 (https://www.orekit.org/site-orekit-10.3/architecture/frames.html) so it is probably better to use the former.

ryandotelliott commented 7 months ago

@aMarcireau I see this was marked as completed, was this ever implemented?

aMarcireau commented 3 months ago

Hi @DeveloperRyan,

Apologies for the late answer. This was marked as "complete" because I believe the feature to be out of the scope of this library. Converting to GCRS requires ephemeris that needs to be downloaded regularly from a third-party provider (for instance https://datacenter.iers.org/data/csv/finals2000A.all.csv) and a sequence of non-trivial transforms (https://docs.astropy.org/en/stable/coordinates/index.html).

Under the hood, Astropy uses https://github.com/liberfa/erfa, which is a C library. I think that a port of erfa to Rust would be very neat and might lead to substantial performance gains (erfa uses bespoke matrix operations whilst a Rust library could be built around something like https://docs.rs/nalgebra/latest/nalgebra/ and benefit from its optimised routines). I would be very keen to contribute to a project like this but unfortunately I do not have time to start it myself at the moment.