Skip to content

Commit 8064fe1

Browse files
authored
Merge pull request #682 from PyAutoLabs/feature/remove-fit-quick-plots
feat: remove fit_quick.png — quick updates write the normal fit subplot
2 parents 54d3178 + 368f928 commit 8064fe1

13 files changed

Lines changed: 114 additions & 256 deletions

File tree

autolens/imaging/model/plotter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from autolens.imaging.fit_imaging import FitImaging
1414
from autolens.imaging.plot.fit_imaging_plots import (
1515
subplot_fit,
16-
subplot_fit_quick,
1716
subplot_fit_log10,
1817
subplot_of_planes,
1918
subplot_tracer_from_fit,
@@ -76,8 +75,11 @@ def should_plot(name):
7675
source_plane_lines, source_plane_line_colors,
7776
)
7877

78+
# Quick updates write the normal fit subplot (plain `fit.png`, final
79+
# plane as source) regardless of plane count, so the live display
80+
# always has one canonical filename to refresh.
7981
if quick_update:
80-
subplot_fit_quick(
82+
subplot_fit(
8183
fit, output_path=output_path, output_format=fmt,
8284
image_plane_lines=ip_lines, image_plane_line_colors=ip_colors,
8385
source_plane_lines=sp_lines, source_plane_line_colors=sp_colors,

autolens/imaging/plot/fit_imaging_plots.py

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -312,94 +312,6 @@ def subplot_fit(
312312
save_figure(fig, path=output_path, filename=f"fit{plane_index_tag}", format=output_format)
313313

314314

315-
def subplot_fit_quick(
316-
fit,
317-
output_path: Optional[str] = None,
318-
output_format: str = None,
319-
colormap: Optional[str] = None,
320-
image_plane_lines=None,
321-
image_plane_line_colors=None,
322-
source_plane_lines=None,
323-
source_plane_line_colors=None,
324-
title_prefix: str = None,
325-
):
326-
"""
327-
Produce a 6-panel quick-update subplot summarising an imaging fit.
328-
329-
Arranges the following panels in a 2 × 3 grid:
330-
331-
* Data
332-
* Model image
333-
* Normalised residual map (symmetric scale)
334-
* Lens-light-subtracted image
335-
* Source model image
336-
* Source plane image
337-
338-
Uses the standard ``plot_array`` / ``_plot_source_plane`` for
339-
consistent styling with arcsecond axes. Fit properties are now
340-
``@cached_property`` so repeated access is cheap.
341-
342-
For single-plane tracers the function delegates to
343-
:func:`subplot_fit_x1_plane`.
344-
"""
345-
if len(fit.tracer.planes) == 1:
346-
return subplot_fit_x1_plane(
347-
fit, output_path=output_path,
348-
output_format=output_format, colormap=colormap,
349-
title_prefix=title_prefix,
350-
)
351-
352-
final_plane_index = len(fit.tracer.planes) - 1
353-
source_vmax = _get_source_vmax(fit)
354-
355-
_pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t)
356-
fig, axes = subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
357-
axes_flat = list(axes.flatten())
358-
359-
# Top row: Data, Model Image, Normalized Residual Map
360-
plot_array(array=fit.data, ax=axes_flat[0],
361-
title=_pf("Data"), colormap=colormap)
362-
363-
plot_array(array=fit.model_data, ax=axes_flat[1],
364-
title=_pf("Model Image"), colormap=colormap)
365-
366-
plot_array(array=fit.normalized_residual_map, ax=axes_flat[2],
367-
title=_pf("Normalized Residual"), colormap=colormap,
368-
symmetric=True)
369-
370-
# Bottom row: Lens Light Subtracted, Source Model Image, Source Plane
371-
try:
372-
subtracted = fit.subtracted_images_of_planes_list[final_plane_index]
373-
except (IndexError, AttributeError):
374-
subtracted = None
375-
if subtracted is not None:
376-
plot_array(array=subtracted, ax=axes_flat[3],
377-
title=_pf("Lens Light Subtracted"), colormap=colormap,
378-
vmin=0.0 if source_vmax else None, vmax=source_vmax)
379-
else:
380-
axes_flat[3].axis("off")
381-
382-
try:
383-
source_model = fit.model_images_of_planes_list[final_plane_index]
384-
except (IndexError, AttributeError):
385-
source_model = None
386-
if source_model is not None:
387-
plot_array(array=source_model, ax=axes_flat[4],
388-
title=_pf("Source Model Image"), colormap=colormap,
389-
vmax=source_vmax)
390-
else:
391-
axes_flat[4].axis("off")
392-
393-
_plot_source_plane(
394-
fit, axes_flat[5], final_plane_index, zoom_to_brightest=False,
395-
colormap=colormap, title=_pf("Source Plane"), vmax=source_vmax,
396-
)
397-
398-
hide_unused_axes(axes_flat)
399-
tight_layout()
400-
save_figure(fig, path=output_path, filename="fit_quick", format=output_format, dpi=100)
401-
402-
403315
def subplot_fit_x1_plane(
404316
fit,
405317
output_path: Optional[str] = None,
@@ -945,28 +857,6 @@ def subplot_fit_combined(
945857
save_figure(fig, path=output_path, filename="fit_combined", format=output_format)
946858

947859

948-
def subplot_fit_combined_quick(
949-
fit_list: List,
950-
output_path: Optional[str] = None,
951-
output_format: str = None,
952-
colormap: Optional[str] = None,
953-
title_prefix: str = None,
954-
):
955-
"""
956-
Placeholder quick-update subplot for combined multi-dataset imaging fits.
957-
958-
Currently delegates to :func:`subplot_fit_combined` but writes
959-
``fit_quick.png`` so the live display picks it up.
960-
"""
961-
subplot_fit_combined(
962-
fit_list,
963-
output_path=output_path,
964-
output_format=output_format,
965-
colormap=colormap,
966-
title_prefix=title_prefix,
967-
)
968-
969-
970860
def subplot_fit_combined_log10(
971861
fit_list: List,
972862
output_path: Optional[str] = None,

autolens/interferometer/model/plotter.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from autolens.interferometer.fit_interferometer import FitInterferometer
1313
from autolens.interferometer.plot.fit_interferometer_plots import (
1414
subplot_fit,
15-
subplot_fit_quick,
1615
subplot_fit_dirty_images,
1716
subplot_fit_interferometer_combined,
1817
subplot_fit_real_space,
@@ -70,14 +69,17 @@ def should_plot(name):
7069
source_plane_lines, source_plane_line_colors,
7170
)
7271

73-
if should_plot("subplot_fit"):
72+
if should_plot("subplot_fit") or quick_update:
7473
subplot_fit(
7574
fit, output_path=output_path, output_format=fmt,
7675
image_plane_lines=ip_lines, image_plane_line_colors=ip_colors,
7776
source_plane_lines=sp_lines, source_plane_line_colors=sp_colors,
7877
title_prefix=self.title_prefix,
7978
)
8079

80+
if quick_update:
81+
return
82+
8183
if plot_setting(section="tracer", name="subplot_tracer"):
8284
subplot_tracer_from_fit(
8385
fit, output_path=output_path, output_format=fmt,
@@ -86,13 +88,6 @@ def should_plot(name):
8688
title_prefix=self.title_prefix,
8789
)
8890

89-
if quick_update:
90-
subplot_fit_quick(
91-
fit, output_path=output_path, output_format=fmt,
92-
title_prefix=self.title_prefix,
93-
)
94-
return
95-
9691
if should_plot("subplot_fit_dirty_images"):
9792
subplot_fit_dirty_images(
9893
fit, output_path=output_path, output_format=fmt,

autolens/interferometer/plot/fit_interferometer_plots.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -307,73 +307,6 @@ def subplot_fit_dirty_images(
307307
save_figure(fig, path=output_path, filename="fit_dirty_images", format=output_format)
308308

309309

310-
def subplot_fit_quick(
311-
fit,
312-
output_path: Optional[str] = None,
313-
output_format: str = None,
314-
colormap: Optional[str] = None,
315-
title_prefix: str = None,
316-
):
317-
"""
318-
Produce a 6-panel quick-update subplot for an interferometer fit.
319-
320-
Arranges the following panels in a 2 × 3 grid:
321-
322-
* Dirty Image (data)
323-
* Dirty Model Image
324-
* Dirty Normalised Residual Map
325-
* Visibility Normalised Residual (Real) vs UV distance
326-
* Visibility Normalised Residual (Imag) vs UV distance
327-
* Source plane image / reconstruction
328-
329-
Uses the standard ``plot_array`` / ``plot_yx`` / ``_plot_source_plane``
330-
for consistent styling. Dirty images are passed directly as autoarray
331-
``Array2D`` objects so axes show arcsecond coordinates.
332-
"""
333-
_pf = (lambda t: f"{title_prefix.rstrip()} {t}") if title_prefix else (lambda t: t)
334-
fig, axes = subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
335-
axes_flat = list(axes.flatten())
336-
337-
# Top row: Dirty Image, Dirty Model Image, Dirty Normalized Residual
338-
plot_array(array=fit.dirty_image, ax=axes_flat[0],
339-
title=_pf("Dirty Image"), colormap=colormap)
340-
341-
plot_array(array=fit.dirty_model_image, ax=axes_flat[1],
342-
title=_pf("Dirty Model Image"), colormap=colormap)
343-
344-
plot_array(array=fit.dirty_normalized_residual_map, ax=axes_flat[2],
345-
title=_pf("Dirty Norm Residual"), colormap=colormap,
346-
symmetric=True)
347-
348-
# Bottom row: Visibility residuals (Real/Imag scatter) + Source Plane
349-
norm_resid_vis = np.asarray(fit.normalized_residual_map)
350-
uv_dist = np.asarray(fit.dataset.uv_distances) / 1e3
351-
352-
plot_yx(
353-
y=np.real(norm_resid_vis), x=uv_dist, ax=axes_flat[3],
354-
title=_pf("Vis Norm Resid (Real)"),
355-
xtick_suffix='"', ytick_suffix=r"$\sigma$",
356-
plot_axis_type="scatter",
357-
)
358-
359-
plot_yx(
360-
y=np.imag(norm_resid_vis), x=uv_dist, ax=axes_flat[4],
361-
title=_pf("Vis Norm Resid (Imag)"),
362-
xtick_suffix='"', ytick_suffix=r"$\sigma$",
363-
plot_axis_type="scatter",
364-
)
365-
366-
# Source plane: reuse _plot_source_plane (handles both parametric and pixelized)
367-
final_plane_index = len(fit.tracer.planes) - 1
368-
_plot_source_plane(
369-
fit, axes_flat[5], final_plane_index, zoom_to_brightest=False,
370-
colormap=colormap, title=_pf("Source Plane"),
371-
)
372-
373-
tight_layout()
374-
save_figure(fig, path=output_path, filename="fit_quick", format=output_format, dpi=100)
375-
376-
377310
def subplot_fit_interferometer_combined(
378311
fit_list,
379312
output_path: Optional[str] = None,

autolens/point/model/plotter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from autolens.point.fit.dataset import FitPointDataset
77
from autolens.point.plot.fit_point_plots import subplot_fit as subplot_fit_point
8-
from autolens.point.plot.fit_point_plots import subplot_fit_quick as subplot_fit_quick_point
98
from autolens.point.dataset import PointDataset
109
from autolens.point.plot.point_dataset_plots import subplot_dataset
1110

@@ -80,8 +79,12 @@ def should_plot(name):
8079
)
8180

8281
if quick_update:
83-
subplot_fit_quick_point(
82+
subplot_fit_point(
8483
fit, output_path=output_path, output_format=fmt,
84+
image_plane_lines=ip_lines,
85+
image_plane_line_colors=ip_colors,
86+
source_plane_lines=sp_lines,
87+
source_plane_line_colors=sp_colors,
8588
title_prefix=self.title_prefix,
8689
)
8790
return

autolens/point/plot/fit_point_plots.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -86,45 +86,3 @@ def subplot_fit(
8686
save_figure(fig, path=output_path, filename="fit", format=output_format)
8787

8888

89-
def subplot_fit_quick(
90-
fit,
91-
output_path: Optional[str] = None,
92-
output_format: str = None,
93-
title_prefix: str = None,
94-
):
95-
"""
96-
Produce a single-panel quick-update subplot for a `FitPointDataset`.
97-
98-
Shows the observed positions with the model-predicted positions
99-
overlaid in red. A minimal progress view for quick updates during
100-
sampling — will be expanded in future.
101-
"""
102-
from autogalaxy.util.plot_utils import plot_grid
103-
104-
obs_grid = np.array(
105-
fit.dataset.positions.array
106-
if hasattr(fit.dataset.positions, "array")
107-
else fit.dataset.positions
108-
)
109-
model_grid = np.array(
110-
fit.positions.model_data.array
111-
if hasattr(fit.positions.model_data, "array")
112-
else fit.positions.model_data
113-
)
114-
115-
_prefix = f"{title_prefix.rstrip()} " if title_prefix else ""
116-
fig, ax = subplots(1, 1, figsize=conf_subplot_figsize(1, 1))
117-
118-
plot_grid(
119-
grid=obs_grid,
120-
ax=ax,
121-
title=f"{_prefix}{fit.dataset.name} Positions",
122-
output_path=None,
123-
output_filename=None,
124-
output_format=output_format,
125-
)
126-
ax.scatter(model_grid[:, 1], model_grid[:, 0], c="r", s=20, zorder=5, label="Model")
127-
ax.legend(fontsize=7, loc="upper right")
128-
129-
tight_layout()
130-
save_figure(fig, path=output_path, filename="fit_quick", format=output_format, dpi=100)

autolens/weak/model/plotter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from autolens.weak.fit import FitWeak
66
from autolens.weak.plot.weak_dataset_plots import subplot_weak_dataset
77
from autolens.weak.plot.fit_weak_plots import subplot_fit_weak
8-
from autolens.weak.plot.fit_weak_plots import subplot_fit_quick as subplot_fit_quick_weak
98

109

1110
class PlotterWeak(Plotter):
@@ -42,7 +41,7 @@ def fit_weak(self, fit: FitWeak, quick_update: bool = False):
4241
fit
4342
The maximum log likelihood `FitWeak` of the non-linear search.
4443
quick_update
45-
If `True`, a lighter-weight quick-update subplot is output instead of the full fit subplot.
44+
If `True`, the fit subplot is always output and all other outputs are skipped.
4645
"""
4746

4847
def should_plot(name):
@@ -52,7 +51,7 @@ def should_plot(name):
5251
fmt = self.fmt
5352

5453
if quick_update:
55-
subplot_fit_quick_weak(
54+
subplot_fit_weak(
5655
fit,
5756
output_path=output_path,
5857
output_format=fmt,

autolens/weak/plot/fit_weak_plots.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -160,27 +160,6 @@ def plot_chi_squared_map(
160160
)
161161

162162

163-
def subplot_fit_quick(
164-
fit,
165-
output_path: Optional[str] = None,
166-
output_format: Optional[str] = None,
167-
title_prefix: Optional[str] = None,
168-
):
169-
"""
170-
Placeholder quick-update subplot for a ``FitWeak``.
171-
172-
Currently delegates to the full ``subplot_fit_weak``. Will be
173-
replaced with a lighter-weight render in future.
174-
"""
175-
subplot_fit_weak(
176-
fit,
177-
output_path=output_path,
178-
output_filename="fit_quick",
179-
output_format=output_format,
180-
title_prefix=title_prefix,
181-
)
182-
183-
184163
def subplot_fit_weak(
185164
fit,
186165
output_path: Optional[str] = None,

0 commit comments

Comments
 (0)