I have grabbed a bunch of points in 3d that define a relatively simple 3d surface (three of them):
I've been trying to figure out how to come up with a function for each (using curve_fit
from scipy
), but I'm probably doing something wrong -- I thought that going with something like a quadratic function would be enough for this:
def f(X, a, b, c, d, e, f):
x, y = X
return a + b*x + c*y + d*x**2 + e*y**2 + f*x*y
popt, pcov = curve_fit(f, (mirek, brightness), normal)
print(popt)
But the resulting coefficients have a huge error that doesn't come anywhere close to approximating the original surface.
Could anyone please point me to the right direction? I'm capable to learn, but this (reversing a math function out of observed behavior) is a completely new thing for me.
Also, I mostly have generic opensource tools at my disposal (ruby, python, gnuplot, etc), so telling me that there's a Mathematica/Matlab package would not help much...
scipy.interpolate.NdBSpline
... $\endgroup$