orca.transform.flagging

Flagging transforms for measurement sets.

Provides high-level flagging operations that combine detection and application, including AOFlagger integration and autocorrelation-based antenna flagging.

Functions

flag_with_aoflagger

Run AOFlagger RFI detection on a measurement set.

flag_ants

Flag specified antennas in a measurement set.

flag_ant_chan_from_autocorr

Flag antennas and channels based on autocorrelation anomalies.

flag_on_autocorr

Identify and flag bad antennas from autocorrelation statistics.

identify_bad_ants

Identify bad antennas without applying flags.

save_flag_metadata

Save flag statistics in a compact binary format.

Attributes

log

FLAG_COUNT_FACTOR

Functions

flag_with_aoflagger(→ str)

Run AOFlagger RFI detection on a measurement set.

flag_ants(→ str)

Flag all visibilities involving specified antennas.

flag_ant_chan_from_autocorr(→ str)

Flag antennas and channels based on autocorrelation anomalies.

flag_on_autocorr(→ str)

Identify and flag bad antennas from autocorrelation statistics.

identify_bad_ants(→ List[int])

Identify bad antennas from autocorrelation statistics.

save_flag_metadata(→ str)

Save FLAG column in a compact bit-packed binary format.

Module Contents

orca.transform.flagging.log[source]
orca.transform.flagging.FLAG_COUNT_FACTOR = 10[source]
orca.transform.flagging.flag_with_aoflagger(ms: str, strategy: str = '/opt/share/aoflagger/strategies/nenufar-lite.lua', in_memory: bool = False, n_threads: int = 5) str[source]

Run AOFlagger RFI detection on a measurement set.

Parameters:
  • ms – Path to the measurement set.

  • strategy – Path to the AOFlagger Lua strategy file.

  • in_memory – If True, load data into memory for processing.

  • n_threads – Number of threads for AOFlagger.

Returns:

Path to the flagged measurement set.

Raises:

RuntimeError – If AOFlagger returns a non-zero exit code.

orca.transform.flagging.flag_ants(ms: str, ants: List[int]) str[source]

Flag all visibilities involving specified antennas.

Parameters:
  • ms – Path to the measurement set.

  • ants – List of antenna indices (0-indexed) to flag.

Returns:

Path to the modified measurement set.

orca.transform.flagging.flag_ant_chan_from_autocorr(ms: str, threshold: float = 5.0) str[source]

Flag antennas and channels based on autocorrelation anomalies.

Parameters:
  • ms – Path to the measurement set.

  • threshold – Sigma threshold for outlier detection.

Returns:

Path to the flagged measurement set.

Note

Currently only works on single spectral window data.

orca.transform.flagging.flag_on_autocorr(ms, date: datetime.date | None = None, thresh: float = 7.0, column='DATA') str[source]

Identify and flag bad antennas from autocorrelation statistics.

Optionally loads a priori bad antenna list for the given date before performing autocorrelation-based detection.

Parameters:
  • ms – Path to the measurement set.

  • date – Observation date for loading a priori bad antennas.

  • thresh – Sigma threshold for flagging (default 7.0).

  • column – Data column to analyze (‘DATA’ or ‘CORRECTED_DATA’).

Returns:

Path to the flagged measurement set.

orca.transform.flagging.identify_bad_ants(t: casacore.tables.table, thresh: float = 7, column='DATA') List[int][source]

Identify bad antennas from autocorrelation statistics.

Compares each antenna’s autocorrelation bandpass to a median template for core and outrigger antennas separately. Antennas with normalized deviations exceeding the threshold are flagged.

Parameters:
  • t – Open casacore table object for the measurement set.

  • thresh – Sigma threshold for flagging (default 7.0).

  • column – Data column to analyze (‘DATA’ or ‘CORRECTED_DATA’).

Returns:

List of antenna indices identified as bad.

Raises:

AssertionError – If data contains multiple timestamps or spectral windows.

orca.transform.flagging.save_flag_metadata(ms: str, output_dir: str = '/lustre/pipeline/slow-averaged/') str[source]

Save FLAG column in a compact bit-packed binary format.

Creates a binary file containing the packed flag data, which can be unpacked later using numpy.unpackbits().

Parameters:
  • ms – Path to the measurement set.

  • output_dir – Directory for output file.

Returns:

Path to the measurement set (unchanged).