TypeError: m >= (kx+1)(ky+1) must hold
means that you've supplied too few points, not that the data must be grid data. m
is equal to len(X)
(or len(Y)
, or len(Z)
).
kx
and ky
control the degree of the spline.
So, for example, if you increase the length of x
, y
and z
:
import scipy.interpolate as interpolate
x = [1,2,1,2,1,3,2,3,3]
y = [1,2,2,1,3,1,3,2,3]
z = [1,2,1,2,0,0,0,0,0]
kx, ky = 2, 2 # spline order
assert len(x) >= (kx+1)*(ky+1)
tck = interpolate.bisplrep(x, y, z, kx=kx, ky=ky)
print(interpolate.bisplev(1.5,1.5,tck))
prints
2.109375