Skip to content

Commit 6412ca4

Browse files
Jammy2211claude
authored andcommitted
Add subplot_fit_quick for point source quick updates
Single-panel quick-update subplot showing observed positions with model-predicted positions overlaid in red. Minimal progress view for quick updates during sampling. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 0e45d43 commit 6412ca4

2 files changed

Lines changed: 53 additions & 4 deletions

File tree

autolens/point/model/plotter.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
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
89
from autolens.point.dataset import PointDataset
910
from autolens.point.plot.point_dataset_plots import subplot_dataset
1011

@@ -78,7 +79,14 @@ def should_plot(name):
7879
source_plane_lines, source_plane_line_colors,
7980
)
8081

81-
if should_plot("subplot_fit") or quick_update:
82+
if quick_update:
83+
subplot_fit_quick_point(
84+
fit, output_path=output_path, output_format=fmt,
85+
title_prefix=self.title_prefix,
86+
)
87+
return
88+
89+
if should_plot("subplot_fit"):
8290
subplot_fit_point(
8391
fit, output_path=output_path, output_format=fmt,
8492
image_plane_lines=ip_lines,
@@ -87,6 +95,3 @@ def should_plot(name):
8795
source_plane_line_colors=sp_colors,
8896
title_prefix=self.title_prefix,
8997
)
90-
91-
if quick_update:
92-
return

autolens/point/plot/fit_point_plots.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,47 @@ def subplot_fit(
8484

8585
tight_layout()
8686
save_figure(fig, path=output_path, filename="fit", format=output_format)
87+
88+
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)

0 commit comments

Comments
 (0)