Skip to content

Commit b491a11

Browse files
committed
Remove all Plotter classes; replace with standalone matplotlib functions
All Plotter classes (AbstractPlotter, Array2DPlotter, Grid2DPlotter, YX1DPlotter, ImagingPlotter, InterferometerPlotter, FitImagingPlotter, FitInterferometerPlotter, MapperPlotter, InversionPlotter and their Meta variants) are deleted. The new API is function-based and closer to raw matplotlib: - plot_array_2d / plot_grid_2d / plot_yx_1d — structure-level wrappers that handle autoarray → numpy extraction before calling plot_array / plot_grid / plot_yx. - subplot_imaging_dataset / subplot_interferometer_dataset / subplot_interferometer_dirty_images — standalone subplot functions. - subplot_fit_imaging / subplot_fit_interferometer / subplot_fit_interferometer_dirty_images — standalone fit subplots. - plot_mapper / plot_mapper_image / subplot_image_and_mapper — mapper plots. - subplot_of_mapper / subplot_mappings — inversion subplots. Helper utilities (auto_mask_edge, zoom_array, numpy_grid, numpy_lines, numpy_positions, subplot_save) are now public functions in autoarray/plot/plots/utils.py and exported via autoarray.plot. All 746 tests pass. https://claude.ai/code/session_01B9sVEV54XWCa2LJw1C8gvv
1 parent e5f769d commit b491a11

31 files changed

Lines changed: 1767 additions & 2330 deletions

autoarray/dataset/plot/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from autoarray.dataset.plot.imaging_plots import subplot_imaging_dataset
2+
from autoarray.dataset.plot.interferometer_plots import (
3+
subplot_interferometer_dataset,
4+
subplot_interferometer_dirty_images,
5+
)
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import numpy as np
2+
from typing import Optional
3+
4+
import matplotlib.pyplot as plt
5+
6+
from autoarray.plot.plots.array import plot_array
7+
from autoarray.plot.plots.utils import (
8+
auto_mask_edge,
9+
zoom_array,
10+
numpy_grid,
11+
numpy_lines,
12+
numpy_positions,
13+
subplot_save,
14+
)
15+
16+
17+
def _plot_dataset_array(
18+
array,
19+
ax,
20+
title,
21+
colormap,
22+
use_log10,
23+
grid=None,
24+
positions=None,
25+
lines=None,
26+
):
27+
"""Internal helper: plot one array component onto *ax*."""
28+
if array is None:
29+
return
30+
31+
array = zoom_array(array)
32+
33+
try:
34+
arr = array.native.array
35+
extent = array.geometry.extent
36+
except AttributeError:
37+
arr = np.asarray(array)
38+
extent = None
39+
40+
plot_array(
41+
array=arr,
42+
ax=ax,
43+
extent=extent,
44+
mask=auto_mask_edge(array) if hasattr(array, "mask") else None,
45+
grid=numpy_grid(grid),
46+
positions=numpy_positions(positions),
47+
lines=numpy_lines(lines),
48+
title=title,
49+
colormap=colormap,
50+
use_log10=use_log10,
51+
)
52+
53+
54+
def subplot_imaging_dataset(
55+
dataset,
56+
output_path: Optional[str] = None,
57+
output_filename: str = "subplot_dataset",
58+
output_format: str = "png",
59+
colormap=None,
60+
use_log10: bool = False,
61+
grid=None,
62+
positions=None,
63+
lines=None,
64+
):
65+
"""
66+
3×3 subplot of all ``Imaging`` dataset components.
67+
68+
Panels (row-major):
69+
0. Data
70+
1. Data (log10)
71+
2. Noise-Map
72+
3. PSF (if present)
73+
4. PSF log10 (if present)
74+
5. Signal-To-Noise Map
75+
6. Over-sample size (light profiles)
76+
7. Over-sample size (pixelization)
77+
78+
Parameters
79+
----------
80+
dataset
81+
An ``Imaging`` dataset instance.
82+
output_path
83+
Directory to save the figure. ``None`` calls ``plt.show()``.
84+
output_filename
85+
Base filename without extension.
86+
output_format
87+
File format, e.g. ``"png"``.
88+
colormap
89+
Matplotlib colormap name. ``None`` uses the package default.
90+
use_log10
91+
Apply log10 normalisation to non-log panels.
92+
grid, positions, lines
93+
Optional overlays forwarded to every panel.
94+
"""
95+
fig, axes = plt.subplots(3, 3, figsize=(21, 21))
96+
axes = axes.flatten()
97+
98+
_plot_dataset_array(dataset.data, axes[0], "Data", colormap, use_log10, grid, positions, lines)
99+
_plot_dataset_array(dataset.data, axes[1], "Data (log10)", colormap, True, grid, positions, lines)
100+
_plot_dataset_array(dataset.noise_map, axes[2], "Noise-Map", colormap, use_log10, grid, positions, lines)
101+
102+
if dataset.psf is not None:
103+
_plot_dataset_array(dataset.psf.kernel, axes[3], "Point Spread Function", colormap, use_log10)
104+
_plot_dataset_array(dataset.psf.kernel, axes[4], "PSF (log10)", colormap, True)
105+
106+
_plot_dataset_array(dataset.signal_to_noise_map, axes[5], "Signal-To-Noise Map", colormap, use_log10, grid, positions, lines)
107+
_plot_dataset_array(dataset.grids.over_sample_size_lp, axes[6], "Over Sample Size (Light Profiles)", colormap, use_log10)
108+
_plot_dataset_array(dataset.grids.over_sample_size_pixelization, axes[7], "Over Sample Size (Pixelization)", colormap, use_log10)
109+
110+
plt.tight_layout()
111+
subplot_save(fig, output_path, output_filename, output_format)

autoarray/dataset/plot/imaging_plotters.py

Lines changed: 0 additions & 200 deletions
This file was deleted.

0 commit comments

Comments
 (0)