Skip to content

feat: LEGGOS area magnification on LensCalc (arc phase 6a) #684

Closed

Description

@Jammy2211

Overview

Arc phase 6a (epic cluster-strong-lensing): the LEGGOS II (arXiv:2606.20804) Eq. 6-7 area magnification as a LensCalc API — sum the image-plane area of an arc mask and invert the local Hessian magnification per sub-pixel to get the source-plane area; their ratio is the arc's area magnification, and the source-plane area links to source size. Works for any mass object and for a PyAutoLens Tracer via LensCalc.from_tracer (multi-plane via plane_j).

Plan

  • source_plane_area_from(mask, sub_size) — A_src = Σ sub-pixel area / |μ| (Eq. 7).
  • area_magnification_from(mask, sub_size) — μ_area = A_img / A_src for a mask covering one image (Eq. 6).
  • area_magnification_list_from(mask, sub_size) — split a mask into images (same-parity connected regions; the critical curve is the boundary) and return one value per image.
  • Unit tests: analytic SIS annulus segment, sub_size convergence, parity split, multi-plane callable.
  • Later slices: 6b workspace_test validation vs simulated truth, 6c workspace docs, 6d assistant LEGGOS ingest.

Tier: judge — merge mode: human /prm (human authorized "do phase 6" 2026-10-30; merges still per tier).

Detailed implementation plan

Affected Repositories

  • PyAutoGalaxy (primary)

Suggested branch: feature/area-magnification-lenscalc

Implementation Steps

  1. autogalaxy/operate/lens_calc.py: three methods after magnification_2d_via_hessian_from; sub-pixel grid from aa.Grid2D.from_mask(mask, over_sample_size=sub_size).over_sampled, μ via magnification_2d_via_hessian_from on a Grid2DIrregular of the sub-pixel centres.
  2. Segmentation: native boolean arrays of (unmasked & μ>0) and (unmasked & μ<0) at pixel level (pixel-centre μ), scipy.ndimage.label for connected regions → per-segment Mask2D.
  3. Tests in test_autogalaxy/operate/test_lens_calc.py (or a new test_area_magnification.py).

Key Files

  • autogalaxy/operate/lens_calc.py
  • test_autogalaxy/operate/

Original Prompt

Click to expand starting prompt

Area magnification on LensCalc (LEGGOS Eq. 6-7): per-pixel inversion over an image-plane mask

Type: feature
Target: autogalaxy
Repos:

  • PyAutoGalaxy
    Epic: cluster-strong-lensing
    Phase: 6a
    Parent: draft/feature/autolens/area_magnification_leggos.md
    Arc: draft/feature/autolens/source_cluster_arc.md
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Consequence: judge
    Filed: 2026-10-30
    Witness: LensCalc.area_magnification_from(mask) reproduces the analytic SIS annulus-segment area magnification to <0.5% at sub_size 4 with error falling as sub_size grows; area_magnification_list_from(mask) splits a mask covering several images into same-parity connected segments and returns one value per image; works for a Tracer via LensCalc.from_tracer(..., plane_j=); full PyAutoGalaxy + PyAutoLens suites pass.

Original request (human, 2026-10-30)

ship it when the tests pass, do all steps and then do phase 6

Phase-6 parent (verbatim user request, 2026-08-19): "Ability to get areas only Magnification as extension to
source science scripts. Look at LEGGOS paper for description of equations but basically area extension to the
above, seems like standard calculation in cluster lensing. [...] Remember also that area can link to source size."

Slice

Phase 6 is split: 6a library API (this prompt, PyAutoGalaxy LensCalc, which PyAutoLens reaches through
LensCalc.from_tracer); 6b autolens_workspace_test validation against simulated truth (uniform-disk source of
known area, resolution and segmentation controls, CI smoke); 6c workspace docs (source_science scripts:
area magnification + source size); 6d autolens_assistant LEGGOS II wiki/literature ingest. Forward ShapeSolver
stays out of scope (transferred to cluster-pointsolver-speed).

Work

  1. LensCalc.source_plane_area_from(mask, sub_size=4, xp=np): A_src = sum over the mask's sub-pixels of
    (sub-pixel area / |mu|), mu from magnification_2d_via_hessian_from (LEGGOS Eq. 7). This is the source-plane
    area the image region maps from — the link to source size.
  2. LensCalc.area_magnification_from(mask, sub_size=4, xp=np): mu_area = A_img / A_src (LEGGOS Eq. 6), for a
    mask covering ONE image. Document that a mask spanning several images of the same source double-counts A_src.
  3. LensCalc.area_magnification_list_from(mask, sub_size=4): split the mask into images — connected regions of
    the same parity (sign of mu; the critical curve is the boundary) — and return one mu_area per segment
    (plus the segment masks), so a whole-arc mask gives per-image values.
  4. Unit tests: analytic SIS annulus segment (outer image, theta in [r1, r2] maps to beta = theta - theta_E);
    sub_size convergence; parity split of a mask straddling the tangential critical curve; multi-plane via a
    mocked/Tracer-like deflection callable; NumPy path (JAX optional, importorskip).

Activity

  1. Jammy2211 commented on Oct 30, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR Created

    PR: #685. Workspace follow-ups are later slices (6b validation in autolens_workspace_test, 6c source_science docs).

  2. Jammy2211 commented on Oct 30, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged #685, pending release. LensCalc.source_plane_area_from, area_magnification_from, image_masks_from, area_magnification_list_from (LEGGOS II Eq. 6-7). Next: 6b validation vs simulated truth in autolens_workspace_test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions