autolens.FitImaging#

class FitImaging[source]#

Bases: FitImaging, AbstractFitInversion

Fits an imaging dataset using a Tracer object.

The fit performs the following steps:

  1. Compute the sum of all images of galaxy light profiles in the Tracer.

  2. Blur this with the imaging PSF to created the blurred_image.

  3. Subtract this image from the data to create the profile_subtracted_image.

  4. If the Tracer has any linear algebra objects (e.g. linear light profiles, a pixelization / regulariation) fit the profile_subtracted_image with these objects via an inversion.

  5. Compute the model_data as the sum of the blurred_image and reconstructed_data of the inversion (if an inversion is not performed the model_data is only the blurred_image.

  6. Subtract the model_data from the data and compute the residuals, chi-squared and likelihood via the noise-map (if an inversion is performed the log_evidence, including additional terms describing the linear algebra solution, is computed).

When performing a model-fit`via an `AnalysisImaging object the figure_of_merit of this FitImaging object is called and returned in the log_likelihood_function.

Parameters
  • dataset (Imaging) – The imaging dataset which is fitted by the galaxies in the tracer.

  • tracer (Tracer) – The tracer of galaxies whose light profile images are used to fit the imaging data.

  • settings_pixelization (SettingsPixelization) – Settings controlling how a pixelization is fitted for example if a border is used when creating the pixelization.

  • settings_inversion (SettingsInversion) – Settings controlling how an inversion is fitted for example which linear algebra formalism is used.

  • preloads (Preloads) – Contains preloaded calculations (e.g. linear algebra matrices) which can skip certain calculations in the fit.

  • run_time_dict (Optional[Dict]) – A dictionary which if passed to the fit records how long fucntion calls which have the profile_func decorator take to run.

Methods

galaxy_linear_obj_data_dict_from

Returns a dictionary mapping every galaxy containing a linear object (e.g.

refit_with_new_preloads

Returns a new fit which uses the dataset, tracer and other objects of this fit, but uses a different set of preloads input into this function.

Attributes

blurred_image

Returns the image of all light profiles in the fit's tracer convolved with the imaging dataset's PSF.

chi_squared

Returns the chi-squared terms of the model data's fit to an dataset, by summing the chi-squared-map.

chi_squared_map

Returns the chi-squared-map between the residual-map and noise-map, where:

data

rtype

Union[Array1D, Array2D, ArrayIrregular, Visibilities]

figure_of_merit

rtype

float

galaxy_model_image_dict

A dictionary which associates every galaxy in the tracer with its model_image.

grid

rtype

Union[ndarray, Grid2D, Grid2DIterate, Grid2DIrregular]

image

rtype

Array2D

imaging

rtype

Imaging

inversion

A property that is only computed once per instance and then replaces itself with an ordinary attribute.

linear_light_profile_intensity_dict

When linear light profiles are used in an inversion, their intensity parameter values are solved for via linear algebra.

log_evidence

Returns the log evidence of the inversion's fit to a dataset, where the log evidence includes a number of terms which quantify the complexity of an inversion's reconstruction (see the Inversion module):

log_likelihood

Returns the log likelihood of each model data point's fit to the dataset, where:

log_likelihood_with_regularization

Returns the log likelihood of an inversion's fit to the dataset, including a regularization term which comes from an inversion:

mask

Overwrite this method so it returns the mask of the dataset which is fitted to the input data.

model_data

Returns the model-image that is used to fit the data.

model_image

rtype

Array2D

model_images_of_planes_list

A list of every model image of every plane in the tracer.

model_obj_linear_light_profiles_to_light_profiles

The model object may contain linear light profiles, which solve for the intensity during the Inversion.

noise_map

rtype

Union[Array1D, Array2D, ArrayIrregular, VisibilitiesNoiseMap]

noise_normalization

Returns the noise-map normalization term of the noise-map, summing the noise_map value in every pixel as:

normalized_residual_map

Returns the normalized residual-map between the masked dataset and model data, where:

perform_inversion

Returns a bool specifying whether this fit object performs an inversion.

profile_subtracted_image

Returns the dataset's image with all blurred light profile images in the fit's tracer subtracted.

reduced_chi_squared

rtype

float

residual_map

Returns the residual-map between the masked dataset and model data, where:

signal_to_noise_map

The signal-to-noise_map of the dataset and noise-map which are fitted.

subtracted_images_of_planes_list

A list of the subtracted image of every plane.

total_mappers

The total number of Mapper objects used by the inversion in this fit.

tracer_linear_light_profiles_to_light_profiles

The Tracer where all linear light profiles have been converted to ordinary light profiles, where their intensity values are set to the values inferred by this fit.

tracer_to_inversion

rtype

TracerToInversion

unmasked_blurred_image

The blurred image of the overall fit that would be evaluated without a mask being used.

unmasked_blurred_image_of_planes_list

The blurred image of every galaxy in the tracer used in this fit, that would be evaluated without a mask being used.

w_tilde

Only call the w_tilde property of a dataset used to perform efficient linear algebra calcualtions if the SettingsInversion()` object has use_w_tilde=True, to avoid unnecessary computation.

property blurred_image: Array2D#

Returns the image of all light profiles in the fit’s tracer convolved with the imaging dataset’s PSF.

For certain lens models the blurred image does not change (for example when all light profiles in the tracer are fixed in the lens model). For faster run-times the blurred image can be preloaded.

Return type

Array2D

property profile_subtracted_image: Array2D#

Returns the dataset’s image with all blurred light profile images in the fit’s tracer subtracted.

Return type

Array2D

property model_data: Array2D#

Returns the model-image that is used to fit the data.

If the tracer does not have any linear objects and therefore omits an inversion, the model data is the sum of all light profile images blurred with the PSF.

If a inversion is included it is the sum of this image and the inversion’s reconstruction of the image.

Return type

Array2D

property galaxy_model_image_dict: Dict[Galaxy, ndarray]#

A dictionary which associates every galaxy in the tracer with its model_image.

This image is the image of the sum of:

  • The images of all ordinary light profiles in that plane summed and convolved with the imaging data’s PSF.

  • The images of all linear objects (e.g. linear light profiles / pixelizations), where the images are solved for first via the inversion.

For modeling, this dictionary is used to set up the adapt_images that adaptmodel_images_of_planes_list certain pixelizations to the data being fitted.

Return type

Dict[Galaxy, ndarray]

property model_images_of_planes_list: List[Array2D]#

A list of every model image of every plane in the tracer.

This image is the image of the sum of:

  • The images of all ordinary light profiles in that plane summed and convolved with the imaging data’s PSF.

  • The images of all linear objects (e.g. linear light profiles / pixelizations), where the images are solved for first via the inversion.

This is used to visualize the different contibutions of light from the image-plane, source-plane and other planes in a fit.

Return type

List[Array2D]

property subtracted_images_of_planes_list: List[Array2D]#

A list of the subtracted image of every plane.

A subtracted image of a plane is the data where all other plane images are subtracted from it, therefore showing how a plane appears in the data in the absence of all other planes.

This is used to visualize the contribution of each plane in the data.

Return type

List[Array2D]

property unmasked_blurred_image: Array2D#

The blurred image of the overall fit that would be evaluated without a mask being used.

Linear objects are tied to the mask defined to used to perform the fit, therefore their unmasked blurred image cannot be computed.

Return type

Array2D

property unmasked_blurred_image_of_planes_list: List[Array2D]#

The blurred image of every galaxy in the tracer used in this fit, that would be evaluated without a mask being used.

Linear objects are tied to the mask defined to used to perform the fit, therefore their unmasked blurred image cannot be computed.

Return type

List[Array2D]

property tracer_linear_light_profiles_to_light_profiles: Tracer#

The Tracer where all linear light profiles have been converted to ordinary light profiles, where their intensity values are set to the values inferred by this fit.

This is typically used for visualization, because linear light profiles cannot be used in LightProfilePlotter or GalaxyPlotter objects.

Return type

Tracer

refit_with_new_preloads(preloads, settings_inversion=None)[source]#

Returns a new fit which uses the dataset, tracer and other objects of this fit, but uses a different set of preloads input into this function.

This is used when setting up the preloads objects, to concisely test how using different preloads objects changes the attributes of the fit.

Parameters
  • preloads (Preloads) – The new preloads which are used to refit the data using the

  • settings_inversion (Optional[SettingsInversion]) – Settings controlling how an inversion is fitted for example which linear algebra formalism is used.

Return type

A new fit which has used new preloads input into this function but the same dataset, tracer and other settings.