Skip to content

fix(calibration): fail safe on ambiguous bad-pol MS coherence - #132

Draft
jakobtfaber wants to merge 1 commit into
mainfrom
agent/bad-pol-baseline-coherence
Draft

fix(calibration): fail safe on ambiguous bad-pol MS coherence#132
jakobtfaber wants to merge 1 commit into
mainfrom
agent/bad-pol-baseline-coherence

Conversation

@jakobtfaber

Copy link
Copy Markdown
Contributor

Summary

The MS-coherence fallback for single-polarization failure detection could assign the clean receptor label under amplitude-imbalanced failures. Real-MS validation showed two contributing problems:

  1. casa_tables returns visibility cells as (rows, correlations, channels), but the fallback treated them as (rows, channels, correlations), so frequency channels were being analyzed as polarization indices.
  2. A raw coherence ratio is not reliable when receptor amplitudes differ substantially or both receptors have very low absolute coherence.

This change corrects the axis handling, computes phase coherence per baseline, and makes the fallback abstain when it cannot safely label a receptor. The phase-table path remains the required method for amplitude-imbalanced antennas.

Changes

  • Read the real MS layout as (n_rows, n_pol, n_chan).
  • Compute unit-phasor coherence per baseline and use the median across baselines.
  • Record median receptor amplitudes and skip MS labeling at a 2x or greater amplitude ratio.
  • Require at least one receptor to reach 0.5 coherence before applying a ratio-based label.
  • Return amplitude_imbalanced_antennas so callers can identify antennas requiring phase-table analysis.
  • Update mocks to use CASA's real axis order and add 2x, 3x, and 10x imbalance regressions.
  • Convert the real-MS smoke test from label-agnostic flagging to a fail-safe no-flag assertion.

Validation

  • tests/test_detect_bad_polarizations.py tests/test_run_pre_calibration_flagging.py: 17 passed.
  • tests/test_bad_pol_wiring_smoke.py --run-slow: 1 passed against a generated UVH5 converted to a real CASA MS.
  • ruff check on the three changed files: passed.
  • Targeted git diff --check: passed.

Closes #73.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad-pol detection (MS-coherence path): pol-label can invert under amplitude-imbalanced single-pol failure

1 participant