Hi all,
I'm trying to test the math3 interpolation to find a desired interpolated value based on a x input. I've got the following code:
import system
from org.apache.commons.math3.analysis.interpolation import LinearInterpolator
from org.apache.commons.math3.analysis.polynomials import PolynomialSplineFunction
# Example data points
x_data = [18, 19, 20, 21, 22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42] # Replace with your x values
y_data = [35,39,43,44,45,47,49,51,52,52,53,54,55,55,56,57,57,58,58,59,59,59,60,60,60] # Replace with your y values
# Create a linear interpolator
interpolator = LinearInterpolator()
interpolation_function = interpolator.interpolate(x_data, y_data)
# Find the value on the curve at a given point
x_value = 18 # Replace with the desired x value
interpolated_value = interpolation_function.value(x_value)
# Print the interpolated value
system.tag.writeAsync("[default]site_lathe/graph/DesiredRecovery",interpolated_value)
It worked!
Then, I changed the xvalue = 18 to something like x_value = system.tag.read(" a path to a memory float tag"), and error in gateway said:
org.python.core.PyException: TypeError: value(): 1st arg can't be coerced to org.apache.commons.math3.analysis.differentiation.DerivativeStructure, double
Any advises will be much appreciated!