From d6446cf712b34b62128b5b2c047a1f1a3058b7a9 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 19 Jan 2024 10:04:48 +0000 Subject: [PATCH 1/5] added data_subtracted_dict to inversion --- autoarray/inversion/inversion/abstract.py | 29 ++++++++++++++++++ .../inversion/plot/inversion_plotters.py | 18 ++++++++--- .../inversion/inversion/test_abstract.py | 30 +++++++++++++++++++ 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/autoarray/inversion/inversion/abstract.py b/autoarray/inversion/inversion/abstract.py index 1d77d129c..68abe3c34 100644 --- a/autoarray/inversion/inversion/abstract.py +++ b/autoarray/inversion/inversion/abstract.py @@ -637,6 +637,35 @@ def mapped_reconstructed_image(self) -> Array2D: """ return sum(self.mapped_reconstructed_image_dict.values()) + @cached_property + def data_subtracted_dict(self) -> Dict[LinearObj, Array2D]: + """ + Returns a dictionary of the data subtracted by the reconstructed images of combinations of all but one of the + linear objects the inversion. + + This produces images of the data showing what each linear object is actually fitted to, after accounting for + the signal in the other linear objects. + + Returns + ------- + A dictionary of the data subtracted by the reconstructed images of combinations of all but one of the + linear objects the inversion. + """ + + data_subtracted_dict = {} + + for linear_obj in self.linear_obj_list: + + data_subtracted_dict[linear_obj] = copy.copy(self.data) + + for linear_obj_other in self.linear_obj_list: + + if linear_obj != linear_obj_other: + + data_subtracted_dict[linear_obj] -= self.mapped_reconstructed_image_dict[linear_obj_other] + + return data_subtracted_dict + @cached_property @profile_func def regularization_term(self) -> float: diff --git a/autoarray/inversion/plot/inversion_plotters.py b/autoarray/inversion/plot/inversion_plotters.py index ecb07b57a..eea6c3451 100644 --- a/autoarray/inversion/plot/inversion_plotters.py +++ b/autoarray/inversion/plot/inversion_plotters.py @@ -103,6 +103,7 @@ def figures_2d(self, reconstructed_image: bool = False): def figures_2d_of_pixelization( self, pixelization_index: int = 0, + data_subtracted: bool = False, reconstructed_image: bool = False, reconstruction: bool = False, errors: bool = False, @@ -143,6 +144,17 @@ def figures_2d_of_pixelization( mapper_plotter = self.mapper_plotter_from(mapper_index=pixelization_index) + if data_subtracted: + array = self.inversion.data_subtracted_dict[mapper_plotter.mapper] + + self.mat_plot_2d.plot_array( + array=array, + visuals_2d=self.get_visuals_2d_for_data(), + auto_labels=AutoLabels( + title="Data Subtracted", filename="data_subtracted" + ), + ) + if reconstructed_image: array = self.inversion.mapped_reconstructed_image_dict[ mapper_plotter.mapper @@ -248,10 +260,8 @@ def subplot_of_mapper( self.include_2d._mapper_image_plane_mesh_grid = False - self.mat_plot_2d.plot_array( - array=self.inversion.data, - visuals_2d=self.get_visuals_2d_for_data(), - auto_labels=AutoLabels(title=f" Data"), + self.figures_2d_of_pixelization( + pixelization_index=mapper_index, data_subtracted=True ) self.figures_2d_of_pixelization( diff --git a/test_autoarray/inversion/inversion/test_abstract.py b/test_autoarray/inversion/inversion/test_abstract.py index aa7e7583f..b2cd4d6fa 100644 --- a/test_autoarray/inversion/inversion/test_abstract.py +++ b/test_autoarray/inversion/inversion/test_abstract.py @@ -469,6 +469,36 @@ def test__mapped_reconstructed_image(): assert (inversion.mapped_reconstructed_image == 3.0 * np.ones(2)).all() +def test__data_subtracted_dict(): + + linear_obj_0 = aa.m.MockLinearObj() + + mapped_reconstructed_data_dict = {linear_obj_0: np.ones(3)} + + # noinspection PyTypeChecker + inversion = aa.m.MockInversion( + data=3.0*np.ones(3), + linear_obj_list=[linear_obj_0], + mapped_reconstructed_data_dict=mapped_reconstructed_data_dict, + ) + + assert (inversion.data_subtracted_dict[linear_obj_0] == 3.0*np.ones(3)).all() + + linear_obj_1 = aa.m.MockLinearObj() + + mapped_reconstructed_data_dict = {linear_obj_0: np.ones(3), linear_obj_1: 2.0*np.ones(3)} + + # noinspection PyTypeChecker + inversion = aa.m.MockInversion( + data=3.0*np.ones(3), + linear_obj_list=[linear_obj_0, linear_obj_1], + mapped_reconstructed_data_dict=mapped_reconstructed_data_dict, + ) + + assert (inversion.data_subtracted_dict[linear_obj_0] == np.ones(3)).all() + assert (inversion.data_subtracted_dict[linear_obj_1] == 2.0*np.ones(3)).all() + + def test__reconstruction_raises_exception_for_linalg_error(): # noinspection PyTypeChecker inversion = aa.m.MockInversion( From 26e1829495caefaef49721762b4dba62a2b65560 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 19 Jan 2024 10:10:48 +0000 Subject: [PATCH 2/5] add to visualize config --- autoarray/config/visualize/plots.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/autoarray/config/visualize/plots.yaml b/autoarray/config/visualize/plots.yaml index 961cd8a41..33578ef31 100644 --- a/autoarray/config/visualize/plots.yaml +++ b/autoarray/config/visualize/plots.yaml @@ -29,6 +29,7 @@ inversion: # Settings for plots of inversions (e all_at_end_png: true # Plot all individual plots listed below as .png (even if False)? all_at_end_fits: true # Plot all individual plots listed below as .fits (even if False)? all_at_end_pdf: false # Plot all individual plots listed below as publication-quality .pdf (even if False)? + data_subtracted: false # Plot individual plots of the data with the other inversion linear objects subtracted? errors: false # Plot image of the errors of every mesh-pixel reconstructed value? mesh_pixels_per_image_pixels : false # Plot the number of image-plane mesh pixels per masked data pixels? reconstructed_image: false # Plot image of the reconstructed data (e.g. in the image-plane)? From f7035c805bf22ec6a3478937571680afe47669ad Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 19 Jan 2024 10:28:02 +0000 Subject: [PATCH 3/5] imshow reconstructed for delaunay uses log10 --- .../inversion/plot/inversion_plotters.py | 37 ++++++++++++------- autoarray/plot/mat_plot/two_d.py | 1 + autoarray/plot/wrap/base/colorbar.py | 14 +++---- .../wrap/two_d/interpolated_reconstruction.py | 10 +++-- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/autoarray/inversion/plot/inversion_plotters.py b/autoarray/inversion/plot/inversion_plotters.py index eea6c3451..f44ad81bd 100644 --- a/autoarray/inversion/plot/inversion_plotters.py +++ b/autoarray/inversion/plot/inversion_plotters.py @@ -284,19 +284,21 @@ def subplot_of_mapper( ) self.mat_plot_2d.use_log10 = False - self.mat_plot_2d.contour = contour_original - self.include_2d._mapper_image_plane_mesh_grid = True self.figures_2d_of_pixelization( - pixelization_index=mapper_index, reconstructed_image=True + pixelization_index=mapper_index, reconstruction=True ) - self.include_2d._mapper_image_plane_mesh_grid = False + self.set_title(label="Source Reconstruction (Unzoomed)") self.figures_2d_of_pixelization( - pixelization_index=mapper_index, mesh_pixels_per_image_pixels=True + pixelization_index=mapper_index, + reconstruction=True, + zoom_to_brightest=False, ) + self.set_title(label=None) - self.include_2d._mapper_image_plane_mesh_grid = mapper_image_plane_mesh_grid + self.mat_plot_2d.use_log10 = True + self.mat_plot_2d.contour = contour_original self.figures_2d_of_pixelization( pixelization_index=mapper_index, reconstruction=True @@ -310,19 +312,26 @@ def subplot_of_mapper( ) self.set_title(label=None) - self.figures_2d_of_pixelization(pixelization_index=mapper_index, errors=True) + self.mat_plot_2d.use_log10 = False + self.mat_plot_2d.contour = contour_original + + self.include_2d._mapper_image_plane_mesh_grid = True + self.figures_2d_of_pixelization( + pixelization_index=mapper_index, reconstructed_image=True + ) + + self.include_2d._mapper_image_plane_mesh_grid = False + self.figures_2d_of_pixelization( + pixelization_index=mapper_index, mesh_pixels_per_image_pixels=True + ) + + self.include_2d._mapper_image_plane_mesh_grid = mapper_image_plane_mesh_grid + self.set_title(label="Errors (Unzoomed)") self.figures_2d_of_pixelization( pixelization_index=mapper_index, errors=True, zoom_to_brightest=False ) - try: - self.figures_2d_of_pixelization( - pixelization_index=mapper_index, regularization_weights=True - ) - except IndexError: - pass - self.set_title(label="Regularization Weights (Unzoomed)") try: self.figures_2d_of_pixelization( diff --git a/autoarray/plot/mat_plot/two_d.py b/autoarray/plot/mat_plot/two_d.py index fae9f6453..d822a7351 100644 --- a/autoarray/plot/mat_plot/two_d.py +++ b/autoarray/plot/mat_plot/two_d.py @@ -624,6 +624,7 @@ def _plot_delaunay_mapper( colorbar_tickparams=self.colorbar_tickparams, aspect=aspect_inv, ax=ax, + use_log10=self.use_log10 ) self.title.set(auto_title=auto_labels.title) diff --git a/autoarray/plot/wrap/base/colorbar.py b/autoarray/plot/wrap/base/colorbar.py index e52f67d98..33fa54856 100644 --- a/autoarray/plot/wrap/base/colorbar.py +++ b/autoarray/plot/wrap/base/colorbar.py @@ -161,7 +161,7 @@ def set( return cb def set_with_color_values( - self, units: Units, cmap: str, color_values: np.ndarray, ax=None, norm=None + self, units: Units, cmap: str, color_values: np.ndarray, ax=None, norm=None, use_log10: bool = False ): """ Set the figure's colorbar using an array of already known color values. @@ -181,12 +181,12 @@ def set_with_color_values( mappable = cm.ScalarMappable(cmap=cmap) mappable.set_array(color_values) - manual_tick_values = self.tick_values_from(norm=norm) - manual_tick_labels = self.tick_labels_from( - manual_tick_values=manual_tick_values, units=units + tick_values = self.tick_values_from(norm=norm, use_log10=use_log10) + tick_labels = self.tick_labels_from( + manual_tick_values=tick_values, units=units ) - if manual_tick_values is None and manual_tick_labels is None: + if tick_values is None and tick_labels is None: cb = plt.colorbar( mappable=mappable, ax=ax, @@ -196,11 +196,11 @@ def set_with_color_values( cb = plt.colorbar( mappable=mappable, ax=ax, - ticks=manual_tick_values, + ticks=tick_values, **self.config_dict, ) cb.ax.set_yticklabels( - labels=manual_tick_labels, va=self.manual_alignment or "center" + labels=tick_labels, va=self.manual_alignment or "center" ) return cb diff --git a/autoarray/plot/wrap/two_d/interpolated_reconstruction.py b/autoarray/plot/wrap/two_d/interpolated_reconstruction.py index fac5952fd..65578140f 100644 --- a/autoarray/plot/wrap/two_d/interpolated_reconstruction.py +++ b/autoarray/plot/wrap/two_d/interpolated_reconstruction.py @@ -39,6 +39,7 @@ def imshow_reconstruction( colorbar_tickparams: wb.ColorbarTickParams = None, aspect=None, ax=None, + use_log10: bool = False ): """ Given a `Mapper` and a corresponding array of `pixel_values` (e.g. the reconstruction values of a Delaunay @@ -76,6 +77,10 @@ def imshow_reconstruction( if pixel_values is None: return + interpolation_array = mapper.interpolated_array_from(values=pixel_values) + + norm = cmap.norm_from(array=interpolation_array, use_log10=use_log10) + vmin = cmap.vmin_from(array=pixel_values) vmax = cmap.vmax_from(array=pixel_values) @@ -86,16 +91,15 @@ def imshow_reconstruction( if colorbar is not None: colorbar = colorbar.set_with_color_values( - units=units, cmap=cmap, color_values=color_values, ax=ax + units=units, cmap=cmap, norm=norm, color_values=color_values, ax=ax, use_log10=use_log10 ) if colorbar is not None and colorbar_tickparams is not None: colorbar_tickparams.set(cb=colorbar) - interpolation_array = mapper.interpolated_array_from(values=pixel_values) - plt.imshow( X=interpolation_array.native, cmap=cmap, + norm=norm, extent=mapper.source_plane_mesh_grid.geometry.extent_square, aspect=aspect, ) From d725f4feabb34848c63d3255ccfb048a081dd39f Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Mon, 22 Jan 2024 11:02:06 +0000 Subject: [PATCH 4/5] Inversion uses log10 --- autoarray/inversion/inversion/abstract.py | 7 +++---- .../inversion/plot/inversion_plotters.py | 5 +++-- autoarray/plot/mat_plot/two_d.py | 4 +++- autoarray/plot/wrap/base/colorbar.py | 13 +++++++++--- .../wrap/two_d/interpolated_reconstruction.py | 9 +++++++-- autoarray/plot/wrap/two_d/voronoi_drawer.py | 20 ++++++++++++++++++- .../inversion/inversion/test_abstract.py | 14 +++++++------ .../plot/wrap/two_d/test_voronoi_drawer.py | 4 ++-- 8 files changed, 55 insertions(+), 21 deletions(-) diff --git a/autoarray/inversion/inversion/abstract.py b/autoarray/inversion/inversion/abstract.py index 68abe3c34..a6256d6fd 100644 --- a/autoarray/inversion/inversion/abstract.py +++ b/autoarray/inversion/inversion/abstract.py @@ -655,14 +655,13 @@ def data_subtracted_dict(self) -> Dict[LinearObj, Array2D]: data_subtracted_dict = {} for linear_obj in self.linear_obj_list: - data_subtracted_dict[linear_obj] = copy.copy(self.data) for linear_obj_other in self.linear_obj_list: - if linear_obj != linear_obj_other: - - data_subtracted_dict[linear_obj] -= self.mapped_reconstructed_image_dict[linear_obj_other] + data_subtracted_dict[ + linear_obj + ] -= self.mapped_reconstructed_image_dict[linear_obj_other] return data_subtracted_dict diff --git a/autoarray/inversion/plot/inversion_plotters.py b/autoarray/inversion/plot/inversion_plotters.py index f44ad81bd..bb32f5847 100644 --- a/autoarray/inversion/plot/inversion_plotters.py +++ b/autoarray/inversion/plot/inversion_plotters.py @@ -298,13 +298,14 @@ def subplot_of_mapper( self.set_title(label=None) self.mat_plot_2d.use_log10 = True - self.mat_plot_2d.contour = contour_original + + self.set_title(label="Source Reconstruction (log10)") self.figures_2d_of_pixelization( pixelization_index=mapper_index, reconstruction=True ) - self.set_title(label="Source Reconstruction (Unzoomed)") + self.set_title(label="Source Reconstruction (Unzoomed log10)") self.figures_2d_of_pixelization( pixelization_index=mapper_index, reconstruction=True, diff --git a/autoarray/plot/mat_plot/two_d.py b/autoarray/plot/mat_plot/two_d.py index d822a7351..2ca707912 100644 --- a/autoarray/plot/mat_plot/two_d.py +++ b/autoarray/plot/mat_plot/two_d.py @@ -624,7 +624,7 @@ def _plot_delaunay_mapper( colorbar_tickparams=self.colorbar_tickparams, aspect=aspect_inv, ax=ax, - use_log10=self.use_log10 + use_log10=self.use_log10, ) self.title.set(auto_title=auto_labels.title) @@ -691,6 +691,7 @@ def _plot_voronoi_mapper( colorbar=self.colorbar, colorbar_tickparams=self.colorbar_tickparams, ax=ax, + use_log10=self.use_log10, ) else: @@ -703,6 +704,7 @@ def _plot_voronoi_mapper( colorbar_tickparams=self.colorbar_tickparams, aspect=aspect_inv, ax=ax, + use_log10=self.use_log10, ) self.title.set(auto_title=auto_labels.title) diff --git a/autoarray/plot/wrap/base/colorbar.py b/autoarray/plot/wrap/base/colorbar.py index 33fa54856..093088af7 100644 --- a/autoarray/plot/wrap/base/colorbar.py +++ b/autoarray/plot/wrap/base/colorbar.py @@ -161,7 +161,13 @@ def set( return cb def set_with_color_values( - self, units: Units, cmap: str, color_values: np.ndarray, ax=None, norm=None, use_log10: bool = False + self, + units: Units, + cmap: str, + color_values: np.ndarray, + ax=None, + norm=None, + use_log10: bool = False, ): """ Set the figure's colorbar using an array of already known color values. @@ -178,12 +184,13 @@ def set_with_color_values( The values of the pixels on the Voronoi mesh which are used to create the colorbar. """ - mappable = cm.ScalarMappable(cmap=cmap) + mappable = cm.ScalarMappable(norm=norm, cmap=cmap) mappable.set_array(color_values) tick_values = self.tick_values_from(norm=norm, use_log10=use_log10) tick_labels = self.tick_labels_from( - manual_tick_values=tick_values, units=units + manual_tick_values=tick_values, + units=units, ) if tick_values is None and tick_labels is None: diff --git a/autoarray/plot/wrap/two_d/interpolated_reconstruction.py b/autoarray/plot/wrap/two_d/interpolated_reconstruction.py index 65578140f..dede61cc7 100644 --- a/autoarray/plot/wrap/two_d/interpolated_reconstruction.py +++ b/autoarray/plot/wrap/two_d/interpolated_reconstruction.py @@ -39,7 +39,7 @@ def imshow_reconstruction( colorbar_tickparams: wb.ColorbarTickParams = None, aspect=None, ax=None, - use_log10: bool = False + use_log10: bool = False, ): """ Given a `Mapper` and a corresponding array of `pixel_values` (e.g. the reconstruction values of a Delaunay @@ -91,7 +91,12 @@ def imshow_reconstruction( if colorbar is not None: colorbar = colorbar.set_with_color_values( - units=units, cmap=cmap, norm=norm, color_values=color_values, ax=ax, use_log10=use_log10 + units=units, + cmap=cmap, + norm=norm, + color_values=color_values, + ax=ax, + use_log10=use_log10, ) if colorbar is not None and colorbar_tickparams is not None: colorbar_tickparams.set(cb=colorbar) diff --git a/autoarray/plot/wrap/two_d/voronoi_drawer.py b/autoarray/plot/wrap/two_d/voronoi_drawer.py index 013c1f72a..56bf67ce9 100644 --- a/autoarray/plot/wrap/two_d/voronoi_drawer.py +++ b/autoarray/plot/wrap/two_d/voronoi_drawer.py @@ -31,6 +31,7 @@ def draw_voronoi_pixels( colorbar: Optional[wb.Colorbar], colorbar_tickparams: Optional[wb.ColorbarTickParams] = None, ax=None, + use_log10: bool = False, ): """ Draws the Voronoi pixels of the input `mapper` using its `mesh_grid` which contains the (y,x) @@ -46,6 +47,12 @@ def draw_voronoi_pixels( The colormap used to plot each Voronoi cell. colorbar The `Colorbar` object in `mat_base` used to set the colorbar of the figure the Voronoi mesh is plotted on. + colorbar_tickparams + The `ColorbarTickParams` object in `mat_base` used to set the tick labels of the colorbar. + ax + The matplotlib axis the Voronoi mesh is plotted on. + use_log10 + If `True`, the colorbar is plotted using a log10 scale. """ if ax is None: @@ -54,6 +61,12 @@ def draw_voronoi_pixels( regions, vertices = mesh_util.voronoi_revised_from(voronoi=mapper.voronoi) if pixel_values is not None: + norm = cmap.norm_from(array=pixel_values, use_log10=use_log10) + + if use_log10: + pixel_values[pixel_values < 1e-4] = 1e-4 + pixel_values = np.log10(pixel_values) + vmin = cmap.vmin_from(array=pixel_values) vmax = cmap.vmax_from(array=pixel_values) @@ -69,7 +82,12 @@ def draw_voronoi_pixels( if colorbar is not None: cb = colorbar.set_with_color_values( - units=units, cmap=cmap, color_values=color_values, ax=ax + units=units, + norm=norm, + cmap=cmap, + color_values=color_values, + ax=ax, + use_log10=use_log10, ) if cb is not None and colorbar_tickparams is not None: diff --git a/test_autoarray/inversion/inversion/test_abstract.py b/test_autoarray/inversion/inversion/test_abstract.py index b2cd4d6fa..b799d3f58 100644 --- a/test_autoarray/inversion/inversion/test_abstract.py +++ b/test_autoarray/inversion/inversion/test_abstract.py @@ -470,33 +470,35 @@ def test__mapped_reconstructed_image(): def test__data_subtracted_dict(): - linear_obj_0 = aa.m.MockLinearObj() mapped_reconstructed_data_dict = {linear_obj_0: np.ones(3)} # noinspection PyTypeChecker inversion = aa.m.MockInversion( - data=3.0*np.ones(3), + data=3.0 * np.ones(3), linear_obj_list=[linear_obj_0], mapped_reconstructed_data_dict=mapped_reconstructed_data_dict, ) - assert (inversion.data_subtracted_dict[linear_obj_0] == 3.0*np.ones(3)).all() + assert (inversion.data_subtracted_dict[linear_obj_0] == 3.0 * np.ones(3)).all() linear_obj_1 = aa.m.MockLinearObj() - mapped_reconstructed_data_dict = {linear_obj_0: np.ones(3), linear_obj_1: 2.0*np.ones(3)} + mapped_reconstructed_data_dict = { + linear_obj_0: np.ones(3), + linear_obj_1: 2.0 * np.ones(3), + } # noinspection PyTypeChecker inversion = aa.m.MockInversion( - data=3.0*np.ones(3), + data=3.0 * np.ones(3), linear_obj_list=[linear_obj_0, linear_obj_1], mapped_reconstructed_data_dict=mapped_reconstructed_data_dict, ) assert (inversion.data_subtracted_dict[linear_obj_0] == np.ones(3)).all() - assert (inversion.data_subtracted_dict[linear_obj_1] == 2.0*np.ones(3)).all() + assert (inversion.data_subtracted_dict[linear_obj_1] == 2.0 * np.ones(3)).all() def test__reconstruction_raises_exception_for_linalg_error(): diff --git a/test_autoarray/plot/wrap/two_d/test_voronoi_drawer.py b/test_autoarray/plot/wrap/two_d/test_voronoi_drawer.py index 3a0167f70..711fa2cbd 100644 --- a/test_autoarray/plot/wrap/two_d/test_voronoi_drawer.py +++ b/test_autoarray/plot/wrap/two_d/test_voronoi_drawer.py @@ -9,7 +9,7 @@ def test__draws_voronoi_pixels_for_sensible_input(voronoi_mapper_9_3x3): voronoi_drawer.draw_voronoi_pixels( mapper=voronoi_mapper_9_3x3, pixel_values=None, - units=None, + units=aplt.Units(), cmap=aplt.Cmap(), colorbar=None, ) @@ -20,7 +20,7 @@ def test__draws_voronoi_pixels_for_sensible_input(voronoi_mapper_9_3x3): voronoi_drawer.draw_voronoi_pixels( mapper=voronoi_mapper_9_3x3, pixel_values=values, - units=None, + units=aplt.Units(), cmap=aplt.Cmap(), colorbar=aplt.Colorbar(fraction=0.1, pad=0.05), ) From 7d1433f2e63f73055a4d764ca41111fdf6c97f7e Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Mon, 22 Jan 2024 11:27:39 +0000 Subject: [PATCH 5/5] plotting criteria to fix log10 plots --- autoarray/config/visualize/plots.yaml | 1 + autoarray/plot/mat_plot/two_d.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/autoarray/config/visualize/plots.yaml b/autoarray/config/visualize/plots.yaml index 33578ef31..3c78eb118 100644 --- a/autoarray/config/visualize/plots.yaml +++ b/autoarray/config/visualize/plots.yaml @@ -12,6 +12,7 @@ imaging: # Settings for plots of imaging datas psf: false fit: # Settings for plots of all fits (e.g. FitImagingPlotter, FitInterferometerPlotter). subplot_fit: true # Plot subplot of all fit quantities for any dataset (e.g. the model data, residual-map, etc.)? + subplot_fit_log10: true # Plot subplot of all fit quantities for any dataset using log10 color maps (e.g. the model data, residual-map, etc.)? all_at_end_png: true # Plot all individual plots listed below as .png (even if False)? all_at_end_fits: true # Plot all individual plots listed below as .fits (even if False)? all_at_end_pdf: false # Plot all individual plots listed below as publication-quality .pdf (even if False)? diff --git a/autoarray/plot/mat_plot/two_d.py b/autoarray/plot/mat_plot/two_d.py index 2ca707912..29b7089ee 100644 --- a/autoarray/plot/mat_plot/two_d.py +++ b/autoarray/plot/mat_plot/two_d.py @@ -239,6 +239,9 @@ def plot_array( if array is None or np.all(array == 0): return + if self.use_log10 and (np.all(array == array[0]) or np.all(array < 0)): + return + if array.pixel_scales is None and self.units.use_scaled: raise exc.ArrayException( "You cannot plot an array using its scaled unit_label if the input array does not have "