autolens.FitInterferometer#
- class FitInterferometer[source]#
Bases:
FitInterferometer,AbstractFitInversionFits an interferometer dataset using a Tracer object.
The fit performs the following steps:
Compute the sum of all images of galaxy light profiles in the Tracer.
Fourier transform this image with the transformer object and uv_wavelengths to create the profile_visibilities.
Subtract these visibilities from the data to create the profile_subtracted_visibilities.
If the Tracer has any linear algebra objects (e.g. linear light profiles, a pixelization / regulariation) fit the profile_subtracted_visibilities with these objects via an inversion.
Compute the model_data as the sum of the profile_visibilities and reconstructed_data of the inversion (if an inversion is not performed the model_data is only the profile_visibilities.
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 addition terms describing the linear algebra solution, is computed).
When performing a model-fit` via ` AnalysisInterferometer` object the figure_of_merit of this object is called and returned in the log_likelihood_function.
- Parameters:
dataset (
Interferometer) – The interforometer 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 interferometer 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.preloads – An optional PreloadsInterferometer carrying channel-invariant inversion quantities (e.g. the curvature_matrix F) computed once and reused by this fit instead of being rebuilt. Used by the datacube shared-state path, where every spectral channel shares the lens model. None (the default) leaves the standard per-fit behaviour unchanged.
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
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 data of the dataset being fitted.
dirty_chi_squared_mapThe dirty chi-squared map, computed by applying the inverse Fourier transform to the chi-squared-map visibilities (((data - model_data) / noise_map) ** 2.0).
dirty_imageThe dirty image of the observed visibility data, computed by applying the inverse Fourier transform to the data visibilities.
dirty_model_imageThe dirty model image, computed by applying the inverse Fourier transform to the model data visibilities.
The naturally weighted, normalised dirty image of the model visibilities, W~ m / sum(w), formed from model_image_natural with the dataset's sparse_operator (see autoarray.fit.fit_interferometer.dirty_model_image_natural_from).
dirty_noise_mapThe dirty noise-map, computed by applying the inverse Fourier transform to the noise-map visibilities.
dirty_normalized_residual_mapThe dirty normalized residual map, computed by applying the inverse Fourier transform to the normalized residual-map visibilities ((data - model_data) / noise_map).
dirty_residual_mapThe dirty residual map, computed by applying the inverse Fourier transform to the residual-map visibilities (data - model_data).
The naturally weighted dirty residual map, dirty_image_natural - dirty_model_image_natural, which is Re(F^H W (d - F m)) / sum(w): the natural dirty image of the visibility residuals, computed without them.
dirty_signal_to_noise_mapThe dirty signal-to-noise map, computed by applying the inverse Fourier transform to the signal-to-noise visibilities.
figure_of_meritThe overall goodness-of-fit of the model to the dataset.
A dictionary which associates every galaxy in the tracer with its image.
A dictionary which associates every galaxy in the tracer with its model visibilities.
A dictionary which associates every galaxy in the tracer with its signal-to-noise map.
gridsThe grids of (y,x) coordinates associated with the dataset, adjusted by any grid_offset and grid_rotation_angle specified in the dataset_model.
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
The fit's inversion, guaranteed to carry the visibilities it fitted as its dataset's data, for output quantities that read them (e.g. data_subtracted_dict, plotted by subplot_of_mapper).
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 mask of the interferometer fit, returned as an all-False array matching the shape of the visibility data.
Returns the model data that is used to fit the data.
the lensed image of every ordinary (non-linear) light profile (profile_image) plus, when the fit has an inversion, the solved linear objects' reconstruction mapped to the image plane (inversion.mapped_reconstructed_data, linear light profiles and pixelized sources) -- the real-space image whose visibilities are model_data.
model_obj_linear_light_profiles_to_light_profilesThe model object may contain linear light profiles, which solve for the intensity during the Inversion.
A list of every model image of every plane in the tracer.
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.
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.
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
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 visibility data and model data (data - model_data).
signal_to_noise_mapThe signal-to-noise_map of the dataset and noise-map which are fitted.
The chi-squared of this fit computed from the dataset's sparse_operator without any visibility-sized array, which chi_squared (and so log_likelihood and, without an inversion, figure_of_merit) returns on an array-free dataset (see aa.FitInterferometer.sparse_chi_squared).
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.
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.
Returns the object which builds this fit's inversion from its tracer's linear objects.
transformerThe Fourier transformer used to map between image space and visibility (uv-plane) space.
- profile_image#
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
- profile_visibilities#
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
- profile_subtracted_visibilities#
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 sparse_chi_squared#
The chi-squared of this fit computed from the dataset’s sparse_operator without any visibility-sized array, which chi_squared (and so log_likelihood and, without an inversion, figure_of_merit) returns on an array-free dataset (see aa.FitInterferometer.sparse_chi_squared).
It is data_term - 2 m^T d~ + m^T W~ m for the fit’s total image-plane model image m (the tracer’s lensed ordinary light profile_image plus any inversion’s mapped_reconstructed_data), so it equals the dense sum(|d - model_data|^2 / sigma^2) exactly, with or without an inversion (see ag.interferometer.fit_interferometer.sparse_chi_squared_from). None when the dataset has no sparse_operator; raises a DatasetException if the fit overrides an array-free dataset’s data or noise-map. Every branch is structural, so it is safe under jax.jit.
- property tracer_to_inversion: TracerToInversion#
Returns the object which builds this fit’s inversion from its tracer’s linear objects.
The inversion fits the profile_subtracted_visibilities, except when _uses_precomputed_data_term, where data=None is passed and the sparse inversion touches no visibility-sized array:
With no ordinary light profile nothing is subtracted, so the inversion takes its data vector from the operator’s cached dirty image and the data term of its fast_chi_squared from the operator’s cached scalar.
On an array-free dataset with ordinary light profiles (e.g. lens light), it is passed the dirty image d~ - W~ i_p and data term data_term - 2 i_p^T d~ + i_p^T W~ i_p of the profile-subtracted visibilities, both formed from one W~ i_p product (sparse_profile_terms_from), so the profile visibilities F i_p are never formed.
On an in-memory sparse dataset with ordinary light profiles the subtracted dirty image is still supplied (the data vector must use it) alongside the subtracted visibilities. Where the visibilities exist they remain available to outputs via fit.data.
On an array-free dataset the fit’s data and noise-map cannot be overridden, as the subtracted dirty image and data term are formed from the operator’s precomputed ones (_require_no_array_free_overrides).
- 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 inversion_with_data: AbstractInversion | None#
The fit’s inversion, guaranteed to carry the visibilities it fitted as its dataset’s data, for output quantities that read them (e.g. data_subtracted_dict, plotted by subplot_of_mapper).
On the sparse path with no ordinary light profile (_uses_precomputed_data_term) the likelihood’s inversion is built with data=None, so that it touches no visibility-sized array. Nothing was subtracted from the visibilities in that case, so the data it fitted are fit.data: this returns a shallow copy of the inversion (solved first, so it shares the reconstruction and every other cached quantity) whose dataset interface carries fit.data. In every other case it returns inversion itself.
On an array-free dataset (built by Interferometer.from_stream / from_sparse_terms) fit.data is None, so there are no visibilities to carry and inversion itself is returned; output quantities that read the visibilities are unavailable on such a fit.
- property model_data: Visibilities#
Returns the model data 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 Fourier transformed to visibilities.
If a inversion is included it is the sum of these visibilities and the inversion’s reconstructed visibilities.
On an array-free dataset (built by Interferometer.from_stream / from_sparse_terms) there is no transformer to form model visibilities with, so this raises an aa.exc.DatasetException; the real-space model_image_natural and its natural dirty image dirty_model_image_natural describe the model there.
- property galaxy_image_dict: Dict[Galaxy, ndarray]#
A dictionary which associates every galaxy in the tracer with its image.
This image is the image of the sum of:
The images of all ordinary light profiles in that tracer summed.
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 adapt certain pixelizations to the data being fitted.
- property model_image_natural: Array2D#
the lensed image of every ordinary (non-linear) light profile (profile_image) plus, when the fit has an inversion, the solved linear objects’ reconstruction mapped to the image plane (inversion.mapped_reconstructed_data, linear light profiles and pixelized sources) – the real-space image whose visibilities are model_data.
It is built from these two terms rather than from galaxy_image_dict, whose entry for a galaxy with both ordinary and linear light holds only the linear reconstruction.
It needs neither visibilities nor a transformer, so it is available on an array-free dataset (built by Interferometer.from_stream / from_sparse_terms), where it is the image the natural-weighted dirty model image dirty_model_image_natural is formed from.
- Type:
The real-space (image-plane) model image m of the fit, on the dataset’s real_space_mask
- property dirty_model_image_natural: Array2D#
The naturally weighted, normalised dirty image of the model visibilities, W~ m / sum(w), formed from model_image_natural with the dataset’s sparse_operator (see autoarray.fit.fit_interferometer.dirty_model_image_natural_from).
It is the model counterpart of the dataset’s dirty_image_natural and needs no visibilities, so it is how a fit on an array-free dataset is visualized. It is available on any dataset carrying a sparse_operator (array-free, or in-memory after apply_sparse_operator()); otherwise it raises an aa.exc.DatasetException.
- property dirty_residual_map_natural: Array2D#
The naturally weighted dirty residual map, dirty_image_natural - dirty_model_image_natural, which is Re(F^H W (d - F m)) / sum(w): the natural dirty image of the visibility residuals, computed without them.
- property galaxy_signal_to_noise_map_dict: Dict[Galaxy, ndarray]#
A dictionary which associates every galaxy in the tracer with its signal-to-noise map.
This signal-to-noise map is the signal-to-noise map of the sum of:
The images of all ordinary light profiles in that tracer summed.
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 adapt certain pixelizations to the data being fitted.
- property galaxy_model_visibilities_dict: Dict[Galaxy, ndarray]#
A dictionary which associates every galaxy in the tracer with its model visibilities.
These visibilities are the sum of:
The visibilities of all ordinary light profiles in that tracer summed and Fourier transformed to visibilities space.
The visibilities of all linear objects (e.g. linear light profiles / pixelizations), where the visibilities are solved for first via the inversion.
On an array-free dataset there is no transformer and this raises an aa.exc.DatasetException.
- property model_visibilities_of_planes_list: List[Visibilities]#
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.
On an array-free dataset there is no transformer and this raises an aa.exc.DatasetException.
- 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.