Python API

Statistic readers

class aoquality.BaselineStat(ms_file, verbose=True)[source]

Bases: BaseAOQuality

AO quality baseline statistics

ant1

Antenna 1

Type:

array of int

ant2

Antenna 2

Type:

array of int

ant_name

Name of the stations

Type:

array of str

ant_pos

Positions of the stations

Type:

array

blenght

Baseline length in meter

Type:

array

get_combined_stat(stat_name, action_fct=<function nanmedian>)[source]
Return combined statistics applying action_fct over the frequency axis.

Useful when gathering statistics from combined QUALITY tables, but safe to use for non combined QUALITY tables as well: it will be a no-op in this case.

Parameters:
  • stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

  • action_fct (fct, optional) – The function to apply over the frequency axis

Returns:

ant1 (n_baselines), ant2 (n_baselines), blenght (n_baselines), stat (n_baselines, n_pol)

get_antenna_stat(stat_name, reducer=<function nanmedian>)[source]

Per-antenna summary statistic aggregated from cross-baselines.

Parameters:
  • stat_name (str) – Statistic name. See aoquality.available_stats.

  • reducer (callable) – Applied over matching baselines per antenna (default: nanmedian).

Returns:

Station names. ant_stats (n_ant, n_pol): Reduced statistic per antenna and polarisation.

Return type:

ant_names (n_ant,)

plot_baseline_stats(stat_name, pol=0, flag_autocorr=True, log=False, vmin=None, vmax=None, name='')[source]

Plot 2D matrix of baselines statistics

Parameters:
  • stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

  • pol (int, optional) – The polarization to plot: 0:XX, 1:XY, 2:YX, 3:YY

Returns:

the matplotlib figure

Return type:

Figure

plot_antennae_stats(stat_name, pol=0, log=False, vmin=None, vmax=None, name='')[source]

Plot the statistic for each individual antennae/station

Parameters:
  • stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

  • pol (int, optional) – The polarization to plot: 0:XX, 1:XY, 2:YX, 3:YY

Returns:

the matplotlib figure

Return type:

Figure

plot_baseline_length_stats(stat_name, pol=0, log=False, vmin=None, vmax=None, name='')[source]

Plot the statistic for each baselines as function of baseline length

Parameters:
  • stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

  • pol (int, optional) – The polarization to plot: 0:XX, 1:XY, 2:YX, 3:YY

Returns:

the matplotlib figure

Return type:

Figure

class aoquality.FrequencyStat(ms_file, verbose=True)[source]

Bases: BaseAOQuality

AO quality frequency statistics

freqs

Frequencies

Type:

array

get_combined_stat(stat_name, action_fct=<function nanmedian>)[source]
Return combined statistics applying action_fct over the frequency axis.

Useful when gathering statistics from combined QUALITY tables, but safe to use for non combined QUALITY tables as well: it will be a no-op in this case.

Parameters:
  • stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

  • action_fct (fct, optional) – The function to apply over the frequency axis

Returns:

freqs (n_freqs,) and stat (n_freqs, n_pol).

Return type:

tuple

plot_freq_stats(stat_name, pol=0, log=False, vmin=None, vmax=None, name='')[source]

Plot frequency statistics

Parameters:
  • stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

  • pol (int, optional) – The polarization to plot: 0:XX, 1:XY, 2:YX, 3:YY

Returns:

the matplotlib figure

Return type:

Figure

class aoquality.TimeStat(ms_file, verbose=True)[source]

Bases: BaseAOQuality

AO quality time statistics

time

Time

Type:

array

get_combined_stat(stat_name)[source]
Return combined statistics.

Useful when gathering statistics from combined QUALITY tables

Parameters:

stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

Returns:

time (n_time), freqs (n_freqs), stat (n_freqs, n_time, n_pol)

plot_time_stats(stat_name, pol=0, log=False, vmin=None, vmax=None, name='')[source]

Plot time statistics

Parameters:
  • stat_name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

  • pol (int, optional) – The polarization to plot: 0:XX, 1:XY, 2:YX, 3:YY

Returns:

the matplotlib figure

Return type:

Figure

Combined reader

class aoquality.AOQuality(ms_files, verbose=True)[source]

Load all three quality statistic types from one or more Measurement Sets.

baseline
Type:

BaselineStat

frequency
Type:

FrequencyStat

time
Type:

TimeStat

classmethod from_ms(ms_file, verbose=True)[source]

Load quality statistics from a single MS or .qs file.

classmethod from_ms_list(ms_files, verbose=True)[source]

Load and combine quality statistics from a list of MS or .qs files.

Shared base class

The three readers inherit the derived statistics (Mean, Std, SNR, RFIPercentage, …) and the combining helpers from this base class.

class aoquality.BaseAOQuality(ms_file, kind=[], value=[], verbose=True)[source]

Base reader for AOQuality statistics stored in a Measurement Set.

Reads the QUALITY_KIND_NAME table and exposes every statistic listed in available_stats — either directly from the table or as a derived property (Mean, Std, SNR, RFIPercentage, …). Subclasses (BaselineStat, FrequencyStat, TimeStat) add the relevant axis (baseline, frequency, or time).

classmethod from_ms_list(ms_files, verbose=True)[source]

Read and combine the statistics from several Measurement Sets.

Parameters:
  • ms_files (list of str) – Paths to the Measurement Sets (or .qs files).

  • verbose (bool, optional) – Print each file being opened.

Returns:

A single reader holding the concatenated statistics.

Return type:

BaseAOQuality

property Std

Standard deviation of the visibilities

property Variance

Variance of the visibilities

property DStd

Standard deviation of the channels difference visibilities

property DVariance

Variance of the channels difference visibilities

property Mean

Mean of the visibilities

property SNR

Mean of the visibilities over rms of the channel difference’s visibilities

property RFIPercentage

Percentage of RFI flagged data

get_stat(name)[source]

Return the given statistic.

Parameters:

name (str) – The statistic to retrieve. See aoquality.available_stats for a list of available statistics

Module-level helpers

aoquality.make_ant_matrix(ant1, ant2, m, a_max=None)[source]

Make antenna x antenna matrix from flat array

Parameters:
  • ant1 (array) – Antenna 1

  • ant2 (array) – Antenna 2

  • m (array) – Flat array

  • a_max (int, optional) – Max antenna number

Returns:

antenna x antenna matrix

Return type:

array (n_ant, n_ant)

Two module-level constants are also exported:

  • aoquality.available_stats — the list of statistic names that can be requested ('SNR', 'RFIPercentage', 'Std', 'Mean', …).

  • aoquality.pol_dict — mapping of polarisation index (0-3) to its name (XX, XY, YX, YY).