autolens.FitImaging#
- class FitImaging[source]#
Bases:
FitImaging,AbstractFitInversionFits an imaging dataset using a Tracer object.
The fit performs the following steps:
Compute the sum of all images of galaxy light profiles in the Tracer.
Blur this with the imaging PSF to created the blurred_image.
Subtract this image from the data to create the profile_subtracted_image.
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.
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.
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 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.dataset_model (
Optional[DatasetModel]) – Attributes which allow for parts of a dataset to be treated as a model (e.g. the background sky level).adapt_images (
Optional[AdaptImages]) – Contains the adapt-images which are used to make a pixelization’s mesh and regularization adapt to the reconstructed galaxy’s morphology.settings (
Settings) – Settings controlling how an inversion is fitted for example which linear algebra formalism is used.
Methods
append_linear_light_profiles_to_modelFor a model instance, this function replaces all linear light profiles with instances of their standard light profile counterparts.
galaxy_linear_obj_data_dict_fromReturns a dictionary mapping every galaxy containing a linear object (e.g. a linear light profile / pixelization) in the model_obj to the model_data of its linear objects.
Attributes
Returns the image of all light profiles in the fit's tracer convolved with the imaging dataset's PSF.
chi_squaredReturns the chi-squared terms of the model data's fit to an dataset, by summing the chi-squared-map.
chi_squared_mapReturns the chi-squared-map between the residual-map and noise-map, where:
dataThe imaging data being fitted, with any background sky level subtracted.
figure_of_meritThe overall goodness-of-fit of the model to the dataset.
A dictionary which associates every galaxy in the tracer before operation (e.g. no PSF convolution or NUFFT performed).
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
gridsThe grids of (y,x) coordinates associated with the dataset, adjusted by any grid_offset specified in the dataset_model.
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
linear_light_profile_intensity_dictWhen linear light profiles are used in an inversion, their intensity parameter values are solved for via linear algebra.
log_evidenceReturns the log Bayesian evidence of the inversion's fit to a dataset, which extends the log likelihood by including penalty terms that quantify the complexity of the inversion's reconstruction:
log_likelihoodReturns the log likelihood of each model data point's fit to the dataset, where:
log_likelihood_with_regularizationReturns the log likelihood of an inversion's fit to the dataset, including a regularization term which comes from an inversion:
maskThe 2D mask of the dataset being fitted, where False entries are unmasked and included in the fit and True entries are masked and excluded.
Returns the model-image that is used to fit the data.
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
model_obj_linear_light_profiles_to_light_profilesThe model object may contain linear light profiles, which solve for the intensity during the Inversion.
noise_mapThe noise-map of the dataset being fitted, representing the RMS noise in each pixel.
noise_normalizationReturns the noise-map normalization term of the noise-map, summing the noise_map value in every pixel as:
normalized_residual_mapReturns the normalized residual-map between the masked dataset and model data, where:
perform_inversionReturns a bool specifying whether this fit object performs an inversion.
Returns the dataset's image with all blurred light profile images in the fit's tracer subtracted.
reduced_chi_squaredThe reduced chi-squared of the model's fit to the dataset, defined as:
residual_flux_fraction_mapReturns the residual flux fraction map, which shows the fraction of signal in each pixel that is not fitted by the model, therefore where:
residual_mapReturns the residual-map between the masked dataset and model data, where:
signal_to_noise_mapThe signal-to-noise_map of the dataset and noise-map which are fitted.
sparse_operatorOnly call the sparse_operator property of a dataset used to perform efficient linear algebra calculations if the Settings()` object has use_sparse_operator=True, to avoid unnecessary computation.
A dictionary which associates every galaxy in the tracer with its subtracted image.
A list of the subtracted image of every plane.
A dictionary which associates every galaxy in the tracer with its subtracted image.
total_mappersThe total number of Mapper objects used by the inversion in this fit.
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.
The blurred image of the overall fit that would be evaluated without a mask being used.
The blurred image of every galaxy in the tracer used in this fit, that would be evaluated without a mask being used.
- property blurred_image: Array2D#
Returns the image of all light profiles in the fit’s tracer convolved with the imaging dataset’s PSF.
- property profile_subtracted_image: Array2D#
Returns the dataset’s image with all blurred light profile images in the fit’s tracer subtracted.
- property tracer_to_inversion: TracerToInversion#
- inversion#
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
- 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.
- property galaxy_image_dict: Dict[Galaxy, ndarray]#
A dictionary which associates every galaxy in the tracer before operation (e.g. no PSF convolution or NUFFT performed).
This image is the image of the sum of:
The images of all ordinary light profiles in that plane summed before any operation is performed on them.
The images of all linear objects (e.g. linear light profiles / pixelizations), where the images are solved for first via the inversion.
This dictionary is used to output to .fits file the galaxy images.
- galaxy_model_image_dict#
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
- property subtracted_images_of_galaxies_dict: Dict[Galaxy, ndarray]#
A dictionary which associates every galaxy in the tracer with its subtracted image.
A subtracted image of a galaxy is the data where all other galaxy images are subtracted from it, therefore showing how a galaxy appears in the data in the absence of all other galaxies.
This is used to visualize the contribution of each galaxy in the data.
- property subtracted_signal_to_noise_maps_of_galaxies_dict: Dict[Galaxy, ndarray]#
A dictionary which associates every galaxy in the tracer with its subtracted image.
A subtracted image of a galaxy is the data where all other galaxy images are subtracted from it, therefore showing how a galaxy appears in the data in the absence of all other galaxies.
This is used to visualize the contribution of each galaxy in the data.
- model_images_of_planes_list#
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
- 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.
- 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.
- 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.
- 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 LightProfile or Galaxy objects.