Skip to content

feat: oversampled PSF inversion wiring — mapping formalism (phase 2b) #356

Description

@Jammy2211

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

  1. 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.
  2. 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.
  3. 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).
  4. 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.
  5. Memory profile note in the PR (realistic pixelization, s=2), per design §4.

Key Files

  • autoarray/inversion/mappers/abstract.pymapping_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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions