Jeff Whitaker wrote:

Armin Moser wrote:

Hi,

I would like to interpolate an array of shape (801,676) to regularily

spaced datapoints using griddata. This interpolation is quick if the

(x,y) supporting points are computed as X,Y = meshgrid(x,y). If this

condition is not fullfilled the delaunay triangulation is extremely

slow, i.e. not useable. Is this a known property of the used

triangulation? The triangulation can be performed with matlab without

any problems.

Armin

Armin: You could try installing the natgrid toolkit and see if that

speeds up griddata at all. If not, please post a test script with data

and maybe we can figure out what is going on.

I have already tried natgrid and it didn't improve the situation. As

suggested I append a script demonstrating the problem.

Thanks

Armin

------8<-------------

from numpy import *

from pylab import *

import time

deg2rad = pi/180.0

ai = 0.12*deg2rad

x = linspace(13,40,676)

y = linspace(10,22,801)

x = x*deg2rad

y = y*deg2rad

[x,y] = meshgrid(x,y)

z = (x**2+y**2)

xi = linspace(x.min(),x.max(),x.shape[1])

yi = linspace(y.min(),y.max(),y.shape[0])

tic= time.time()

zi = griddata(x.flatten(),y.flatten(),z.flatten(),xi,yi)

toc = time.time()

print toc-tic

fac = 2*pi/1.2681

nx = fac * (cos(y)*cos(x) - cos(ai))

ny = fac * (cos(y)*sin(x))

nz = fac * (sin(y) + sin(ai))

np = sqrt(nx**2 + ny**2)

z = (np**2+nz**2)*exp(-0.001*nz)

xi = linspace(np.min(),np.max(),x.shape[1])

yi = linspace(nz.min(),nz.max(),y.shape[0])

tic = time.time()

zi = griddata(np.flatten(),nz.flatten(),z.flatten(),xi,yi)

toc = time.time()

print toc-tic