webbpsf_ext.image_manip.distort_image

webbpsf_ext.image_manip.distort_image(hdulist_or_filename, ext=0, to_frame='sci', fill_value=0, xnew_coords=None, ynew_coords=None, return_coords=False, aper=None, sci_cen=None, pixelscale=None, oversamp=None)[source]

Distort an image

Apply SIAF instrument distortion to an image that is assumed to be in its ideal coordinates. The header information should contain the relevant SIAF point information, such as SI instrument, aperture name, pixel scale, detector oversampling, and detector position (‘sci’ coords).

This function then transforms the image to the new coordinate system using scipy’s RegularGridInterpolator (linear interpolation).

Parameters
  • hdulist_or_filename (str or HDUList) – A PSF from WebbPSF, either as an HDUlist object or as a filename

  • ext (int) – Extension of HDUList to perform distortion on.

  • fill_value (float or None) – Value used to fill in any blank space by the skewed PSF. Default = 0. If set to None, values outside the domain are extrapolated.

  • to_frame (str) –

    Type of input coordinates.

    • ‘tel’: arcsecs V2,V3

    • ‘sci’: pixels, in conventional DMS axes orientation

    • ‘det’: pixels, in raw detector read out axes orientation

    • ‘idl’: arcsecs relative to aperture reference location.

  • xnew_coords (None or ndarray) – Array of x-values in new coordinate frame to interpolate onto. Can be a 1-dimensional array of unique values, in which case the final image will be of size (ny_new, nx_new). Or a 2d array that corresponds to full regular grid and has same shape as ynew_coords (ny_new, nx_new). If set to None, then final image is same size as input image, and coordinate grid spans the min and max values of siaf_ap.convert(xidl,yidl,’idl’,to_frame).

  • ynew_coords (None or ndarray) – Array of y-values in new coordinate frame to interpolate onto. Can be a 1-dimensional array of unique values, in which case the final image will be of size (ny_new, nx_new). Or a 2d array that corresponds to full regular grid and has same shape as xnew_coords (ny_new, nx_new). If set to None, then final image is same size as input image, and coordinate grid spans the min and max values of siaf_ap.convert(xidl,yidl,’idl’,to_frame).

  • return_coords (bool) – In addition to returning the final image, setting this to True will return the full set of new coordinates. Output will then be (psf_new, xnew, ynew), where all three array have the same shape.

  • aper (None or pysiaf.Aperture) – Option to pass the SIAF aperture if it is already known or specified to save time on generating a new one. If set to None, then automatically determines a new pysiaf aperture based on information stored in the header.

  • sci_cen (tuple or None) – Science pixel values associated with center of array. If set to None, then will grab values from DET_X and DET_Y header keywords.

  • pixelscale (float or None) – Pixel scale of input image in arcsec/pixel. If set to None, then will search for PIXELSCL and PIXSCALE keywords in header.

  • oversamp (int or None) – Oversampling of input image relative to native detector pixel scale. If set to None, will search for OSAMP and DET_SAMP keywords.