orca.transform.hot_baselines

Hot-baseline and amplitude-vs-UV diagnostics.

Ported from the standalone hot_baseline_worker.py script into the orca package so that the Celery pipeline does not depend on preliminary_pipeline/.

The main entry point is run_diagnostics(), which is called by the Phase-2 Celery task when hot_baselines=True.

Attributes

logger

Functions

extract_ant_number(name)

Extract the integer antenna number from a name like 'LWA-042'.

get_ms_id_map(→ Dict[int, int])

Map LWA antenna numbers to MS row indices from the ANTENNA sub-table.

build_complete_map(→ pandas.DataFrame)

Build a DataFrame mapping correlator numbers to hardware info.

get_antenna_positions(→ numpy.ndarray)

Read ECEF antenna positions from the MS.

get_mean_frequency(→ float)

Read the mean frequency from the SPECTRAL_WINDOW sub-table.

get_data_matrix(→ Tuple[Dict[str, numpy.ndarray], ...)

Compute per-baseline mean and std amplitude matrices from an MS.

apply_uv_cut(→ numpy.ndarray)

Blank baselines shorter than uv_cut_m metres.

analyze_amp_vs_uv(→ List[Tuple[int, int]])

Identify outlier baselines from amplitude-vs-UV-distance scatter.

identify_bad_components(→ Tuple[List[Tuple[int, int]], ...)

Find hot baselines and bad antennas from the cross-pol heatmap.

apply_flags_to_ms(→ None)

Flag bad antennas and baselines in the MS FLAG column.

plot_heatmap(→ None)

Save a single heatmap as a PNG.

plot_diagnosis_figure(→ None)

Save a two-panel diagnosis heatmap with overlays.

run_diagnostics(→ None)

Run the full hot-baseline analysis on a concatenated MS.

Module Contents

orca.transform.hot_baselines.logger[source]
orca.transform.hot_baselines.extract_ant_number(name)[source]

Extract the integer antenna number from a name like ‘LWA-042’.

orca.transform.hot_baselines.get_ms_id_map(ms_name: str) Dict[int, int][source]

Map LWA antenna numbers to MS row indices from the ANTENNA sub-table.

orca.transform.hot_baselines.build_complete_map(ms_id_map: Dict[int, int]) pandas.DataFrame[source]

Build a DataFrame mapping correlator numbers to hardware info.

Uses corr_num directly from SYSTEM_CONFIG (verified against the wiring spreadsheet) rather than inferring it from MS ANTENNA table row indices. ms_id_map is still used to verify which antennas are present in the MS.

orca.transform.hot_baselines.get_antenna_positions(ms_name: str) numpy.ndarray[source]

Read ECEF antenna positions from the MS.

orca.transform.hot_baselines.get_mean_frequency(ms_name: str) float[source]

Read the mean frequency from the SPECTRAL_WINDOW sub-table.

orca.transform.hot_baselines.get_data_matrix(ms_name: str, data_col: str = 'CORRECTED_DATA') Tuple[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray], int][source]

Compute per-baseline mean and std amplitude matrices from an MS.

Reads in chunks for memory efficiency.

Returns:

(mean_matrices, std_matrices, n_ant) — dicts keyed by pol name.

orca.transform.hot_baselines.apply_uv_cut(matrix: numpy.ndarray, pos_array: numpy.ndarray, uv_cut_m: float) numpy.ndarray[source]

Blank baselines shorter than uv_cut_m metres.

orca.transform.hot_baselines.analyze_amp_vs_uv(raw_mean: Dict[str, numpy.ndarray], pos_array: numpy.ndarray, n_ant: int, mean_freq: float | None = None, sigma_cut: float = 5.0, plot_prefix: str = 'amp_vs_uv') List[Tuple[int, int]][source]

Identify outlier baselines from amplitude-vs-UV-distance scatter.

Uses a rolling-median envelope to detect baselines whose amplitude exceeds sigma_cut MADs above the local median.

Returns:

List of (ant1, ant2) tuples for bad baselines.

orca.transform.hot_baselines.identify_bad_components(combined_matrix: numpy.ndarray, df_map: pandas.DataFrame, n_ant: int, extra_bad_baselines: List[Tuple[int, int]] | None = None, sigma_cut: float = 5.0, threshold_percent: float = 0.1) Tuple[List[Tuple[int, int]], Set[int], List[str]][source]

Find hot baselines and bad antennas from the cross-pol heatmap.

Returns:

(heatmap_bad_baselines, bad_antennas, report_lines).

orca.transform.hot_baselines.apply_flags_to_ms(ms_name: str, bad_antennas: Set[int], bad_baselines: List[Tuple[int, int]]) None[source]

Flag bad antennas and baselines in the MS FLAG column.

orca.transform.hot_baselines.plot_heatmap(matrix: numpy.ndarray, title: str, filename: str, vmin: float | None = None, vmax: float | None = None, grid_lines: List[float] | None = None, axis_ticks: numpy.ndarray | None = None, axis_labels: numpy.ndarray | None = None) None[source]

Save a single heatmap as a PNG.

orca.transform.hot_baselines.plot_diagnosis_figure(matrix: numpy.ndarray, bad_antennas: Set[int], bad_baselines: List[Tuple[int, int]], filename: str, uv_baselines: List[Tuple[int, int]] | None = None) None[source]

Save a two-panel diagnosis heatmap with overlays.

orca.transform.hot_baselines.run_diagnostics(args_obj, run_logger=None) None[source]

Run the full hot-baseline analysis on a concatenated MS.

Parameters:
  • args_obj – Object with attributes ms, col, uv_cut, uv_cut_lambda, sigma, uv_sigma, threshold, apply_antenna_flags, apply_baseline_flags, run_uv, run_heatmap.

  • run_logger – Optional logger; defaults to module logger.