Overview
Extend the potential-correction (gravitational imaging) subpackage al.pc (shipped in #618; ported from Cao et al. 2025, https://github.com/caoxiaoyue/lensing_potential_correction, cite via https://github.com/caoxiaoyue/potential_correction_paper) from Imaging to Interferometer datasets, fitting in visibility space. This reaches the technique's benchmark regime: the JVAS B1938+666 detections of Powell et al. 2025 (Nat. Astron. 9, 1714) and Vegetti et al. 2026 were made with a visibility-space gravitational-imaging code.
Plan
- New visibility-space fits in
al.pc: FitDpsiInterferometer (δψ-only inversion of a visibility residual) and FitDpsiSrcInterferometer (joint source+δψ), where the correction response is −T(D_s·D_ψ) via transformer.transform_mapping_matrix (already xp-parameterized) in place of the imaging PSF blur matrix B; real/imag block stacking and complex-noise handling mirror the existing interferometer inversion conventions (noise_normalization_complex_from).
- δψ mesh built from the dataset's real-space mask (cleaned), reusing
PairRegularDpsiMesh unchanged; source gradients remain image-plane (ray-traced real-space grid).
- Iterative engine support: the per-step source-mapping update uses the transformed mapping matrix instead of
convolved_mapping_matrix_from; IterFitDpsiSrcInterferometer (or dataset-dispatching extension of the existing engine — decided in implementation by whichever mirrors the FitImaging/FitInterferometer split most cleanly).
- Analysis classes for evidence-based hyper-parameter sampling over interferometer data.
al.pc.dense_util untouched — its xp kernels are data-agnostic (mapping matrix + noise vector in).
- Workspace follow-up (library-first gate):
autolens_workspace_test scripts — jax_likelihood_functions/interferometer/potential_correction.py (xp/jit parity on the visibility evidence) and an interferometer subhalo_recovery regression (SimulatorInterferometer + NFW subhalo), smoke-wired.
- NumPy-first; JAX rides the transformer's existing xp support. Unit tests numpy-only. Citations maintained in all new modules.
Detailed implementation plan
Affected Repositories
- PyAutoLens (primary)
- autolens_workspace_test (workspace follow-up)
Work Classification
Both (library first, workspace follows)
Branch Survey
| Repository |
Current Branch |
Dirty? |
| ./PyAutoLens |
main |
1 file (paper_jax/paper.md, unrelated JOSS draft — warning only) |
| ./autolens_workspace_test |
main |
clean |
Suggested branch: feature/potential-correction-interferometer
Worktree root: ~/Code/PyAutoLabs-wt/potential-correction-interferometer/
Implementation Steps
autolens/potential_correction/fit_interferometer.py: FitDpsiInterferometer + FitDpsiSrcInterferometer.
- Correction response: densify
D_s @ D_ψ (sparse product, then .toarray()), apply dataset.transformer.transform_mapping_matrix → complex [n_vis, n_dpsi]; stack real/imag rows to match how the interferometer inversion's operated_mapping_matrix enters the curvature (mirror autoarray/inversion/inversion/interferometer/abstract.py::operated_mapping_matrix_list exactly).
- Source blocks from
al.FitInterferometer's inversion (operated_mapping_matrix, regularization_matrix) at the smooth starting model, as the imaging fit does with FitImaging.
- Noise: per-component inverse variance from the complex noise map; evidence noise term via
aa.util.fit.noise_normalization_complex_from; χ² over real+imag residuals.
- δψ mesh:
PairRegularDpsiMesh(real_space_mask, pixel_scale, factor); δψ regularization via the existing DpsiLinearObj adapter.
autolens/potential_correction/iterative.py: dataset seam — replace the imaging-only psf.convolved_mapping_matrix_from update and psf_matrix property with a dispatch on dataset type (imaging → PSF matrix path; interferometer → transform_mapping_matrix path); gauge constraints and LM kernels unchanged.
autolens/potential_correction/analysis.py: DpsiInvInterferometerAnalysis / DpsiSrcInvInterferometerAnalysis (or dataset-generic analyses — implementation judgment).
- Exports in
autolens/potential_correction/__init__.py + docs/api page update.
- Unit tests (numpy-only): matrix-injection evidence-term tests for the complex-noise formulation; end-to-end finite evidence on the
interferometer_7 fixture family; transformed-response shape/consistency vs direct transformer.visibilities_from on a δ-function correction.
- Workspace step (after library PR): the two
autolens_workspace_test scripts + smoke_tests.txt/env_vars.yaml wiring, mirroring the imaging ones.
Key Files
autolens/potential_correction/{fit.py,iterative.py,analysis.py,dense_util.py} — the imaging implementations being extended.
autoarray/operators/transformer.py — transform_mapping_matrix(mapping_matrix, xp=np) (DFT + NUFFT variants).
autoarray/inversion/inversion/interferometer/abstract.py — the operated-mapping-matrix conventions to mirror.
autoarray/fit/fit_util.py::noise_normalization_complex_from — the visibility noise term.
Original Prompt
Click to expand starting prompt
merge, and then the follow up will be to get this running on interferometer data as currently its just imaging
Prompt file: PyAutoMind/active/potential_correction_interferometer.md
Overview
Extend the potential-correction (gravitational imaging) subpackage
al.pc(shipped in #618; ported from Cao et al. 2025, https://github.com/caoxiaoyue/lensing_potential_correction, cite via https://github.com/caoxiaoyue/potential_correction_paper) fromImagingtoInterferometerdatasets, fitting in visibility space. This reaches the technique's benchmark regime: the JVAS B1938+666 detections of Powell et al. 2025 (Nat. Astron. 9, 1714) and Vegetti et al. 2026 were made with a visibility-space gravitational-imaging code.Plan
al.pc:FitDpsiInterferometer(δψ-only inversion of a visibility residual) andFitDpsiSrcInterferometer(joint source+δψ), where the correction response is−T(D_s·D_ψ)viatransformer.transform_mapping_matrix(already xp-parameterized) in place of the imaging PSF blur matrixB; real/imag block stacking and complex-noise handling mirror the existing interferometer inversion conventions (noise_normalization_complex_from).PairRegularDpsiMeshunchanged; source gradients remain image-plane (ray-traced real-space grid).convolved_mapping_matrix_from;IterFitDpsiSrcInterferometer(or dataset-dispatching extension of the existing engine — decided in implementation by whichever mirrors the FitImaging/FitInterferometer split most cleanly).al.pc.dense_utiluntouched — its xp kernels are data-agnostic (mapping matrix + noise vector in).autolens_workspace_testscripts —jax_likelihood_functions/interferometer/potential_correction.py(xp/jit parity on the visibility evidence) and an interferometersubhalo_recoveryregression (SimulatorInterferometer + NFW subhalo), smoke-wired.Detailed implementation plan
Affected Repositories
Work Classification
Both (library first, workspace follows)
Branch Survey
paper_jax/paper.md, unrelated JOSS draft — warning only)Suggested branch:
feature/potential-correction-interferometerWorktree root:
~/Code/PyAutoLabs-wt/potential-correction-interferometer/Implementation Steps
autolens/potential_correction/fit_interferometer.py:FitDpsiInterferometer+FitDpsiSrcInterferometer.D_s @ D_ψ(sparse product, then.toarray()), applydataset.transformer.transform_mapping_matrix→ complex [n_vis, n_dpsi]; stack real/imag rows to match how the interferometer inversion'soperated_mapping_matrixenters the curvature (mirrorautoarray/inversion/inversion/interferometer/abstract.py::operated_mapping_matrix_listexactly).al.FitInterferometer's inversion (operated_mapping_matrix,regularization_matrix) at the smooth starting model, as the imaging fit does withFitImaging.aa.util.fit.noise_normalization_complex_from; χ² over real+imag residuals.PairRegularDpsiMesh(real_space_mask, pixel_scale, factor); δψ regularization via the existingDpsiLinearObjadapter.autolens/potential_correction/iterative.py: dataset seam — replace the imaging-onlypsf.convolved_mapping_matrix_fromupdate andpsf_matrixproperty with a dispatch on dataset type (imaging → PSF matrix path; interferometer →transform_mapping_matrixpath); gauge constraints and LM kernels unchanged.autolens/potential_correction/analysis.py:DpsiInvInterferometerAnalysis/DpsiSrcInvInterferometerAnalysis(or dataset-generic analyses — implementation judgment).autolens/potential_correction/__init__.py+ docs/api page update.interferometer_7fixture family; transformed-response shape/consistency vs directtransformer.visibilities_fromon a δ-function correction.autolens_workspace_testscripts +smoke_tests.txt/env_vars.yamlwiring, mirroring the imaging ones.Key Files
autolens/potential_correction/{fit.py,iterative.py,analysis.py,dense_util.py}— the imaging implementations being extended.autoarray/operators/transformer.py—transform_mapping_matrix(mapping_matrix, xp=np)(DFT + NUFFT variants).autoarray/inversion/inversion/interferometer/abstract.py— the operated-mapping-matrix conventions to mirror.autoarray/fit/fit_util.py::noise_normalization_complex_from— the visibility noise term.Original Prompt
Click to expand starting prompt
Prompt file:
PyAutoMind/active/potential_correction_interferometer.md