orca.utils.flagutils

Flag file utilities for antenna and visibility flagging.

Provides functions for reading and writing flag data, looking up bad antennas from the flag database, and visualizing flag statistics.

Attributes

FLAG_TABLE

df

Functions

get_bad_ants(date[, sources])

Return a list of bad antennas for a given date and kinds of flags.

unpack_flag_metadata(→ numpy.ndarray)

Unpacks binary flag metadata from a packed binary file into its original FLAG column shape.

plot_flag_metadata_all_polarizations_subplot(→ None)

Plots the flag metadata for all polarizations in a single subplot figure.

get_bad_antenna_names(date_time_str)

Get a list of bad antenna names (e.g., 'LWA-005B') using the 'development' conda environment.

get_bad_correlator_numbers(date_time_str)

Module Contents

orca.utils.flagutils.FLAG_TABLE = '/opt/devel/yuping/ant_flags.csv'[source]
orca.utils.flagutils.df[source]
orca.utils.flagutils.get_bad_ants(date: datetime.date, sources=['AI-VAR', 'AI-LO'])[source]

Return a list of bad antennas for a given date and kinds of flags.

Parameters:
  • date – The date

  • sources – Sources of flags. Default is [‘AI-VAR’, ‘AI-LO’].

Returns:

A list of bad antenna corr numbers.

orca.utils.flagutils.unpack_flag_metadata(input_file: str, original_shape: tuple) numpy.ndarray[source]

Unpacks binary flag metadata from a packed binary file into its original FLAG column shape.

Parameters:

input_filestr

Path to the binary file containing the packed flag data.

original_shapetuple

The shape of the original FLAG array (e.g., (polarizations, channels, rows)).

Returns:

np.ndarray

A Boolean array of the same shape as the original FLAG column.

orca.utils.flagutils.plot_flag_metadata_all_polarizations_subplot(flags: numpy.ndarray, output_dir: str = None) None[source]

Plots the flag metadata for all polarizations in a single subplot figure.

Parameters:

flagsnp.ndarray

A Boolean array of shape (polarizations, channels, rows) representing the flag data.

output_dirstr, optional

Directory where the plot will be saved. If None, the plot is displayed interactively.

orca.utils.flagutils.get_bad_antenna_names(date_time_str)[source]

Get a list of bad antenna names (e.g., ‘LWA-005B’) using the ‘development’ conda environment.

Parameters:

date_time_str (str) – Date and time string in ISO format, e.g. ‘2025-01-28 19:20:04’

Returns:

List of bad antenna names

Return type:

list

orca.utils.flagutils.get_bad_correlator_numbers(date_time_str)[source]