Q:

scipy griddata interpolation returns a vector filled with nan

I have a list of points on in 3d that I would like to interpolate on a 3d grid.
coords = array([[  8.33399963,  12.94800186,  15.22500038],
       [  8.57299995,  13.90000153,  14.14700031],...)

I have the grid x,y,z coordinates, which together with numpy.meshgrid are used to create the grid:
xi,yi,zi = np.meshgrid(bbox[:,0],bbox[:,1],bbox[:,2])

and then when I try to perform the interpolation:
griddata(coords,np.random.choice([.1,1,2],size=len(coords)),(xi,yi,zi),method='linear')

I get a vector of nans:
array([[[ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan],
        [ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan],
        [ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan],
        [ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan],
        [ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan],
        [ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan],
        [ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan],
        [ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan]],....

What am I doing wrong here?

A:

I do not know what xi,yi,zi values are but most likely they are outside the domain defined by coords. If you use meshgrid to generate the grid, then pay attention to the order of the arrays:

In the 3-D case with inputs of length M, N and P, outputs are of shape (N, M, P) for ‘xy’ indexing and (M, N, P) for ‘ij’ indexing.

Try this:
In [61]: coords = 20 * np.random.random((200, 3)) - 1

In [62]: xi, yi, zi = np.meshgrid(np.arange(coords[:, 0].min()+2, coords[:,0].max()-2), np.arange(coords[:, 1].min()+2, coords[:,1
    ...: ].max()-2), np.arange(coords[:, 2].min()+2, coords[:,2].max()-2), indexing='ij')

In [63]: griddata(coords,np.random.choice([.1,1,2],size=len(coords)),(xi.astype(np.float), yi.astype(np.float), zi.astype(np.float
    ...: )),method='linear')

You will still get some nan values where points poorly sample the function but most values are defined. 
Another possibility is that you are just seeing the first "plane" which may contain mostly nan. Try np.sum(np.isfinite(g)) to see how may points are valid out of all points np.prod(g.shape) where g is thr output from griddata().

