[docs]classFitInterferometerPlotter(Plotter):def__init__(self,fit:FitInterferometer,mat_plot_1d:MatPlot1D=MatPlot1D(),visuals_1d:Visuals1D=Visuals1D(),include_1d:Include1D=Include1D(),mat_plot_2d:MatPlot2D=MatPlot2D(),visuals_2d:Visuals2D=Visuals2D(),include_2d:Include2D=Include2D(),residuals_symmetric_cmap:bool=True,):""" Plots the attributes of `FitInterferometer` objects using the matplotlib method `imshow()` and many other matplotlib functions which customize the plot's appearance. The `mat_plot_1d` and `mat_plot_2d` attributes wrap matplotlib function calls to make the figure. By default, the settings passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files, but a user can manually input values into `MatPlot2d` to customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be extracted from the `FitInterferometer` and plotted via the visuals object, if the corresponding entry is `True` in the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. Parameters ---------- fit The fit to an interferometer dataset the plotter plots. mat_plot_1d Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. include_1d Specifies which attributes of the `FitInterferometer` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. include_2d Specifies which attributes of the `FitInterferometer` are extracted and plotted as visuals for 2D plots. residuals_symmetric_cmap If true, the `residual_map` and `normalized_residual_map` are plotted with a symmetric color map such that `abs(vmin) = abs(vmax)`. """super().__init__(mat_plot_1d=mat_plot_1d,include_1d=include_1d,visuals_1d=visuals_1d,mat_plot_2d=mat_plot_2d,include_2d=include_2d,visuals_2d=visuals_2d,)self.fit=fitself._fit_interferometer_meta_plotter=FitInterferometerPlotterMeta(fit=self.fit,get_visuals_2d_real_space=self.get_visuals_2d_real_space,mat_plot_1d=self.mat_plot_1d,include_1d=self.include_1d,visuals_1d=self.visuals_1d,mat_plot_2d=self.mat_plot_2d,include_2d=self.include_2d,visuals_2d=self.visuals_2d,residuals_symmetric_cmap=residuals_symmetric_cmap,)self.figures_2d=self._fit_interferometer_meta_plotter.figures_2dself.subplot=self._fit_interferometer_meta_plotter.subplot# self.subplot_fit = self._fit_interferometer_meta_plotter.subplot_fitself.subplot_fit_dirty_images=(self._fit_interferometer_meta_plotter.subplot_fit_dirty_images)defget_visuals_2d_real_space(self)->Visuals2D:returnself.get_2d.via_mask_from(mask=self.fit.dataset.real_space_mask)@propertydefgalaxies(self)->List[Galaxy]:returnself.fit.galaxies_linear_light_profiles_to_light_profiles
[docs]defgalaxies_plotter_from(self,galaxies:List[Galaxy])->GalaxiesPlotter:""" Returns a `GalaxiesPlotter` corresponding to an input galaxies list. Returns ------- galaxies The galaxies used to make the `GalaxiesPlotter`. """returnGalaxiesPlotter(galaxies=galaxies,grid=self.fit.grids.uniform,mat_plot_2d=self.mat_plot_2d,visuals_2d=self.get_visuals_2d_real_space(),include_2d=self.include_2d,)
@propertydefinversion_plotter(self)->aplt.InversionPlotter:""" Returns an `InversionPlotter` corresponding to the `Inversion` of the fit. Returns ------- InversionPlotter An object that plots inversions which is used for plotting attributes of the inversion. """returnaplt.InversionPlotter(inversion=self.fit.inversion,mat_plot_2d=self.mat_plot_2d,visuals_2d=self.get_visuals_2d_real_space(),include_2d=self.include_2d,)
[docs]defsubplot_fit(self):""" Standard subplot of the attributes of the plotter's `FitImaging` object. """self.open_subplot_figure(number_subplots=9)self.figures_2d(amplitudes_vs_uv_distances=True)self.mat_plot_1d.subplot_index=2self.mat_plot_2d.subplot_index=2self.figures_2d(dirty_image=True)self.figures_2d(dirty_signal_to_noise_map=True)self.mat_plot_1d.subplot_index=4self.mat_plot_2d.subplot_index=4self.figures_2d(dirty_model_image=True)self.mat_plot_1d.subplot_index=5self.mat_plot_2d.subplot_index=5self.figures_2d(normalized_residual_map_real=True)self.figures_2d(normalized_residual_map_imag=True)self.mat_plot_1d.subplot_index=7self.mat_plot_2d.subplot_index=7self.figures_2d(dirty_normalized_residual_map=True)self.mat_plot_2d.cmap.kwargs["vmin"]=-1.0self.mat_plot_2d.cmap.kwargs["vmax"]=1.0self.set_title(label="Normalized Residual Map (1 sigma)")self.figures_2d(dirty_normalized_residual_map=True)self.set_title(label=None)self.mat_plot_2d.cmap.kwargs.pop("vmin")self.mat_plot_2d.cmap.kwargs.pop("vmax")self.figures_2d(dirty_chi_squared_map=True)self.mat_plot_2d.output.subplot_to_figure(auto_filename="subplot_fit")self.close_subplot_figure()
[docs]defsubplot_fit_real_space(self):""" Standard subplot of the real-space attributes of the plotter's `FitInterferometer` object. Depending on whether `LightProfile`'s or an `Inversion` are used to represent galaxies, different methods are called to create these real-space images. """ifnotself.galaxies.has(cls=aa.Pixelization):galaxies_plotter=self.galaxies_plotter_from(galaxies=self.galaxies)galaxies_plotter.subplot(image=True,auto_filename="subplot_fit_real_space")elifself.galaxies.has(cls=aa.Pixelization):self.open_subplot_figure(number_subplots=6)mapper_index=0self.inversion_plotter.figures_2d_of_pixelization(pixelization_index=mapper_index,reconstructed_image=True)self.inversion_plotter.figures_2d_of_pixelization(pixelization_index=mapper_index,reconstruction=True)self.mat_plot_2d.output.subplot_to_figure(auto_filename=f"subplot_fit_real_space")self.close_subplot_figure()