Skip to content

feat: signed per-image point magnifications + ResultPoint surface (Source & Cluster 5a) #797

Closed

Description

@Jammy2211

Point magnification: signed per-image magnifications on the point fit/Result surface + multi-plane witness

Type: feature
Target: PyAutoLens
Repos:

  • PyAutoLens
    Themes:
  • cluster
  • point-source
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Status: draft
    Consequence: judge
    Review-minutes: 10
    Unattended: ready
    Epic: cluster-strong-lensing
    Phase: 5a
    Parent: draft/feature/autolens/point_magnification_api.md
    Filed: 2026-10-23

Original user request (verbatim, from the phase-5 parent)

Ability to get Magnification at a point in source science scripts, important for clusters
and then extend to multi plane for clusters. It is common for lens modeling codes to give
the magnification at a point in the image plane. PyAutoLens may do that but its not
documented clearly, and should be in all source_science.py examples and the point source
package.

Why this slice

Brain's Feature Agent (2026-10-23) classifies the phase-5 parent as split-into-phases
(declared large, derived too-large). Phase 5a is the library-only slice; phase 5b (the
workspace source_science.py documentation across both tiers, plus the multi-plane worked
example) follows once 5a is pending-release. One bounded phase at a time.

Current source (PyAutoLens b273f9c7d, 2026-10-22) confirms the parent's audit:

  • autolens/point/fit/abstract.py:111 magnifications_at_positions computes μ at every
    observed image position through LensCalc.from_tracer(use_multi_plane, plane_j) →
    magnification_2d_via_hessian_from, then returns abs(magnifications) (line 141).
    Parity is discarded before every consumer: fluxes.py (model fluxes, solved flux),
    positions/source/separations.py:184 (magnification weighting, μ**-2), and
    plot/source_plane_panel.py:271 (which applies np.abs again).
  • autolens/point/model/result.py ResultPoint exposes only grid and
    max_log_likelihood_fit; no magnification accessor on the Result surface.
  • PointDataset has no magnification attribute (observed positions, fluxes, noise only).
  • The parent's fourth item (stale Tracer.magnification_2d_from claim in
    cluster/likelihood_function.py) is ALREADY GONE — no edit required; record this.

Bounded phase-5a task (PyAutoLens only)

  1. Signed magnification funnel. Split magnifications_at_positions into a signed
    base (signed_magnifications_at_positions, the raw Hessian value, parity preserved)
    and keep magnifications_at_positions returning abs(...) of it so every existing
    consumer (fluxes, magnification weighting, source-plane panel) is numerically unchanged.
    The parity decision for this phase: signed magnification is exposed as a new accessor;
    the existing unsigned default is unchanged.
    Document in the docstrings that parity
    (sign) is the physical image-parity observable and that flux/weighting consumers use
    |μ| by construction.
  2. Result surface. Add ResultPoint.magnifications_at_positions and
    ResultPoint.signed_magnifications_at_positions (via max_log_likelihood_fit), so a
    user reads per-image μ and parity from a finished point-source fit without rebuilding
    the fit. Keep the Result pickle/aggregator surface unchanged otherwise.
  3. Multi-plane witness. A test asserting that the point fit's magnification for a
    source at a given plane_redshift equals LensCalc.from_tracer(tracer, use_multi_plane=True, plane_j=j).magnification_2d_via_hessian_from(positions)
    directly, on a three-plane fixture (the parent's #678 final-plane-default trap:
    the test must fail if plane_j silently resolves to the final plane).
  4. Parity witness. A test on a simple SIE two-image (or four-image) fixture asserting
    that signed_magnifications_at_positions has the expected mixed signs and that
    magnifications_at_positions == abs(signed); both NumPy and JAX (use_jax=True) paths.
  5. Point-package docstring pass: PointDataset/fit module docstrings state where μ at a
    point lives (fit accessor; LensCalc.magnification_2d_via_hessian_from for arbitrary
    (y,x)) — docstrings only, no new dataset attribute (the dataset holds observations, not
    model quantities; deferred unless phase 5b finds a need).

Validation: focused test_autolens/point/ (fit, fluxes, separations, result) and the
multi-plane solver tests; full PyAutoLens suite before ship; black. Workspace point-source
smoke (autolens_workspace_test point_source scripts) must be unchanged numerically.

Out of scope here, owned by phase 5b (human direction 2026-10-23: users must find this in
autolens_workspace): the eleven source_science.py scripts, plus a guide pass in
guides/lens_calc.py (mu at arbitrary (y,x) via the Hessian), guides/advanced/multi_plane.py
(per-source plane_j) and the point-source results surface in guides/results/; also (phase 5b), posterior-draw
errors (phase 7), maps (phase 8), any forward PointSolver repair (transferred to
cluster-pointsolver-speed), optimisation/profiling/robustness work (separate issues).

Solver boundary — inherited from the parent (approved 2026-10-01)

Magnification at supplied/observed coordinates proceeds independently of PointSolver
repairs. No example or test in this slice discovers image positions with a forward solve;
positions are supplied fixture inputs.

Activity

  1. Jammy2211 commented on Oct 23, 2026

    @Jammy2211
    CollaboratorAuthor

    Implementation complete and committed locally on feature/point-magnification-signed-surface (worktree commit feat: signed per-image point magnifications + ResultPoint surface, 6 files, +310/−10). Not yet pushed.

    • Full pytest test_autolens: 941 passed, 1 xfailed, 0 failed. Focused test_autolens/point: 308 passed, 1 xfailed.
    • black --check passes on every changed file; repo-wide formatting untouched.
    • No workspace, workspace_test or HowToLens script calls the accessor (option iii: no workspace impact).
    • Heart at ship time: YELLOW — manifest drift: workspace checkouts (manifest ↔ disk) — 1 mismatch(es) vs PyAutoMind/repos.yaml; release validation incomplete: no rehearsal for current source. Awaiting the human's acknowledgement before push + PR.

    Workspace documentation (source_science.py both tiers, guides/lens_calc.py, guides/advanced/multi_plane.py, point-source results guide) is phase 5b, filed after this ships.

  2. Jammy2211 commented on Oct 23, 2026

    @Jammy2211
    CollaboratorAuthor

    Human acknowledged the two Heart YELLOW reasons (manifest drift 1 mismatch; no release rehearsal) and authorized ship + /prm on green. Library PR: #798 @6cb5eed0f, pending-release.

  3. Jammy2211 commented on Oct 23, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped: #798 merged as f791ac7 (2026-10-23). All CI jobs green (docs, unittest 3.12/3.13/nojax); autolens_workspace_test smoke 37/37 passed against the branch. PyAutoLens release pending. Phase 5b (workspace docs) follows as Mind draft/docs/autolens_workspace/point_magnification_workspace_docs.md.

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