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) and plot_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
aplt alongside 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) and simulator.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}.py demos)
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 (.ellipticities for |γ|, .phis for the shear angle in degrees, .grid for positions) — never index the raw [γ₂, γ₁] storage (encapsulation rule from series step 2). γ_t = −Re[γ e^{−2iφ}], γ_x = −Im[γ e^{−2iφ}] with φ the position angle about centre.
plot_shear_profile(obj, centre=, bins=, ax=None, output_*=) accepting a WeakDataset or FitWeak (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 over extent_from(), FFT inversion κ̂ = [(k1²−k2²)γ̂1 + 2k1k2 γ̂2]/k², optional Gaussian smoothing, return aa.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
SimulatorShearYX SIS 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.plot pytest recursion gotcha).
- 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 — ShearYX2DIrregular public 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).
Overview
Step 6 of the weak-lensing series (
PyAutoMind/z_features/weak_shear.md): add the two canonical cluster weak-lensing diagnostics missing fromautolens/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
autolens/weak/plot/:shear_tangential_cross_from(shear_yx, centre)andplot_shear_profile(binned γ_t/γ_x vs radius with error bars).convergence_via_kaiser_squires_from(grid the irregular shear field, FFT KS inversion) +plot_convergence_map.apltalongside the existing nine weak helpers.scripts/weak/fit.py(profile of data vs model) andsimulator.py(KS map), navigator catalogue regeneration if summaries change.Detailed implementation plan
Affected Repositories
scripts/weak/{simulator,fit}.pydemos)Branch Survey
Suggested branch:
feature/weak-viz-profilesWorktree:
~/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.autolens/plot/__init__.py(weak block, lines ~75-87).test_autolens/weak/test_shear_profile.py+test_convergence.py(NumPy-only):SimulatorShearYXSIS dataset: binned γ_t matches θ_E/2r within bin tolerance; γ_x ≈ 0 (atol ~1e-10 noise-free).al.plotpytest recursion gotcha).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.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
--autocontinuation (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).