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
15 changes: 9 additions & 6 deletions autogalaxy/analysis/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def __init__(self, image_path: Union[Path, str], title_prefix: str = None):
@property
def fmt(self) -> List[str]:
"""The output file format(s) read from ``config/visualize/plots.yaml``."""
return conf.instance["visualize"]["plots"]["subplot_format"]
try:
return conf.instance["visualize"]["plots"]["subplot_format"]
except KeyError:
return conf.instance["visualize"]["plots"]["format"]

def output_from(self) -> aplt.Output:
"""Return an ``autoarray`` ``Output`` object pointed at ``image_path``."""
Expand Down Expand Up @@ -94,15 +97,15 @@ def galaxies(
def should_plot(name):
return plot_setting(section="galaxies", name=name)

if should_plot("subplot_galaxy_images"):
if should_plot("galaxy_images"):
galaxies_plots.subplot_galaxy_images(
galaxies=galaxies,
grid=grid,
output_path=self.image_path,
output_format=self.fmt,
)

if should_plot("subplot_galaxies"):
if should_plot("galaxies"):
galaxies_plots.subplot_galaxies(
galaxies=galaxies,
grid=grid,
Expand Down Expand Up @@ -133,7 +136,7 @@ def should_plot(name):

output = self.output_from()

if should_plot("subplot_inversion"):
if should_plot("inversion"):
from autoarray.inversion.plot.inversion_plots import subplot_of_mapper

mapper_list = inversion.cls_list_from(cls=aa.Mapper)
Expand All @@ -144,7 +147,7 @@ def should_plot(name):
inversion=inversion,
mapper_index=i,
output_path=output.path,
output_filename=f"subplot_inversion_{i}",
output_filename=f"inversion_{i}",
output_format=fmt,
)

Expand All @@ -170,7 +173,7 @@ def should_plot(name):
return plot_setting(section="adapt", name=name)

if adapt_images.galaxy_name_image_dict is not None:
if should_plot("subplot_adapt_images"):
if should_plot("adapt_images"):
adapt_plots.subplot_adapt_images(
adapt_galaxy_name_image_dict=adapt_images.galaxy_name_image_dict,
output_path=self.image_path,
Expand Down
4 changes: 2 additions & 2 deletions autogalaxy/config/visualize/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ ticks:
number_of_ticks_2d: 3
contour:
total_contours: 10
include_values: false
include_values: true
colorbar:
fraction: 0.047
pad: 0.01
labelrotation: 90
labelsize: 22
labelsize_subplot: 18
labelsize_subplot: 22
5 changes: 3 additions & 2 deletions autogalaxy/ellipse/plot/fit_ellipse_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import autoarray as aa
from autoarray import plot as aplt
from autoarray.plot.utils import conf_subplot_figsize

from autogalaxy.ellipse.plot import fit_ellipse_plot_util
from autogalaxy.ellipse.fit_ellipse import FitEllipse
Expand Down Expand Up @@ -147,7 +148,7 @@ def subplot_fit_ellipse(
disable_data_contours : bool
If ``True``, suppress ellipse contour overlays on the image panel.
"""
fig, axes = plt.subplots(1, 2, figsize=(14, 7))
fig, axes = plt.subplots(1, 2, figsize=conf_subplot_figsize(1, 2))

_plot_data(
fit_list=fit_list,
Expand Down Expand Up @@ -212,7 +213,7 @@ def subplot_ellipse_errors(
fit_ellipse_list[i].append(aa.Grid2DIrregular.from_yx_1d(y=y, x=x))

n = len(fit_ellipse_list)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i in range(n):
Expand Down
3 changes: 2 additions & 1 deletion autogalaxy/galaxy/plot/adapt_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Dict

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize

from autogalaxy.galaxy.galaxy import Galaxy
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
Expand Down Expand Up @@ -45,7 +46,7 @@ def subplot_adapt_images(
n = len(adapt_galaxy_name_image_dict)
cols = min(n, 3)
rows = (n + cols - 1) // cols
fig, axes = plt.subplots(rows, cols, figsize=(7 * cols, 7 * rows))
fig, axes = plt.subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
axes_list = [axes] if n == 1 else list(np.array(axes).flatten())

for i, (_, galaxy_image) in enumerate(adapt_galaxy_name_image_dict.items()):
Expand Down
8 changes: 4 additions & 4 deletions autogalaxy/galaxy/plot/galaxies_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from autogalaxy.galaxy.galaxies import Galaxies
from autogalaxy.plot.plot_utils import _to_lines, _to_positions, plot_array, plot_grid, _save_subplot, _critical_curves_from
from autoarray.plot.utils import hide_unused_axes
from autoarray.plot.utils import hide_unused_axes, conf_subplot_figsize
from autogalaxy import exc


Expand Down Expand Up @@ -73,7 +73,7 @@ def subplot_galaxies(
multiple_images=None,
tangential_critical_curves=None,
radial_critical_curves=None,
auto_filename="subplot_galaxies",
auto_filename="galaxies",
):
"""Create a standard five-panel summary subplot for a collection of galaxies.

Expand Down Expand Up @@ -141,7 +141,7 @@ def _defl_x():
n = len(panels)
cols = min(n, 3)
rows = (n + cols - 1) // cols
fig, axes = plt.subplots(rows, cols, figsize=(7 * cols, 7 * rows))
fig, axes = plt.subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
axes_flat = [axes] if n == 1 else list(np.array(axes).flatten())

for i, (_, array, title, p, l) in enumerate(panels):
Expand Down Expand Up @@ -201,7 +201,7 @@ def subplot_galaxy_images(
gs = Galaxies(galaxies=galaxies)

n = len(gs)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i in range(n):
Expand Down
5 changes: 3 additions & 2 deletions autogalaxy/galaxy/plot/galaxy_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import TYPE_CHECKING

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize

from autogalaxy.galaxy.galaxy import Galaxy
from autogalaxy.profiles.light.abstract import LightProfile
Expand Down Expand Up @@ -47,7 +48,7 @@ def subplot_of_light_profiles(
return

n = len(light_profiles)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i, lp in enumerate(light_profiles):
Expand Down Expand Up @@ -129,7 +130,7 @@ def _deflections_x(mp):
if not flag:
continue

fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = [axes] if n == 1 else list(axes.flatten())

for i, mp in enumerate(mass_profiles):
Expand Down
32 changes: 17 additions & 15 deletions autogalaxy/imaging/plot/fit_imaging_plots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import matplotlib.pyplot as plt

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize

from autogalaxy.imaging.fit_imaging import FitImaging
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
Expand Down Expand Up @@ -39,29 +40,30 @@ def subplot_fit(
(currently unused).
"""
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, "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", r"$\sigma$"),
(fit.chi_squared_map, "Chi-Squared Map", r"$\chi^2$"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (array, title) in enumerate(panels):
for i, (array, title, cb_unit) in enumerate(panels):
plot_array(
array=array,
title=title,
colormap=colormap,
use_log10=use_log10,
positions=positions,
cb_unit=cb_unit,
ax=axes_flat[i],
)

plt.tight_layout()
_save_subplot(fig, output_path, "subplot_fit", output_format)
_save_subplot(fig, output_path, "fit", output_format)


def subplot_of_galaxy(
Expand Down Expand Up @@ -112,7 +114,7 @@ def subplot_of_galaxy(
),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (array, title) in enumerate(panels):
Expand All @@ -125,13 +127,13 @@ def subplot_of_galaxy(
)

plt.tight_layout()
_save_subplot(fig, output_path, f"subplot_of_galaxy_{galaxy_index}", output_format)
_save_subplot(fig, output_path, f"of_galaxy_{galaxy_index}", output_format)


def subplot_fit_imaging_list(
fit_list,
output_path=None,
output_filename: str = "subplot_fit_combined",
output_filename: str = "fit_combined",
output_format="png",
):
"""
Expand All @@ -152,14 +154,14 @@ def subplot_fit_imaging_list(
File format string or list, e.g. ``"png"`` or ``["png"]``.
"""
n = len(fit_list)
fig, axes = plt.subplots(n, 5, figsize=(35, 7 * n))
fig, axes = plt.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", ax=axes[i][3])
plot_array(array=fit.chi_squared_map, title="Chi-Squared Map", ax=axes[i][4])
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])
plt.tight_layout()
_save_subplot(fig, output_path, output_filename, output_format)
2 changes: 1 addition & 1 deletion autogalaxy/interferometer/model/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def should_plot(name):
subplot_interferometer_dirty_images(
dataset,
output_path=self.image_path,
output_filename="subplot_dataset",
output_filename="dataset",
output_format=self.fmt[0] if isinstance(self.fmt, (list, tuple)) else self.fmt,
)

Expand Down
24 changes: 13 additions & 11 deletions autogalaxy/interferometer/plot/fit_interferometer_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import autoarray as aa
from autoarray.plot import plot_visibilities_1d
from autoarray.plot.utils import conf_subplot_figsize

from autogalaxy.interferometer.fit_interferometer import FitInterferometer
from autogalaxy.galaxy.plot import galaxies_plots
Expand Down Expand Up @@ -45,7 +46,7 @@ def subplot_fit(
(fit.chi_squared_map, "Chi-Squared Map"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (vis, title) in enumerate(panels):
Expand Down Expand Up @@ -86,23 +87,24 @@ def subplot_fit_dirty_images(
Reserved for future symmetric-colormap support (currently unused).
"""
panels = [
(fit.dirty_image, "Dirty Image"),
(fit.dirty_signal_to_noise_map, "Dirty Signal-To-Noise Map"),
(fit.dirty_model_image, "Dirty Model Image"),
(fit.dirty_residual_map, "Dirty Residual Map"),
(fit.dirty_normalized_residual_map, "Dirty Normalized Residual Map"),
(fit.dirty_chi_squared_map, "Dirty Chi-Squared Map"),
(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$"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())

for i, (array, title) in enumerate(panels):
for i, (array, title, cb_unit) in enumerate(panels):
plot_array(
array=array,
title=title,
colormap=colormap,
use_log10=use_log10,
cb_unit=cb_unit,
ax=axes_flat[i],
)

Expand Down Expand Up @@ -152,7 +154,7 @@ def subplot_fit_real_space(
output_format=output_format,
colormap=colormap,
use_log10=use_log10,
auto_filename="subplot_fit_real_space",
auto_filename="fit_real_space",
)
else:
panels = [
Expand All @@ -161,7 +163,7 @@ def subplot_fit_real_space(
(fit.dirty_residual_map, "Dirty Residual Map"),
]
n = len(panels)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
fig, axes = plt.subplots(1, n, figsize=conf_subplot_figsize(1, n))
axes_flat = list(axes.flatten())
for i, (array, title) in enumerate(panels):
plot_array(
Expand Down
1 change: 0 additions & 1 deletion autogalaxy/plot/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ def plot_array(
output_path=_output_path,
output_filename=output_filename,
output_format=output_format,
structure=array,
)


Expand Down
3 changes: 2 additions & 1 deletion autogalaxy/profiles/plot/basis_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np

import autoarray as aa
from autoarray.plot.utils import conf_subplot_figsize

from autogalaxy.profiles.basis import Basis
from autogalaxy.plot.plot_utils import _to_positions, plot_array, _save_subplot
Expand Down Expand Up @@ -59,7 +60,7 @@ def subplot_image(
n = len(basis.light_profile_list)
cols = min(n, 4)
rows = (n + cols - 1) // cols
fig, axes = plt.subplots(rows, cols, figsize=(7 * cols, 7 * rows))
fig, axes = plt.subplots(rows, cols, figsize=conf_subplot_figsize(rows, cols))
axes_flat = [axes] if n == 1 else list(np.array(axes).flatten())

_positions = _to_positions(positions)
Expand Down
Loading
Loading