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
6 changes: 5 additions & 1 deletion autoarray/dataset/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from autoarray.dataset.plot.imaging_plots import subplot_imaging_dataset
from autoarray.dataset.plot.imaging_plots import (
subplot_imaging_dataset,
subplot_imaging,
subplot_imaging_dataset_list,
)
from autoarray.dataset.plot.interferometer_plots import (
subplot_interferometer_dataset,
subplot_interferometer_dirty_images,
Expand Down
123 changes: 105 additions & 18 deletions autoarray/dataset/plot/imaging_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def subplot_imaging_dataset(
lines=None,
):
"""
3×3 subplot of all ``Imaging`` dataset components.
3×3 subplot of core ``Imaging`` dataset components.

Panels (row-major):
0. Data
1. Data (log10)
2. Noise-Map
3. PSF (if present)
4. PSF log10 (if present)
4. PSF (log10, if present)
5. Signal-To-Noise Map
6. Over-sample size (light profiles)
7. Over-sample size (pixelization)
6. Over Sample Size (Light Profiles, if present)
7. Over Sample Size (Pixelization, if present)

Parameters
----------
Expand Down Expand Up @@ -107,20 +107,107 @@ def subplot_imaging_dataset(
positions=positions,
lines=lines,
)
plot_array(
dataset.grids.over_sample_size_lp,
ax=axes[6],
title="Over Sample Size (Light Profiles)",
colormap=colormap,
use_log10=use_log10,
)
plot_array(
dataset.grids.over_sample_size_pixelization,
ax=axes[7],
title="Over Sample Size (Pixelization)",
colormap=colormap,
use_log10=use_log10,
)

over_sample_size_lp = getattr(getattr(dataset, "grids", None), "over_sample_size_lp", None)
if over_sample_size_lp is not None:
plot_array(
over_sample_size_lp,
ax=axes[6],
title="Over Sample Size (Light Profiles)",
colormap=colormap,
use_log10=use_log10,
)

over_sample_size_pix = getattr(getattr(dataset, "grids", None), "over_sample_size_pixelization", None)
if over_sample_size_pix is not None:
plot_array(
over_sample_size_pix,
ax=axes[7],
title="Over Sample Size (Pixelization)",
colormap=colormap,
use_log10=use_log10,
)

plt.tight_layout()
subplot_save(fig, output_path, output_filename, output_format)


def subplot_imaging(
dataset,
output_path=None,
output_filename: str = "subplot_dataset",
output_format="png",
):
"""
1×n subplot of core ``Imaging`` dataset components.

Panels: Data | Noise Map | Signal-To-Noise Map | PSF (if present)

Parameters
----------
dataset
An ``Imaging`` dataset instance.
output_path
Directory to save the figure. ``None`` calls ``plt.show()``.
output_filename
Base filename without extension.
output_format
File format string or list, e.g. ``"png"`` or ``["png"]``.
"""
if isinstance(output_format, (list, tuple)):
output_format = output_format[0]

panels = [
(dataset.data, "Data"),
(dataset.noise_map, "Noise Map"),
(dataset.signal_to_noise_map, "Signal-To-Noise Map"),
]
try:
panels.append((dataset.psf.kernel, "PSF"))
except Exception:
pass

n = len(panels)
fig, axes = plt.subplots(1, n, figsize=(7 * n, 7))
axes_flat = list(axes.flatten()) if n > 1 else [axes]
for i, (array, title) in enumerate(panels):
plot_array(array, ax=axes_flat[i], title=title)
plt.tight_layout()
subplot_save(fig, output_path, output_filename, output_format)


def subplot_imaging_dataset_list(
dataset_list,
output_path=None,
output_filename: str = "subplot_dataset_combined",
output_format="png",
):
"""
n×3 subplot showing core components for each dataset in a list.

Each row shows: Data | Noise Map | Signal-To-Noise Map

Parameters
----------
dataset_list
List of ``Imaging`` dataset instances.
output_path
Directory to save the figure. ``None`` calls ``plt.show()``.
output_filename
Base filename without extension.
output_format
File format string or list, e.g. ``"png"`` or ``["png"]``.
"""
if isinstance(output_format, (list, tuple)):
output_format = output_format[0]

n = len(dataset_list)
fig, axes = plt.subplots(n, 3, figsize=(21, 7 * n))
if n == 1:
axes = [axes]
for i, dataset in enumerate(dataset_list):
plot_array(dataset.data, ax=axes[i][0], title="Data")
plot_array(dataset.noise_map, ax=axes[i][1], title="Noise Map")
plot_array(dataset.signal_to_noise_map, ax=axes[i][2], title="Signal-To-Noise Map")
plt.tight_layout()
subplot_save(fig, output_path, output_filename, output_format)
Empty file.
2 changes: 0 additions & 2 deletions test_autoarray/plot/mat_plot/test_mat_plot.py

This file was deleted.

2 changes: 0 additions & 2 deletions test_autoarray/plot/test_multi_plotters.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import autoarray.plot as aplt
from os import path
import shutil
directory = path.dirname(path.realpath(__file__))
def test__constructor():
output = aplt.Output()
assert output.path == None
assert output._format == None
assert output.format == "show"
assert output.filename == None
output = aplt.Output(path="Path", format="png", filename="file")
assert output.path == "Path"
assert output._format == "png"
assert output.format == "png"
assert output.filename == "file"
if path.exists(output.path):
shutil.rmtree(output.path)
def test__input_path_is_created():
test_path = path.join(directory, "files", "output_path")
if path.exists(test_path):
shutil.rmtree(test_path)
assert not path.exists(test_path)
output = aplt.Output(
path=test_path,
format="png",
)
output.to_figure(structure=None, auto_filename="test")
assert path.exists(test_path)
import autoarray.plot as aplt

from os import path

import shutil

directory = path.dirname(path.realpath(__file__))


def test__constructor():
output = aplt.Output()

assert output.path == None
assert output._format == None
assert output.format == "show"
assert output.filename == None

output = aplt.Output(path="Path", format="png", filename="file")

assert output.path == "Path"
assert output._format == "png"
assert output.format == "png"
assert output.filename == "file"

if path.exists(output.path):
shutil.rmtree(output.path)


def test__input_path_is_created():
test_path = path.join(directory, "files", "output_path")

if path.exists(test_path):
shutil.rmtree(test_path)

assert not path.exists(test_path)

output = aplt.Output(
path=test_path,
format="png",
)
output.to_figure(structure=None, auto_filename="test")

assert path.exists(test_path)
Empty file.
2 changes: 0 additions & 2 deletions test_autoarray/plot/visuals/test_visuals.py

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Loading