autolens.Preloads#

class autolens.Preloads(w_tilde: Optional[autoarray.dataset.imaging.WTildeImaging] = None, use_w_tilde: Optional[bool] = None, blurred_image: Optional[autoarray.structures.arrays.uniform_2d.Array2D] = None, traced_grids_of_planes_for_inversion: Optional[autoarray.structures.grids.uniform_2d.Grid2D] = None, sparse_image_plane_grid_pg_list: Optional[List[List[autoarray.structures.grids.uniform_2d.Grid2D]]] = None, relocated_grid: Optional[autoarray.structures.grids.uniform_2d.Grid2D] = None, linear_obj_list: Optional[autoarray.inversion.mappers.abstract.AbstractMapper] = None, operated_mapping_matrix: Optional[numpy.ndarray] = None, curvature_matrix_preload: Optional[numpy.ndarray] = None, curvature_matrix_counts: Optional[numpy.ndarray] = None, regularization_matrix: Optional[numpy.ndarray] = None, log_det_regularization_matrix_term: Optional[float] = None, traced_sparse_grids_list_of_planes=None, sparse_image_plane_grid_list=None, failed=False)[source]#
__init__(w_tilde: Optional[autoarray.dataset.imaging.WTildeImaging] = None, use_w_tilde: Optional[bool] = None, blurred_image: Optional[autoarray.structures.arrays.uniform_2d.Array2D] = None, traced_grids_of_planes_for_inversion: Optional[autoarray.structures.grids.uniform_2d.Grid2D] = None, sparse_image_plane_grid_pg_list: Optional[List[List[autoarray.structures.grids.uniform_2d.Grid2D]]] = None, relocated_grid: Optional[autoarray.structures.grids.uniform_2d.Grid2D] = None, linear_obj_list: Optional[autoarray.inversion.mappers.abstract.AbstractMapper] = None, operated_mapping_matrix: Optional[numpy.ndarray] = None, curvature_matrix_preload: Optional[numpy.ndarray] = None, curvature_matrix_counts: Optional[numpy.ndarray] = None, regularization_matrix: Optional[numpy.ndarray] = None, log_det_regularization_matrix_term: Optional[float] = None, traced_sparse_grids_list_of_planes=None, sparse_image_plane_grid_list=None, failed=False)[source]#

Class which offers a concise API for settings up the preloads, which before a model-fit are set up via a comparison of two fits using two different models. If a quantity in these two fits is identical, it does not change thoughout the model-fit and can therefore be preloaded to avoid computation, speeding up the analysis.

For example, the image-plane source-plane pixelization grid (which may be computationally expensive to compute via a KMeans algorithm) does not change for the majority of model-fits, because the associated model parameters are fixed. Preloading avoids rerruning the KMeans algorithm for every model fitted, by preloading it in memory and using this preload in every fit.

Parameters
  • blurred_image – The preloaded array of values containing the blurred image of a lens model fit (e.g. that light profile of every galaxy in the model). This can be preloaded when no light profiles in the model vary.

  • w_tilde – A class containing values that enable an inversion’s linear algebra to use the w-tilde formalism. This can be preloaded when no component of the model changes the noise map (e.g. hyper galaxies are fixed).

  • use_w_tilde – Whether to use the w tilde formalism, which superseeds the value in SettingsInversions such that w tilde will be disabled for model-fits it is not applicable (e.g. because the noise-map changes).

  • traced_grids_of_planes_for_inversion

    The two dimensional grids corresponding to the traced grids in a lens fit. This can be preloaded when no

    mass profiles in the model vary.

  • sparse_image_plane_grid_pg_list – The two dimensional grids corresponding to the sparse image plane grids in a lens fit, that is ray-traced to the source plane to form the source pixelization. This can be preloaded when no pixelizations in the model vary.

  • relocated_grid – The two dimensional grids corresponding to the grid that has had its border pixels relocated for a pixelization in a lens fit. This can be preloaded when no mass profiles in the model vary.

  • linear_obj_list – The mapper of a fit, which preloading avoids recalculation of the mapping matrix and image to source pixel mappings. This can be preloaded when no pixelizations in the model vary.

  • operated_mapping_matrix – A matrix containing the mappings between PSF blurred image pixels and source pixels used in the linear algebra of an inversion. This can be preloaded when no mass profiles and pixelizations in the model vary.

  • curvature_matrix_preload – A matrix containing preloaded value used to construct the curvature matrix from the blurred mapping matrix. This can be preloaded when no mass profiles and pixelizations in the model vary.

  • curvature_matrix_counts – A matrix containing the length of values in the curvature matrix preloaded, which are used to construct the curvature matrix from the blurred mapping matrix. This can be preloaded when no mass profiles and pixelizations in the model vary.

Returns

The preloads object used to skip certain calculations in the log likelihood function.

Return type

Preloads

Methods

__init__([w_tilde, use_w_tilde, …])

Class which offers a concise API for settings up the preloads, which before a model-fit are set up via a comparison of two fits using two different models.

check_via_fit(fit)

output_info_to_summary(file_path)

reset_all()

Reset all preloads, typically done at the end of a model-fit to save memory.

set_blurred_image(fit_0, fit_1)

If the LightProfile’s in a model are all fixed parameters their corresponding image and therefore PSF blurred image do not change during the model fit and can therefore be preloaded.

set_curvature_matrix(fit_0, fit_1)

If the MassProfile’s and Pixelization’s in a model are fixed, the mapping of image-pixels to the source-pixels does not change during the model-fit and therefore its associated cruvature matrix is also fixed, meaning the curvature matrix preloaded.

set_linear_obj_list(fit_0, fit_1)

If the MassProfile’s and Pixelization’s in a model are fixed, the mapping of image-pixels to the source-pixels does not change during the model-fit and the list of Mapper’s containing this information can be preloaded.

set_operated_mapping_matrix_with_preloads(…)

If the MassProfile’s and Pixelization’s in a model are fixed, the mapping of image-pixels to the source-pixels does not change during the model-fit and matrices used to perform the linear algebra in an inversion can be preloaded, which help efficiently construct the curvature matrix.

set_regularization_matrix_and_term(fit_0, fit_1)

If the MassProfile’s and Pixelization’s in a model are fixed, the mapping of image-pixels to the source-pixels does not change during the model-fit and therefore its associated regularization matrices are also fixed, meaning the log determinant of the regularization matrix term of the Bayesian evidence can be preloaded.

set_relocated_grid(fit_0, fit_1)

If the MassProfile’s in a model are fixed their traced grids (which may have had coordinates relocated at the border) does not change during the model=fit and can therefore be preloaded.

set_sparse_image_plane_grid_pg_list(fit_0, fit_1)

If the Pixelization’s in a model are fixed their image-plane sparse grid (which defines the set of pixels that are ray-traced to construct the source-plane pixelization) do not change during the model=fit and can therefore be preloaded.

set_traced_grids_of_planes_for_inversion(…)

If the MassProfiles’s in a model are fixed their deflection angles and therefore corresponding traced grids do not change during the model-fit and can therefore be preloaded.

set_w_tilde_imaging(fit_0, fit_1)

The w-tilde linear algebra formalism speeds up inversions by computing beforehand quantities that enable efficiently construction of the curvature matrix.

setup_all_via_fits(fit_0, fit_1)

Setup the Preloads from two fits which use two different lens model of a model-fit.

Attributes

info

The information on what has or has not been preloaded, which is written to the file preloads.summary.