Skip to content

feat: magnification uncertainty map from posterior draws (arc 8c) #692

Closed

Description

@Jammy2211

Overview

Third slice (8c) of phase 8 of the cluster strong-lensing arc: the magnification uncertainty map of LEGGOS II figure 4. Each image-plane pixel shows the fractional error of its magnification over the posterior draws that phase 7b added to every source science script, with the best-fit constant-magnification contours on top, so a reader sees where the lens model pins the magnification down and where it does not (near the critical curves).

Plan

  • PyAutoGalaxy: a function returning the per-pixel fractional magnification error from a list of per-draw magnification maps and the best-fit map, and a plot of it with the best-fit contours and critical curves (8a conventions), colour range capped because the error diverges on the critical curves.
  • PyAutoLens: export through aplt.
  • Workspace: in all 11 source_science.py scripts the existing draw loop also stores each draw's magnification map, and a new section plots the uncertainty map.
  • Witness: one full run of the imaging example (100 draws); no full runs of the other ten.

Tier: judge — merge mode: human /prm (PyAutoGalaxy → PyAutoLens → autolens_workspace).

Detailed implementation plan

Affected Repositories

  • PyAutoGalaxy (primary)
  • PyAutoLens
  • autolens_workspace

Branch Survey

Repository Current Branch Dirty?
./PyAutoGalaxy main clean
./PyAutoLens main clean
./autolens_workspace main clean

Suggested branch: feature/magnification-maps-uncertainty

Implementation Steps

  1. autogalaxy/galaxy/plot/galaxies_plots.py (beside 8a's plot_magnification_2d): magnification_fractional_error_2d_from(magnification_list, magnification_best) -> Array2D and plot_magnification_uncertainty_2d(magnification_list, magnification_best, grid, mass_obj=None, contour_levels=(2, 5, 10, 20, 50, 100), include_critical_curves=True, vmin=0.0, vmax=None, ...); export; tests (constant draws → zero error; known spread → known fraction; plot output).
  2. autolens/plot/__init__.py export; tracer test.
  3. autolens_workspace, all 11 source_science.py: inside the 7b draw loop, magnification_map_list.append(lens_calc.magnification_2d_from(grid=map_grid)) on a coarse grid; new __Magnification Uncertainty Map__ section using the max-likelihood tracer for the best-fit map; regenerate_navigator.py autolens; smoke all 11.
  4. Full run of scripts/imaging/source_science.py for the witness.

Key Files

  • autogalaxy/galaxy/plot/galaxies_plots.py — plot_magnification_2d, _magnification_contours
  • autogalaxy/operate/lens_calc.py — magnification_2d_from
  • autolens_workspace/scripts/*/source_science.py and */features/*/source_science.py — __Posterior Draws__

Original Prompt

Click to expand starting prompt

Magnification maps 8c: LEGGOS Fig-4 fractional magnification uncertainty map

Type: feature
Target: PyAutoGalaxy
Repos:

  • PyAutoGalaxy
  • PyAutoLens
  • autolens_workspace
    Themes:
  • visualization
  • cluster
    Epic: cluster-strong-lensing
    Phase: 8c
    Parent: draft/feature/autolens/magnification_maps_visualization.md
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Status: formalised
    Consequence: judge
    Review-minutes: 25
    Unattended: no
    Filed: 2026-11-02

Context

Slice of phase 8. Per image pixel sigma_mu/|mu_best| over the phase-7b posterior draws (each draw → 8a mu map), with
the best-fit constant-mu contours overlaid, as LEGGOS II Fig. 4. Library helper only if the draw loop proves reusable.
Workspace: source_science scripts (start with imaging). Witness: map renders from 100 draws on imaging simple.

Original request (human, 2026-11-02)

start 8c
yes go ahead, all 11 scripts

Approved plan (2026-11-02)

  1. PyAutoGalaxy: magnification_fractional_error_2d_from(magnification_list, magnification_best) (half the 16-84
    percentile range of |mu| over the draws / |mu_best| per pixel) and plot_magnification_uncertainty_2d( magnification_list, magnification_best, grid, mass_obj=None, ...) — fractional-error map, colour range capped
    (diverges on the critical curves), best-fit constant-mu contours via the 8a helper, optional critical curves.
  2. PyAutoLens: aplt export + test.
  3. autolens_workspace: all 11 source_science.py scripts — the 7b draw loop also stores each draw's mu map (coarser
    grid), new __Magnification Uncertainty Map__ section; catalogue regen; smoke all 11.
  4. Witness: one full run of imaging/source_science.py (100 draws); report fractional errors away from the critical
    curves next to 7b's 1-2% scalar errors. No full runs of the other 10 (human 2026-11-02: end-to-end runs overkill).

Activity

  1. Jammy2211 commented on Nov 2, 2026

    @Jammy2211
    CollaboratorAuthor

    PRs open (judge tier, human /prm, merge in this order):

    1. feat: magnification uncertainty map from posterior draws (LEGGOS Fig. 4) #693 — magnification_fractional_error_2d_from, plot_magnification_uncertainty_2d (test_autogalaxy 1475 passed)
    2. feat: aplt magnification uncertainty map PyAutoLens#817 — aplt exports (1021 passed)
    3. docs: magnification uncertainty map in every source_science script (arc phase 8c) autolens_workspace#616 — all 11 source_science scripts (smoke clean)

    Witness (full imaging run, 100 draws): median sigma/|mu| 0.23% / 0.50% / 2.0% / 8.8% for |mu| in 1-3 / 3-10 / 10-30 / >30. Heart STALE acknowledged by the human 2026-11-02.

  2. Jammy2211 commented on Nov 2, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged in order:

    1. feat: magnification uncertainty map from posterior draws (LEGGOS Fig. 4) #693 (f397c6b2) — magnification_fractional_error_2d_from, plot_magnification_uncertainty_2d
    2. feat: aplt magnification uncertainty map PyAutoLens#817 (03ab1f82) — aplt exports
    3. docs: magnification uncertainty map in every source_science script (arc phase 8c) autolens_workspace#616 — magnification uncertainty map in all 11 source_science scripts

    Library PRs pending release. Next in phase 8: 8d (fit-subplot wiring + the "make them pretty" pass).

    🤖 Generated with Claude Code

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