Command line — aostats

aostats groups four commands for inspecting AOQuality statistics:

aostats [plot | plot-grid | find-bad-obs | find-bad-stations] --help

Every command accepts paths that the readers understand — a Measurement Set, a directory, or a .qs file.

plot — single-MS diagnostic plots

aostats plot obs.MS SNR -o stat_snr

Produces time–frequency, baseline–frequency, and frequency-summary plots for one observation.

plot-grid — multi-observation grids

Compares a statistic across many observations at once, producing three PNGs: frequency × observation, antenna × observation, and LST × observation.

aostats plot-grid obs_20231208/ obs_20231210/ obs_20231212/ SNR --out-dir plots/ --name dec2023

One row per observation; labels default to the date inferred from each path (override with --label).

find-bad-obs — flag bad MS time chunks

Detects anomalous time chunks across a set of MS files by fitting a robust LST trend to the chosen statistic and sigma-clipping the residuals — useful for spotting bad scans before stacking.

aostats find-bad-obs ms_list.txt SNR --out-dir qa/ --name night1

The input is one or more text files listing MS paths (one per line). It writes the flagged MS list, a per-MS score table, and raw/residual diagnostic plots.

find-bad-stations — detect bad antennas per observation

Loads one combined .qs file per observation, computes per-antenna statistics, and sigma-clips across antennas within each observation to flag outliers. The JSON output is ready for nenudata bad-stations import.

aostats find-bad-stations quality_l2_cal/20231208_CYGA/combined.qs SNR -o bad_stations_cal.json

When a path’s basename starts with combined, the observation label is inferred from the parent directory (e.g. 20231208_CYGA). It works equally on calibrator or target QS files.

Reference

aostats

Usage

aostats [OPTIONS] COMMAND [ARGS]...

Options

--version

Show the version and exit.

find-bad-obs

Flag bad MS chunks via LST-trend detrending and sigma-clipping.

MS_LISTS: text files listing MS paths (one per line). STAT_NAME: statistic used for scoring.

Usage

aostats find-bad-obs [OPTIONS] MS_LISTS... {mean|std|dstd|count|dcount|sum|dsu
                     m|dsump2|variance|dvariance|snr|rficount|rfipercentage}

Options

--longitude <longitude>

Observer longitude [deg East] for LST calculation

Default:

2.1924

--reducer <reducer>

Collapse within-MS time axis to a scalar

Default:

'mean'

Options:

mean | median

--window-h <window_h>

LST window [hours] for the robust running trend

Default:

1.0

--min-pts <min_pts>

Minimum neighbours per trend estimate

Default:

25

--nsigma <nsigma>

Sigma-clipping threshold

Default:

3.0

--clip-iters <clip_iters>

Maximum sigma-clipping iterations

Default:

5

--log-resid, --linear-resid

Use log10 residuals (default) or linear residuals

Default:

True

-o, --out-dir <out_dir>
Default:

'.'

-n, --name <name>

Output filename tag

Default:

'run'

Arguments

MS_LISTS

Required argument(s)

STAT_NAME

Required argument

find-bad-stations

Per-observation bad antenna detection via cross-antenna sigma-clipping.

Loads one combined QS file per calibration observation, computes per-antenna statistics, sigma-clips across antennas within each observation, and writes a JSON file mapping obs_label -> [bad_antenna_names].

Use “nenudata apply-bad-antennas” to propagate results to target observations.

QS_FILES: one combined .qs path per calibration observation. STAT_NAME: statistic to use (e.g. SNR).

Usage

aostats find-bad-stations [OPTIONS] QS_FILES... {mean|std|dstd|count|dcount|su
                          m|dsum|dsump2|variance|dvariance|snr|rficount|rfiper
                          centage}

Options

-o, --out <out>

Output JSON file

Default:

'bad_antennas.json'

--nsigma <nsigma>

Sigma-clipping threshold (per-obs, across antennas)

Default:

3.0

--maxiters <maxiters>

Maximum sigma-clipping iterations

Default:

10

--core-only, --all-antennas

Core antennas only (MR0xx) or include remote

Default:

True

-l, --label <labels>

Obs label per QS file (default: inferred from path)

Arguments

QS_FILES

Required argument(s)

STAT_NAME

Required argument

plot

Plot Statistics from AO Quality Tables

MS_FILES: Input MS files STAT_NAME: Statistic Name

Usage

aostats plot [OPTIONS] MS_FILES... {mean|std|dstd|count|dcount|sum|dsum|dsump2
             |variance|dvariance|snr|rficount|rfipercentage}

Options

-o, --out_prefix <out_prefix>

Prefix to the output filename

Default:

'stat'

-p, --pol <pol>

Polarization index: 0->XX, 1->XY, 2->YX, 3->YY

Default:

0

--log

Plot in log scale

--vmin <vmin>

Minimum value

--vmax <vmax>

Maximum value

--name <name>

Title of the plot

Arguments

MS_FILES

Required argument(s)

STAT_NAME

Required argument

plot-grid

Multi-observation grid plots: freq x obs, antenna x obs, LST x obs.

QS_FILES: one .qs (or MS) path per observation. STAT_NAME: statistic to plot.

Usage

aostats plot-grid [OPTIONS] QS_FILES... {mean|std|dstd|count|dcount|sum|dsum|d
                  sump2|variance|dvariance|snr|rficount|rfipercentage}

Options

-o, --out-dir <out_dir>

Output directory

Default:

'.'

-n, --name <name>

Output filename prefix

Default:

'grid'

-l, --label <labels>

Row label per QS file (default: date extracted from path)

--longitude <longitude>

Observer longitude [deg East] for LST calculation

Default:

2.1924

--lst-step <lst_step>

LST bin size [seconds] for the time grid

Default:

4.0

Arguments

QS_FILES

Required argument(s)

STAT_NAME

Required argument