Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autogalaxy/analysis/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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"):
Expand Down Expand Up @@ -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"):
Expand Down Expand Up @@ -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"):
Expand Down
6 changes: 6 additions & 0 deletions autogalaxy/ellipse/model/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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"):
Expand All @@ -91,20 +93,23 @@ 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"):
fit_ellipse_plots.subplot_fit_ellipse(
fit_list=fit_list,
output_path=self.image_path,
output_format=self.fmt,
title_prefix=self.title_prefix,
)

fit_ellipse_plots._plot_data(
fit_list=fit_list,
output_path=self.image_path,
output_format=self.fmt,
use_log10=True,
title_prefix=self.title_prefix,
)

if should_plot("data_no_ellipse"):
Expand All @@ -114,4 +119,5 @@ def should_plot(name):
output_format=self.fmt,
use_log10=True,
disable_data_contours=True,
title_prefix=self.title_prefix,
)
6 changes: 5 additions & 1 deletion autogalaxy/ellipse/plot/fit_ellipse_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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])

Expand Down
4 changes: 3 additions & 1 deletion autogalaxy/galaxy/plot/adapt_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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],
Expand Down
16 changes: 10 additions & 6 deletions autogalaxy/galaxy/plot/galaxies_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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))
Expand All @@ -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],
Expand Down
5 changes: 5 additions & 0 deletions autogalaxy/imaging/model/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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:
Expand All @@ -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"):
Expand Down Expand Up @@ -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]):
Expand All @@ -151,4 +155,5 @@ def should_plot(name):
fit_list,
output_path=self.image_path,
output_format=self.fmt,
title_prefix=self.title_prefix,
)
34 changes: 20 additions & 14 deletions autogalaxy/imaging/plot/fit_imaging_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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))
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions autogalaxy/interferometer/model/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -83,13 +84,15 @@ 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:
fit_interferometer_plots.subplot_fit_dirty_images(
fit=fit,
output_path=self.image_path,
output_format=self.fmt,
title_prefix=self.title_prefix,
)

if quick_update:
Expand All @@ -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"):
Expand Down
Loading
Loading