Overview
Phase 2b of oversampled PSF convolution: wire the phase-2a Convolver API (#354, PR #355) into the inversion's mapping formalism, per §4 of the approved design (PyAutoMind/feature/autoarray/oversampling_design.md, approved in #353). Blocked until PR #355 merges — it builds directly on the 2a API.
Plan
- Add
Mapper.mapping_matrix_over_sampled: one row per sub-pixel, no sub_fraction fold (the existing mapping_matrix folds sub-pixels to image resolution before the Convolver ever sees them, which is exactly what oversampled convolution must intercept).
- Route
AbstractInversionImaging.operated_mapping_matrix_list (autoarray/inversion/inversion/imaging/abstract.py:104-116 — the actual PSF application site; mapping.py itself needs no logic change) through the oversampled Convolver path when psf.convolve_over_sample_size > 1.
- Loud guards on the two paths that consume
psf.kernel.native directly and cannot support oversampling yet: InversionImagingSparse.psf_weighted_data and the preloaded linear-func operated matrices (abstract.py:215-230).
- Memory profile of the ×s² FFT cube (
(ny·s, nx·s, n_src)) on a realistic pixelization before anything defaults on — the main risk flagged in the design; chunking is the noted mitigation.
Detailed implementation plan
Affected Repositories
- PyAutoArray (primary, only repo edited)
Branch Survey
Deferred to start (task is blocked on PR #355; survey ages out).
Suggested branch: feature/psf-oversample-inversion
Implementation Steps
inversion/mappers/abstract.py: mapping_matrix_over_sampled property reusing the existing sub→pix index maps (slim_for_sub_slim), emitting shape (n_unmasked·s², n_src) in per-pixel sub-block order — the 2a Convolver input format.
inversion/inversion/imaging/abstract.py::operated_mapping_matrix_list: when self.psf.convolve_over_sample_size > 1, pass linear_obj.mapping_matrix_over_sampled to psf.convolved_mapping_matrix_from (which already handles the fine-grid scatter/convolve/bin from 2a); otherwise unchanged.
- Guards:
InversionImagingSparse.psf_weighted_data and the linear-func kernel consumers raise InversionException/DatasetException when the psf is oversampled (deferred formalism, per the approved design).
- Tests (numpy-only): delta-kernel identity (
mapping_matrix_over_sampled binned by mean == mapping_matrix); end-to-end mapping-formalism inversion at s=2 against a brute-force reference built from the ground-truth machinery; guard tests; full suite.
- Memory profile note in the PR (realistic pixelization, s=2), per design §4.
Key Files
autoarray/inversion/mappers/abstract.py — mapping_matrix (sub_fraction fold) at lines 255–275
autoarray/inversion/inversion/imaging/abstract.py — PSF application + linear-func preloads
autoarray/inversion/inversion/imaging/sparse.py — guard target
PyAutoMind/feature/autoarray/oversampling_design.md §4 — the approved design (do not re-design)
Acceptance
- Full PyAutoArray pytest suite green; s=1 inversions byte-identical.
- s=2 mapping-formalism inversion matches the brute-force reference.
- Memory profile recorded in the PR body.
Original Prompt
Click to expand starting prompt
See PyAutoMind/issued/oversampling_phase_2b_inversion_wiring.md (phase 2b split of oversampling_phase_2_core_api.md; design approved in #353; predecessor #354 / PR #355).
Overview
Phase 2b of oversampled PSF convolution: wire the phase-2a Convolver API (#354, PR #355) into the inversion's mapping formalism, per §4 of the approved design (
PyAutoMind/feature/autoarray/oversampling_design.md, approved in #353). Blocked until PR #355 merges — it builds directly on the 2a API.Plan
Mapper.mapping_matrix_over_sampled: one row per sub-pixel, nosub_fractionfold (the existingmapping_matrixfolds sub-pixels to image resolution before the Convolver ever sees them, which is exactly what oversampled convolution must intercept).AbstractInversionImaging.operated_mapping_matrix_list(autoarray/inversion/inversion/imaging/abstract.py:104-116— the actual PSF application site;mapping.pyitself needs no logic change) through the oversampled Convolver path whenpsf.convolve_over_sample_size > 1.psf.kernel.nativedirectly and cannot support oversampling yet:InversionImagingSparse.psf_weighted_dataand the preloaded linear-func operated matrices (abstract.py:215-230).(ny·s, nx·s, n_src)) on a realistic pixelization before anything defaults on — the main risk flagged in the design; chunking is the noted mitigation.Detailed implementation plan
Affected Repositories
Branch Survey
Deferred to start (task is blocked on PR #355; survey ages out).
Suggested branch:
feature/psf-oversample-inversionImplementation Steps
inversion/mappers/abstract.py:mapping_matrix_over_sampledproperty reusing the existing sub→pix index maps (slim_for_sub_slim), emitting shape(n_unmasked·s², n_src)in per-pixel sub-block order — the 2a Convolver input format.inversion/inversion/imaging/abstract.py::operated_mapping_matrix_list: whenself.psf.convolve_over_sample_size > 1, passlinear_obj.mapping_matrix_over_sampledtopsf.convolved_mapping_matrix_from(which already handles the fine-grid scatter/convolve/bin from 2a); otherwise unchanged.InversionImagingSparse.psf_weighted_dataand the linear-func kernel consumers raiseInversionException/DatasetExceptionwhen the psf is oversampled (deferred formalism, per the approved design).mapping_matrix_over_sampledbinned by mean ==mapping_matrix); end-to-end mapping-formalism inversion at s=2 against a brute-force reference built from the ground-truth machinery; guard tests; full suite.Key Files
autoarray/inversion/mappers/abstract.py—mapping_matrix(sub_fraction fold) at lines 255–275autoarray/inversion/inversion/imaging/abstract.py— PSF application + linear-func preloadsautoarray/inversion/inversion/imaging/sparse.py— guard targetPyAutoMind/feature/autoarray/oversampling_design.md§4 — the approved design (do not re-design)Acceptance
Original Prompt
Click to expand starting prompt
See
PyAutoMind/issued/oversampling_phase_2b_inversion_wiring.md(phase 2b split ofoversampling_phase_2_core_api.md; design approved in #353; predecessor #354 / PR #355).