Jeff Whitaker wrote: > Armin Moser wrote: >> 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.
Reducing the original grid from 676x801 to 100x120, I get benchmarks of about 6 seconds with natgrid and 0.15 s with Robert's delaunay. This seems quite repeatable. I also tried randomizing x and y in the first benchmark with natgrid, and it made only a slight difference. Eric >> >> Thanks >> Armin >> > > Armin: On my mac, your two benchmarks take 15 and 14 seconds. Do you > consider that too slow? > > Perhaps this is just a toy example to test griddata, but I assume you > realize that you wouldn't normally use griddata to interpolate data on > one regular grid to another regular grid. griddata is strictly for > interpolating scatter data (not on a regular mesh) to a regular mesh. > > -Jeff >> ------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 >> > > ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users