[SciPy-User] 2D interpolation on random points of a function defined on a regular grid
Antonio
tritemio@gmail....
Tue Apr 23 19:05:34 CDT 2013
Hi,
I'm trying (with no success) to compute the interpolated values of a 2D
function that is known on a regular grid X,Y. Although the function is
defined on a regular grid I want to compute the interpolation on arbitrary
positions.
I though I could use scipy.interpolate.interp2d, but apparently that
function works only to compute interpolation on a regular (rectilinear)
grid.
Here it is a (not working) example:
# Generate a simple 2D function
nx, ny = 5,4 # size of x and y axis
xd = arange(nx) # x axis
yd = arange(ny) # y axis
data = arange(nx*ny).reshape(ny,nx) # assume this is the result of
# a function evaluation on the
Cartesian
# grid [xd , yd]
# Generate some points where to compute the interpolation
x = rand(10)*xd.max()
y = rand(10)*yd.max()
# Interpolation (DOESN'T WORK)
import scipy.interpolate as SI
interp_fun = SI.interp2d(xd,yd,data)
z = interp_fun(x,y)
Is there a way in scipy to perform such interpolation?
Antonio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130423/52c567d2/attachment.html
More information about the SciPy-User
mailing list