def __init__( self, mat_plot_2d: MatPlot2D = MatPlot2D(), visuals_2d: Visuals2D = Visuals2D(), include_2d: Include2D = Include2D(), ): super().__init__(mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d)
def __init__( self, light_profile: LightProfile, grid: aa.type.Grid1D2DLike, 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(), ): """ Plots the attributes of `LightProfile` objects using the matplotlib methods `plot()` and `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 `LightProfile` 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 ---------- light_profile The light profile the plotter plots. grid The 2D (y,x) grid of coordinates used to evaluate the light profile quantities that are plotted. 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 `LightProfile` 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 `LightProfile` are extracted and plotted as visuals for 2D plots. """ self.light_profile = light_profile self.grid = grid super().__init__( mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, include_1d=include_1d, visuals_1d=visuals_1d, )
def __init__( self, mass_obj, grid: aa.type.Grid2DLike, get_visuals_2d: Callable, mat_plot_2d: MatPlot2D = MatPlot2D(), visuals_2d: Visuals2D = Visuals2D(), include_2d: Include2D = Include2D(), ): super().__init__( mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d ) self.mass_obj = mass_obj self.grid = grid self._get_visuals_2d = get_visuals_2d
def __init__( self, fit: FitQuantity, mat_plot_2d: MatPlot2D = MatPlot2D(), visuals_2d: Visuals2D = Visuals2D(), include_2d: Include2D = Include2D(), ): """ Plots the attributes of `FitQuantity` 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 `FitQuantity` 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_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 `FitQuantity` are extracted and plotted as visuals for 2D plots. """ super().__init__(mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d) self.fit = fit
def visualize_fit_quantity( self, fit: FitQuantity, visuals_2d: Visuals2D = Visuals2D(), fit_quanaity_plotter_cls=FitQuantityPlotter, ): """ Visualizes a `FitQuantity` object, which fits a quantity of a light or mass profile (e.g. an image, potential) to the same quantity of another light or mass profile. Images are output to the `image` folder of the `visualize_path` in a subfolder called `fit_quantity`. When used with a non-linear search the `visualize_path` points to the search's results folder and this function visualizes the maximum log likelihood `FitQuantity` inferred by the search so far. Visualization includes individual images of attributes of the `FitQuantity` (e.g. the model data, residual map) and a subplot of all `FitQuantity`'s images on the same figure. The images output by the `Visualizer` are customized using the file `config/visualize/plots.ini` under the [fit_quantity] header. Parameters ---------- fit The maximum log likelihood `FitQuantity` of the non-linear search which is used to plot the fit. visuals_2d An object containing attributes which may be plotted over the figure (e.g. the centres of mass and light profiles). """ def should_plot(name): return plot_setting(section="fit_quantity", name=name) mat_plot_2d = self.mat_plot_2d_from(subfolders="fit_quantity") fit_quantity_plotter = fit_quanaity_plotter_cls( fit=fit, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, include_2d=self.include_2d, ) if should_plot("subplot_fit"): fit_quantity_plotter.subplot_fit_quantity() mat_plot_2d = self.mat_plot_2d_from(subfolders="fit_quantity") fit_quantity_plotter = FitQuantityPlotter( fit=fit, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, include_2d=self.include_2d, ) fit_quantity_plotter.figures_2d( image=should_plot("image"), noise_map=should_plot("noise_map"), model_image=should_plot("model_image"), residual_map=should_plot("residual_map"), normalized_residual_map=should_plot("normalized_residual_map"), chi_squared_map=should_plot("chi_squared_map"), ) if should_plot("all_at_end_fits"): mat_plot_2d = self.mat_plot_2d_from(subfolders="fit_quantity/fits", format="fits") fit_imaging_plotter = FitQuantityPlotter( fit=fit, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d) fit_imaging_plotter.figures_2d( image=True, noise_map=True, signal_to_noise_map=True, model_image=True, residual_map=True, normalized_residual_map=True, chi_squared_map=True, )
def __init__( self, light_profile_pdf_list: List[LightProfile], grid: aa.type.Grid2DLike, 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(), sigma: Optional[float] = 3.0, ): """ Plots the attributes of a list of `LightProfile` objects using the matplotlib methods `plot()` and `imshow()` and many other matplotlib functions which customize the plot's appearance. Figures plotted by this object average over a list light profiles to computed the average value of each attribute with errors, where the 1D regions within the errors are plotted as a shaded region to show the range of plausible models. Therefore, the input list of galaxies is expected to represent the probability density function of an inferred model-fit. 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 `LightProfile` 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 ---------- light_profile_pdf_list The list of light profiles whose mean and error values the plotter plots. grid The 2D (y,x) grid of coordinates used to evaluate the light profile quantities that are plotted. 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 `LightProfile` 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 `LightProfile` are extracted and plotted as visuals for 2D plots. sigma The confidence interval in terms of a sigma value at which the errors are computed (e.g. a value of sigma=3.0 uses confidence intevals at ~0.01 and 0.99 the PDF). """ super().__init__( light_profile=None, grid=grid, mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, include_2d=include_2d, ) self.light_profile_pdf_list = light_profile_pdf_list self.sigma = sigma self.low_limit = (1 - math.erf(sigma / math.sqrt(2))) / 2