skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.43k stars 213 forks source link

Create Satellite object from vector? #278

Closed ghost closed 1 year ago

ghost commented 5 years ago

I've just started to study skyfield, but I'd like to use it in a project where propagate satellite vectors numerically but I would like to return them to EarthSatellite to make use of the Topos and other features.
Is there a way to create a new satellite object from a state vector (position & velocity) and possibly define the reference frame?

brandon-rhodes commented 5 years ago

There is not an easy way to do that, no; satellite SGP4 parameter sets are not generated from single state vectors, but by integrating many observations against the SGP4 theory to produce elements that have the least error when used to generate those positions. Skyfield does have a few routines that convert to and from Keplerian orbit parameters, but I'm not sure how closely a naively Kepler-derived set of elements, if translated over into SGP4 parameters, would really follow the course of a satellite. I'm told that this is a standard reference on the subject, though, if you're interested!

https://www.celestrak.com/software/vallado-sw.php

(And if you do make progress in converting plain old Kepler element sets back into SGP4 params, I'll be interested to hear if the result follows the actual satellite's track, and with what error bar, if you ever have time to report back!)

ghost commented 5 years ago

A buddy and I have been trying to unlock the mysteries of TLE specifically the covariance, but without something to test it's just guessing. However, we have some ideas, I'll let you know if anything useful comes from it. Thanks for the consideration.

ckuethe commented 5 years ago

https://github.com/aerospaceresearch/orbitdeterminator looks interesting, though I haven't made time to play with it.

brandon-rhodes commented 4 years ago

@appa-nerd I just ran across the routine rv2coe() in the underlying SGP4 library. It looks like it might do what you are asking:

https://github.com/brandon-rhodes/python-sgp4/blob/e6178785d15996885c6ed7fb33585ca6e5d8dd67/sgp4/ext.py#L224

*                           function rv2coe
*
*  this function finds the classical orbital elements given the geocentric
*    equatorial position and velocity vectors.

Does that look like the capability you were asking about?

dcajacob commented 1 year ago

While you can create a TLE from a single vector, it isn't recommended. We call that a single point solution, but rv2coe isn't the way to do it, because it returns osculating orbital elements, not the mean elements used in the TLE. I've just released a proof of concept for creating a valid TLE from an ephemeris (a time series of state vectors, like GPS data): https://github.com/dcajacob/tle-tailor

brandon-rhodes commented 1 year ago

Thanks very much for the clarification and for the link, @dcajacob! Looking back at this 2019 issue with the hindsight of a few more years, I'm thinking that Skyfield would be the wrong place to put a vector-to-satellite routine, and that it belongs in a more comprehensive satellite-elements package. So for now I'm going to close this issue, though I welcome further links and discussion here in the comments. If the scope of Skyfield ever expands and we decide that TLE generation does belong in Skyfield itself, then we can re-open this issue at that time.

dcajacob commented 1 year ago

Agreed. I'm not advocating for putting this in skyfield. The idea was just to point folks in the right direction if they come across this thread in the future. It's a common question regarding TLEs.