3-D interpolation using LinearNDInterpolator (Python) -


i want interpolate 3-d data using scipy linearndinterpolator function (python 2.7). can't quite figure out how use it, though: below attempt. i'm getting error valueerror: different number of values , points. leads me believe shape of "coords" not appropriate these data, looks in documentation shape okay.

note in data want use (instead of example) spacing of grid irregular, regulargridinterpolator not trick.

thanks help!

def f(x,y,z):     return 2 * x**3 + 3 * y**2 - z  x = np.linspace(1,2,2) y = np.linspace(1,2,2) z = np.linspace(1,2,2)   data = f(*np.meshgrid(x, y, z, indexing='ij', sparse=true))  coords = np.zeros((len(x),len(y),len(z),3)) coords[...,0] = x.reshape((len(x),1,1)) coords[...,1] = y.reshape((1,len(y),1)) coords[...,2] = z.reshape((1,1,len(z))) coords = coords.reshape(data.size,3)  my_interpolating_function = linearndinterpolator(coords,data)   pts = np.array([[2.1, 6.2, 8.3], [3.3, 5.2, 7.1]]) print(my_interpolating_function(pts)) 


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

c# - Json.Net Serialize String from URI -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -