[SciPy-user] 2-D interpolation of irregularly spaced data

Emmanuelle Gouillart emmanuelle.gouillart@normalesup....
Sun Sep 14 09:02:17 CDT 2008


	Hello,

	I have an irregular 2-D mesh, and 1-D data measured at the
vertices of the mesh (the mesh is finer where the data vary more
rapidly), and I need to interpolate the data at other (also irregularly
spaced) points. To do so, I use the delaunay scikit and its
NNInterpolator which can take an iregular mesh. The problem is that I
cannot call the interpolator with irregularly spaced points, so that my
code is running very slowly now. Here is a minimal example of what I do
now (with regular grids and few points for clarity):

***
import scikits.delaunay as d

def evolve(positions, mesh, values):
    tri = d.Triangulation(mesh[0], mesh[1])
    interpolator = d.NNInterpolator(tri, values)
    return  array([interpolator(x,y) for (x,y) in positions.T]).ravel()

#Mesh    
X, Y = mgrid[-1:1:20j, -1:1:20j] #regular grid for clarity 
X = X.flatten()
Y = Y.flatten()
mesh = array([X,Y])
#Values
values = Y**2
#Positions
positions = mgrid[-0.5:0.5:20j, -0.5:0.5:20j]
positions = array([positions[0].flatten(), positions[1].flatten()])

new_values = evolve(positions, mesh, values)
***

Any hints about I could accelerate the interpolation? (Usually, I work
with meshes of size ~1.e4 and positions of size ~1.e6). Any help will be
very welcome!

Cheers,

Emmanuelle 


More information about the SciPy-user mailing list