Repository navigation
Description
Overview
Step 6 of the weak-lensing series (PyAutoMind/z_features/weak_shear.md): add the two canonical cluster weak-lensing diagnostics missing from autolens/weak/plot/ — the azimuthally averaged tangential/cross shear radial profile (THE standard observable in cluster weak lensing; the cross component is the B-mode null test) and a Kaiser-Squires convergence-map reconstruction. Science anchors: Oguri et al. 2012 (SGAS), Medezinski et al. 2016 (A2744). Independent of the other queued series steps; step 7 (real-data A2744) will reuse both plotters.
Plan
- Add shear-profile math + plotters to
autolens/weak/plot/:shear_tangential_cross_from(shear_yx, centre)andplot_shear_profile(binned γ_t/γ_x vs radius with error bars). - Add
convergence_via_kaiser_squires_from(grid the irregular shear field, FFT KS inversion) +plot_convergence_map. - Re-export both plotters into
apltalongside the existing nine weak helpers. - NumPy-only unit tests against the SIS analytic profile γ_t(r) = θ_E/2r, γ_x = 0.
- Workspace follow-up: demo both in
scripts/weak/fit.py(profile of data vs model) andsimulator.py(KS map), navigator catalogue regeneration if summaries change.
Detailed implementation plan
Affected Repositories
- PyAutoLens (primary — library)
- autolens_workspace (follow-up — extend
scripts/weak/{simulator,fit}.pydemos)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoLens | main (post #580) | clean |
| ./autolens_workspace | main (post #241) | pre-existing regenerated dataset files only |
Suggested branch: feature/weak-viz-profiles
Worktree: ~/Code/PyAutoLabs-wt/weak-viz-profiles/
Note: autolens_workspace remains claimed by lenstool-example; the workspace demo uses the parallel-worktree pattern (fourth use; scripts/weak/ has zero overlap).
Implementation Steps
autolens/weak/plot/shear_profile_plots.py:shear_tangential_cross_from(shear_yx, centre=(0.0, 0.0))→(gamma_t, gamma_x, radii)per galaxy. Use ONLY the public accessors (.ellipticitiesfor |γ|,.phisfor the shear angle in degrees,.gridfor positions) — never index the raw[γ₂, γ₁]storage (encapsulation rule from series step 2). γ_t = −Re[γ e^{−2iφ}], γ_x = −Im[γ e^{−2iφ}] with φ the position angle aboutcentre.plot_shear_profile(obj, centre=, bins=, ax=None, output_*=)accepting aWeakDatasetorFitWeak(plot data profile; if a fit, overlay the model-shear profile). Radial bins: plain mean + standard error per bin; γ_x series expected consistent with zero.
autolens/weak/plot/convergence_plots.py:convergence_via_kaiser_squires_from(shear_yx, shape_native=(50, 50), smoothing_sigma_pixels=1.0)— bin the irregular (γ1, γ2) onto a regular grid overextent_from(), FFT inversion κ̂ = [(k1²−k2²)γ̂1 + 2k1k2 γ̂2]/k², optional Gaussian smoothing, returnaa.Array2D.plot_convergence_map(...)imshow-style with galaxy positions overlaid.
- Re-export both plot functions in
autolens/plot/__init__.py(weak block, lines ~75-87). - Tests
test_autolens/weak/test_shear_profile.py+test_convergence.py(NumPy-only):- Noise-free
SimulatorShearYXSIS dataset: binned γ_t matches θ_E/2r within bin tolerance; γ_x ≈ 0 (atol ~1e-10 noise-free). - KS map: peak within one grid pixel of the lens centre; κ positive at centre; B-mode (imaginary residual) negligible.
- Direct module imports in tests (the
al.plotpytest recursion gotcha).
- Noise-free
- Full
test_autolens/suite.
Workspace follow-up (second PR, library-first gate)
scripts/weak/fit.py: add a__Shear Profile__section plotting data-vs-model γ_t/γ_x profiles.scripts/weak/simulator.py: add a__Convergence Map__section with the KS reconstruction.- Regenerate navigator catalogue (
PyAutoBuild/autobuild/regenerate_navigator.py autolens) — Contents lines change.
Key Files
autolens/weak/plot/{weak_dataset_plots,fit_weak_plots}.py— existing helpers + save/subplot conventions to match.autogalaxy/util/shear_field.py—ShearYX2DIrregularpublic accessors.test_autolens/weak/test_fit.py— SIS fixture pattern to reuse.
Autonomy
--auto continuation (launch 2026-07-09), effective level supervised (header supervised, feature cap supervised): plan-to-issue, mechanical stretches proceed, ship sign-off parks as a batched question here, merge stays human. Brain Feature Agent failed to classify this prompt (no repos resolved, suggested research); classification emulated inline per WORKFLOW.md — recorded for post-hoc review.
Original Prompt
Click to expand starting prompt
Weak lensing shear profile and convergence map visualization. Add the two canonical cluster weak-lensing diagnostics missing from autolens/weak/plot: (1) an azimuthally averaged tangential and cross shear radial profile helper (binned gamma_t / gamma_x vs radius with error bars, cross-shear as the standard B-mode null test) computed about a chosen centre from a WeakDataset or FitWeak; (2) a Kaiser-Squires style convergence map reconstruction plotted from the shear field. Re-export into aplt alongside the existing nine quiver helpers and demo both in autolens_workspace/scripts/weak (extend simulator.py / fit.py outputs). Tangential shear profiles are THE standard observable in cluster weak lensing (Oguri 2012 SGAS; Medezinski 2016 A2744).
Activity
Jammy2211 commentedon Jul 9, 2026
Scope addition (user direction, 2026-07-09): the workspace half of this task also adopts the standard
al.util.dataset.should_simulateauto-simulation pattern (the imaging-style__Dataset Auto-Simulation__section, pointed atscripts/weak/simulator.py) inscripts/weak/fit.pyand migratesscripts/weak/modeling.py's plainexists()check to it. Prompt 9 (PYAUTO_SMALL_DATASETS) updated to reference this rather than duplicate it.Jammy2211 commentedon Jul 9, 2026
Ship sign-off requested (supervised checkpoint — run parked here)
What was done. Both halves implemented, validated and committed locally on
feature/weak-viz-profiles(nothing pushed). Library commitb508ffa8:shear_profile_plots.py(per-galaxy γ_t/γ_x + binned profiles +plot_shear_profilewith model overlay for fits) andconvergence_plots.py(Kaiser-Squires E/B-mode inversion +plot_convergence_map), both re-exported intoaplt, plus 6 new unit tests. Workspace commitd6090b72:__Shear Profile__section infit.py,__Convergence Map__section insimulator.py, theshould_simulateauto-simulation adoption infit.py+modeling.py(user-directed scope addition), navigator catalogue regenerated in-branch (so the staleness CI leg passes first time, unlike PR #241).Validation.
simulator.pyandfit.pyran in the worktree; figures attached to the PR after push.fit.pyauto-simulated the dataset from scratch afterrm -rf(proving theshould_simulatepath); χ² = 437.510 for 400 DoF — bit-identical to the series' known value.dataset.json) was restored, not committed.Heart: YELLOW, reason set unchanged from the list you acknowledged at the weak-modeling sign-off earlier today (stale 2026-07-08 workspace-validation report, stale parked scripts, assistant version pin, install verification, release validation, old Mind PR).
The question. Approve shipping? On approval: push both branches, open the PyAutoLens PR (
pending-release) and the autolens_workspace PR (library-first gate), append the autonomy-log row — same shape as #580/#241. Amendments welcome here; any session resumes fromactive.md.Jammy2211 commentedon Jul 9, 2026
Ship approved — PRs open: #582 (library,
pending-release) and PyAutoLabs/autolens_workspace#244 (workspace, merge after the library PR). Watching CI; will merge library-first on green and close this issue.Jammy2211 commentedon Jul 9, 2026
Shipped ✅
Both PRs merged library-first with all CI green on the first run (the in-branch catalogue regeneration avoided #241's staleness red):
should_simulateadoption across the weak scriptsThe weak series now has its full core visualization suite (11 aplt helpers). Continuing the home straight: step 5 (
likelihood_function.py) next. Closing.