Skip to content

fix: guard sparse interferometer operator against unequal real/imag noise sigma #502

Description

@Jammy2211

Overview

InterferometerSparseOperator builds W~ = Re(FᴴWF) from a single precision operator computed with noise_map.real only (dataset.py:362). That is exact only when every visibility has equal real and imaginary sigma. With unequal sigmas the sparse InversionInterferometerSparse curvature matrix silently disagrees with the dense path (5e-16 → 5e-10..3e-2 relative, geometry dependent), on the single-mapper route too. Simulated and real datasets satisfy the equality, so it is latent — but nothing guards it. Found during #499/#500.

Plan

  • Raise a clear DatasetException from Interferometer.apply_sparse_operator when any visibility has unequal real/imag sigma, naming the cause and the dense-path workaround.
  • Unit test: unequal sigma raises; equal, non-uniform sigma passes.
  • Docstring notes on apply_sparse_operator and InterferometerSparseOperator.
  • Assess (in the PR, no implementation) whether a general two-operator extension is worth doing.
Detailed implementation plan

Affected Repositories

  • PyAutoArray (primary)

Branch Survey

Repository Current Branch Dirty?
./PyAutoArray main clean (parallel worktree alongside numba-cpu-nnls-iteration-reduction — disjoint files)

Suggested branch: feature/sparse-interferometer-unequal-sigma-guard

Implementation Steps

  1. autoarray/dataset/interferometer/dataset.py — at the top of apply_sparse_operator, if not np.allclose(self.noise_map.real, self.noise_map.imag): raise exc.DatasetException(...) with a message stating the W~ operator is built from the real-part sigma only and requires sigma_real == sigma_imag per visibility; suggest not calling apply_sparse_operator (dense mapping path) or equalising the sigmas.
  2. Same file / inversion_interferometer_util.py — docstring notes on the precondition.
  3. test_autoarray/dataset/interferometer/test_dataset.py — test__apply_sparse_operator__unequal_real_imag_noise_raises and an equal-but-non-uniform sigma control that succeeds.
  4. PR body: short assessment of the two-operator generalisation (real- and imag-weighted precision operators combined in apply_operator).

Key Files

  • autoarray/dataset/interferometer/dataset.py — guard + docstring
  • test_autoarray/dataset/interferometer/test_dataset.py — tests

Original Prompt

Click to expand starting prompt

Sparse interferometer W~ path silently assumes equal real/imag noise sigma

Type: bug
Target: PyAutoArray
Repos:

  • PyAutoArray
  • workspaces
    Difficulty: medium
    Autonomy: supervised
    Priority: normal
    Status: formalised

Sparse interferometer W~ path silently assumes equal real/imag noise sigma

Type: bug
Target: PyAutoArray
Repos:

  • PyAutoArray
    Difficulty: medium
    Autonomy: supervised
    Priority: normal

Problem

InterferometerSparseOperator builds the real-space operator W~ = Re(F^H W F) from a single
NUFFT precision operator. That reduction is only exact when every visibility has equal real and
imaginary noise sigma. With sigma_real != sigma_imag the sparse InversionInterferometerSparse
curvature matrix disagrees with the dense InversionInterferometerMapping path even on the
single-mapper route: measured 5e-16 relative with equal sigmas vs 5e-10 to 3e-2 with unequal
sigmas (geometry dependent). Pre-existing, not introduced by #500. SimulatorInterferometer and
real datasets satisfy the equality, so it is latent — but nothing guards it.

Fix

  1. Raise a clear InversionException (or in Interferometer.apply_sparse_operator) when the noise
    map has unequal real/imag sigma for any visibility, with a unit test. Do this first.
  2. Assess extending the operator to the general case (two precision operators, real- and
    imag-weighted, combined in apply_operator) — only if the cost is modest; otherwise the guard stands.

Context

Found 2026-08-28 while shipping #499 / #500. The misc/jax_assertions/fit_interferometer_sparse_operator.py parity
scripts in both test workspaces document the limitation in their
docstrings and deliberately use equal-sigma noise maps; they need no change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions