Negative RAAN and AOP: KeplerianOrbit vs TLE

Dear all,

I am working on fitting Two-Line Elements from an orbit propagator. To compute a “first guess”, I initialize a TLE object from osculating elements from a KeplerianOrbit object.

However, I run into issues when the Right Ascension of Ascending Node (RAAN) or the Argument of Perigee (AOP) are negative. These values can indeed be negative in a KeplerianOrbit object, but a TLE does not accept them. When creating the TLE, no exception is raised, and I can even use this TLE object for further computations, but an exception is raised when asking for a string representing this TLE.

The code is the following:

from org.orekit.orbits import KeplerianOrbit
initial_orbit_keplerian = KeplerianOrbit(initial_orbit)

perigee_argument = initial_orbit_keplerian.getPerigeeArgument()
raan = initial_orbit_keplerian.getRightAscensionOfAscendingNode()
    
from org.orekit.propagation.analytical.tle import TLE
tle_first_guess = TLE(satellite_number, 
                      classification,
                      launch_date.year,
                      launch_number,
                      launch_piece,
                      ephemeris_type,
                      element_number,
                      separation_date,
                      initial_orbit_keplerian.getKeplerianMeanMotion(),
                      0.0,  # Mean motion first derivative
                      0.0,  # Mean motion second derivative
                      initial_orbit_keplerian.getE(),
                      initial_orbit_keplerian.getI(),
                      perigee_argument,
                      raan,
                      initial_orbit_keplerian.getMeanAnomaly(),
                      revolution_number,
                      b_star_first_guess)

print(tle_first_guess.toString())

Raises the following exception:

---------------------------------------------------------------------------
JavaError                                 Traceback (most recent call last)
<ipython-input-20-da382527e187in <module>
----1 tle_first_guess.toString()

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
org.orekit.errors.OrekitInternalError: internal error, please notify development team by creating an issue at https://gitlab.orekit.org/orekit/orekit/issues
	at org.orekit.propagation.analytical.tle.TLE.toString(TLE.java:693)
Caused by: org.orekit.errors.OrekitException: invalid TLE parameter for object 99,999: raan = -120.1314
	at org.orekit.propagation.analytical.tle.TLE.addPadding(TLE.java:507)
	at org.orekit.propagation.analytical.tle.TLE.buildLine2(TLE.java:461)
	at org.orekit.propagation.analytical.tle.TLE.getLine2(TLE.java:357)
	at org.orekit.propagation.analytical.tle.TLE.toString(TLE.java:691)

For now I am checking the sign before creating the TLE object (see code below). It is no big deal, but maybe it would be good to add the angle ranges to the documentation or to check the sign in the TLE constructor.

perigee_argument = initial_orbit_keplerian.getPerigeeArgument()
if perigee_argument < 0:
    perigee_argument += float(2*np.pi)
    
raan = initial_orbit_keplerian.getRightAscensionOfAscendingNode()
if raan < 0:
    raan += float(2*np.pi)

Cheers
Clément

Good point about it at least should be in documentation. Since the TLEs hypothetically have to be carried around as TLEs if the format doesn’t accept it we should probably address it with more than just documentation. Do we address it at serialization time perhaps?

Hi,

This is a dimensional problem in the TLE display. Indeed, the “-” sign occupies a character that causes one character too many for the display of the RAAN in the TLE. However, that’s an issue that has to be, at least, documented as you proposed with Hank. The OrekitInternalError exception is not a user-friendly one and has to be replaced by a more explicit message.

Right Ascension of Ascending Node and the Argument of Perigee are positive angles in the TLE format (see). In that respect, there are two possibilities:

  1. Throw an exception if the user initialized negative angles.
  2. If the angles are negative, then normalize them between 0 and 2 pi inside the TLE constructor (more user-friendly because no exceptions are thrown).

@yzokras can you open an issue on the Gitlab forge ?

Regards,
Bryan

I would prefer option 2.

1 Like

I prefer #2 as well but maybe only at time of serialization when it matters…

Thank you all for your feedbacks!

I created an issue in Gitlab: https://gitlab.orekit.org/orekit/orekit/-/issues/664

I also agree that option number 2 is the most user-friendly. Here is a merge request for a proposal to fix this: https://gitlab.orekit.org/orekit/orekit/-/merge_requests/51

The merge request https://gitlab.orekit.org/orekit/orekit/-/merge_requests/51 was merged.