webbpsf_ext.image_manip.image_shift_with_nans
- webbpsf_ext.image_manip.image_shift_with_nans(image, xshift, yshift, shift_method='fourier', interp='linear', gstd_pix=None, window_func=None, grid_method='cubic', oversample=1, return_oversample=False, total=True, order=1, pad=False, cval=nan, preserve_nans=False, return_padded=False, **kwargs)[source]
Shift image by a fractional amount accounting for NaNs
- Parameters:
image (ndarray) – 2D image or 3D image cube [nz,ny,nx].
xshift (float) – Shift in x direction (pixels).
yshift (float) – Shift in y direction (pixels).
shift_method (str) – Method to use for shifting. Options are: - ‘fourier’ : Shift in Fourier space - ‘fshift’ : Shift using interpolation - ‘opencv’ : Shift using OpenCV warpAffine
interp (str) – Type of interpolation to use during the sub-pixel shift. Valid values are: - ‘fshift’ : ‘linear’, ‘cubic’, and ‘quintic’ (default=’linear’) - opencv : ‘linear’, ‘cubic’, and ‘lanczos’ (default=’lanczos’)
use_griddata (bool) – Use griddata interpolation to fix NaNs. Default is True.
grid_method (str) – Interpolation method over NaNs to use for griddata. Options are ‘nearest’, ‘linear’, or ‘cubic’. Default is ‘cubic’.
oversample (int) – Factor to oversample the image before sub-pixel shifting. Default is 1. An oversample factor of 2 will increase the image size by 2x in each dimension.
return_oversample (bool) – Return the oversampled image after shifting. Default is False.
total (bool) – If True, then the total flux in the image is conserved. Default is True. Would want to set this to false if the image is in units of surface brightness (e.g., MJy/sr) and not flux (e.g., MJy).
order (int) – The order of the spline interpolation for zrebin function, Default is 3. Only used if oversample>1. If order=0, then frebin is used.
pad (bool) – Pad the image before shifting, then truncate? Default is False.
cval (sequence or float, optional) – The values to set the padded values for each axis. Default is NaN. NaNs are then replaced with interpolated values during shifted and can be added back to the image using preserve_nans.
preserve_nans (bool) – Add NaNs back to the image after shifting. Default is False.
return_padded (bool) – Return the padded image after shifting. Default is False.
gstd_pix (float) – Standard deviation of Gaussian kernel for smoothing. Default is None.
window_func (string, float, or tuple) – Name of window function from scipy.signal.windows to use prior to shifting. The idea is to reduce artifacts from high frequency information during sub-pixel shifting. This effectively acts as a low-pass filter applied to the Fourier transform of the image prior to shifting. Uses skimage.filters.window() to generate the window. Will apply to oversampled image, so make sure to adjust any function parameters accordingly. For example: