Skip to content

fix: default FitPositionsSource to jacobian weighting; correct magnification normalisation - #792

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/positions-source-jacobian-default
Oct 21, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/positions-source-jacobian-default

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

FitPositionsSource now defaults to the "jacobian" source-plane weighting. Each source-plane residual δᵢ is weighted by the precision tensor Bᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹, i.e. it is measured in the image-plane noise ellipse. This is the Gravity.jl source-plane likelihood (Lombardi 2024, arXiv:2406.15280, Eq. 46). It is also Keeton 2001 Eq. 10 and Lenstool's tensor mode (forme 8).

The old default, the scalar "magnification" weighting (Jullo et al. 2007 Eq. 10), is biased near critical curves. On the point_source true model its source χ² is 10,023, against 4.25 in the image plane and 5.41 with "jacobian". Its normalisation Σ log(2πσ²/μ²) was also 1-D and depended on the model, which rewarded high magnification. "magnification" stays as an opt-in, now with the same model-independent 2-D normalisation Σ log((2π)²σ⁴), i.e. Eq. 46 with B ≈ μ²Θ.

Refs #791 (library part; the workspace follows).

API Changes

  • Default changed: FitPositionsSource.weighting is now "jacobian" (was "magnification"). Source-plane χ² and log-likelihood values from FitPositionsSource change.
  • Behaviour changed: the "magnification" normalisation is now Σ log((2π)²σ⁴), model-independent and the same as "jacobian". It was Σ log(2πσ²/μ²). This affects FitPositionsSource only; FitPositionsSourceSolved already used this normalisation.
  • Internal: FitPositionsSourceSolved inherits noise_normalization from its parent instead of duplicating it. Its values are unchanged.
    See full details below.

Test Plan

  • pytest test_autolens -q -x: 911 passed, 1 xfailed.
  • Re-derived pinned values by hand:
    • no-mass (A = I) normalisation 4.5789 and logL −6.2895;
    • IsothermalSph jacobian χ² = (r−0.1)²/σ² (radial eigenvalue 1);
    • magnification χ² = r²/σ² = 4 exactly (the old pinned 3.99996 was an approximation).
  • New test test__fit_positions_source__jacobian__true_model_outranks_perturbed_models_near_critical: an elliptical PowerLaw with slope 2.3 (radial eigenvalue ≠ 1) and a quad with μ up to about 17. The true model outranks perturbations of R_E + 0.01 and of the centre by +0.005 in y and in x.
  • Source-plane panel: the default draws the A·σ ellipse, and an explicit magnification subclass still draws the σ/|μ| circle.
Full API Changes (for automation & release notes)

Changed Behaviour

  • al.FitPositionsSource.weighting: the default is now "jacobian" (was "magnification").
  • al.FitPositionsSource.noise_normalization with weighting = "magnification": now Σᵢ log((2π)² σᵢ⁴) (was Σᵢ log(2π σᵢ²/µᵢ²)).
  • al.FitPositionsSource.log_likelihood / chi_squared: change accordingly.

Removed

  • FitPositionsSourceSolved.noise_normalization override: replaced by the identical inherited property, so behaviour is unchanged.

Migration

  • To keep the old scalar χ² weighting, opt in with a subclass:
    class FitPositionsSourceMagnification(al.FitPositionsSource):
        weighting = "magnification"
    The old 1-D, μ-dependent normalisation is not available.
  • Pinned literals in downstream workspaces that use FitPositionsSource (e.g. autolens_workspace_test jax_likelihood/source_plane.py) must be re-measured.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…ication normalisation

FitPositionsSource now defaults to weighting="jacobian" (B_i = A_i^-T Theta_i A_i^-1,
Gravity.jl Lombardi 2024 Eq. 46). The opt-in "magnification" weighting keeps its
scalar mu^2/sigma^2 chi-squared (Jullo 2007 Eq. 10) but now uses the same
model-independent 2-D normalisation sum log((2pi)^2 sigma^4) instead of the 1-D,
mu-dependent sum log(2pi sigma^2/mu^2). FitPositionsSourceSolved inherits the
normalisation (values unchanged). Tests re-derived analytically; new near-critical
anisotropic test checks the true model outranks perturbations.

Refs #791

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Oct 21, 2026
@Jammy2211
Jammy2211 merged commit 4f5baf9 into main Oct 21, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/positions-source-jacobian-default branch October 21, 2026 19:57
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant