autolens.Convolver

class autolens.Convolver(mask, kernel)
__init__(mask, kernel)

Class to setup the 1D convolution of an / mapping matrix.

Take a simple 3x3 and masks:

[[2, 8, 2], [5, 7, 5], [3, 1, 4]]

[[True, False, True], (True means that the value is masked) [False, False, False], [True, False, True]]

A set of values in a corresponding 1d array of this might be represented as:

[2, 8, 2, 5, 7, 5, 3, 1, 4]

and after masking as:

[8, 5, 7, 5, 1]

Setup is required to perform 2D real-space convolution on the masked array. This module finds the relationship between the unmasked 2D data, masked data and kernel, so that 2D real-space convolutions can be efficiently applied to reduced 1D masked structures.

This calculation also accounts for the blurring of light outside of the masked regions which blurs into the masked region.

Methods

__init__(mask, kernel) Class to setup the 1D convolution of an / mapping matrix.
convolve_image(image, blurring_image) For a given 1D array and blurring array, convolve the two using this convolver.
convolve_image_no_blurring(image) For a given 1D array and blurring array, convolve the two using this convolver.
convolve_mapping_matrix(mapping_matrix) For a given inversion mapping matrix, convolve every pixel’s mapped with the PSF kernel.

Attributes

convolve_jit
convolve_matrix_jit
convolve_no_blurring_jit
frame_at_coordinates_jit Returns the frame (indexes of pixels light is blurred into) and kernel_frame (kernel kernel values of those pixels) for a given coordinate in a masks and its PSF.
frame_at_coordinates_jit

Returns the frame (indexes of pixels light is blurred into) and kernel_frame (kernel kernel values of those pixels) for a given coordinate in a masks and its PSF.

Parameters:
  • coordinates (Tuple[int, int]) – The coordinates of mask_index_array on which the frame should be centred
  • kernel_shape_native (Tuple[int, int]) – The shape of the kernel for which this frame will be used
convolve_image(image, blurring_image)

For a given 1D array and blurring array, convolve the two using this convolver.

Parameters:
  • image – 1D array of the values which are to be blurred with the convolver’s PSF.
  • blurring_image – 1D array of the blurring values which blur into the array after PSF convolution.
convolve_image_no_blurring(image)

For a given 1D array and blurring array, convolve the two using this convolver.

Parameters:
  • image – 1D array of the values which are to be blurred with the convolver’s PSF.
  • blurring_image – 1D array of the blurring values which blur into the array after PSF convolution.
convolve_mapping_matrix(mapping_matrix)

For a given inversion mapping matrix, convolve every pixel’s mapped with the PSF kernel.

A mapping matrix provides non-zero entries in all elements which map two pixels to one another (see inversions.mappers).

For example, lets take an which is masked using a ‘cross’ of 5 pixels:

[[ True, False, True]], [[False, False, False]], [[ True, False, True]]

As example mapping matrix of this cross is as follows (5 pixels x 3 source pixels):

[1, 0, 0] [0->0] [1, 0, 0] [1->0] [0, 1, 0] [2->1] [0, 1, 0] [3->1] [0, 0, 1] [4->2]

For each source-pixel, we can create an of its unit-surface brightnesses by util the non-zero entries back to masks. For example, doing this for source pixel 1 gives:

[[0.0, 1.0, 0.0]], [[1.0, 0.0, 0.0]] [[0.0, 0.0, 0.0]]

And source pixel 2:

[[0.0, 0.0, 0.0]], [[0.0, 1.0, 1.0]] [[0.0, 0.0, 0.0]]

We then convolve each of these with our PSF kernel, in 2 dimensions, like we would a hyper grid. For example, using the kernel below:

kernel:

[[0.0, 0.1, 0.0]] [[0.1, 0.6, 0.1]] [[0.0, 0.1, 0.0]]

Blurred Source Pixel 1 (we don’t need to perform the convolution into masked pixels):

[[0.0, 0.6, 0.0]], [[0.6, 0.0, 0.0]], [[0.0, 0.0, 0.0]]

Blurred Source pixel 2:

[[0.0, 0.0, 0.0]], [[0.0, 0.7, 0.7]], [[0.0, 0.0, 0.0]]

Finally, we map each of these blurred back to a blurred mapping matrix, which is analogous to the mapping matrix.

[0.6, 0.0, 0.0] [0->0] [0.6, 0.0, 0.0] [1->0] [0.0, 0.7, 0.0] [2->1] [0.0, 0.7, 0.0] [3->1] [0.0, 0.0, 0.6] [4->2]

If the mapping matrix is sub-gridded, we perform the convolution on the fractional surface brightnesses in an identical fashion to above.

Parameters:mapping_matrix – The 2D mapping matrix describing how every inversion pixel maps to a pixel on the data pixel.