Strange Behavior of KeplerianOrbit

Hello everyone,

I may be overlooking something very trivial, but running the following code throws me a strange error:

p2 = Vector3D(float(pos_x_array[0])*1000, 
              float(pos_y_array[0])*1000, 
              float(pos_z_array[0])*1000)                  # in [m]

v2 = Vector3D(float(vel_x_array[0])*1000, 
              float(vel_y_array[0])*1000, 
              float(vel_z_array[0])*1000)                  # in [m/s]

PVcoord = PVCoordinates(p2, v2)

print(PVcoord)
print(type(PVcoord))

KeplerOrbit = KeplerianOrbit(PVcoord, ECI, initialDate, Mu_earth)
{P(882599.856801, 4329281.121656001, 5322653.8791438), V(-6626.5659551, 3337.3076321, -1611.2564281), A(0.0, 0.0, 0.0)}
<class 'org.orekit.utils.PVCoordinates'>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [37], in <cell line: 14>()
     11 print(PVcoord)
     12 print(type(PVcoord))
---> 14 Keplerorbit = KeplerianOrbit(PVcoord, ECI, initialDate, Mu_earth)

TypeError: 'Orbit' object is not callable

KeplerianOrbit method is created as it should be but I have no idea why ‘Orbit’ object is not callable in my case. Any ideas on this issue?

Thank you for the discussion in advance,
Baris

Hey there,

Did you make sure that your Mu_earth is a Python float?
None of Orbit’s constructors are public so this could partially explain the error.

Best,
Romain.

Hi @Echulion,

Your code is not complete. It is really weird.
Here is mine,

mu = Constants.EIGEN5C_EARTH_MU
eme2000 = FramesFactory.getEME2000()
initialDate = AbsoluteDate('2022-08-08T03:53:06.891648', utc)
p2 = Vector3D(882599.856801, 4329281.121656001, 5322653.8791438)
v2 = Vector3D(-6626.5659551, 3337.3076321, -1611.2564281)

PVcoord = PVCoordinates(p2, v2)

print(PVcoord)
print(type(PVcoord))

KeplerOrbit = KeplerianOrbit(PVcoord, eme2000, initialDate, mu)

Hello @Serrof, yes I checked it again and it is a Python float.

Yes @lirw1984, I did not share the complete code since I thought that frame, absolute date and standart earth gravitational parameter are quite straight forward and obvious.

The code works well all by itself and I can get Kepler Elements with no problem, but when I want to check Kepler elements at each time step inside a propagation loop, it throws that error. Strange really.

Hi @Echulion,

OK. I’ve no idea what you are doing.

Hi @Echulion,

Your problem looks similar to the one in this post.
You may be missing an explicit cast to KeplerianOrbit here.

Quoting Petrus:

Does that solve your issue ?

Hello @MaximeJ, its good to see you :blush:

Yes, my problem is indeed the one you have shared in that post and @luc described it on the point. I’ve tried to explicitly cast my orbit but it still returns me “orbit” type as following:

p2 = Vector3D(float(pos_x_array[0])*1000, 
              float(pos_y_array[0])*1000, 
              float(pos_z_array[0])*1000)                  # in [m]

v2 = Vector3D(float(vel_x_array[0])*1000, 
              float(vel_y_array[0])*1000, 
              float(vel_z_array[0])*1000)                  # in [m/s]

PVcoord = PVCoordinates(p2, v2)

orbit = OrbitType.KEPLERIAN.convertType(CartesianOrbit(PVcoord, ECI, initialDate, Mu_earth))
print(type(orbit))
orbit = KeplerianOrbit.cast_(orbit)
print(type(orbit))
<class 'org.orekit.orbits.Orbit'>
<class 'org.orekit.orbits.Orbit'>

Considering the discussion made in the post you’ve shared, I would expect to get a KeplerianOrbit after casting. :man_shrugging:t3: