views:

217

answers:

2

Hi,

I realize that there is a griddata for numpy via matplotlib, but is there a griddata3 (same has griddata, but for higher dimensions).

In other words, I have (x,y,z,d(x,y,z)) where (x,y,z) form an irregular grid and d(x,y,z) is a scalar function of three variables. I need to generate d(xi,yi,zi) for a new set of (xi,yi,zi) points using some kind of interpolation that can handle the non-uniformity of the original (x,y,z) data. Ultimately, the (xi,yi,zi,d(xi,yi,zi)) data will have to be rendered as a surface somehow, but that's a problem for later. I also do not have an analytical form for the d(.) function; I just have data for it.

Any help appreciated.

A: 

I am not familiar with griddata3, but you might want to look into meshgrid and this related post.

bpowah
+1  A: 

Not sure how you intend to render a surface of a scalar function of 3 variables, except perhaps using cutplanes or something similar. Mayavi (really VTK which powers Mayavi) has support for efficient Delaunay triangulation via enthought.mayavi.mlab.pipeline.delaunay3d, which is the core of the algorithm used by griddata3. See the 2D example code they have posted, just add one dimension (and use delaunay3d instead). I don't know of a way to explicitly get the interpolated values used to render the surface, but there might be a way to sample it through Mayavi, you could dig through the documentation or ask on one of the Enthought mailing lists.

Alternatively, one of the C functions in the NCAR natgrid library may be useful i.e. dsgrid3d. There is a partial wrapper implemented as a matplotlib toolkit.

dwf
thanks! I will look into these.
reckoner