# Orbit Elliptical Fitting

Question: Given a set of XYZ (3D) coordinates in the Earth-fixed frame, after converting them to the inertial frame, how do I perform orbit fitting in the least-squares sense (meaning minimising all least squares residuals below)? My objective is to come up with an orbit ellipse (6 elements) that best-fits those points such that the L2-norm of the residuals are minimised, but I'm not sure where I should start... I know there are programs and software out there to do it, but I'd like to try to make my own :) • Interesting question! One example of a problem like this (set of coordinates in the Earth-fixed frame) might be something like reverse-engineering a ground-track lat/lon plus altitude dataset to Keplerian elements (and then one might think "Why stop there?" and back into an artificial TLE). I suppose if you already have the XYZ converted to ECI you could either vary the Keplerian elements or choose a cartesian expression, fit that, then convert to Kelperian. Ideally they'd produce the same results, but in practice one might work better with one fitting algorithm, and the other with another.
– uhoh
Mar 12 '20 at 4:20
• I noticed that you omitted the times of the data points which makes the task easier, but if the data were available it might be a better choice in practice to use it. Of course then you need a propagator, and then the orbits are not perfect ellipses, and... etc.
– uhoh
Mar 12 '20 at 4:23
• You can use elliptical regression. This require solving a minimization problem (minimize squared distante to ellipse) using ellipse parameters. See more here Mar 12 '20 at 7:00
• One word of warning: If you have less that about half an orbit, there can be significant numerical stability problems that will lead to massive uncertainty in the semi-major axis. Apr 2 '20 at 18:41
• I can visually see what you mean by that, thanks for pointing it out! Apr 4 '20 at 10:15

What you are looking for is called orbit determination, and in particular batch least squares orbit determination.

To learn about it I can recommend Statistical Orbit Determination by Bob Schutz, Byron Tapley and George H. Born.

I understand that you want to try to do it yourself. Nevertheless, if at some point you are looking to do it with software, it is not very complicated either. Here is an example with Orekit: https://nbviewer.jupyter.org/github/GorgiAstro/orbit-determination-examples/blob/a5b592656cadb411f7edafdf15e16d8b3ca3eeaa/01-keplerian-od-with-iod.ipynb [disclaimer: I am the author of this example]. It demonstrates:

• Initial Orbit Determination (IOD) using Gibbs method using three position vectors, which is necessary if you don't have any clue about the orbit, because the Batch Least Squares estimation requires a first guess
• Batch Least Squares (BLS) estimation • Thank you! I'll try it out, and good recommendation for the textbook! Mar 12 '20 at 14:07
• Thank you once again for pointing me in the right direction, I realised I forgot to mark your answer as correct - there it is! Mar 17 '20 at 11:41