feat: input pixelized mass profiles (potential correction phase 2) - #505
Merged
Conversation
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>
This was referenced Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withInputDeflections(mass model from known deflection angles; convergence derived via the mask's sparse first-derivative operators from phase 1, PyAutoArray#390) andInputPotential(mass model from known lensing-potential values; deflections and convergence derived via the first/second-derivative operators), plusGaussianRandomField(a potential that is a GRF realization with power-law spectrum, for simulating extended perturbations) and theLinearNDInterpolatorExtDelaunay-with-nearest-fallback interpolator they share.Ported from the
potential_correctionpackage 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 modernizedpix_mass.pysemantics, on the current (non-deprecated) decorator API. The GRF realization uses a plain-numpy Fourier filter instead of the original'spowerboxdependency (documented convention difference; spectrum shape and seed reproducibility preserved). No new dependencies.A predecessor
InputDeflections(scipy-griddatabased) 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,InputPotentialandGaussianRandomField(data-holding profiles constructed from arrays/masks, not free-parameter model components), plus theLinearNDInterpolatorExtinterpolation helper.See full details below.
Test Plan
test_autogalaxysuite 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 toInputPotential.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.yamlsuperscript entries for the three new profiles.Migration
Generated by the PyAutoLabs agent workflow.