Skip to content

feat: input pixelized mass profiles (potential correction phase 2) - #505

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/potential-correction-port
Jul 17, 2026
Merged

feat: input pixelized mass profiles (potential correction phase 2)#505
Jammy2211 merged 1 commit into
mainfrom
feature/potential-correction-port

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Phase 2 of porting the gravitational-imaging (potential correction) technique into the PyAuto stack (PyAutoLabs/PyAutoLens#618): pixelized input mass profiles. Adds a new autogalaxy/profiles/mass/input/ package with InputDeflections (mass model from known deflection angles; convergence derived via the mask's sparse first-derivative operators from phase 1, PyAutoArray#390) and InputPotential (mass model from known lensing-potential values; deflections and convergence derived via the first/second-derivative operators), plus GaussianRandomField (a potential that is a GRF realization with power-law spectrum, for simulating extended perturbations) and the LinearNDInterpolatorExt Delaunay-with-nearest-fallback interpolator they share.

Ported from the potential_correction package of Cao et al. 2025 (https://github.com/caoxiaoyue/lensing_potential_correction); all new modules cite it and https://github.com/caoxiaoyue/potential_correction_paper. Cross-checked against the author's updated (2026, JAX-migration phase 1) tree: these classes match its modernized pix_mass.py semantics, on the current (non-deprecated) decorator API. The GRF realization uses a plain-numpy Fourier filter instead of the original's powerbox dependency (documented convention difference; spectrum shape and seed reproducibility preserved). No new dependencies.

A predecessor InputDeflections (scipy-griddata based) was removed from autogalaxy in April 2025 (a9f1a262); this reintroduction is operator-based, mask-aware and adds the potential-input variant.

Phase 3 (the autolens/potential_correction/ subpackage) follows in a separate PR — see the issue plan.

API Changes

Added only — nothing removed or changed. Three new mass profiles under ag.mp: InputDeflections, InputPotential and GaussianRandomField (data-holding profiles constructed from arrays/masks, not free-parameter model components), plus the LinearNDInterpolatorExt interpolation helper.
See full details below.

Test Plan

  • 9 new tests: deflections/convergence exact on linear/quadratic potentials (all finite-difference schemes exact by construction), interpolation exact at triangulation nodes and at off-node positions for linear fields, operator preloading, GRF seed reproducibility / zero mean / amplitude scaling / profile-realization consistency.
  • Full test_autogalaxy suite run before commit (execution contract).
Full API Changes (for automation & release notes)

Added

  • ag.mp.InputDeflections(deflections_y, deflections_x, image_plane_grid, mask, Hy=None, Hx=None) — pixelized mass model from known deflection angles on the unmasked pixels of a cleaned mask; deflections interpolated (Delaunay linear, nearest fallback), convergence = 0.5·(Hy·αy + Hx·αx); potential returns zeros.
  • ag.mp.InputPotential(lensing_potential, image_plane_grid, mask, Hy=None, Hx=None, Hyy=None, Hxx=None) — pixelized mass model from known lensing-potential values; deflections = ∇ψ and convergence = ½∇²ψ via the mask's sparse derivative operators.
  • ag.mp.GaussianRandomField(mask, power_amplitude=1.0, power_slope=1.0, seed=1) — lensing potential drawn as a Gaussian random field with P(k) = A·k^(−β), delegated to InputPotential.
  • autogalaxy/profiles/mass/input/gaussian_random_field.py::gaussian_random_field_from(shape_native, pixel_scale, power_amplitude, power_slope, seed) — the numpy-FFT GRF realization.
  • ag.mp.LinearNDInterpolatorExt(points, values) — linear Delaunay interpolation with nearest-neighbour fallback outside the convex hull.
  • notation.yaml superscript entries for the three new profiles.

Migration

  • None — additive only.

Generated by the PyAutoLabs agent workflow.

Adds autogalaxy/profiles/mass/input/: InputDeflections and
InputPotential (pixelized mass models from known deflections /
lensing-potential values on a masked grid, derivatives via the
PyAutoArray sparse mask operators from phase 1), GaussianRandomField
(power-law GRF potential realization, numpy-FFT, no powerbox dep) and
the LinearNDInterpolatorExt helper. Ported from the
potential_correction package of Cao et al. 2025
(https://github.com/caoxiaoyue/lensing_potential_correction); cite via
https://github.com/caoxiaoyue/potential_correction_paper.

Phase 2 of PyAutoLabs/PyAutoLens#618.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 17, 2026
@Jammy2211
Jammy2211 merged commit a904db9 into main Jul 17, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/potential-correction-port branch July 17, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant