feat: visibility-space potential corrections — sparse-operator route (interferometer phase 1)#624
Merged
Conversation
Adds al.pc.FitDpsiSrcInterferometer — the joint source+dpsi inversion of interferometer visibilities — with the sparse-operator (w-tilde) route as the primary implementation (joint curvature via the dataset's InterferometerSparseOperator FFT machinery from extent-indexed COO triplets; data vector via the dirty image; chi2 via one forward NUFFT; scales with real-space pixels, independent of visibility count) and the dense transform_mapping_matrix route as the small-n_vis parity reference. Adds DpsiSrcInvInterferometerAnalysis + docs entries. Sparse route verified identical to the dense route on the interferometer_7 fixture. Phase 1 of #623 (parent epic #618). Ported and extended from Cao et al. 2025 (https://github.com/caoxiaoyue/lensing_potential_correction); cite via https://github.com/caoxiaoyue/potential_correction_paper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 1 of extending the potential-correction (gravitational imaging) subpackage to interferometer data (#623; parent epic #618):
al.pc.FitDpsiSrcInterferometerjointly inverts visibilities for the pixelized source and pixelized potential corrections δψ, plusDpsiSrcInvInterferometerAnalysisfor evidence-based hyper-parameter sampling. This reaches toward the technique's benchmark regime — the JVAS B1938+666 detections (Powell et al. 2025, Nat. Astron. 9, 1714; Vegetti et al. 2026) were made in visibility space.The sparse-operator (w-tilde) route is the primary implementation, per the scaling requirement: the joint curvature
[f | G]ᵀ·(TᴴC⁻¹T)·[f | G](source mapping block f, correction responseG = −D_s·D_ψ) is assembled through the dataset'sInterferometerSparseOperatorFFT machinery from extent-indexed COO triplets — onecurvature_matrix_diag_fromcall over the concatenated blocks — and the data vector against the dirty image, so cost scales with real-space mask pixels, independent of the visibility count. χ² costs a single forward NUFFT of the reconstructed image. The densetransform_mapping_matrixroute (real/imag row-stacked) is retained behinduse_sparse_operator=Falseas the small-n_vis parity reference. Evidence uses the complex-noise normalization (noise_normalization_complex_from) with per-component χ².The δψ mesh builds from the dataset's real-space mask via the existing
PairRegularDpsiMesh; source gradients remain image-plane;dense_util's xp kernels are consumed unchanged (data-agnostic). Requiresdataset.apply_sparse_operator()for the sparse route (loudInversionExceptionotherwise — no silent fallback).Phase 2 (follow-up on #623): the iterative LM engine's interferometer seam and the
autolens_workspace_testscripts (visibility subhalo-recovery regression +jax_likelihood_functions/interferometer/potential_correction.py).Cites Cao et al. 2025 (https://github.com/caoxiaoyue/lensing_potential_correction; cite via https://github.com/caoxiaoyue/potential_correction_paper).
API Changes
Added only — nothing removed or changed:
al.pc.FitDpsiSrcInterferometerandal.pc.DpsiSrcInvInterferometerAnalysis, plus docs entries.See full details below.
Test Plan
interferometer_7fixture (curvature, data vector, evidence — the load-bearing parity), end-to-end finite evidence with correct block shapes, hand-computed dense evidence terms (solution/χ²/noise normalization), and the loud missing-sparse-operator error.test_autolens/potential_correctionsuite: 46 passed.test_autolenssuite run before commit (execution contract).Full API Changes (for automation & release notes)
Added
al.pc.FitDpsiSrcInterferometer(dataset, lens_start, source_start, dpsi_pixelization, src_pixelization, src_image_mesh=None, settings_inversion=None, use_sparse_operator=True, preloads=None)— visibility-space joint source+δψ inversion;log_evidence,solve_src_dpsi,best_fit_source/best_fit_dpsi,model_visibilities, sparse (curvature_matrix_diag_fromw-tilde) and dense (operated_mapping_matrix) routes.al.pc.DpsiSrcInvInterferometerAnalysis(...)—af.Analysiswith the visibility evidence as likelihood (failed inversions → logged −1e8 penalty).docs/api/potential_correction.rstentries for both.Migration
Generated by the PyAutoLabs agent workflow.