Repository navigation
Description
Overview
Delaunay/KNN source reconstructions are plotted as flat-shaded triangles (tripcolor, one colour per triangle). That shows where the mesh spends resolution, but it is not the piecewise-linear (barycentric) interpolant the likelihood evaluates between vertices — reported on PyAutoLabs/.github#46 with a minimal example (true Sersic at the vertices of a Hilbert-Delaunay mesh). This task keeps the triangles as the default, adds an interpolated view built from the mapper's own interpolator, always shows it in inversion_#.png, and adds an off-by-default config switch to show it in the lens fit.png.
Plan
- Keep flat-shaded triangles as the default source plot; reword the
_plot_delaunaydocstring to say plainly they show mesh resolution, not the between-vertex interpolant. - Add an interpolated view: a fresh interpolator of the mapper's own type (same
mesh,mesh_grid),data_grid= a uniform plot grid over the panel extent (~400x400 default, configurable), evaluated and drawn withimshow— exactly the interpolant the likelihood uses. KNN and DelaunayNN mappers use their own interpolants; log colour scales supported; rectangular meshes skip cleanly. inversion_#.png: panel 11 "Source Reconstruction (Interpolated)" always appears for Delaunay/KNN/NN meshes.fit.png(PyAutoLens only — autogalaxy's fit.png has no source panel): newfit: subplot_fit_source_interpolated: falseswitch; when on, imaging panel 7 (mid zoom) and interferometer panel 7 (zoomed) are drawn as "Source Plane (Interpolated)". Layout unchanged.- Config pattern as in the Oct 2026 point-figure work: key +
# ...?comment in libraryplots.yaml(PyAutoLens, PyAutoArrayfit:section), read viashould_plot(name)in the imaging and interferometer fit plotters, then mirrored into autolens_workspace, autolens_workspace_test, HowToLens, autolens_assistant, autolens_visualization (libraries first). - Tier: judge — effective level: supervised; merge mode: human /prm.
Detailed implementation plan
Affected Repositories
- PyAutoArray (primary)
- PyAutoLens
- Workspace mirrors (config only, after library PRs): autolens_workspace, autolens_workspace_test, HowToLens, autolens_assistant, autolens_visualization
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| PyAutoArray | main | clean (fresh cloud clone) |
| PyAutoLens | main | clean (fresh cloud clone) |
Shared claims (human-approved, no file overlap): PyAutoArray with galaxy-duplicate-pytree-registration (autoarray/abstract_ndarray.py only); autolens_workspace with cluster-regime-narrative (scripts/cluster/ only).
Suggested branch: feature/delaunay-interpolated-plot
Implementation Steps
autoarray/plot/inversion.pyinterpolated_values_from(mapper, pixel_values, extent, shape_native): buildtype(mapper.interpolator)(mesh=..., mesh_grid=..., data_grid=Grid2D.from_extent(extent, shape_native), adapt_data=...)with numpy; evaluatesum(weights * recon[mappings])from the sparse mappings/weights in chunks (no dense mapping matrix, so large meshes and grids stay cheap); pixels outside the mesh convex hull → NaN (transparent) so nearest-vertex extrapolation is not drawn as source.plot_inversion_interpolated(...):imshowwith the same extent / norm (norm_from, log10) / colorbar conventions as the triangle panel; returns without drawing for rectangular interpolators.- Reword the
_plot_delaunaydocstring.
autoarray/inversion/plot/inversion_plots.pysubplot_of_mapper: panel 11 = interpolated reconstruction, titled "Source Reconstruction (Interpolated)"; grid size from visualize config (default 400).autoarray/inversion/plot/mapper_plots.py:plot_mapper(..., interpolated=False)passthrough so downstream callers can request it.autoarray/config/visualize/plots.yaml:fit: subplot_fit_source_interpolated: false # In fit.png, draw the mid-zoom source panel as the interpolated reconstruction the likelihood uses (Delaunay/KNN meshes), instead of flat triangles?- PyAutoLens
autolens/imaging/plot/fit_imaging_plots.pyandautolens/interferometer/plot/fit_interferometer_plots.py:_plot_source_plane(..., interpolated=False);subplot_fit(..., source_interpolated=False)redraws panel 7. - PyAutoLens
autolens/imaging/model/plotter.py,autolens/interferometer/model/plotter.py: passshould_plot("subplot_fit_source_interpolated"); add the key toautolens/config/visualize/plots.yaml. - Workspace mirrors of the key/comment/default (after library PRs merge).
Witness / testing
- Unit tests: interpolated values equal the fresh interpolator's
mapping_matrix @ reconstructionon a small plot grid (Delaunay, KNN, NN); log-scale case; rectangular skip; panel 11 title present; lenssubplot_fitswitch changes panel 7. - Reporter's minimal example (true Sersic at Hilbert-Delaunay vertices): interpolated panel matches the analytic interpolant.
- Laptop follow-ups (cannot run in the cloud session that opened this — no LFS datasets / gallery harness / worktrees): workspace smoke for the affected workspaces; re-render the Delaunay figures in autolens_visualization / autogalaxy_visualization.
Key Files
autoarray/plot/inversion.py— interpolated view + docstringautoarray/inversion/plot/inversion_plots.py—inversion_#.pngpanel 11autolens/imaging/plot/fit_imaging_plots.py,autolens/interferometer/plot/fit_interferometer_plots.py— fit.png panel 7autolens/imaging/model/plotter.py,autolens/interferometer/model/plotter.py— config readconfig/visualize/plots.yaml(libraries + workspaces)
Original Prompt
Click to expand starting prompt
Delaunay source plots: show the piecewise-linear interpolant the likelihood uses
Type: feature
Target: autoarray
Repos:
- PyAutoArray
Difficulty: small
Autonomy: supervised
Priority: medium
Consequence: judge
Community: Autolens.plot: Inaccurate Delaunay mesh plots? .github#46
Filed: 2026-11-17
From @Lasloruhberg on hub #46 (Bugs & Errors, 2026-11-13, with a minimal script and figure).
What
autoarray/plot/inversion.py _plot_delaunay draws Delaunay/KNN reconstructions with
ax.tripcolor default flat shading: one colour per triangle (mean of its vertices). Its
docstring now justifies this (the area integral per triangle equals the linear interpolant's),
but the figure is blocky and is not the reconstruction the likelihood uses between vertices.
The reporter's example: a perfect source (true Sersic at the mesh vertices) is visibly
misrepresented by the plot.
Design decided by the human on 2026-11-17 (and promised to the reporter on #46,
PyAutoLabs/.github#46 (comment)):
- Keep flat-shaded triangles as the default source plot. They show how much resolution the
mesh spends where: small triangles mean fine structure is being resolved, which an
interpolated image hides. Fix the docstring/tutorial wording so it says this plainly. - Add the interpolated view (reporter's method: evaluate the mapper's own interpolator on a
uniform plotting grid over the source extent, via a fresh interpolator of the same type,
meshandmesh_grid, withdata_grid= the plot grid, thenimshow), so the figure is
exactly the barycentric interpolant the likelihood uses. inversion_#.png: the interpolated reconstruction always appears as an extra panel.fit.png: a visualization-config switch, off by default, to show the interpolated
panel as well.- Mind cost for big meshes (default grid ~400x400, configurable), KNN mappers (their own
interpolant) and log colour scales.
Witness
The reporter's minimal example (true Sersic on a Hilbert-Delaunay mesh) shows the plot matching
the interpolant, and the autolens_visualization / autogalaxy_visualization Delaunay figures are
re-rendered and look right.
Activity
Jammy2211 commentedon Nov 17, 2026
Library PRs created
interpolated=onplot_inversion_reconstruction/plot_mapper),inversion_#.pngpanel 11 "Source Reconstruction (Interpolated)", reworded_plot_delaunaydocstring, and the config keys.fit.pngswitchfit: subplot_fit_source_interpolated(default false), which redraws imaging panel 7 (mid zoom) and interferometer panel 7 (zoomed) as "Source Plane (Interpolated)". Merge after feat: interpolated view of Delaunay/kNN source reconstructions #701.API changes: added only (new kwargs, helpers and config keys). Nothing is removed or renamed.
Evidence (cloud session):
mapping_matrix @ reconto 1.8e-15.Next:
/start_workspace, to mirrorsubplot_fit_source_interpolatedinto autolens_workspace, autolens_workspace_test, HowToLens, autolens_assistant and autolens_visualization. These are config-only changes and merge after the library PRs.Laptop follow-ups, not yet run (the cloud session has no LFS datasets or gallery harness):
Merge mode: human
/prm(judge tier).Generated by Claude Code
Jammy2211 commentedon Nov 17, 2026
Workspace PRs open (merge after the library PRs)
Each one mirrors
fit: subplot_fit_source_interpolated: false(same comment and default) intoconfig/visualize/plots.yaml:fit.pngin the gallery, which is left for the human to decide.The autogalaxy workspaces were not mirrored: the switch is lens-only, because autogalaxy's
fit.pnghas no source panel.Merge order (human
/prm): PyAutoArray#701, then PyAutoLens#864, then the five workspace PRs.Laptop follow-ups before close-out:
inversion_#.pngpanel 11), and check them.Generated by Claude Code
Jammy2211 commentedon Nov 17, 2026
Design change (human, 2026-11-17): interpolated panel is on by default
fit: subplot_fit_source_interpolatednow defaults to true.Imaging
fit.pngwith a Delaunay/kNN source. The right-hand column, top to bottom, is:The mid-zoom panel is gone in this layout. Setting the key to
false, or using a rectangular or parametric source, restores max / mid / no zoom.Interferometer
fit.pnghas only two source panels:false: zoomed and no zoom;Changes and tests:
truein feat: interpolated view of Delaunay/kNN source reconstructions #701 and in the 5 workspace PRs.fit.pngfrom a Delaunay test fit and checked the layout.Generated by Claude Code
feat: inversion source column = max zoom / interpolated / no zoom (#700)
Jammy2211 commentedon Nov 18, 2026
Laptop follow-ups: smoke tests, re-renders and the agreed layout changes
The cloud session couldn't run the smoke tests or the figure re-renders. I ran both on the laptop. Reviewing the figures led to some layout changes, which are now pushed to the same branches.
Decision (human, 2026-11-18):
fit: subplot_fit_source_interpolateddefaults to true (interpolated view on). The human has also approved the re-rendered figures (2026-11-18).Changes pushed after review
e8a174a6inversion_#.png: right column is Source Plane (Max Zoom) / Source Plane (Interpolated) / Source Plane (No Zoom), matchingfit.png. The interpolated panel is now square with a full-height colorbar;imshow(aspect="auto")had been resetting the box aspect. Title changed from "Source Reconstruction (Interpolated)" to "Source Plane (Interpolated)". Rectangular inversions are unchanged.1e212b43bfit.png: No Zoom is always bottom right, and the middle-right panel is Interpolated (Delaunay/KNN with the key on, max-zoom extent) or Mid Zoom otherwise.fit_log10.pnggets the same column. The interferometerfit.pngdrops Dirty Signal-To-Noise Map; Dirty Model Image moves to panel 2, giving the interferometer the same source column as imaging (Max / Interpolated or Mid / No). Its source panels now share one colour scale: the Interpolated panel had autoscaled to 4.18 against 4.06.627a35cb,bee5f24,9b3cbab,787cc0a,e99de4cplots.yamlcomment for the key updated to the new placement.This resolves the known gap filed as
draft/feature/autolens/interferometer_fit_png_show_zoomed_no_zoom.md: the interferometerfit.pngnow shows Max Zoom, Interpolated and No Zoom.Library tests after the changes: PyAutoArray
test_autoarray2470 passed, PyAutoLenstest_autolens1032 passed, 1 xfailed.Smoke tests (branch libraries, final pushed heads)
Run with
pyauto-heart smoke autolens autolens_test howtolens(isolated cached environments, live branch source) at PyAutoArraye8a174a6, PyAutoLens1e212b43b, autolens_workspace627a35cb, autolens_workspace_testbee5f24, HowToLens9b3cbab.Two earlier runs, on the original cloud-session heads and on the first round of edits, also gave 124/124. No skips, timeouts or failures.
Caveat: the laptop's canonical PyAutoNerves, PyAutoFit and PyAutoGalaxy checkouts, which the task bundle links to, were 1, 3 and 6 commits behind
origin/main(docs and session commits, plus the PyAutoGalaxyconverthelper rename #717). No script failed.Figures checked
Rendered through each gallery's harness (
gallery/gallery_run.sh imaging interferometer), both of which passed--check. Each figure was compared pixel for pixel with the same producer run againstmainPyAutoArray/PyAutoLens and identical sibling libraries.fit.png,fit_log10.pngandinversion_0_0.pnghave Max Zoom / Interpolated / No Zoom on a shared scale (0 to 3.21). The interpolated panel covers the max-zoom extent, lines up with the triangle panels and is blank outside the mesh hull.fit.pnghas Max Zoom / Interpolated / No Zoom, all on 0 to 4.06, with the S/N panel gone.inversion_0_0.pnghas the new right column. Parametricfit.pnghas Max / Mid / No Zoom.inversion_0_0.pnghas the new right column. These are the only galaxy figures that changed.fit.png), a KNN mesh (new layouts), and Delaunay with the key false (fit.pngback to Max/Mid/No).Noted, not changed, and all pre-existing on main:
zoom_to_brightest), so its three source panels look alike;_plot_rectangularhas the sameimshow(aspect="auto")pattern);Re-rendered gallery PNGs were not committed.
Rendered images (laptop)
C:\Users\Jammy\Workspace\Science\scratch\delaunay_interpolated_plot_2026-11-18\index.html, images in...\img\~/Code/PyAutoLabs-wt/delaunay-interpolated-plot/autolens_visualization/scripts/{imaging,interferometer}/images/visualization/{delaunay,parametric}/Next: human
/prm, library first (PyAutoArray#701, then PyAutoLens#864, then the 5 workspace PRs).🤖 Generated with Claude Code
Jammy2211 commentedon Nov 18, 2026
Shipped
All seven PRs were merged on 2026-11-18 by human-typed
/prm, library first. CI was GREEN on every head.e8a174a61e212b43b627a35cbbee5f249b3cbab787cc0ae99de4cWhat users get:
plot_mapper(..., interpolated=True)draws a Delaunay/kNN source reconstruction as the interpolant the likelihood uses.fit.pngandfit_log10.pngshow it in the middle of the right-hand column, between Max Zoom and No Zoom. It is on by default (fit: subplot_fit_source_interpolated: true);falseshows Mid Zoom instead.inversion_#.pngfor Delaunay/kNN meshes has the same Max Zoom / Interpolated / No Zoom column.fit.pngdrops the Dirty S/N panel so it has the same source column.Laptop verification is in the comment above: smoke 124/124, and figures pixel-diffed against main and approved by the human.
PyAutoArray and PyAutoLens are merged but not yet released: they are pending release.
🤖 Generated with Claude Code