autogalaxy.Mapper#
- class Mapper[source]#
Bases:
LinearObjTo understand a Mapper one must be familiar Mesh objects and the mesh and pixelization packages, where the four grids are explained (image_plane_data_grid, source_plane_data_grid, image_plane_mesh_grid,`source_plane_mesh_grid`)
If you are unfamiliar with the above objects, read through the docstrings of the pixelization, mesh and image_mesh packages.
A Mapper determines the mappings between the masked data grid’s pixels (image_plane_data_grid and source_plane_data_grid) and the pixelization’s pixels (image_plane_mesh_grid and source_plane_mesh_grid).
The 1D Indexing of each grid is identical in the data and source frames (e.g. the transformation does not change the indexing, such that source_plane_data_grid[0] corresponds to the transformed value of image_plane_data_grid[0] and so on).
A mapper therefore only needs to determine the index mappings between the grid_slim and mesh_grid, noting that associations are made by pairing source_plane_mesh_grid with source_plane_data_grid.
Mappings are represented in the 2D ndarray pix_indexes_for_sub_slim_index, whereby the index of a pixel on the mesh_grid maps to the index of a pixel on the grid_slim as follows:
pix_indexes_for_sub_slim_index[0, 0] = 0: the data’s 1st sub-pixel (index 0) maps to the pixelization’s 1st pixel (index 0).
pix_indexes_for_sub_slim_index[1, 0] = 3: the data’s 2nd sub-pixel (index 1) maps to the pixelization’s 4th pixel (index 3).
pix_indexes_for_sub_slim_index[2, 0] = 1: the data’s 3rd sub-pixel (index 2) maps to the pixelization’s 2nd pixel (index 1).
The second dimension of this array (where all three examples above are 0) is used for cases where a single pixel on the grid_slim maps to multiple pixels on the mesh_grid. For example, using a Delaunay pixelization, where every grid_slim pixel maps to three Delaunay pixels (the corners of the triangles):
pix_indexes_for_sub_slim_index[0, 0] = 0: the data’s 1st sub-pixel (index 0) maps to the
pixelization’s 1st pixel (index 0). - pix_indexes_for_sub_slim_index[0, 1] = 3: the data’s 1st sub-pixel (index 0) also maps to the pixelization’s 2nd pixel (index 3). - pix_indexes_for_sub_slim_index[0, 2] = 5: the data’s 1st sub-pixel (index 0) also maps to the pixelization’s 6th pixel (index 5).
The mapper allows us to create a mapping matrix, which is a matrix representing the mapping between every unmasked data pixel and the pixels of a pixelization. This matrix is the basis of performing an Inversion, which reconstructs the data using the source_plane_mesh_grid.
- Parameters:
interpolator – The interpolator which computes the mappings between image-plane data pixels and source-plane mesh pixels, including the source_plane_data_grid, source_plane_mesh_grid, interpolation weights, and adapt_data.
regularization (
Optional[AbstractRegularization]) – The regularization scheme which may be applied to this linear object in order to smooth its solution, which for a mapper smooths neighboring pixels on the mesh.settings (
Settings) – Settings controlling how an inversion is fitted, for example which linear algebra formalism is used.image_plane_mesh_grid – The sparse set of (y,x) coordinates computed from the unmasked data in the image frame. This is transformed to create the source_plane_mesh_grid accessed via self.source_plane_mesh_grid.
xp – The array module to use (numpy by default; pass jax.numpy for JAX support).
Methods
Returns the total weight of every pixelization pixel, which is the sum of the weights of all data-points that map to that pixel.
Map a masked 2d image in the image domain to the source domain and sum up all mappings on the source-pixels.
Returns the signal in each pixelization pixel, where this signal is an estimate of the expected signal each pixelization pixel contains given the data pixels it maps too.
Returns the index mappings between every masked data-point (not subgridded) on the data and the mapper pixels / parameters that it maps too.
Attributes
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
An object describing how the different parameters in the linear object neighbor one another, which is used to apply smoothing to neighboring parameters via regularization.
operated_mapping_matrix_overrideAn Inversion takes the mapping_matrix of each linear object and combines it with the data's operators (e.g. a PSF for Imaging data) to compute the operated_mapping_matrix.
The total number of parameters used to reconstruct the data.
The mapping of every data pixel (given its sub_slim_index) to pixelization pixels (given their pix_indexes).
The number of mappings of every data pixel to pixelization pixels.
The interoplation weights of the mapping of every data pixel (given its sub_slim_index) to pixelization pixels (given their pix_indexes).
regularization_matrixThe regularization matrix H is used to impose smoothness on our inversion's reconstruction.
The mappings between every sub-pixel data point on the sub-gridded data and each data point for a grid which does not use sub gridding (e.g. sub_size=1).
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
Returns the index mappings between each of the pixelization's pixels and the masked data's sub-pixels.
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
- property params: int#
The total number of parameters used to reconstruct the data.
For example for the following linear objects:
AbstractLinearObjFuncList the number of analytic functions.
Mapper the number of pixels in the mesh used to reconstruct the data.
- Return type:
The number of parameters used to reconstruct the data.
- property mask#
- property mesh#
- property mesh_geometry#
- property over_sampler#
- property source_plane_data_grid#
- property source_plane_mesh_grid#
- property adapt_data#
- property neighbors: Neighbors#
An object describing how the different parameters in the linear object neighbor one another, which is used to apply smoothing to neighboring parameters via regularization.
For example for the following linear objects:
AbstractLinearObjFuncList whether certain analytic functions reconstruct nearby components next to one another.
Mapper how the pixels on the mesh used to reconstruct the data neighbor one another.
- Return type:
An object describing how the parameters of the linear object neighbor one another.
- property pix_indexes_for_sub_slim_index: ndarray#
The mapping of every data pixel (given its sub_slim_index) to pixelization pixels (given their pix_indexes).
The sub_slim_index refers to the masked data sub-pixels and pix_indexes the pixelization pixel indexes, for example:
pix_indexes_for_sub_slim_index[0, 0] = 2: The data’s first (index 0) sub-pixel maps to the pixelization’s
third (index 2) pixel.
pix_indexes_for_sub_slim_index[2, 0] = 4: The data’s third (index 2) sub-pixel maps to the pixelization’s
fifth (index 4) pixel.
- property pix_sizes_for_sub_slim_index: ndarray#
The number of mappings of every data pixel to pixelization pixels.
The sub_slim_index refers to the masked data sub-pixels and pix_indexes the pixelization pixel indexes, for example:
pix_sizes_for_sub_slim_index[0] = 2: The data’s first (index 0) sub-pixel maps to 2 pixels in the
pixelization.
pix_sizes_for_sub_slim_index[2] = 4: The data’s third (index 2) sub-pixel maps to 4 pixels in the
pixelization.
- property pix_weights_for_sub_slim_index: ndarray#
The interoplation weights of the mapping of every data pixel (given its sub_slim_index) to pixelization pixels (given their pix_indexes).
The sub_slim_index refers to the masked data sub-pixels and pix_indexes the pixelization pixel indexes, for example:
pix_weights_for_sub_slim_index[0, 0] = 0.1: The data’s first (index 0) sub-pixel mapping to the
pixelization’s third (index 2) pixel has an interpolation weight of 0.1.
pix_weights_for_sub_slim_index[2, 0] = 0.2: The data’s third (index 2) sub-pixel mapping to the
pixelization’s fifth (index 4) pixel has an interpolation weight of 0.2.
- property slim_index_for_sub_slim_index: ndarray#
The mappings between every sub-pixel data point on the sub-gridded data and each data point for a grid which does not use sub gridding (e.g. sub_size=1).
- property sub_slim_indexes_for_pix_index: List[List]#
Returns the index mappings between each of the pixelization’s pixels and the masked data’s sub-pixels.
Given that even pixelization pixel maps to multiple data sub-pixels, index mappings are returned as a list of lists where the first entries are the pixelization index and second entries store the data sub-pixel indexes.
For example, if sub_slim_indexes_for_pix_index[2][4] = 10, the pixelization pixel with index 2 (e.g. mesh_grid[2,:]) has a mapping to a data sub-pixel with index 10 (e.g. `grid_slim[10, :]).
This is effectively a reversal of the array pix_indexes_for_sub_slim_index.
- unique_mappings#
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property.
Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
- mapping_matrix#
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property.
Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
- sparse_triplets_data#
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property.
Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
- sparse_triplets_curvature#
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property.
Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
- pixel_signals_from(signal_scale, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautogalaxy/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>)[source]#
Returns the signal in each pixelization pixel, where this signal is an estimate of the expected signal each pixelization pixel contains given the data pixels it maps too.
A full description of this is given in the function `mapper_util.adaptive_pixel_signals_from().
- Parameters:
signal_scale (
float) – A factor which controls how rapidly the smoothness of regularization varies from high signal regions to low signal regions.
- slim_indexes_for_pix_indexes(pix_indexes)[source]#
Returns the index mappings between every masked data-point (not subgridded) on the data and the mapper pixels / parameters that it maps too.
The slim_index refers to the masked data pixels (without subgridding) and pix_indexes the pixelization pixel indexes, for example:
slim_indexes_for_pix_indexes[0] = [2, 3]: The data’s first (index 0) pixel maps to the
pixelization’s third (index 2) and fourth (index 3) pixels.
- Parameters:
pix_indexes (
List) – A list of all pixelization indexes for which the data-points that map to these pixelization pixels are computed.
- data_weight_total_for_pix_from()[source]#
Returns the total weight of every pixelization pixel, which is the sum of the weights of all data-points that map to that pixel.
- mapped_to_source_from(array)[source]#
Map a masked 2d image in the image domain to the source domain and sum up all mappings on the source-pixels.
For example, suppose we have an image and a mapper. We can map every image-pixel to its corresponding mapper’s source pixel and sum the values based on these mappings.
This will produce something similar to a reconstruction, by passing the linear algebra / inversion.
- Parameters:
array_slim – The masked 2D array of values in its slim representation (e.g. the image data) which are mapped to the source domain in order to compute their average values.
- property image_plane_data_grid#
- property mesh_pixels_per_image_pixels#