Hello Vincent,
I should have mentionned earlier that I am currently running Python Wrapper on the 12.1.2 version, sorry for that.
I adapted your benchmark to Python and found the Ephemeris
to be indeed faster, with the Wrapper too.
However my use case is a bit different because I do not propagate to the same date multiple times, but instead at increments of time, and it seems to have an impact.
Here is a more detailled example, in which the Ephemeris
is slower than the SpacecraftStateInterpolator
(by a factor of 2 in average) :
from config import OREKIT_DATA
import datetime
import orekit
from orekit.pyhelpers import setup_orekit_curdir
from java.util import ArrayList
from org.hipparchus.analysis.polynomials import SmoothStepFactory
from org.orekit.frames import FramesFactory
from org.orekit.orbits import OrbitBlender, PositionAngleType, KeplerianOrbit
from org.orekit.propagation import SpacecraftState, SpacecraftStateInterpolator, Propagator
from org.orekit.propagation.analytical import Ephemeris, KeplerianPropagator
from org.orekit.time import AbsoluteDate, DateComponents, TimeComponents, TimeScalesFactory
from org.orekit.utils import Constants
from org.orekit.propagation.sampling import PythonOrekitFixedStepHandler
class StateCollectorHandler(PythonOrekitFixedStepHandler):
"""Custom step handler to collect states into an ArrayList."""
def __init__(self, states_list):
self.states_list = states_list
super(StateCollectorHandler, self).__init__()
def init(self, spacecraftState: SpacecraftState, absoluteDate: AbsoluteDate, double: float):
"""Required by OrekitFixedStepHandler."""
pass
def handleStep(self, spacecraftState):
# Add current state to the list
self.states_list.add(spacecraftState)
def finish(self, finalState):
"""Required by OrekitFixedStepHandler."""
pass
def get_states(orbit, date, step, nb_steps):
# Create list of states
states = ArrayList().of_(SpacecraftState)
propagator = Propagator.cast_(KeplerianPropagator(orbit))
# Set up custom step handler
step_handler = StateCollectorHandler(states)
propagator.setStepHandler(step, step_handler) # Use custom handler to add states at one day intervals
propagator.propagate(date.shiftedBy(step * nb_steps))
return states
def launch_test(launch_type):
# Create some orbit
date = AbsoluteDate(DateComponents(2001, 1, 1), TimeComponents(12, 0, 0.0), TimeScalesFactory.getUTC())
mu = Constants.EIGEN5C_EARTH_MU
frame = FramesFactory.getEME2000()
orbit = KeplerianOrbit((6378.0 + 500.0), 0.001, 0.001, 0.0, 0.0, 0.0, PositionAngleType.MEAN, frame, date, mu)
# Get states list
nb_steps = 10
states = get_states(orbit, date, 86400.0, 10)
# Create new propagator
propagator = Propagator.cast_(KeplerianPropagator(orbit))
# Create orbit blender
orbitBlender = OrbitBlender(SmoothStepFactory.getQuintic(), propagator, frame)
# Create spacecraft state interpolator
interpolator = SpacecraftStateInterpolator(2, 1.0e-3, frame, orbitBlender, None, None, None, None)
if launch_type == 'interpolator':
start = datetime.datetime.now()
for i in range(nb_steps):
interpolator.interpolate(date, states)
date = date.shiftedBy(86400.0)
# print(f"Interpolator interpolate method : {datetime.datetime.now() - start}")
return datetime.datetime.now() - start
elif launch_type == 'ephemeris':
# Create ephemeris
ephemeris = Ephemeris(states, interpolator)
start = datetime.datetime.now()
for i in range(nb_steps):
ephemeris.propagate(date)
date = date.shiftedBy(86400.0)
# print(f"Ephemeris propagate method : {datetime.datetime.now() - start}")
return datetime.datetime.now() - start
if __name__ == '__main__':
vm = orekit.initVM()
setup_orekit_curdir(filename=OREKIT_DATA)
interp_times = []
ephem_times = []
for i in range(100):
interp_times.append(launch_test('interpolator'))
ephem_times.append(launch_test('ephemeris'))
interp_avg_time = sum(interp_times, datetime.timedelta(0))/len(interp_times)
ephem_avg_time = sum(ephem_times, datetime.timedelta(0))/len(ephem_times)
print(f'Interpolator interpolate method average time : {interp_avg_time}')
print(f'Ephemeris propagate method average time : {ephem_avg_time}')
Interpolator interpolate method average time : 0:00:00.000304
Ephemeris propagate method average time : 0:00:00.000597
Regards,
Grégoire