Frame Transformation between Frames

Hi,

I am working on a project wherein I need the heliocentric states of Earth and Mars expressed in EME2000 frame. I am guessing the way to approach this to obtain the Earth and Mars using frame = sun.getInertiallyOrientedFrame() and then transform it to EME2000. The way I went about this is as follows:

# Obtain Earth and Mars positions 
earth = CelestialBodyFactory.getEarth()
earthpvprovider = PVCoordinatesProvider.cast_(earth)
mars = CelestialBodyFactory.getMars()
marspvprovider = PVCoordinatesProvider.cast_(mars)
sun = CelestialBodyFactory.getSun()
eci = sun.getInertiallyOrientedFrame()
eme2000 = FramesFactory.getEME2000()

earthp = earthpvprovider.getPVCoordinates(EPOCH_DEP.get_absolutedate(), eci).getPosition()
earthv = earthpvprovider.getPVCoordinates(EPOCH_DEP.get_absolutedate(), eci).getVelocity()
marsp = marspvprovider.getPVCoordinates(EPOCH_ARR.get_absolutedate(),eci).getPosition()
marsv = marspvprovider.getPVCoordinates(EPOCH_ARR.get_absolutedate(),eci).getVelocity()

transform_epoch = eci.getTransformTo(eme2000, EPOCH_DEP.get_absolutedate())
transform_arrival = eci.getTransformTo(eme2000, EPOCH_ARR.get_absolutedate())

earthp_eme2000 = transform_epoch.transformPosition(earthp)

But I am getting the following error. Can somebody explain where I am going wrong here? Thanks!

AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_21945/3051891755.py in <module>
     16 transform_arrival = eci.getTransformTo(eme2000, EPOCH_ARR.get_absolutedate())
     17 
---> 18 earthp_eme2000 = transform_epoch.transformPosition(earthp)
     19 
     20 lambert = IodLambert(CelestialBodyFactory.getSun().getGM())

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

Hello @suraj101195,

You are getting this error because the “transformPosition” method comes from StaticTransform which is then inherited by Transform. The python wrapper needs to have explicitely the right object to access its methods so you need to cast your Transform to a `StaticTransform"

You can check the Transform documentation for more information (i’m putting the 12.2 version) : Transform (OREKIT 12.2 API)

Solution

static_transform_epoch = StaticTransform.cast_(transform_epoch)
earthp_eme2000 = static_transform_epoch.transformPosition(earthp)

Recommanded python wrapper documentation

I highly recommend to everyone coming onto this thread to check the following documentation if they have not done so already :

It explains the most common errors and how to use the Python wrapper.

Cheers,
Vincent