converted to python version

I am a python user. In the process of implementing the original Java version of the program in python, I encountered this code. I am not sure how to implement it in python.The key is the “currentState → {” in the middle.

Hi @chu1995,

This is an implementation of the interface FieldOrekitFixedStepHandler, using a lambda function in Java. The overridden method is the handleStep method .
I believe you cannot do that with lambdas in Python, you’ll have to write the class. There’s an example by Petrus Hyvonen here.
In your case, you’ll have to define a class inheriting from PythonFieldOrekitFixedStepHandler.


Thank you for your answer. I carefully studied the code at the location you specified, but I didn’t understand it. I hope you can provide more detailed guidance. I have been stuck at this location for a long time. :smiling_face_with_tear:

Hi again @chu1995,


                                         currentState -> {...

You need, in Python, to define a class inheriting from PythonFieldOrekitFixedStepHandler:

class MyFixedHandler(PythonFieldOrekitFixedStepHandler):
            def init(self, s0, t, step):  # All native defined calls needs to be implemented

            def handleStep(self, currentState):
                # Here you need to translate in Python the code of the Java handler

            def finish(self, s):

In method handleStep you need to translate in Python the code of the Java handler.
Starting with:

final TimeStampedFieldPVCoordinates<DerivativeStructure> PV_t =

And finishing with

                    //printing all the standard deviations on the file error.txt
                    PW.format(Locale.US, "%f\t%f\t%f\t%f\t%f%n",
                              currentState.getDate().durationFrom(date_0).getReal() / 3600,


Then, you will be able to write:
numProp.getMultiplexer().add(zero.add(int_step), MyFixedHandler()

This should reproduce the Java behavior you didn’t understand.


Thanks for your answer, it helped me learn a new skill!!!