webbpsf_ext.image_manip.replace_nans
- webbpsf_ext.image_manip.replace_nans(image, mean_func=<function nanmean>, in_place=False, use_griddata=True, grid_method='cubic', x_stddev=2, use_fft=False, **kwargs)[source]
Replace NaNs in an image with interpolated values
If input is a cube, first replaces NaNs using mean of cube.
Remaining NaNs are then replaced using griddata interpolation. Default is cubic interpolation.
Any remaining NaNs are then replaced using astropy convolution.
- Parameters:
image (ndarray) – 2D image or 3D image cube [nz,ny,nx].
mean_func (function) – Function to use for calculating the mean of the cube. Default is np.nanmean. Set this to None if you want to skip this step and only use griddata replacement.
use_griddata (bool) – Use griddata interpolation to fix NaNs. Default is True.
grid_method (str) – Interpolation method to use for griddata. Options are ‘nearest’, ‘linear’, or ‘cubic’. Default is ‘cubic’.
x_stddev (float) – Standard deviation of Gaussian kernel for smoothing. Default is 2.
use_fft (bool) – Use FFT convolution. Default is False.
- Keyword Arguments:
boundary (str, optional) –
- A flag indicating how to handle boundaries:
- NoneSet the
resultvalues to zero where the kernel extends beyond the edge of the array.
- NoneSet the
’fill’ : (default) Set values outside the array boundary to
fill_value.’wrap’ : Periodic boundary that wrap to the other side of
array.- ’extend’Set values outside the array to the nearest
array value.
- ’extend’Set values outside the array to the nearest
fill_value (float, optional) – The value to use outside the array when using
boundary='fill'.