diff --git a/autogalaxy/analysis/plotter.py b/autogalaxy/analysis/plotter.py index 97928974..ad2523d8 100644 --- a/autogalaxy/analysis/plotter.py +++ b/autogalaxy/analysis/plotter.py @@ -105,6 +105,7 @@ def should_plot(name): grid=grid, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("subplot_galaxies"): @@ -113,6 +114,7 @@ def should_plot(name): grid=grid, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("fits_galaxy_images"): @@ -151,6 +153,7 @@ def should_plot(name): output_path=output.path, output_filename=f"inversion_{i}", output_format=fmt, + title_prefix=self.title_prefix, ) if should_plot("csv_reconstruction"): @@ -180,6 +183,7 @@ def should_plot(name): adapt_galaxy_name_image_dict=adapt_images.galaxy_name_image_dict, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("fits_adapt_images"): diff --git a/autogalaxy/ellipse/model/plotter.py b/autogalaxy/ellipse/model/plotter.py index 96565bba..6be3cdb3 100644 --- a/autogalaxy/ellipse/model/plotter.py +++ b/autogalaxy/ellipse/model/plotter.py @@ -33,6 +33,7 @@ def should_plot(name): dataset, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) image_list = [ @@ -76,6 +77,7 @@ def should_plot(name): fit_list=fit_list, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("ellipse_residuals"): @@ -91,6 +93,7 @@ def should_plot(name): output_path=self.image_path, output_format=self.fmt, disable_data_contours=True, + title_prefix=self.title_prefix, ) if should_plot("subplot_fit_ellipse"): @@ -98,6 +101,7 @@ def should_plot(name): fit_list=fit_list, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) fit_ellipse_plots._plot_data( @@ -105,6 +109,7 @@ def should_plot(name): output_path=self.image_path, output_format=self.fmt, use_log10=True, + title_prefix=self.title_prefix, ) if should_plot("data_no_ellipse"): @@ -114,4 +119,5 @@ def should_plot(name): output_format=self.fmt, use_log10=True, disable_data_contours=True, + title_prefix=self.title_prefix, ) diff --git a/autogalaxy/ellipse/plot/fit_ellipse_plots.py b/autogalaxy/ellipse/plot/fit_ellipse_plots.py index 745ce5d6..68855250 100644 --- a/autogalaxy/ellipse/plot/fit_ellipse_plots.py +++ b/autogalaxy/ellipse/plot/fit_ellipse_plots.py @@ -21,6 +21,7 @@ def _plot_data( disable_data_contours: bool = False, suffix: str = "", ax=None, + title_prefix: str = None, ): """Plot the 2-D image data with fitted ellipse contours overlaid. @@ -61,9 +62,10 @@ def _plot_data( lines = [np.array(e.array) for e in ellipse_list if e is not None] positions = lines + _title = f"{title_prefix.rstrip()} Ellipse Fit" if title_prefix else "Ellipse Fit" plot_array( array=fit_list[0].data, - title="Ellipse Fit", + title=_title, output_path=output_path, output_filename=f"{output_filename}{suffix}", output_format=output_format, @@ -126,6 +128,7 @@ def subplot_fit_ellipse( colormap="default", use_log10=False, disable_data_contours: bool = False, + title_prefix: str = None, ): """Create a two-panel subplot summarising a list of ellipse fits. @@ -156,6 +159,7 @@ def subplot_fit_ellipse( use_log10=use_log10, disable_data_contours=disable_data_contours, ax=axes[0], + title_prefix=title_prefix, ) _plot_ellipse_residuals(fit_list=fit_list, for_subplot=True, ax=axes[1]) diff --git a/autogalaxy/galaxy/plot/adapt_plots.py b/autogalaxy/galaxy/plot/adapt_plots.py index f50ecb62..45e772bb 100644 --- a/autogalaxy/galaxy/plot/adapt_plots.py +++ b/autogalaxy/galaxy/plot/adapt_plots.py @@ -14,6 +14,7 @@ def subplot_adapt_images( output_format=None, colormap="default", use_log10=False, + title_prefix: str = None, ): """Create a subplot showing the adapt (model) image for each galaxy. @@ -48,10 +49,11 @@ def subplot_adapt_images( fig, axes = subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols)) axes_list = [axes] if n == 1 else list(np.array(axes).flatten()) + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) for i, (_, galaxy_image) in enumerate(adapt_galaxy_name_image_dict.items()): plot_array( array=galaxy_image, - title="Galaxy Image", + title=_pf("Galaxy Image"), colormap=colormap, use_log10=use_log10, ax=axes_list[i], diff --git a/autogalaxy/galaxy/plot/galaxies_plots.py b/autogalaxy/galaxy/plot/galaxies_plots.py index 5ee76ea9..f8a57afe 100644 --- a/autogalaxy/galaxy/plot/galaxies_plots.py +++ b/autogalaxy/galaxy/plot/galaxies_plots.py @@ -73,6 +73,7 @@ def subplot_galaxies( tangential_critical_curves=None, radial_critical_curves=None, auto_filename="galaxies", + title_prefix: str = None, ): """Create a standard five-panel summary subplot for a collection of galaxies. @@ -129,12 +130,13 @@ def _defl_x(): d = gs.deflections_yx_2d_from(grid=grid) return aa.Array2D(values=d.slim[:, 1], mask=grid.mask) + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) panels = [ - ("image", gs.image_2d_from(grid=grid), "Image", pos_no_cc, None), - ("convergence", gs.convergence_2d_from(grid=grid), "Convergence", pos, lines), - ("potential", gs.potential_2d_from(grid=grid), "Potential", pos, lines), - ("deflections_y", _defl_y(), "Deflections Y", pos, lines), - ("deflections_x", _defl_x(), "Deflections X", pos, lines), + ("image", gs.image_2d_from(grid=grid), _pf("Image"), pos_no_cc, None), + ("convergence", gs.convergence_2d_from(grid=grid), _pf("Convergence"), pos, lines), + ("potential", gs.potential_2d_from(grid=grid), _pf("Potential"), pos, lines), + ("deflections_y", _defl_y(), _pf("Deflections Y"), pos, lines), + ("deflections_x", _defl_x(), _pf("Deflections X"), pos, lines), ] n = len(panels) @@ -168,6 +170,7 @@ def subplot_galaxy_images( use_log10=False, tangential_critical_curves=None, radial_critical_curves=None, + title_prefix: str = None, ): """Create a subplot showing the individual image of each galaxy. @@ -198,6 +201,7 @@ def subplot_galaxy_images( """ _check_no_linear(galaxies) gs = Galaxies(galaxies=galaxies) + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) n = len(gs) fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n)) @@ -206,7 +210,7 @@ def subplot_galaxy_images( for i in range(n): plot_array( array=gs[i].image_2d_from(grid=grid), - title=f"Image Of Galaxies {i}", + title=_pf(f"Image Of Galaxies {i}"), colormap=colormap, use_log10=use_log10, ax=axes_flat[i], diff --git a/autogalaxy/imaging/model/plotter.py b/autogalaxy/imaging/model/plotter.py index 92f002e7..8448edd0 100644 --- a/autogalaxy/imaging/model/plotter.py +++ b/autogalaxy/imaging/model/plotter.py @@ -40,6 +40,7 @@ def should_plot(name): dataset, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("fits_dataset"): @@ -83,6 +84,7 @@ def should_plot(name): fit=fit, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if quick_update: @@ -96,6 +98,7 @@ def should_plot(name): galaxy_index=galaxy_index, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("fits_fit"): @@ -128,6 +131,7 @@ def should_plot(name): dataset_list, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) def fit_imaging_combined(self, fit_list: List[FitImaging]): @@ -151,4 +155,5 @@ def should_plot(name): fit_list, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) diff --git a/autogalaxy/imaging/plot/fit_imaging_plots.py b/autogalaxy/imaging/plot/fit_imaging_plots.py index a2148fd0..c7b45e10 100644 --- a/autogalaxy/imaging/plot/fit_imaging_plots.py +++ b/autogalaxy/imaging/plot/fit_imaging_plots.py @@ -16,6 +16,7 @@ def subplot_fit( use_log10=False, positions=None, residuals_symmetric_cmap: bool = True, + title_prefix: str = None, ): """Create a six-panel subplot summarising a :class:`~autogalaxy.imaging.fit_imaging.FitImaging`. @@ -40,13 +41,14 @@ def subplot_fit( Reserved for future symmetric-colormap support on residual panels (currently unused). """ + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) panels = [ - (fit.data, "Data", None), - (fit.signal_to_noise_map, "Signal-To-Noise Map", None), - (fit.model_data, "Model Image", None), - (fit.residual_map, "Residual Map", None), - (fit.normalized_residual_map, "Normalized Residual Map", None), - (fit.chi_squared_map, "Chi-Squared Map", r"$\chi^2$"), + (fit.data, _pf("Data"), None), + (fit.signal_to_noise_map, _pf("Signal-To-Noise Map"), None), + (fit.model_data, _pf("Model Image"), None), + (fit.residual_map, _pf("Residual Map"), None), + (fit.normalized_residual_map, _pf("Normalized Residual Map"), None), + (fit.chi_squared_map, _pf("Chi-Squared Map"), r"$\chi^2$"), ] n = len(panels) fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n)) @@ -76,6 +78,7 @@ def subplot_of_galaxy( use_log10=False, positions=None, residuals_symmetric_cmap: bool = True, + title_prefix: str = None, ): """Create a three-panel subplot focused on a single galaxy contribution. @@ -103,15 +106,16 @@ def subplot_of_galaxy( residuals_symmetric_cmap : bool Reserved for future symmetric-colormap support (currently unused). """ + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) panels = [ - (fit.data, "Data"), + (fit.data, _pf("Data")), ( fit.subtracted_images_of_galaxies_list[galaxy_index], - f"Subtracted Image of Galaxy {galaxy_index}", + _pf(f"Subtracted Image of Galaxy {galaxy_index}"), ), ( fit.model_images_of_galaxies_list[galaxy_index], - f"Model Image of Galaxy {galaxy_index}", + _pf(f"Model Image of Galaxy {galaxy_index}"), ), ] n = len(panels) @@ -136,6 +140,7 @@ def subplot_fit_imaging_list( output_path=None, output_filename: str = "fit_combined", output_format=None, + title_prefix: str = None, ): """ nĂ—5 subplot summarising a list of ``FitImaging`` objects. @@ -154,16 +159,17 @@ def subplot_fit_imaging_list( output_format File format string or list, e.g. ``"png"`` or ``["png"]``. """ + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) n = len(fit_list) fig, axes = subplots(n, 5, figsize=conf_subplot_figsize(n, 5)) if n == 1: axes = [axes] for i, fit in enumerate(fit_list): - plot_array(array=fit.data, title="Data", ax=axes[i][0]) - plot_array(array=fit.signal_to_noise_map, title="Signal-To-Noise Map", ax=axes[i][1]) - plot_array(array=fit.model_data, title="Model Image", ax=axes[i][2]) - plot_array(array=fit.normalized_residual_map, title="Normalized Residual Map", cb_unit=r"$\sigma$", ax=axes[i][3]) - plot_array(array=fit.chi_squared_map, title="Chi-Squared Map", cb_unit=r"$\chi^2$", ax=axes[i][4]) + plot_array(array=fit.data, title=_pf("Data"), ax=axes[i][0]) + plot_array(array=fit.signal_to_noise_map, title=_pf("Signal-To-Noise Map"), ax=axes[i][1]) + plot_array(array=fit.model_data, title=_pf("Model Image"), ax=axes[i][2]) + plot_array(array=fit.normalized_residual_map, title=_pf("Normalized Residual Map"), cb_unit=r"$\sigma$", ax=axes[i][3]) + plot_array(array=fit.chi_squared_map, title=_pf("Chi-Squared Map"), cb_unit=r"$\chi^2$", ax=axes[i][4]) tight_layout() _save_subplot(fig, output_path, output_filename, output_format) diff --git a/autogalaxy/interferometer/model/plotter.py b/autogalaxy/interferometer/model/plotter.py index 785b9c77..ef6306bd 100644 --- a/autogalaxy/interferometer/model/plotter.py +++ b/autogalaxy/interferometer/model/plotter.py @@ -37,6 +37,7 @@ def should_plot(name): output_path=self.image_path, output_filename="dataset", output_format=self.fmt[0] if isinstance(self.fmt, (list, tuple)) else self.fmt, + title_prefix=self.title_prefix, ) if should_plot("fits_dataset"): @@ -83,6 +84,7 @@ def should_plot(name): fit=fit, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("subplot_fit_dirty_images") or quick_update: @@ -90,6 +92,7 @@ def should_plot(name): fit=fit, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if quick_update: @@ -100,6 +103,7 @@ def should_plot(name): fit=fit, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) if should_plot("fits_galaxy_images"): diff --git a/autogalaxy/interferometer/plot/fit_interferometer_plots.py b/autogalaxy/interferometer/plot/fit_interferometer_plots.py index 25636d6f..bade136a 100644 --- a/autogalaxy/interferometer/plot/fit_interferometer_plots.py +++ b/autogalaxy/interferometer/plot/fit_interferometer_plots.py @@ -18,6 +18,7 @@ def subplot_fit( colormap="default", use_log10=False, residuals_symmetric_cmap: bool = True, + title_prefix: str = None, ): """Create a three-panel subplot summarising a :class:`~autogalaxy.interferometer.fit_interferometer.FitInterferometer`. @@ -41,10 +42,11 @@ def subplot_fit( residuals_symmetric_cmap : bool Reserved for future symmetric-colormap support (currently unused). """ + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) panels = [ - (fit.residual_map, "Residual Map"), - (fit.normalized_residual_map, "Normalized Residual Map"), - (fit.chi_squared_map, "Chi-Squared Map"), + (fit.residual_map, _pf("Residual Map")), + (fit.normalized_residual_map, _pf("Normalized Residual Map")), + (fit.chi_squared_map, _pf("Chi-Squared Map")), ] n = len(panels) fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n)) @@ -64,6 +66,7 @@ def subplot_fit_dirty_images( colormap="default", use_log10=False, residuals_symmetric_cmap: bool = True, + title_prefix: str = None, ): """Create a six-panel subplot of dirty-image diagnostics for an interferometer fit. @@ -87,13 +90,14 @@ def subplot_fit_dirty_images( residuals_symmetric_cmap : bool Reserved for future symmetric-colormap support (currently unused). """ + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) panels = [ - (fit.dirty_image, "Dirty Image", None), - (fit.dirty_signal_to_noise_map, "Dirty Signal-To-Noise Map", None), - (fit.dirty_model_image, "Dirty Model Image", None), - (fit.dirty_residual_map, "Dirty Residual Map", None), - (fit.dirty_normalized_residual_map, "Dirty Normalized Residual Map", r"$\sigma$"), - (fit.dirty_chi_squared_map, "Dirty Chi-Squared Map", r"$\chi^2$"), + (fit.dirty_image, _pf("Dirty Image"), None), + (fit.dirty_signal_to_noise_map, _pf("Dirty Signal-To-Noise Map"), None), + (fit.dirty_model_image, _pf("Dirty Model Image"), None), + (fit.dirty_residual_map, _pf("Dirty Residual Map"), None), + (fit.dirty_normalized_residual_map, _pf("Dirty Normalized Residual Map"), r"$\sigma$"), + (fit.dirty_chi_squared_map, _pf("Dirty Chi-Squared Map"), r"$\chi^2$"), ] n = len(panels) fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n)) @@ -119,6 +123,7 @@ def subplot_fit_real_space( output_format=None, colormap="default", use_log10=False, + title_prefix: str = None, ): """Create a real-space summary subplot for an interferometer fit. @@ -156,12 +161,14 @@ def subplot_fit_real_space( colormap=colormap, use_log10=use_log10, auto_filename="fit_real_space", + title_prefix=title_prefix, ) else: + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) panels = [ - (fit.dirty_image, "Dirty Image"), - (fit.dirty_model_image, "Dirty Model Image"), - (fit.dirty_residual_map, "Dirty Residual Map"), + (fit.dirty_image, _pf("Dirty Image")), + (fit.dirty_model_image, _pf("Dirty Model Image")), + (fit.dirty_residual_map, _pf("Dirty Residual Map")), ] n = len(panels) fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n)) diff --git a/autogalaxy/quantity/model/plotter.py b/autogalaxy/quantity/model/plotter.py index 089e054b..17b4594b 100644 --- a/autogalaxy/quantity/model/plotter.py +++ b/autogalaxy/quantity/model/plotter.py @@ -68,4 +68,5 @@ def should_plot(name): fit=fit, output_path=self.image_path, output_format=self.fmt, + title_prefix=self.title_prefix, ) diff --git a/autogalaxy/quantity/plot/fit_quantity_plots.py b/autogalaxy/quantity/plot/fit_quantity_plots.py index 8f2d35fc..2d60ee20 100644 --- a/autogalaxy/quantity/plot/fit_quantity_plots.py +++ b/autogalaxy/quantity/plot/fit_quantity_plots.py @@ -6,7 +6,7 @@ from autogalaxy.util.plot_utils import plot_array, _save_subplot -def _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, positions, filename="fit"): +def _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, positions, filename="fit", title_prefix=None): """Render a six-panel fit summary subplot for a single array-valued quantity fit. The panels show: data, signal-to-noise map, model image, residual map, @@ -33,13 +33,14 @@ def _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, pos filename : str Output filename stem (default ``"subplot_fit"``). """ + _pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t) panels = [ - (fit.data, "Data"), - (fit.signal_to_noise_map, "Signal-To-Noise Map"), - (fit.model_data, "Model Image"), - (fit.residual_map, "Residual Map"), - (fit.normalized_residual_map, "Normalized Residual Map"), - (fit.chi_squared_map, "Chi-Squared Map"), + (fit.data, _pf("Data")), + (fit.signal_to_noise_map, _pf("Signal-To-Noise Map")), + (fit.model_data, _pf("Model Image")), + (fit.residual_map, _pf("Residual Map")), + (fit.normalized_residual_map, _pf("Normalized Residual Map")), + (fit.chi_squared_map, _pf("Chi-Squared Map")), ] n = len(panels) fig, axes = subplots(1, n, figsize=conf_subplot_figsize(1, n)) @@ -66,6 +67,7 @@ def subplot_fit( colormap="default", use_log10=False, positions=None, + title_prefix: str = None, ): """Create a summary subplot for a :class:`~autogalaxy.quantity.fit_quantity.FitQuantity`. @@ -93,11 +95,11 @@ def subplot_fit( Point positions to scatter-plot over each panel. """ if isinstance(fit.dataset.data, aa.Array2D): - _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, positions) + _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, positions, title_prefix=title_prefix) else: _subplot_fit_array( - fit.y, output_path, output_format, colormap, use_log10, positions, filename="fit_y" + fit.y, output_path, output_format, colormap, use_log10, positions, filename="fit_y", title_prefix=title_prefix ) _subplot_fit_array( - fit.x, output_path, output_format, colormap, use_log10, positions, filename="fit_x" + fit.x, output_path, output_format, colormap, use_log10, positions, filename="fit_x", title_prefix=title_prefix )