Univariate Noise issue

Hi everyone!

I’ve been asking in recent posts about the different process noise models available in Orekit, and I’ve been working with the UnivariateProcessNoise using the UnivariateFunctions defined (using polynomials).

I am programming in Python and the thing is that using those functions works perfectly fine. However, when I try to use own defined functions using PythonUnivariateFunction I get the following error:

>
    Java stacktrace:
java.lang.RuntimeException: type error
        at org.hipparchus.analysis.PythonUnivariateFunction.value(Native Method)
        at org.orekit.estimation.sequential.UnivariateProcessNoise.getInertialOrbitalProcessNoiseMatrix(UnivariateProcessNoise.java:213)
        at org.orekit.estimation.sequential.UnivariateProcessNoise.getProcessNoiseMatrix(UnivariateProcessNoise.java:174)
        at org.orekit.estimation.sequential.AbstractKalmanEstimationCommon.getNormalizedProcessNoise(AbstractKalmanEstimationCommon.java:508)
        at org.orekit.estimation.sequential.UnscentedKalmanModel.getProcessNoiseMatrix(UnscentedKalmanModel.java:186)
        at org.orekit.estimation.sequential.UnscentedKalmanModel.getProcessNoiseMatrix(UnscentedKalmanModel.java:47)
        at org.hipparchus.filtering.kalman.unscented.UnscentedKalmanFilter.predictionAndCorrectionSteps(UnscentedKalmanFilter.java:126)
        at org.hipparchus.filtering.kalman.unscented.UnscentedKalmanFilter.estimationStep(UnscentedKalmanFilter.java:105)
        at org.orekit.estimation.sequential.UnscentedKalmanEstimator.estimationStep(UnscentedKalmanEstimator.java:123)

The functions I am defining are of the following kind:

class std_radial_pos(PythonUnivariateFunction):
    def value(self, t):
        return np.sqrt(C * t**3 + 0.1)

being C a constant.

I am defining similar functions in LVLH frame for XYZ position and XYZ velocity. Also, for Cd and Cr are defined using Constant from UnivariateFunctions.

If anyone knows what could be happening it would be of tremendous help :smiley:.

Thank you so much in advance,
Antonio.

Update

The error ocurring is the following one:

RuntimeWarning: invalid value encountered in sqrt return np.sqrt(C * t**3 + 0.1)

Debugging to see what is happening I found that at some point the Kalman Estimator is trying to evaluate the process noise at t= -172435.0 s.

Any clue about what is going on? I am not doing backwards propagation and I am providing the measurements in datetime order.

Hello Antonio,
I personally do not have much experience with PythonUnivariateFunction, but looking at your code you are returning the output of np.sqrt(…) directly, which is of numpy.float64 datatype. Orekit does not like these, so I always wrap my numpy computations in the float() function.
Maybe this fixes your problem.

Cheers,
Pascal

Thank you so much for your answer, Pascal. However, after implementing float() the problem persists.