TLE to Keplerian

Hi guys! I’m having an issue with a function where is receive TLEs but I need to use a numerical propagator, my first idea was to use TLEpropagator() and then .getInitialState.getOrbit() but I doesn’t work well. so I tried some ideas I found on the forum but nothing seems to work I always get the wrong mean anomaly in the outputs I get -124 when I should get 159.
If anyone can help me out thank you so much .

    def propagate(self):
        propagatorBis = self.satellite["propagator"]  # We keep the old propagator for now
        defaultMass = 2.0 # We need for the propagator to define a default mass for the calculation 

        TLEinitialOrbit = propagatorBis.propagate(self.initialDate).getOrbit()

        initialOrbit = OrbitType.KEPLERIAN.convertType(TLEinitialOrbit)
        initialState = SpacecraftState(initialOrbit,defaultMass)   # We create an object initial state for the numerical propagator 
        integrator = ClassicalRungeKuttaIntegrator(self.timeStep)
        propagator = NumericalPropagator(integrator)
        if self.nbMultiplexer == 0:
      #  propagator.setOrbitType(orbitType)
        propagator.setInitialState(initialState) #Set the initial state
        keplerianInitialOrbit = KeplerianOrbit(initialOrbit)
        print("Mean Anomaly :",FastMath.toDegrees(keplerianInitialOrbit.getMeanAnomaly()))
        print("RAAN  :",FastMath.toDegrees(keplerianInitialOrbit.getRightAscensionOfAscendingNode()))
        print("Eccentricity  :",(keplerianInitialOrbit.getE()))
        print("Date  :",(keplerianInitialOrbit.getDate()))
        propagator.setMasterMode(self.timeStep, self.multiplexer) 



Hi @Anthony ,

Why do you think you should get 159?

What I do is to get the position and velocity at any date by TLEPropagator, then create a CartesianOrbit.

tleProp = TLEPropagator.selectExtrapolator(tle)

pv = tleProp.getPVCoordinates(absdateOd, eme2000)

initialOrbit = CartesianOrbit(pv, eme2000, absdateOd, mu)

Hi @lirw1984 thank you for your answer ! I think I should get 159 because it is the Mean Anomaly written in the TLE. I never tried PVCoordinates yet but I will try it out .

I found a solution which is writting a function that parses the tles to extract the keplerian and compute the SMA to build a Keplerian Orbit and it works I have the proper anomaly value.

Here is the code if someone needs

def parse_tle(line1, line2):
    keplerian = {}
    keplerian['mean_motion'] = float(line2[52:63])
    keplerian['eccentricity'] = float('0.' + line2[26:33])
    keplerian['inclination'] = float(line2[8:16])
    keplerian['right_ascension'] = float(line2[17:25])
    keplerian['argument_of_perigee'] = float(line2[34:42])
    keplerian['mean_anomaly'] = float(line2[43:51])
        # Calculate semi-major axis (a) using mean motion (n) and Earth's gravitational constant (mu)
    mu = 398600.4418  # Earth's gravitational constant in km^3/s^2
    n = keplerian['mean_motion'] * 2 * FastMath.PI / 86400  # Convert mean motion to radians/minute
    a = (mu / (n ** 2)) ** (1 / 3)  # Calculate semi-major axis in kilometers
    keplerian['semi_major_axis'] = a
    return keplerian

Hi there,

The orbital elements written as strings in a TLE are mean ones according to the SGP4 theory.
When you use a TLEPropagator, you’re implicitly converting to osculating ones. So it’s expected to be some numerical differences between the two, especially on the anomaly which is the fast variable.


Hi @Serrof , I can’t thank you enough for your comment it is very interesting, I thought that the Mean anomaly in the TLE was the Mean anomaly at the TLE epoch I thought that it gives us the position on the orbit given the RAAN and AOP . But then If it is a “Mean” mean-anomaly how do I get a position ? because I have inclinaison eccentricity raan aop epoch but in need my angular position on the orbit . Don’t I ?

O but do you mean that it is to be expected that the Mean Anomaly varies ? Because I mean at Initial state. The deal is that I was surprised to see that the Mean Anomaly at t=0 isn’t the same given that t=0 is the TLE date so the mean anomaly should ( from my understanding) be the same as in the TLE ?

Hi again,

If you want the position and velocity or the osculating elements, you need to do something like @lirw1984 said.


Hi @Anthony ,

Additionally, the frame (coordinate system) of TLE is TEME(True Equator Mean Equinox), while the most used frame is eme2000.

1 Like

Could it explains the difference I had at initial state for the mean anomaly ?

@Serrof Hi Serrof thank you for your answer. What do you mean ? I want to use the Keplerian not cartesian parameter . And what do you call osculating parameters ? Are you using cartesian keplerian ? From my understanding with Keplerian parameters the only osculating parameter in the anomaly ( mean true or excentric ) because It will cycle periodically 0 to 2pi as I move along my orbit . Or what do mean ?

I found this " the osculating orbit of an object in space at a given moment in time is the gravitational Kepler orbit (i.e. an elliptic or other conic one) that it would have around its central body if perturbations were absent.[1] That is, it is the orbit that coincides with the current orbital state vectors (position and velocity). "

Hi Anthony,

Osculating Keplerian elements are the ones you would have if there was no perturbation whatsoever (so basically just a spherical Earth). The anomaly is just one of them. When you actually consider perturbations, all six osculating elements evolve over time. Mean elements are obtained by somehow averaging them, and there are many ways of doing it. I suggest you read an astrodynamics textbook on these topics.

You can obtain the osculating Keplerian elements from a TLE by using lirw1984’s code and calling the relevant getters e.g. getA.


1 Like

Hi Romain,

Ok thank you for this explanation.