About transformPosition Method

Greetings everyone,

I have previously managed to work with the codes of Clément Jonglez (a.k.a GorgiAstro) on my laptop. I wanted to work with same stuff on my desktop as well (because why not, right…?), however the same code that works on my laptop, does not work on my desktop.

Here is part of the code where we will be comparing propagation results with cpf results in lvlh frame:

# Propagating the bounded propagator to retrieve the intermediate states

from slrDataUtils import orekitPV2dataframe

PV_eci_df = pd.DataFrame()
PV_ecef_df = pd.DataFrame()
PV_tle_eci_df = pd.DataFrame()
deltaPV_tle_lvlh_df = pd.DataFrame(columns=['x', 'y', 'z', 'pos_norm', 'vx', 'vy', 'vz', 'vel_norm'])
deltaPV_cpf_lvlh_df = pd.DataFrame(columns=['x', 'y', 'z', 'norm'])

# Saving all intermediate states
from java.util import ArrayList
states_list = ArrayList()

from org.hipparchus.geometry.euclidean.threed import Vector3D
X = []
Y = []
Z = []
date_current = date_start
while date_current.compareTo(date_end) <= 0:
    datetime_current = absolutedate_to_datetime(date_current)    
    spacecraftState = bounded_propagator.propagate(date_current)
    
    states_list.add(spacecraftState)
    
    PV_eci = spacecraftState.getPVCoordinates(eci)
    PV_eci_df = PV_eci_df.append(orekitPV2dataframe(PV_eci, datetime_current))
    
    PV_ecef = spacecraftState.getPVCoordinates(ecef)
    PV_ecef_df = PV_ecef_df.append(orekitPV2dataframe(PV_ecef, datetime_current))
    
    PV_tle_eci = sgp4Propagator.getPVCoordinates(date_current, eci)
    PV_tle_eci_df = PV_tle_eci_df.append(orekitPV2dataframe(PV_tle_eci, datetime_current))
    
    '''
    When getting PV coordinates using the SGP4 propagator in LVLH frame, 
    it is actually a "delta" from the PV coordinates resulting from the 
    orbit determination because this LVLH frame is centered on the satellite's 
    current position based on the orbit determination
    '''
    deltaPV_lvlh = sgp4Propagator.getPVCoordinates(date_current, lvlh)
    deltaPV_tle_lvlh_df.loc[datetime_current] = [deltaPV_lvlh.getPosition().getX(),
                                                 deltaPV_lvlh.getPosition().getY(), 
                                                 deltaPV_lvlh.getPosition().getZ(),
                                                 deltaPV_lvlh.getPosition().getNorm(),
                                                 deltaPV_lvlh.getVelocity().getX(),
                                                 deltaPV_lvlh.getVelocity().getY(), 
                                                 deltaPV_lvlh.getVelocity().getZ(),
                                                 deltaPV_lvlh.getVelocity().getNorm()]
    
    pos_cpf_ecef = cpfDataFrame.loc[datetime_current]
    ecef2lvlh = ecef.getTransformTo(lvlh, date_current)
    delta_pos_cpf_lvlh_vector = ecef2lvlh.transformPosition(Vector3D(float(pos_cpf_ecef[0]), float(pos_cpf_ecef[1]), float(pos_cpf_ecef[2])))
    deltaPV_cpf_lvlh_df.loc[datetime_current] = [delta_pos_cpf_lvlh_vector.getX(),
                                                 delta_pos_cpf_lvlh_vector.getY(), 
                                                 delta_pos_cpf_lvlh_vector.getZ(),
                                                 delta_pos_cpf_lvlh_vector.getNorm()]
    
    delta_pos_cpf_lvlh_X = delta_pos_cpf_lvlh_vector.getX()
    delta_pos_cpf_lvlh_Y = delta_pos_cpf_lvlh_vector.getY()
    delta_pos_cpf_lvlh_Z = delta_pos_cpf_lvlh_vector.getZ()
    X = np.append(X, delta_pos_cpf_lvlh_X)   # Store for comparison purposes with Kalman method
    Y = np.append(Y, delta_pos_cpf_lvlh_Y)   # Store for comparison purposes with Kalman method
    Z = np.append(Z, delta_pos_cpf_lvlh_Z)   # Store for comparison purposes with Kalman method
 
    date_current = date_current.shiftedBy(dt)

and the error is thrown as:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [44], in <cell line: 20>()
     51 pos_cpf_ecef = cpfDataFrame.loc[datetime_current]
     52 ecef2lvlh = ecef.getTransformTo(lvlh, date_current)
---> 53 delta_pos_cpf_lvlh_vector = ecef2lvlh.transformPosition(Vector3D(float(pos_cpf_ecef[0]), float(pos_cpf_ecef[1]), float(pos_cpf_ecef[2])))
     54 deltaPV_cpf_lvlh_df.loc[datetime_current] = [delta_pos_cpf_lvlh_vector.getX(),
     55                                              delta_pos_cpf_lvlh_vector.getY(), 
     56                                              delta_pos_cpf_lvlh_vector.getZ(),
     57                                              delta_pos_cpf_lvlh_vector.getNorm()]
     59 delta_pos_cpf_lvlh_X = delta_pos_cpf_lvlh_vector.getX()

AttributeError: 'Transform' object has no attribute 'transformPosition'

I really do not understand why is this happening since ‘Transform’ object definitely likes the attribute ‘transformPosition’ on my laptop. Any ideas what might cause this on my desktop?

PS: I am not proficient neither in Java nor in Python but I am trying to do my best :slight_smile: Sorry for asking a question that might be rather trivial.

Thanks!

Edit:

Apparently, instead of using getTransformTo one must use getStaticTransformTo in order to utilize transformPosition. It works that way. However, it still does not makes sense to me why the other way around works perfectly well on my laptop while it doesn’t on my desktop :man_shrugging:

Hey there,

In your activated anaconda environment check your versions of Orekit with pip freeze for example in the terminal. It’s very likely that they are not the same on your two platforms.

Best,
Romain.

1 Like