[SciPy-User] [SciPy-user] 2d interpolation, non-regular lat/lon grid - help with delauney/natgrid??
Scott Sinclair
scott.sinclair.za at gmail.com
Thu Aug 13 12:37:25 EDT 2009
> 2009/8/13 Robert Kern <robert.kern at gmail.com>:
> On Thu, Aug 13, 2009 at 08:47, John [H2O]<washakie at gmail.com> wrote:
>>
>> YOU should've read the (FM)?? Or I? ;)
Looks like everyone needs to :)
>> Actually, I have referred to both docs, but I'm just missing something. &-(
>>
>> Unfortunately, it seems now the problem is that m (basemap instance) expects
>> grid_lon, grid_lat to be of the same length. I tried to convert them into
>> meshgrid objects, but then I get the error I received in the prior message
>> about monotonically increasing axes...
>
> Ah, yes. griddata() only handles regular grids for some reason, not
> arbitrary interpolation points. You will have to use the underlying
> delaunay package to interpolate arbitrary points. Using your variable
> names:
>
> # triangulate data
> tri = delaunay.Triangulation(x,y)
> # interpolate data
> interp = tri.nn_interpolator(z)
> Z0 = interp(gridx, gridy)
Cool, I didn't know about going directly to the delaunay package!
I think the original problem was with the large area of missing data
in the plot. John?
This is just a result of the transformation from a regular grid in
long/lat to the projection co-ordinates. The projected grid is no
longer a regular rectangular grid in the polar projections co-ordinate
system. Have a look at the attached script and set proj_grid to True
or False before running the script, to see the difference between
interpolating from scattered points to a grid that is regular and
rectangular in long/lat and one that is regular in a polar projection.
Cheers,
Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: griddata_demo.py
Type: application/x-python
Size: 1481 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20090813/52c9c495/attachment.bin>
More information about the SciPy-User
mailing list