Reputation: 121
I have a data set data[xi,yi,zi]
I'd like to plot (with interpolation values). With scipy.interpolate, everything looks almost perfect however the interpolation is generating some values beyond the bounds of the input data. for example suppose zi
is bound by 0 < zi < 1
, the rbf interpolatation seems to be returning interpolated values out of the bounds (e.g. >1
); here my simplified attempt:
N=100
data=[xi yi zi]
xis = np.linspace(xi.min(), xi.max(), N)
yis = np.linspace(yi.min(), yi.max(), N)
XI, YI = np.meshgrid(xis,yis)
rbf = scipy.interpolate.Rbf(xi, yi, zi, function='linear')
ZI=rbf(XI,YI)
print ZI.max()
->1.01357328514
Is there a way to pass limits to Rbf and let it know not to go past zi.max() and zi.min() ?
Upvotes: 1
Views: 913
Reputation:
Interpolation with radial basis functions may result in values above the maximum and below the minimum of the given data values. (Illustration). This is a mathematical feature of the method, one cannot pass in an option to disable it. Two possible solutions:
np.clip
to clip the interpolant between the min-max values of the data, when plotting it. scipy.interpolate.LinearNDInterpolator
), which is guaranteed to respect the minimum and maximum of data values.Upvotes: 2