def subplot_detection_imaging(self, fit_imaging_detect, detection_array, mass_array): self.open_subplot_figure(number_subplots=4) self.set_title("Image") fit_imaging_plotter = self.fit_imaging_plotter_from( fit_imaging=fit_imaging_detect) fit_imaging_plotter.figures(image=True) self.set_title("Signal-To-Noise Map") fit_imaging_plotter.figures(signal_to_noise_map=True) self.mat_plot_2d.plot_array( array=detection_array, visuals_2d=self.visuals_2d, auto_labels=mp.AutoLabels(title="Increase in Log Evidence"), ) self.mat_plot_2d.plot_array( array=mass_array, visuals_2d=self.visuals_2d, auto_labels=mp.AutoLabels(title="Subhalo Mass"), ) self.mat_plot_2d.output.subplot_to_figure( auto_filename="subplot_detection_imaging") self.close_subplot_figure()
def figures( self, image=False, source_plane=False, convergence=False, potential=False, deflections_y=False, deflections_x=False, magnification=False, contribution_map=False, ): """Plot the observed _tracer of an analysis, using the `Imaging` class object. The visualization and output type can be fully customized. Parameters ----------- tracer : autolens.imaging.tracer.Imaging Class containing the _tracer, noise_mappers and PSF that are to be plotted. The font size of the figure ylabel. output_path : str The path where the _tracer is output if the output_type is a file format (e.g. png, fits) output_format : str How the _tracer is output. File formats (e.g. png, fits) output the _tracer to harddisk. 'show' displays the _tracer \ in the python interpreter window. """ if image: self.mat_plot_2d.plot_array( array=self.tracer.image_from_grid(grid=self.grid), visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Image", filename="image"), ) if source_plane: self.figures_of_planes( plane_image=True, plane_index=len(self.tracer.planes) - 1 ) super().figures( convergence=convergence, potential=potential, deflections_y=deflections_y, deflections_x=deflections_x, magnification=magnification, ) if contribution_map: self.mat_plot_2d.plot_array( array=self.tracer.contribution_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels( title="Contribution Map", filename="contribution_map" ), )
def figures_2d( self, image=False, noise_map=False, signal_to_noise_map=False, model_image=False, residual_map=False, normalized_residual_map=False, chi_squared_map=False, ): if image: self.mat_plot_2d.plot_array( array=self.fit.data, visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels(title="Image", filename="image_2d"), ) super(FitGalaxyPlotter, self).figures_2d( noise_map=noise_map, signal_to_noise_map=signal_to_noise_map, model_image=model_image, residual_map=residual_map, normalized_residual_map=normalized_residual_map, chi_squared_map=chi_squared_map, )
def subplot( self, image=False, plane_image=False, plane_grid=False, convergence=False, potential=False, deflections_y=False, deflections_x=False, magnification=False, contribution_map=False, auto_filename="subplot_plane", ): self._subplot_custom_plot( image=image, plane_image=plane_image, plane_grid=plane_grid, convergence=convergence, potential=potential, deflections_y=deflections_y, deflections_x=deflections_x, magnification=magnification, contribution_map=contribution_map, auto_labels=mat_plot.AutoLabels(filename=auto_filename), )
def subplot( self, visibilities=False, noise_map=False, u_wavelengths=False, v_wavelengths=False, uv_wavelengths=False, amplitudes_vs_uv_distances=False, phases_vs_uv_distances=False, dirty_image=False, dirty_noise_map=False, dirty_signal_to_noise_map=False, dirty_inverse_noise_map=False, auto_filename="subplot_interferometer", ): self._subplot_custom_plot( visibilities=visibilities, noise_map=noise_map, u_wavelengths=u_wavelengths, v_wavelengths=v_wavelengths, uv_wavelengths=uv_wavelengths, amplitudes_vs_uv_distances=amplitudes_vs_uv_distances, phases_vs_uv_distances=phases_vs_uv_distances, dirty_image=dirty_image, dirty_noise_map=dirty_noise_map, dirty_signal_to_noise_map=dirty_signal_to_noise_map, dirty_inverse_noise_map=dirty_inverse_noise_map, auto_labels=mp.AutoLabels(filename=auto_filename), )
def figure_2d(self): self.mat_plot_2d.plot_array( array=self.array, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Array2D", filename="array"), )
def subplot( self, reconstructed_image=False, reconstruction=False, errors=False, residual_map=False, normalized_residual_map=False, chi_squared_map=False, regularization_weight_list=False, interpolated_reconstruction=False, interpolated_errors=False, auto_filename="subplot_inversion", ): self._subplot_custom_plot( reconstructed_image=reconstructed_image, reconstruction=reconstruction, errors=errors, residual_map=residual_map, normalized_residual_map=normalized_residual_map, chi_squared_map=chi_squared_map, regularization_weight_list=regularization_weight_list, interpolated_reconstruction=interpolated_reconstruction, interpolated_errors=interpolated_errors, auto_labels=mp.AutoLabels(filename=auto_filename), )
def figure_2d(self, color_array=None): self.mat_plot_2d.plot_grid( grid=self.grid, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Grid2D", filename="grid"), color_array=color_array, )
def figure_2d(self, source_pixelilzation_values=None): self.mat_plot_2d.plot_mapper( mapper=self.mapper, visuals_2d=self.visuals_source_with_include_2d, source_pixelilzation_values=source_pixelilzation_values, auto_labels=mp.AutoLabels(title="Mapper", filename="mapper"), )
def figures_1d(self, convergence=False, potential=False): if self.mat_plot_1d.yx_plot.plot_axis_type is None: plot_axis_type_override = "semilogy" else: plot_axis_type_override = None if convergence: convergence_1d = self.mass_profile.convergence_1d_from_grid( grid=self.grid) self.mat_plot_1d.plot_yx( y=convergence_1d, x=convergence_1d.grid_radial, visuals_1d=self.visuals_with_include_1d, auto_labels=mat_plot.AutoLabels( title="Convergence vs Radius", ylabel="Convergence ", xlabel="Radius", legend=self.lensing_obj.__class__.__name__, filename="convergence_1d", ), plot_axis_type_override=plot_axis_type_override, ) if potential: potential_1d = self.mass_profile.potential_1d_from_grid( grid=self.grid) self.mat_plot_1d.plot_yx( y=potential_1d, x=potential_1d.grid_radial, visuals_1d=self.visuals_with_include_1d, auto_labels=mat_plot.AutoLabels( title="Potential vs Radius", ylabel="Potential ", xlabel="Radius", legend=self.lensing_obj.__class__.__name__, filename="potential_1d", ), plot_axis_type_override=plot_axis_type_override, )
def figures_2d(self, image=False): if image: self.mat_plot_2d.plot_array( array=self.light_profile.image_2d_from_grid(grid=self.grid), visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels(title="Image", filename="image_2d"), )
def subplot_with_source_grid(self): self.open_subplot_figure(number_subplots=2) self.figures_2d() self.mat_plot_2d.plot_grid( grid=self.plane.traced_grid_from_grid(grid=self.grid), visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels(), ) self.mat_plot_2d.output.subplot_to_figure() self.close_subplot_figure()
def figures_2d_of_galaxies( self, subtracted_image=False, model_image=False, galaxy_index=None ): galaxy_indexes = self.galaxy_indexes_from_galaxy_index( galaxy_index=galaxy_index ) for galaxy_index in galaxy_indexes: if subtracted_image: self.mat_plot_2d.cmap.kwargs["vmin"] = np.max( self.fit.model_images_of_galaxies[galaxy_index] ) self.mat_plot_2d.cmap.kwargs["vmin"] = np.min( self.fit.model_images_of_galaxies[galaxy_index] ) self.mat_plot_2d.plot_array( array=self.fit.subtracted_images_of_galaxies[galaxy_index], visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title=f"Subtracted Image of Galaxy {galaxy_index}", filename=f"subtracted_image_of_galaxy_{galaxy_index}", ), ) if model_image: self.mat_plot_2d.plot_array( array=self.fit.model_images_of_galaxies[galaxy_index], visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title=f"Model Image of Galaxy {galaxy_index}", filename=f"model_image_of_galaxy_{galaxy_index}", ), )
def figures_2d( self, image=False, convergence=False, potential=False, deflections_y=False, deflections_x=False, magnification=False, contribution_map=False, ): if image: self.mat_plot_2d.plot_array( array=self.galaxy.image_2d_from_grid(grid=self.grid), visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels(title="Image", filename="image_2d"), ) super().figures_2d( convergence=convergence, potential=potential, deflections_y=deflections_y, deflections_x=deflections_x, magnification=magnification, ) if contribution_map: self.mat_plot_2d.plot_array( array=self.galaxy.contribution_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title="Contribution Map", filename="contribution_map_2d"), )
def figure_contribution_map(self, contribution_map_in): """Plot the summed contribution maps of a hyper_galaxies-fit. Set *autogalaxy.datas.arrays.mat_plot_2d.mat_plot_2d* for a description of all input parameters not described below. Parameters ----------- fit : datas.fitting.fitting.AbstractLensHyperFit The hyper_galaxies-fit to the datas, which includes a list of every model image, residual_map, chi-squareds, etc. image_index : int The index of the datas in the datas-set of which the contribution_maps are plotted. """ self.mat_plot_2d.plot_array( array=contribution_map_in, visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title="Contribution Map", filename="contribution_map_2d" ), )
def figure_hyper_galaxy_image(self, galaxy_image): """Plot the image of a hyper_galaxies galaxy image. Set *autogalaxy.datas.arrays.mat_plot_2d.mat_plot_2d* for a description of all input parameters not described below. Parameters ----------- hyper_galaxy_image : datas.imaging.datas.Imaging The hyper_galaxies galaxy image. origin : True If true, the origin of the datas's coordinate system is plotted as a 'x'. """ self.mat_plot_2d.plot_array( array=galaxy_image, visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title="Hyper Galaxy Image", filename="hyper_galaxy_image" ), )
def subplot( self, visibilities=False, noise_map=False, signal_to_noise_map=False, model_visibilities=False, residual_map_real=False, residual_map_imag=False, normalized_residual_map_real=False, normalized_residual_map_imag=False, chi_squared_map_real=False, chi_squared_map_imag=False, dirty_image=False, dirty_noise_map=False, dirty_signal_to_noise_map=False, dirty_model_image=False, dirty_residual_map=False, dirty_normalized_residual_map=False, dirty_chi_squared_map=False, auto_filename="subplot_fit_interferometer", ): self._subplot_custom_plot( visibilities=visibilities, noise_map=noise_map, signal_to_noise_map=signal_to_noise_map, model_visibilities=model_visibilities, residual_map_real=residual_map_real, residual_map_imag=residual_map_imag, normalized_residual_map_real=normalized_residual_map_real, normalized_residual_map_imag=normalized_residual_map_imag, chi_squared_map_real=chi_squared_map_real, chi_squared_map_imag=chi_squared_map_imag, dirty_image=dirty_image, dirty_noise_map=dirty_noise_map, dirty_signal_to_noise_map=dirty_signal_to_noise_map, dirty_model_image=dirty_model_image, dirty_residual_map=dirty_residual_map, dirty_normalized_residual_map=dirty_normalized_residual_map, dirty_chi_squared_map=dirty_chi_squared_map, auto_labels=mp.AutoLabels(filename=auto_filename), )
def subplot( self, image=False, source_plane=False, convergence=False, potential=False, deflections_y=False, deflections_x=False, magnification=False, contribution_map=False, auto_filename="subplot_tracer", ): """Plot the observed _tracer of an analysis, using the `Imaging` class object. The visualization and output type can be fully customized. Parameters ----------- tracer : autolens.imaging.tracer.Imaging Class containing the _tracer, noise_mappers and PSF that are to be plotted. The font size of the figure ylabel. output_path : str The path where the _tracer is output if the output_type is a file format (e.g. png, fits) output_format : str How the _tracer is output. File formats (e.g. png, fits) output the _tracer to harddisk. 'show' displays the _tracer \ in the python interpreter window. """ self._subplot_custom_plot( image=image, source_plane=source_plane, convergence=convergence, potential=potential, deflections_y=deflections_y, deflections_x=deflections_x, magnification=magnification, contribution_map=contribution_map, auto_labels=mp.AutoLabels(filename=auto_filename), )
def subplot( self, image=False, noise_map=False, psf=False, signal_to_noise_map=False, inverse_noise_map=False, absolute_signal_to_noise_map=False, potential_chi_squared_map=False, auto_filename="subplot_imaging", ): self._subplot_custom_plot( image=image, noise_map=noise_map, psf=psf, signal_to_noise_map=signal_to_noise_map, inverse_noise_map=inverse_noise_map, absolute_signal_to_noise_map=absolute_signal_to_noise_map, potential_chi_squared_map=potential_chi_squared_map, auto_labels=mp.AutoLabels(filename=auto_filename), )
def subplot( self, image=False, noise_map=False, signal_to_noise_map=False, model_image=False, residual_map=False, normalized_residual_map=False, chi_squared_map=False, auto_filename="subplot_fit_imaging", ): self._subplot_custom_plot( image=image, noise_map=noise_map, signal_to_noise_map=signal_to_noise_map, model_image=model_image, residual_map=residual_map, normalized_residual_map=normalized_residual_map, chi_squared_map=chi_squared_map, auto_labels=mp.AutoLabels(filename=auto_filename), )
def subplot_image_and_mapper(self, image): self.open_subplot_figure(number_subplots=2) self.mat_plot_2d.plot_array( array=image, visuals_2d=self.visuals_data_with_include_2d, auto_labels=mp.AutoLabels(title="Image"), ) if self.visuals_2d.pixelization_indexes is not None: indexes = self.mapper.slim_indexes_from_pixelization_indexes( pixelization_indexes=self.visuals_2d.pixelization_indexes) self.mat_plot_2d.index_scatter.scatter_grid_indexes( grid=self.mapper.source_grid_slim.mask.masked_grid, indexes=indexes) self.figure_2d() self.mat_plot_2d.output.subplot_to_figure( auto_filename="subplot_image_and_mapper") self.close_subplot_figure()
def figures_1d(self, image=False): if self.mat_plot_1d.yx_plot.plot_axis_type is None: plot_axis_type_override = "semilogy" else: plot_axis_type_override = None if image: image_1d = self.light_profile.image_1d_from_grid(grid=self.grid) self.mat_plot_1d.plot_yx( y=image_1d, x=image_1d.grid_radial, visuals_1d=self.visuals_with_include_1d, auto_labels=mat_plot.AutoLabels( title="Image vs Radius", ylabel="Image", xlabel="Radius", legend=self.light_profile.__class__.__name__, filename="image_1d", ), plot_axis_type_override=plot_axis_type_override, )
def figures_2d( self, image=False, plane_image=False, plane_grid=False, convergence=False, potential=False, deflections_y=False, deflections_x=False, magnification=False, contribution_map=False, title_suffix="", filename_suffix="", ): if image: self.mat_plot_2d.plot_array( array=self.plane.image_2d_from_grid(grid=self.grid), visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title=f"Image{title_suffix}", filename=f"image_2d{filename_suffix}" ), ) if plane_image: self.mat_plot_2d.plot_array( array=self.plane.plane_image_2d_from_grid(grid=self.grid).array, visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title=f"Plane Image{title_suffix}", filename=f"plane_image{filename_suffix}", ), ) if plane_grid: self.mat_plot_2d.plot_grid( grid=self.grid, visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title=f"Plane Grid2D{title_suffix}", filename=f"plane_grid{filename_suffix}", ), ) super().figures_2d( convergence=convergence, potential=potential, deflections_y=deflections_y, deflections_x=deflections_x, magnification=magnification, ) if contribution_map: self.mat_plot_2d.plot_array( array=self.plane.contribution_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mat_plot.AutoLabels( title="Contribution Map", filename="contribution_map_2d" ), )
def figures_2d( self, image=False, noise_map=False, signal_to_noise_map=False, model_image=False, residual_map=False, normalized_residual_map=False, chi_squared_map=False, ): """Plot the model data of an analysis, using the *Fitter* class object. The visualization and output type can be fully customized. Parameters ----------- fit : autolens.lens.fitting.Fitter Class containing fit between the model data and observed lens data (including residual_map, chi_squared_map etc.) output_path : str The path where the data is output if the output_type is a file format (e.g. png, fits) output_format : str How the data is output. File formats (e.g. png, fits) output the data to harddisk. 'show' displays the data \ in the python interpreter window. """ if image: self.mat_plot_2d.plot_array( array=self.fit.data, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Image", filename="image_2d"), ) if noise_map: self.mat_plot_2d.plot_array( array=self.fit.noise_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Noise-Map", filename="noise_map"), ) if signal_to_noise_map: self.mat_plot_2d.plot_array( array=self.fit.signal_to_noise_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Signal-To-Noise Map", filename="signal_to_noise_map"), ) if model_image: self.mat_plot_2d.plot_array( array=self.fit.model_data, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Model Image", filename="model_image"), ) if residual_map: self.mat_plot_2d.plot_array( array=self.fit.residual_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Residual Map", filename="residual_map"), ) if normalized_residual_map: self.mat_plot_2d.plot_array( array=self.fit.normalized_residual_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Normalized Residual Map", filename="normalized_residual_map"), ) if chi_squared_map: self.mat_plot_2d.plot_array( array=self.fit.chi_squared_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Chi-Squared Map", filename="chi_squared_map"), )
def figure_1d(self): self.mat_plot_1d.plot_yx(y=self.y, x=self.x, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels())
def figures_2d( self, visibilities=False, noise_map=False, u_wavelengths=False, v_wavelengths=False, uv_wavelengths=False, amplitudes_vs_uv_distances=False, phases_vs_uv_distances=False, dirty_image=False, dirty_noise_map=False, dirty_signal_to_noise_map=False, dirty_inverse_noise_map=False, ): """ Plot each attribute of the interferometer data_type as individual figures one by one (e.g. the dataset, noise_map, PSF, \ Signal-to_noise-map, etc). Set *autolens.data_type.array.mat_plot_2d.mat_plot_2d* for a description of all innput parameters not described below. Parameters ----------- interferometer : data_type.UVPlaneData The interferometer data_type, which include the observed data_type, noise_map, PSF, signal-to-noise_map, etc. origin : True If true, the origin of the dataset's coordinate system is plotted as a 'x'. """ if visibilities: self.mat_plot_2d.plot_grid( grid=self.interferometer.visibilities.in_grid, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Visibilities", filename="visibilities"), ) if noise_map: self.mat_plot_2d.plot_grid( grid=self.interferometer.visibilities.in_grid, visuals_2d=self.visuals_with_include_2d, color_array=self.interferometer.noise_map.real, auto_labels=mp.AutoLabels(title="Noise-Map", filename="noise_map"), ) if u_wavelengths: self.mat_plot_1d.plot_yx( y=self.interferometer.uv_wavelengths[:, 0], x=None, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="U-Wavelengths", filename="u_wavelengths", ylabel="Wavelengths", ), plot_axis_type_override="linear", ) if v_wavelengths: self.mat_plot_1d.plot_yx( y=self.interferometer.uv_wavelengths[:, 1], x=None, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="V-Wavelengths", filename="v_wavelengths", ylabel="Wavelengths", ), plot_axis_type_override="linear", ) if uv_wavelengths: self.mat_plot_2d.plot_grid( grid=grid_2d_irregular.Grid2DIrregular.from_yx_1d( y=self.interferometer.uv_wavelengths[:, 1] / 10**3.0, x=self.interferometer.uv_wavelengths[:, 0] / 10**3.0, ), visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="UV-Wavelengths", filename="uv_wavelengths"), ) if amplitudes_vs_uv_distances: self.mat_plot_1d.plot_yx( y=self.interferometer.amplitudes, x=self.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Amplitudes vs UV-distances", filename="amplitudes_vs_uv_distances", ylabel="amplitude (Jy)", xlabel="U-Wavelengths ($\lambda$)", ), plot_axis_type_override="scatter", ) if phases_vs_uv_distances: self.mat_plot_1d.plot_yx( y=self.interferometer.phases, x=self.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Phases vs UV-distances", filename="phases_vs_uv_distances", ylabel="phase (deg)", xlabel=r"UV$_{distance}$ (k$\lambda$)", ), plot_axis_type_override="scatter", ) if dirty_image: self.mat_plot_2d.plot_array( array=self.interferometer.dirty_image, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels(title="Dirty Image", filename="dirty_image_2d"), ) if dirty_noise_map: self.mat_plot_2d.plot_array( array=self.interferometer.dirty_noise_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels(title="Dirty Noise Map", filename="dirty_noise_map_2d"), ) if dirty_signal_to_noise_map: self.mat_plot_2d.plot_array( array=self.interferometer.dirty_signal_to_noise_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels( title="Dirty Signal-To-Noise Map", filename="dirty_signal_to_noise_map_2d", ), ) if dirty_inverse_noise_map: self.mat_plot_2d.plot_array( array=self.interferometer.dirty_inverse_noise_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels( title="Dirty Inverse Noise Map", filename="dirty_inverse_noise_map_2d", ), )
def figures_2d( self, reconstructed_image=False, reconstruction=False, errors=False, residual_map=False, normalized_residual_map=False, chi_squared_map=False, regularization_weight_list=False, interpolated_reconstruction=False, interpolated_errors=False, ): """Plot the model data of an analysis, using the *Fitter* class object. The visualization and output type can be fully customized. Parameters ----------- fit : autolens.lens.fitting.Fitter Class containing fit between the model data and observed lens data (including residual_map, chi_squared_map etc.) output_path : str The path where the data is output if the output_type is a file format (e.g. png, fits) output_format : str How the data is output. File formats (e.g. png, fits) output the data to harddisk. 'show' displays the data in the python interpreter window. """ if reconstructed_image: self.mat_plot_2d.plot_array( array=self.inversion.mapped_reconstructed_image, visuals_2d=self.visuals_data_with_include_2d, auto_labels=mp.AutoLabels(title="Reconstructed Image", filename="reconstructed_image"), ) if reconstruction: vmax_custom = False if "vmax" in self.mat_plot_2d.cmap.kwargs: if self.mat_plot_2d.cmap.kwargs["vmax"] is None: reconstruction_vmax_factor = conf.instance["visualize"][ "general"]["inversion"]["reconstruction_vmax_factor"] self.mat_plot_2d.cmap.kwargs["vmax"] = ( reconstruction_vmax_factor * np.max(self.inversion.reconstruction)) vmax_custom = True self.mat_plot_2d.plot_mapper( mapper=self.inversion.mapper, visuals_2d=self.visuals_source_with_include_2d, auto_labels=mp.AutoLabels(title="Source Reconstruction", filename="reconstruction"), source_pixelilzation_values=self.as_mapper( self.inversion.reconstruction), ) if vmax_custom: self.mat_plot_2d.cmap.kwargs["vmax"] = None if errors: self.mat_plot_2d.plot_mapper( mapper=self.inversion.mapper, visuals_2d=self.visuals_source_with_include_2d, auto_labels=mp.AutoLabels(title="Errors", filename="errors"), source_pixelilzation_values=self.as_mapper( self.inversion.errors), ) if residual_map: self.mat_plot_2d.plot_mapper( mapper=self.inversion.mapper, visuals_2d=self.visuals_source_with_include_2d, auto_labels=mp.AutoLabels(title="Residual Map", filename="residual_map"), source_pixelilzation_values=self.as_mapper( self.inversion.residual_map), ) if normalized_residual_map: self.mat_plot_2d.plot_mapper( mapper=self.inversion.mapper, visuals_2d=self.visuals_source_with_include_2d, auto_labels=mp.AutoLabels(title="Normalized Residual Map", filename="normalized_residual_map"), source_pixelilzation_values=self.as_mapper( self.inversion.normalized_residual_map), ) if chi_squared_map: self.mat_plot_2d.plot_mapper( mapper=self.inversion.mapper, visuals_2d=self.visuals_source_with_include_2d, auto_labels=mp.AutoLabels(title="Chi-Squared Map", filename="chi_squared_map"), source_pixelilzation_values=self.as_mapper( self.inversion.chi_squared_map), ) if regularization_weight_list: self.mat_plot_2d.plot_mapper( mapper=self.inversion.mapper, visuals_2d=self.visuals_source_with_include_2d, auto_labels=mp.AutoLabels( title="Regularization weight_list", filename="regularization_weight_list", ), source_pixelilzation_values=self.as_mapper( self.inversion.regularization_weight_list), ) if interpolated_reconstruction: self.mat_plot_2d.plot_array( array=self.inversion. interpolated_reconstructed_data_from_shape_native(), visuals_2d=self.visuals_data_with_include_2d, auto_labels=mp.AutoLabels( title="Interpolated Reconstruction", filename="interpolated_reconstruction", ), ) if interpolated_errors: self.mat_plot_2d.plot_array( array=self.inversion.interpolated_errors_from_shape_native(), visuals_2d=self.visuals_data_with_include_2d, auto_labels=mp.AutoLabels(title="Interpolated Errors", filename="interpolated_errors"), )
def figures_2d( self, image=False, noise_map=False, psf=False, inverse_noise_map=False, signal_to_noise_map=False, absolute_signal_to_noise_map=False, potential_chi_squared_map=False, ): """Plot each attribute of the imaging data_type as individual figures one by one (e.g. the dataset, noise_map, PSF, \ Signal-to_noise-map, etc). Set *autolens.data_type.array.mat_plot_2d.mat_plot_2d* for a description of all innput parameters not described below. Parameters ----------- imaging : data_type.ImagingData The imaging data_type, which includes the observed data_type, noise_map, PSF, signal-to-noise_map, etc. include_origin : True If true, the include_origin of the dataset's coordinate system is plotted as a 'x'. """ if image: self.mat_plot_2d.plot_array( array=self.imaging.image, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Image", filename="image_2d"), ) if noise_map: self.mat_plot_2d.plot_array( array=self.imaging.noise_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels("Noise-Map", filename="noise_map"), ) if psf: self.mat_plot_2d.plot_array( array=self.imaging.psf, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Point Spread Function", filename="psf"), ) if inverse_noise_map: self.mat_plot_2d.plot_array( array=self.imaging.inverse_noise_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Inverse Noise-Map", filename="inverse_noise_map"), ) if signal_to_noise_map: self.mat_plot_2d.plot_array( array=self.imaging.signal_to_noise_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels(title="Signal-To-Noise Map", filename="signal_to_noise_map"), ) if absolute_signal_to_noise_map: self.mat_plot_2d.plot_array( array=self.imaging.absolute_signal_to_noise_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels( title="Absolute Signal-To-Noise Map", filename="absolute_signal_to_noise_map", ), ) if potential_chi_squared_map: self.mat_plot_2d.plot_array( array=self.imaging.potential_chi_squared_map, visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels( title="Potential Chi-Squared Map", filename="potential_chi_squared_map", ), )
def figures_2d_of_planes( self, subtracted_image=False, model_image=False, plane_image=False, plane_index=None, ): """Plot the model data of an analysis, using the *Fitter* class object. The visualization and output type can be fully customized. Parameters ----------- fit : autolens.lens.fitting.Fitter Class containing fit between the model data and observed lens data (including residual_map, chi_squared_map etc.) output_path : str The path where the data is output if the output_type is a file format (e.g. png, fits) output_format : str How the data is output. File formats (e.g. png, fits) output the data to harddisk. 'show' displays the data \ in the python interpreter window. """ plane_indexes = self.plane_indexes_from_plane_index(plane_index=plane_index) for plane_index in plane_indexes: if subtracted_image: try: vmin = self.mat_plot_2d.cmap.kwargs["vmin"] vmin_store = vmin except KeyError: vmin = 0.0 vmin_store = None try: vmax = self.mat_plot_2d.cmap.kwargs["vmax"] vmax_store = vmax except KeyError: vmax = np.max(self.fit.model_images_of_planes[plane_index]) vmax_store = None self.mat_plot_2d.cmap.kwargs["vmin"] = vmin self.mat_plot_2d.cmap.kwargs["vmax"] = vmax self.mat_plot_2d.plot_array( array=self.fit.subtracted_images_of_planes[plane_index], visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels( title=f"Subtracted Image of Plane {plane_index}", filename=f"subtracted_image_of_plane_{plane_index}", ), ) self.mat_plot_2d.cmap.kwargs["vmin"] = vmin_store self.mat_plot_2d.cmap.kwargs["vmax"] = vmax_store if model_image: if self.fit.inversion is None or plane_index == 0: self.mat_plot_2d.plot_array( array=self.fit.model_images_of_planes[plane_index], visuals_2d=self.visuals_with_include_2d, auto_labels=mp.AutoLabels( title=f"Model Image of Plane {plane_index}", filename=f"model_image_of_plane_{plane_index}", ), ) else: inversion_plotter = self.inversion_plotter_of_plane(plane_index=0) inversion_plotter.figures_2d(reconstructed_image=True) if plane_image: if not self.tracer.planes[plane_index].has_pixelization: self.tracer_plotter.figures_2d_of_planes( plane_image=True, plane_index=plane_index ) elif self.tracer.planes[plane_index].has_pixelization: inversion_plotter = self.inversion_plotter_of_plane(plane_index=1) inversion_plotter.figures_2d(reconstruction=True)
def figures_2d( self, visibilities=False, noise_map=False, signal_to_noise_map=False, model_visibilities=False, residual_map_real=False, residual_map_imag=False, normalized_residual_map_real=False, normalized_residual_map_imag=False, chi_squared_map_real=False, chi_squared_map_imag=False, dirty_image=False, dirty_noise_map=False, dirty_signal_to_noise_map=False, dirty_model_image=False, dirty_residual_map=False, dirty_normalized_residual_map=False, dirty_chi_squared_map=False, ): """Plot the model data of an analysis, using the *Fitter* class object. The visualization and output type can be fully customized. Parameters ----------- fit : autolens.lens.fitting.Fitter Class containing fit between the model data and observed lens data (including residual_map, chi_squared_map etc.) output_path : str The path where the data is output if the output_type is a file format (e.g. png, fits) output_format : str How the data is output. File formats (e.g. png, fits) output the data to harddisk. 'show' displays the data \ in the python interpreter window. """ if visibilities: self.mat_plot_2d.plot_grid( grid=self.fit.visibilities.in_grid, visuals_2d=self.visuals_2d, auto_labels=mp.AutoLabels(title="Visibilities", filename="visibilities"), color_array=np.real(self.fit.noise_map), ) if noise_map: self.mat_plot_2d.plot_grid( grid=self.fit.visibilities.in_grid, visuals_2d=self.visuals_2d, auto_labels=mp.AutoLabels(title="Noise-Map", filename="noise_map"), color_array=np.real(self.fit.noise_map), ) if signal_to_noise_map: self.mat_plot_2d.plot_grid( grid=self.fit.visibilities.in_grid, visuals_2d=self.visuals_2d, auto_labels=mp.AutoLabels(title="Signal-To-Noise Map", filename="signal_to_noise_map"), color_array=np.real(self.fit.signal_to_noise_map), ) if model_visibilities: self.mat_plot_2d.plot_grid( grid=self.fit.visibilities.in_grid, visuals_2d=self.visuals_2d, auto_labels=mp.AutoLabels(title="Model Visibilities", filename="model_visibilities"), color_array=np.real(self.fit.model_data), ) if residual_map_real: self.mat_plot_1d.plot_yx( y=np.real(self.fit.residual_map), x=self.fit.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Residual Map vs UV-Distance (real)", filename="real_residual_map_vs_uv_distances", ylabel="V$_{R,data}$ - V$_{R,model}$", xlabel=r"UV$_{distance}$ (k$\lambda$)", ), plot_axis_type_override="scatter", ) if residual_map_imag: self.mat_plot_1d.plot_yx( y=np.imag(self.fit.residual_map), x=self.fit.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Residual Map vs UV-Distance (imag)", filename="imag_residual_map_vs_uv_distances", ylabel="V$_{R,data}$ - V$_{R,model}$", xlabel=r"UV$_{distance}$ (k$\lambda$)", ), plot_axis_type_override="scatter", ) if normalized_residual_map_real: self.mat_plot_1d.plot_yx( y=np.real(self.fit.residual_map), x=self.fit.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Normalized Residual Map vs UV-Distance (real)", filename="real_normalized_residual_map_vs_uv_distances", ylabel="V$_{R,data}$ - V$_{R,model}$", xlabel=r"UV$_{distance}$ (k$\lambda$)", ), plot_axis_type_override="scatter", ) if normalized_residual_map_imag: self.mat_plot_1d.plot_yx( y=np.imag(self.fit.residual_map), x=self.fit.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Normalized Residual Map vs UV-Distance (imag)", filename="imag_normalized_residual_map_vs_uv_distances", ylabel="V$_{R,data}$ - V$_{R,model}$", xlabel=r"UV$_{distance}$ (k$\lambda$)", ), plot_axis_type_override="scatter", ) if chi_squared_map_real: self.mat_plot_1d.plot_yx( y=np.real(self.fit.residual_map), x=self.fit.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Chi-Squared Map vs UV-Distance (real)", filename="real_chi_squared_map_vs_uv_distances", ylabel="V$_{R,data}$ - V$_{R,model}$", xlabel=r"UV$_{distance}$ (k$\lambda$)", ), plot_axis_type_override="scatter", ) if chi_squared_map_imag: self.mat_plot_1d.plot_yx( y=np.imag(self.fit.residual_map), x=self.fit.interferometer.uv_distances / 10**3.0, visuals_1d=self.visuals_1d, auto_labels=mp.AutoLabels( title="Chi-Squared Map vs UV-Distance (imag)", filename="imag_chi_squared_map_vs_uv_distances", ylabel="V$_{R,data}$ - V$_{R,model}$", xlabel=r"UV$_{distance}$ (k$\lambda$)", ), plot_axis_type_override="scatter", ) if dirty_image: self.mat_plot_2d.plot_array( array=self.fit.dirty_image, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels(title="Dirty Image", filename="dirty_image_2d"), ) if dirty_noise_map: self.mat_plot_2d.plot_array( array=self.fit.dirty_noise_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels(title="Dirty Noise Map", filename="dirty_noise_map_2d"), ) if dirty_signal_to_noise_map: self.mat_plot_2d.plot_array( array=self.fit.dirty_signal_to_noise_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels( title="Dirty Signal-To-Noise Map", filename="dirty_signal_to_noise_map_2d", ), ) if dirty_model_image: self.mat_plot_2d.plot_array( array=self.fit.dirty_model_image, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels(title="Dirty Model Image", filename="dirty_model_image_2d"), ) if dirty_residual_map: self.mat_plot_2d.plot_array( array=self.fit.dirty_residual_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels(title="Dirty Residual Map", filename="dirty_residual_map_2d"), ) if dirty_normalized_residual_map: self.mat_plot_2d.plot_array( array=self.fit.dirty_normalized_residual_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels( title="Dirty Normalized Residual Map", filename="dirty_normalized_residual_map_2d", ), ) if dirty_chi_squared_map: self.mat_plot_2d.plot_array( array=self.fit.dirty_chi_squared_map, visuals_2d=self.visuals_with_include_2d_real_space, auto_labels=mp.AutoLabels(title="Dirty Chi-Squared Map", filename="dirty_chi_squared_map_2d"), )