title: 3d Interpolation in Scipy--a density grid
body: <p>I have a set of coordinates representing the 3d positions of a number of objects. These points are taken from a simulation of a 3-d cube. What I need to do is to make a 3d grid on the cube, and then to assign these points to their correct places on the grid, so that I can then find the density of objects in each section of the grid. I've been searching the interpolation and grid documentation (http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html#scipy.interpolate.griddata), for instance, but am unsure what to make of it because I don't have a function associated with these data points. What I was thinking of doing was using an if statement: given an array of points=[x1,y1,z1],[x2,y2,z2],etc, if points[i][0]-gridpoint1[0]&lt;1: if points[i][1]-gridpoint1[1]&lt;1: if points[i][2]-gridpoint1[2]&lt;1, points[i]=bin1[i], where bin1 would be a premade array of zeros. However, I think I'd have to run this for every gridpoint on the grid (the gridpoint would be in the center of every bin), and then to figure out how many non-zero elements there were in each bin, which I am also not sure how to do. I have a feeling I can use some sort of function in scipy to do this entire task more easily, but I am still unsure how to get there. Thanks so much in advance for your help!</p>