interpolate_replace_nans

astropy.convolution.interpolate_replace_nans(array, kernel, convolve=<function convolve>, **kwargs)[source]

Given a data set containing NaNs, replace the NaNs by interpolating from neighboring data points with a given kernel.

Parameters:
arraynumpy.ndarray

Array to be convolved with kernel. It can be of any dimensionality, though only 1, 2, and 3d arrays have been tested.

kernelnumpy.ndarray or astropy.convolution.Kernel

The convolution kernel. The number of dimensions should match those for the array. The dimensions do not have to be odd in all directions, unlike in the non-fft convolve function. The kernel will be normalized if normalize_kernel is set. It is assumed to be centered (i.e., shifts may result if your kernel is asymmetric). The kernel must be normalizable (i.e., its sum cannot be zero).

convolveconvolve or convolve_fft

One of the two convolution functions defined in this package.

Returns:
newarraynumpy.ndarray

A copy of the original array with NaN pixels replaced with their interpolated counterparts