webbpsf_ext.image_manip.fractional_image_shift

webbpsf_ext.image_manip.fractional_image_shift(imarr, xshift, yshift, method='fourier', oversample=1, return_oversample=False, order=1, gstd_pix=None, window_func=None, total=True, **kwargs)[source]

Shift image(s) by a fractional amount

Will first fix any NaNs using astropy convolution.

Parameters:
  • imarr (ndarray) – 2D image or 3D image cube [nz,ny,nx].

  • xshift (float) – Shift in x direction

  • yshift (float) – Shift in y direction

  • method (str) – Method to use for shifting. Options are: - ‘fourier’ : Shift in Fourier space - ‘fshift’ : Shift using interpolation - ‘opencv’ : Shift using OpenCV warpAffine

  • 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.

  • 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.

  • gstd_pix (float) – Standard deviation of Gaussian kernel for smoothing. Default is None.

  • return_oversample (bool) – Return the oversampled image after shifting. Default is False.

  • 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:

    Available options can be found:

    https://docs.scipy.org/doc/scipy-1.12.0/reference/signal.windows.html

  • 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).

Keyword Arguments:
  • 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 0. ((before_1, after_1), … (before_N, after_N)) unique pad constants for each axis. ((before, after),) yields same before and after constants for each axis. (constant,) or int is a shortcut for before = after = constant for all axes.

  • interp (str) – Type of interpolation to use during the sub-pixel shift. Valid values are ‘linear’, ‘cubic’, and ‘quintic’ for fshift method (default: ‘linear’). For opencv method, valid values are ‘linear’, ‘cubic’, and ‘lanczos’ (default: ‘lanczos’).