Skip to content

feat: tangential/cross shear profile + Kaiser-Squires map (weak series step 6) #581

Description

@Jammy2211

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

  1. 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.
  2. 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.
  3. Re-export both plot functions in autolens/plot/__init__.py (weak block, lines ~75-87).
  4. 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).
  5. Full test_autolens/ suite.

Workspace follow-up (second PR, library-first gate)

  1. scripts/weak/fit.py: add a __Shear Profile__ section plotting data-vs-model γ_t/γ_x profiles.
  2. scripts/weak/simulator.py: add a __Convergence Map__ section with the KS reconstruction.
  3. 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.pyShearYX2DIrregular 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions