autolens.OperateImage#

class OperateImage[source]#

Bases: object

Packages methods which operate on the 2D image returned from the image_2d_from function of a light object (e.g. a LightProfile, Galaxy).

The majority of methods apply data operators to the 2D image which perform tasks such as a 2D convolution or Fourier transform.

The methods in OperateImage are inherited by light objects to provide a concise API.

Methods

blurred_image_2d_from

Evaluate the light object's 2D image from a input 2D grid of coordinates and convolve it with a PSF.

has

image_2d_from

padded_image_2d_from

Evaluate the light object's 2D image from a input 2D grid of padded coordinates, where this padding is sufficient to encapsulate all surrounding pixels that will blur light into the original image given the 2D shape of the PSF's kernel.

unmasked_blurred_image_2d_from

Evaluate the light object's 2D image from a input 2D grid of coordinates and convolve it with a PSF, using a grid which is not masked.

visibilities_from

Evaluate the light object's 2D image from a input 2D grid of coordinates and transform this to an array of visibilities using a autoarray.operators.transformer.Transformer object and therefore a Fourier Transform.

blurred_image_2d_from(grid, blurring_grid, psf=None, convolver=None)[source]#

Evaluate the light object’s 2D image from a input 2D grid of coordinates and convolve it with a PSF.

The input 2D grid may be masked, in which case values outside but near the edge of the mask will convolve light into the mask. A blurring grid is therefore required, which contains image pixels on the mask edge whose light is blurred into the light object’s image by the PSF.

The grid and blurring_grid must be a Grid2D objects so the evaluated image can be mapped to a uniform 2D array and binned up for convolution. They therefore cannot be Grid2DIrregular objects.

Parameters:
  • grid (Grid2D) – The 2D (y,x) coordinates of the (masked) grid, in its original geometric reference frame.

  • psf (Optional[Kernel2D]) – The PSF the light object 2D image is convolved with.

  • blurring_grid (Grid2D) – The 2D (y,x) coordinates neighboring the (masked) grid whose light is blurred into the image.

Return type:

Array2D

padded_image_2d_from(grid, psf_shape_2d)[source]#

Evaluate the light object’s 2D image from a input 2D grid of padded coordinates, where this padding is sufficient to encapsulate all surrounding pixels that will blur light into the original image given the 2D shape of the PSF’s kernel.

Convolving an unmasked 2D image with a PSF requires care, because at the edges of the 2D image the light profile values will not be evaluated beyond its edge, even though some of its light will be blurred into these edges.

This function creates the padded image, such that the light profile is evaluated beyond the edge. The array will still require trimming to remove these additional pixels after convolution is performed.

Parameters:
  • grid – The 2D (y,x) coordinates of the (masked) grid, in its original geometric reference frame.

  • psf_shape_2d – The 2D shape of the PSF the light object 2D image is convolved with.

unmasked_blurred_image_2d_from(grid, psf)[source]#

Evaluate the light object’s 2D image from a input 2D grid of coordinates and convolve it with a PSF, using a grid which is not masked.

Convolving an unmasked 2D image with a PSF requires care, because at the edges of the 2D image the light profile values will not be evaluated beyond its edge, even though some of its light will be blurred into these edges.

This function pads the grid first, such that the light profile is evaluated beyond the edge. The function then trims the array the image is evaluated on such that it is the original dimensions of the input 2D grid.

The grid and blurring_grid must be a Grid2D objects so the evaluated image can be mapped to a uniform 2D array and binned up for convolution. They therefore cannot be Grid2DIrregular objects.

Parameters:
  • grid – The 2D (y,x) coordinates of the (masked) grid, in its original geometric reference frame.

  • psf – The PSF the light object 2D image is convolved with.

visibilities_from(grid, transformer)[source]#

Evaluate the light object’s 2D image from a input 2D grid of coordinates and transform this to an array of visibilities using a autoarray.operators.transformer.Transformer object and therefore a Fourier Transform.

The input 2D grid may be masked, in which case values outside the mask are not evaluated. This does not impact the Fourier transform.

The grid must be a Grid2D objects for certain Fourier transforms to be valid. It therefore cannot be a Grid2DIrregular objects.

If the image is all zeros (e.g. because this light object has no light profiles, for example it is a Galaxy object with only mass profiles) the Fourier transformed is skipped for efficiency and a Visibilities object with all zeros is returned.

Parameters:
  • grid (Grid2D) – The 2D (y,x) coordinates of the (masked) grid, in its original geometric reference frame.

  • transformer (Union[TransformerDFT, TransformerNUFFT]) – The PyAutoArray Transformer object describing how the 2D image is Fourier transformed to visiblities in the uv-plane.

Return type:

Visibilities