Skip to content

feat: PointSolver refinement figure (2×2 + teaching GIF + visualizer output) - #788

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/point-solver-refinement-figure
Oct 21, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/point-solver-refinement-figure

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Phase 2 of the point-source figures (#787): a point_solver.png figure showing how the PointSolver refines its triangle tiling onto the multiple images, a teaching GIF in the same style, and an optional visualizer output during modelling. It is both a modelling diagnostic (did the grid cover every image, how many triangles survive each step) and teaching material.

  • Figure: a 2×2 of steps 0, 1, 2 and the final step on one fixed full extent, in the approved variant_f_coarse style: tested triangles grey, kept blue, kept-then-rejected (μ < magnification_threshold) hatched muted blue, neighbour rim orange, up-sampled green, purple critical curve, observed hollow circles, solved red ✕. Step 0 numbers the images and labels the rejected candidate. Kept triangles under ~3 screen pixels are drawn as a centroid ▲ ("Kept (too small to draw)"). Standard arc-second tick labels via apply_extent, no axis-label text. Vertices are (y,x) → plotted (x,y) (the old debug helper was transposed).
  • Animation: animate=True writes point_solver.gif (matplotlib FuncAnimation + PillowWriter, 1.25 s per step, final held 3×, looping). The still and the GIF share draw_point_solver_panel, so they cannot drift.
  • Visualizer (option C): PlotterPoint.point_solver, called by VisualizerPoint.visualize on the full (not quick-update) pass only, i.e. the best fit, behind fit_point_dataset: subplot_point_solver (default false). It re-solves with NumPy (xp=np), because the JAX path pads steps to MAX_CONTAINING_SIZE and hides them inside jit. It logs a warning when any step keeps ≥ 80 % of MAX_CONTAINING_SIZE (20) triangles.
  • Carry-over from phase 1: the model ✕ in the Fit Positions panel is thinner and smaller (s=60, lw=1.2), so the observed dot stays visible under an exact fit.
  • Cleanups: Step.tree_flatten now returns plane_triangles (it returned 5 children for 6 fields, so tree_unflatten raised TypeError). The unused debug module autolens/point/visualise.py (no callers, plt.show() only, transposed axes) is removed.

Defaults confirmed by implementing (flagged for the human, not explicitly signed off):

  • Cluster capping: above 10 solved images, step 0 is not numbered. With more than one rejected candidate, one label is drawn with arrows to up to 5 candidates. The label placement avoids the images and their numbers and stays inside the panel. A tiling too dense to outline (a cluster's 370k step-0 triangles) is drawn as a light grey shade instead of a solid slab of outlines.
  • point/visualise.py is retired outright rather than wrapped.
  • The tree_flatten fix is in this PR.

API Changes

Adds aplt.plot_point_solver (2×2 still or GIF) and the fit_point_dataset: subplot_point_solver visualizer toggle (off by default). Removes the unused debug module autolens.point.visualise. Fixes Step.tree_flatten. The model marker in the point Fit Positions panel is thinner.
See full details below.

Test Plan

  • pytest test_autolens: 873 passed, 1 xfailed (pre-black). After black: test_autolens/point 240 passed, 1 xfailed.
  • New tests:
    • test_autolens/point/plot/test_point_solver_plots.py: panel selection 0/1/2/final, (y,x)→(x,y) swap with NaN rows dropped, rejected lens-centre candidate, ▲ fallback on the final step only, legend entries, still written, GIF written with 4 frames + loop=0 + final frame held 3×, the animation returned without a path, the JAX-cap warning.
    • test_plotter_point.py: toggle off by default; on writes point_solver.png.
    • triangles/test_step.py: tree_flatten round trip.
  • Rendered in autolens_visualization: real-solver point_solver.png for point_source_image_chi_squared and both cluster planes, a coarse teaching PNG + GIF, and re-rendered fit.pngs. The workspace PR follows.
  • Heart: YELLOW, pre-existing and acknowledged by the human: "manifest drift: workspace checkouts (manifest ↔ disk) — 1 mismatch(es) vs PyAutoMind/repos.yaml"; "release validation stale: source moved since rehearsal (PyAutoArray)".
Full API Changes (for automation & release notes)

Added

  • autolens.plot.plot_point_solver(solver, tracer, source_plane_coordinate, positions=None, plane_redshift=None, image_plane_lines=None, output_path=None, output_format=None, title_prefix=None, animate=False, filename="point_solver"): the still, or the GIF with animate=True. Without output_path the still is shown and the FuncAnimation returned.
  • autolens.point.plot.point_solver_plots: point_solver_data_from, plot_point_solver_from_data, draw_point_solver_panel, legend_handles_from, select_steps, split_kept_from, neighbour_rim_from, triangles_xy_from, warn_if_near_jax_cap, PointSolverFigureData.
  • PlotterPoint.point_solver(fit, image_plane_lines=None).
  • Config visualize/plots.yaml: fit_point_dataset: subplot_point_solver: false.

Removed

  • autolens.point.visualise (visualise, plot_triangles, plot_triangles_compare): debug-only, no callers in the library or workspaces.

Changed Behaviour

  • VisualizerPoint.visualize (non-quick-update) outputs point_solver.png when subplot_point_solver is on.
  • Step.tree_flatten includes plane_triangles, so Step.tree_unflatten round-trips.
  • positions_panel.plot_fit_model_positions: the model ✕ is s=60, linewidths=1.2 (was 80 / 2.5).

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…zer output)

- autolens/point/plot/point_solver_plots.py: point_solver.png (steps 0, 1, 2 and final on one
  fixed extent; tested / kept / kept-then-rejected / neighbours / up-sampled triangles,
  critical curve, observed and solved positions, step-0 numbering + rejected annotation,
  arcsec ticks via apply_extent, centroid markers for sub-pixel kept triangles) and a looping
  GIF (PillowWriter, one step per frame, final held 3x) sharing one per-panel draw function.
- aplt.plot_point_solver(solver, tracer, source_plane_coordinate, ..., animate=False).
- PlotterPoint.point_solver + VisualizerPoint (best fit, full visualization only) behind
  fit_point_dataset: subplot_point_solver (default false); NumPy re-solve; warns when a step
  keeps nearly MAX_CONTAINING_SIZE triangles.
- Step.tree_flatten returns plane_triangles (6 children for 6 fields).
- Remove the unused debug autolens/point/visualise.py (transposed, plt.show only).
- Thinner, smaller model cross in the Fit Positions panel so the observed dot stays visible.

Closes #787

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d note in a corner

Each step-0 image number is placed a few points off its own image (one of four
fixed offsets, the first inside the panel and clear of other markers/numbers),
never moved away by a global search. Several rejected candidates (or one with no
clear spot beside it) get one label in the emptiest axes corner with one arrow
per candidate, chosen to avoid covering/crossing images. Tests assert each
number's box is within 10 pt of its image, including a crowded layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 57f1e65 into main Oct 21, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/point-solver-refinement-figure branch October 21, 2026 14:29
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant