title: Filling gaps in a numpy array
body: <p>I just want to interpolate, in the simplest possible terms, a 3D dataset. Linear interpolation, nearest neighbour, all that would suffice (this is to start off some algorithm, so no accurate estimate is required). </p>
  
  <p>In new scipy versions, things like griddata would be useful, but currently I only have scipy 0.8. So I have a "cube" (<code>data[:,:,:]</code>, (NixNjxNk)) array, and an array of flags (<code>flags[:,:,:,]</code>, <code>True</code> or <code>False</code>) of the same size. I want to interpolate my data for the elements of data where the corresponding element of  flag is False, using eg the nearest valid datapoint in data, or some linear combination of "close by" points.</p>
  
  <p>There can be large gaps in the dataset in at least two dimensions. Other than coding a full-blown nearest neighbour algorithm using kdtrees or similar, I can't really find a generic, N-dimensional nearest-neighbour interpolator.</p>