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
8 changes: 4 additions & 4 deletions autogalaxy/ellipse/plot/fit_ellipse_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _plot_data(
fit_list: List[FitEllipse],
output_path=None,
output_filename="ellipse_fit",
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
disable_data_contours: bool = False,
Expand Down Expand Up @@ -80,7 +80,7 @@ def _plot_data(
def _plot_ellipse_residuals(
fit_list: List[FitEllipse],
output_path=None,
output_format="png",
output_format=None,
for_subplot: bool = False,
suffix: str = "",
ax=None,
Expand Down Expand Up @@ -122,7 +122,7 @@ def _plot_ellipse_residuals(
def subplot_fit_ellipse(
fit_list: List[FitEllipse],
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
disable_data_contours: bool = False,
Expand Down Expand Up @@ -166,7 +166,7 @@ def subplot_fit_ellipse(
def subplot_ellipse_errors(
fit_pdf_list: List[List[FitEllipse]],
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
sigma: Optional[float] = 3.0,
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/galaxy/plot/adapt_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def subplot_adapt_images(
adapt_galaxy_name_image_dict: Dict[Galaxy, aa.Array2D],
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
):
Expand Down
4 changes: 2 additions & 2 deletions autogalaxy/galaxy/plot/galaxies_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def subplot_galaxies(
galaxies,
grid: aa.type.Grid1D2DLike,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
positions=None,
Expand Down Expand Up @@ -164,7 +164,7 @@ def subplot_galaxy_images(
galaxies,
grid: aa.type.Grid1D2DLike,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
tangential_critical_curves=None,
Expand Down
4 changes: 2 additions & 2 deletions autogalaxy/galaxy/plot/galaxy_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def subplot_of_light_profiles(
galaxy: Galaxy,
grid: aa.type.Grid1D2DLike,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
positions=None,
Expand Down Expand Up @@ -72,7 +72,7 @@ def subplot_of_mass_profiles(
deflections_y: bool = False,
deflections_x: bool = False,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
):
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/imaging/plot/fit_imaging_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def subplot_fit(
fit: FitImaging,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
positions=None,
Expand Down Expand Up @@ -72,7 +72,7 @@ def subplot_of_galaxy(
fit: FitImaging,
galaxy_index: int,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
positions=None,
Expand Down Expand Up @@ -136,7 +136,7 @@ def subplot_fit_imaging_list(
fit_list,
output_path=None,
output_filename: str = "fit_combined",
output_format="png",
output_format=None,
):
"""
n×5 subplot summarising a list of ``FitImaging`` objects.
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/interferometer/plot/fit_interferometer_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def subplot_fit(
fit: FitInterferometer,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
residuals_symmetric_cmap: bool = True,
Expand Down Expand Up @@ -61,7 +61,7 @@ def subplot_fit(
def subplot_fit_dirty_images(
fit: FitInterferometer,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
residuals_symmetric_cmap: bool = True,
Expand Down Expand Up @@ -117,7 +117,7 @@ def subplot_fit_dirty_images(
def subplot_fit_real_space(
fit: FitInterferometer,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
):
Expand Down
22 changes: 12 additions & 10 deletions autogalaxy/plot/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,24 @@ def _to_positions(*items):
return _to_lines(*items)


def _save_subplot(fig, output_path, output_filename, output_format="png",
def _save_subplot(fig, output_path, output_filename, output_format=None,
dpi=300):
"""Save a subplot figure to disk (or show it if output_path is falsy).
"""Save a subplot figure to disk (or show it if output_format/output_path say so).

For FITS output use the dedicated ``fits_*`` functions instead.
"""
from autoarray.plot.utils import _output_mode_save
from autoarray.plot.utils import _output_mode_save, _conf_output_format

if _output_mode_save(fig, output_filename):
return

fmt = output_format[0] if isinstance(output_format, (list, tuple)) else (output_format or "png")
if output_path:
fmt = output_format[0] if isinstance(output_format, (list, tuple)) else (output_format or _conf_output_format())
if fmt == "show" or not output_path:
plt.show()
else:
os.makedirs(str(output_path), exist_ok=True)
fpath = os.path.join(str(output_path), f"{output_filename}.{fmt}")
fig.savefig(fpath, dpi=dpi, bbox_inches="tight", pad_inches=0.1)
else:
plt.show()
plt.close(fig)


Expand All @@ -99,9 +99,11 @@ def _resolve_colormap(colormap):

def _resolve_format(output_format):
"""Normalise output_format: accept a list/tuple or a plain string."""
from autoarray.plot.utils import _conf_output_format

if isinstance(output_format, (list, tuple)):
return output_format[0]
return output_format or "png"
return output_format or _conf_output_format()


def _numpy_grid(grid):
Expand All @@ -119,7 +121,7 @@ def plot_array(
title="",
output_path=None,
output_filename="array",
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
vmin=None,
Expand Down Expand Up @@ -276,7 +278,7 @@ def plot_grid(
title="",
output_path=None,
output_filename="grid",
output_format="png",
output_format=None,
lines=None,
ax=None,
):
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/profiles/plot/basis_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def subplot_image(
basis: Basis,
grid: aa.type.Grid1D2DLike,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
positions=None,
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/quantity/plot/fit_quantity_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, pos
def subplot_fit(
fit: FitQuantity,
output_path=None,
output_format="png",
output_format=None,
colormap="default",
use_log10=False,
positions=None,
Expand Down
Loading