[SciPy-user] best way to interpolate NAN's in 3d array
Wed Jan 16 09:08:34 CST 2008
On Jan 16, 2008 8:23 AM, Vincent Schut <email@example.com> wrote:
> Hi guru's,
> Let's say I have a (25,50,50) array, with approximately half of the
> items filled, half of them NAN due to missing input data. Could someone
> suggest a good way to interpolate/fill these NAN's?
> What I'm doing currently is using scipy.ndimage.generic_filter with a
> averaging 3x3x3 filter, running it recursively till all NAN's are gone.
> This worked fine for my prototyping arrays of 10x10x10, with 25x50x50
> however things are kind of slow.
> As you can see, the accuracy of the interpolation is not very important
> (my implementation has lots of drawbacks compared to 'real'
> interpolation). Issue is I want to use the result to use
> ndimage.map_coordinates on, which will always return NAN whenever a NAN
> was close to the coordinates mapped to... So the main issue is to get
> rid of those NAN's, and fill them with more or less the
> average/interpolation of the surrounding known values. Or get a NAN- or
> maskedarray sensitive replacement for map_coordinates :-)
I suppose you could solve a discrete Poisson problem with the NaN
values as unknowns and the non-NaN values as Dirichlet boundary
conditions. The solution will be very smooth and similar to your
Nathan Bell firstname.lastname@example.org
More information about the SciPy-user