Nightly Per-Antenna Quality Summary Notebook¶

Josh Dillon, Last Revised February 2021

This notebooks brings together as much information as possible from ant_metrics, auto_metrics and redcal to help figure out which antennas are working properly and summarizes it in a single giant table. It is meant to be lightweight and re-run as often as necessary over the night, so it can be run when any of those is done and then be updated when another one completes.

In [1]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
pd.set_option('display.max_rows', 1000)
from hera_qm.metrics_io import load_metric_file
from hera_cal import utils, io, redcal
import glob
import os
import h5py
from copy import deepcopy
from IPython.display import display, HTML
from hera_notebook_templates.utils import status_colors

%matplotlib inline
%config InlineBackend.figure_format = 'retina'
display(HTML("<style>.container { width:100% !important; }</style>"))
In [2]:
# If you want to run this notebook locally, copy the output of the next cell into the first few lines of this cell.

# JD = "2459122"
# data_path = '/lustre/aoc/projects/hera/H4C/2459122'
# ant_metrics_ext = ".ant_metrics.hdf5"
# redcal_ext = ".maybe_good.omni.calfits"
# nb_outdir = '/lustre/aoc/projects/hera/H4C/h4c_software/H4C_Notebooks/_rtp_summary_'
# os.environ["JULIANDATE"] = JD
# os.environ["DATA_PATH"] = data_path
# os.environ["ANT_METRICS_EXT"] = ant_metrics_ext
# os.environ["REDCAL_EXT"] = redcal_ext
# os.environ["NB_OUTDIR"] = nb_outdir
In [3]:
# Use environment variables to figure out path to data
JD = os.environ['JULIANDATE']
data_path = os.environ['DATA_PATH']
ant_metrics_ext = os.environ['ANT_METRICS_EXT']
redcal_ext = os.environ['REDCAL_EXT']
nb_outdir = os.environ['NB_OUTDIR']
print(f'JD = "{JD}"')
print(f'data_path = "{data_path}"')
print(f'ant_metrics_ext = "{ant_metrics_ext}"')
print(f'redcal_ext = "{redcal_ext}"')
print(f'nb_outdir = "{nb_outdir}"')
JD = "2459740"
data_path = "/mnt/sn1/2459740"
ant_metrics_ext = ".ant_metrics.hdf5"
redcal_ext = ".known_good.omni.calfits"
nb_outdir = "/home/obs/src/H5C_Notebooks/_rtp_summary_"
In [4]:
from astropy.time import Time
utc = Time(JD, format='jd').datetime
print(f'Date: {utc.month}-{utc.day}-{utc.year}')
Date: 6-9-2022
In [5]:
# Per-season options
def ant_to_report_url(ant):
    return f'https://htmlpreview.github.io/?https://github.com/HERA-Team/H5C_Notebooks/blob/main/antenna_report/antenna_{ant}_report.html'

Load Auto Metrics¶

In [6]:
use_auto_metrics = False

# find the auto_metrics file
glob_str = os.path.join(data_path, f'zen.{JD}*.auto_metrics.h5')
auto_metrics_file = sorted(glob.glob(glob_str))

# if it exists, load and extract relevant information
if len(auto_metrics_file) > 0:
    auto_metrics_file = auto_metrics_file[0]
    print(f'Found auto_metrics results file at {auto_metrics_file}.')
    
    auto_metrics = load_metric_file(auto_metrics_file)
    mean_round_modz_cut = auto_metrics['parameters']['mean_round_modz_cut']
    auto_ex_ants = auto_metrics['ex_ants']['r2_ex_ants']
    
    use_auto_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping auto_metrics.')
Found auto_metrics results file at /mnt/sn1/2459740/zen.2459740.25297.sum.auto_metrics.h5.

Load Ant Metrics¶

In [7]:
use_ant_metrics = False

# get a list of all ant_metrics files
glob_str = os.path.join(data_path, f'zen.{JD}.?????.sum{ant_metrics_ext}')
ant_metrics_files = sorted(glob.glob(glob_str))

# if they exist, load as many of them as possible
if len(ant_metrics_files) > 0:
    print(f'Found {len(ant_metrics_files)} ant_metrics files matching glob {glob_str}')
    ant_metrics_apriori_exants = {}
    ant_metrics_xants_dict = {}
    ant_metrics_dead_ants_dict = {}
    ant_metrics_crossed_ants_dict = {}
    ant_metrics_dead_metrics = {}
    ant_metrics_crossed_metrics = {}
    dead_cuts = {}
    crossed_cuts = {}
    for amf in ant_metrics_files:
        with h5py.File(amf, "r") as infile: # use h5py directly since it's much faster than load_metric_file
            # get out results for this file
            dead_cuts[amf] = infile['Metrics']['dead_ant_cut'][()]
            crossed_cuts[amf] = infile['Metrics']['cross_pol_cut'][()]
            xants = infile['Metrics']['xants'][:]
            dead_ants = infile['Metrics']['dead_ants'][:]
            crossed_ants = infile['Metrics']['crossed_ants'][:]        
            try:
                # look for ex_ants in history
                ex_ants_string = infile['Header']['history'][()].decode()
                ex_ants_string = ex_ants_string.split('--apriori_xants')[1]
                ex_ants_string = ex_ants_string.split('--')[0].strip()
            except:
                ex_ants_string = ''
                    
            # This only works for the new correlation-matrix-based ant_metrics
            if 'corr' in infile['Metrics']['final_metrics'] and 'corrXPol' in infile['Metrics']['final_metrics']:
                ant_metrics_dead_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corr'][ant][()]
                                                 for ant in infile['Metrics']['final_metrics']['corr']}
                ant_metrics_crossed_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corrXPol'][ant][()]
                                                    for ant in infile['Metrics']['final_metrics']['corrXPol']}                       
            else:
                raise(KeywordError)
        
        # organize results by file
        ant_metrics_xants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in xants]
        ant_metrics_dead_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in dead_ants]
        ant_metrics_crossed_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in crossed_ants]
        ant_metrics_apriori_exants[amf] = [int(ant) for ant in ex_ants_string.split()]
    
    dead_cut = np.median(list(dead_cuts.values()))
    crossed_cut = np.median(list(crossed_cuts.values()))
        
    use_ant_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping ant_metrics.')
Found 372 ant_metrics files matching glob /mnt/sn1/2459740/zen.2459740.?????.sum.ant_metrics.hdf5

Load chi^2 info from redcal¶

In [8]:
use_redcal = False
glob_str = os.path.join(data_path, f'zen.{JD}.?????.sum{redcal_ext}')

redcal_files = sorted(glob.glob(glob_str))
if len(redcal_files) > 0:
    print(f'Found {len(redcal_files)} ant_metrics files matching glob {glob_str}')
    post_redcal_ant_flags_dict = {}
    flagged_by_redcal_dict = {}
    cspa_med_dict = {}
    for cal in redcal_files:
        hc = io.HERACal(cal)
        _, flags, cspa, chisq = hc.read()
        cspa_med_dict[cal] = {ant: np.nanmedian(cspa[ant], axis=1) for ant in cspa}

        post_redcal_ant_flags_dict[cal] = {ant: np.all(flags[ant]) for ant in flags}
        # check history to distinguish antennas flagged going into redcal from ones flagged during redcal
        tossed_antenna_lines =  hc.history.replace('\n','').split('Throwing out antenna ')[1:]
        flagged_by_redcal_dict[cal] = sorted([int(line.split(' ')[0]) for line in tossed_antenna_lines])
        
    use_redcal = True
else:
    print(f'No files found matching glob {glob_str}. Skipping redcal chisq.')
No files found matching glob /mnt/sn1/2459740/zen.2459740.?????.sum.known_good.omni.calfits. Skipping redcal chisq.

Figure out some general properties¶

In [9]:
# Parse some general array properties, taking into account the fact that we might be missing some of the metrics
ants = []
pols = []
antpol_pairs = []

if use_auto_metrics:
    ants = sorted(set(bl[0] for bl in auto_metrics['modzs']['r2_shape_modzs']))
    pols = sorted(set(bl[2] for bl in auto_metrics['modzs']['r2_shape_modzs']))
if use_ant_metrics:
    antpol_pairs = sorted(set([antpol for dms in ant_metrics_dead_metrics.values() for antpol in dms.keys()]))
    antpols = sorted(set(antpol[1] for antpol in antpol_pairs))
    ants = sorted(set(antpol[0] for antpol in antpol_pairs) | set(ants))
    pols = sorted(set(utils.join_pol(ap, ap) for ap in antpols) | set(pols))
if use_redcal:
    antpol_pairs = sorted(set([ant for cspa in cspa_med_dict.values() for ant in cspa.keys()]) | set(antpol_pairs))
    antpols = sorted(set(antpol[1] for antpol in antpol_pairs))
    ants = sorted(set(antpol[0] for antpol in antpol_pairs) | set(ants))
    pols = sorted(set(utils.join_pol(ap, ap) for ap in antpols) | set(pols))

# Figure out remaining antennas not in data
hd = io.HERAData(sorted(glob.glob(os.path.join(data_path, 'zen.*.sum.uvh5')))[0])
unused_ants = [ant for ant in hd.antpos if ant not in ants]    

Load a priori antenna statuses and node numbers¶

In [10]:
# try to load a priori antenna statusesm but fail gracefully if this doesn't work.
a_priori_statuses = {ant: 'Not Found' for ant in ants}
nodes = {ant: np.nan for ant in ants + unused_ants}
try:
    from hera_mc import cm_hookup

    # get node numbers
    hookup = cm_hookup.get_hookup('default')
    for ant_name in hookup:
        ant = int("".join(filter(str.isdigit, ant_name)))
        if ant in nodes:
            if hookup[ant_name].get_part_from_type('node')['E<ground'] is not None:
                nodes[ant] = int(hookup[ant_name].get_part_from_type('node')['E<ground'][1:])
    
    # get apriori antenna status
    for ant_name, data in hookup.items():
        ant = int("".join(filter(str.isdigit, ant_name)))
        if ant in a_priori_statuses:
            a_priori_statuses[ant] = data.apriori

except Exception as err:
    print(f'Could not load node numbers and a priori antenna statuses.\nEncountered {type(err)} with message: {err}')

Summarize auto metrics¶

In [11]:
if use_auto_metrics:
    # Parse modzs
    modzs_to_check = {'Shape': 'r2_shape_modzs', 'Power': 'r2_power_modzs', 
                      'Temporal Variability': 'r2_temp_var_modzs', 'Temporal Discontinuties': 'r2_temp_diff_modzs'}
    worst_metrics = []
    worst_zs = []
    all_modzs = {}
    binary_flags = {rationale: [] for rationale in modzs_to_check}

    for ant in ants:
        # parse modzs and figure out flag counts
        modzs = {f'{pol} {rationale}': auto_metrics['modzs'][dict_name][(ant, ant, pol)] 
                 for rationale, dict_name in modzs_to_check.items() for pol in pols}
        for pol in pols:
            for rationale, dict_name in modzs_to_check.items():
                binary_flags[rationale].append(auto_metrics['modzs'][dict_name][(ant, ant, pol)] > mean_round_modz_cut)

        # parse out all metrics for dataframe
        for k in modzs:
            col_label = k + ' Modified Z-Score'
            if col_label in all_modzs:
                all_modzs[col_label].append(modzs[k])
            else:
                all_modzs[col_label] = [modzs[k]]
                
    mean_round_modz_cut = auto_metrics['parameters']['mean_round_modz_cut']
else:
    mean_round_modz_cut = 0

Summarize ant metrics¶

In [12]:
if use_ant_metrics:
    a_priori_flag_frac = {ant: np.mean([ant in apxa for apxa in ant_metrics_apriori_exants.values()]) for ant in ants}
    dead_ant_frac = {ap: {ant: np.mean([(ant, ap) in das for das in ant_metrics_dead_ants_dict.values()])
                                 for ant in ants} for ap in antpols}
    crossed_ant_frac = {ant: np.mean([np.any([(ant, ap) in cas for ap in antpols])
                                      for cas in ant_metrics_crossed_ants_dict.values()]) for ant in ants}
    ant_metrics_xants_frac_by_antpol = {antpol: np.mean([antpol in amx for amx in ant_metrics_xants_dict.values()]) for antpol in antpol_pairs}
    ant_metrics_xants_frac_by_ant = {ant: np.mean([np.any([(ant, ap) in amx for ap in antpols])
                                     for amx in ant_metrics_xants_dict.values()]) for ant in ants}
    average_dead_metrics = {ap: {ant: np.nanmean([dm.get((ant, ap), np.nan) for dm in ant_metrics_dead_metrics.values()]) 
                                 for ant in ants} for ap in antpols}
    average_crossed_metrics = {ant: np.nanmean([cm.get((ant, ap), np.nan) for ap in antpols 
                                                for cm in ant_metrics_crossed_metrics.values()]) for ant in ants}
else:
    dead_cut = 0.4
    crossed_cut = 0.0

Summarize redcal chi^2 metrics¶

In [13]:
if use_redcal:
    cspa = {ant: np.nanmedian(np.hstack([cspa_med_dict[cal][ant] for cal in redcal_files])) for ant in antpol_pairs}
    redcal_prior_flag_frac = {ant: np.mean([np.any([afd[ant, ap] and not ant in flagged_by_redcal_dict[cal] for ap in antpols])
                                            for cal, afd in post_redcal_ant_flags_dict.items()]) for ant in ants}
    redcal_flagged_frac = {ant: np.mean([ant in fbr for fbr in flagged_by_redcal_dict.values()]) for ant in ants}

Build DataFrame¶

In [14]:
# build dataframe
to_show = {'Ant': [f'<a href="{ant_to_report_url(ant)}" target="_blank">{ant}</a>' for ant in ants],
           'Node': [nodes[ant] for ant in ants], 
           'A Priori Status': [a_priori_statuses[ant] for ant in ants]}
           #'Worst Metric': worst_metrics, 'Worst Modified Z-Score': worst_zs}
df = pd.DataFrame(to_show)

# create bar chart columns for flagging percentages:
bar_cols = {}
if use_auto_metrics:
    bar_cols['Auto Metrics Flags'] = [float(ant in auto_ex_ants) for ant in ants]
if use_ant_metrics:
    if np.sum(list(a_priori_flag_frac.values())) > 0:  # only include this col if there are any a priori flags
        bar_cols['A Priori Flag Fraction in Ant Metrics'] = [a_priori_flag_frac[ant] for ant in ants]
    for ap in antpols:
        bar_cols[f'Dead Fraction in Ant Metrics ({ap})'] = [dead_ant_frac[ap][ant] for ant in ants]
    bar_cols['Crossed Fraction in Ant Metrics'] = [crossed_ant_frac[ant] for ant in ants]
if use_redcal:
    bar_cols['Flag Fraction Before Redcal'] = [redcal_prior_flag_frac[ant] for ant in ants]
    bar_cols['Flagged By Redcal chi^2 Fraction'] = [redcal_flagged_frac[ant] for ant in ants]  
for col in bar_cols:
    df[col] = bar_cols[col]

# add auto_metrics
if use_auto_metrics:
    for label, modz in all_modzs.items():
        df[label] = modz
z_score_cols = [col for col in df.columns if 'Modified Z-Score' in col]        
        
# add ant_metrics
ant_metrics_cols = {}
if use_ant_metrics:
    for ap in antpols:
        ant_metrics_cols[f'Average Dead Ant Metric ({ap})'] = [average_dead_metrics[ap][ant] for ant in ants]
    ant_metrics_cols['Average Crossed Ant Metric'] = [average_crossed_metrics[ant] for ant in ants]
    for col in ant_metrics_cols:
        df[col] = ant_metrics_cols[col]   

# add redcal chisq
redcal_cols = []
if use_redcal:
    for ap in antpols:
        col_title = f'Median chi^2 Per Antenna ({ap})'
        df[col_title] = [cspa[ant, ap] for ant in ants]
        redcal_cols.append(col_title)

# sort by node number and then by antenna number within nodes
df.sort_values(['Node', 'Ant'], ascending=True)

# style dataframe
table = df.style.hide_index()\
          .applymap(lambda val: f'background-color: {status_colors[val]}' if val in status_colors else '', subset=['A Priori Status']) \
          .background_gradient(cmap='viridis', vmax=mean_round_modz_cut * 3, vmin=0, axis=None, subset=z_score_cols) \
          .background_gradient(cmap='bwr_r', vmin=dead_cut-.25, vmax=dead_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .background_gradient(cmap='bwr_r', vmin=crossed_cut-.25, vmax=crossed_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .background_gradient(cmap='plasma', vmax=4, vmin=1, axis=None, subset=redcal_cols) \
          .applymap(lambda val: 'font-weight: bold' if val < dead_cut else '', subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val < crossed_cut else '', subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .applymap(lambda val: 'color: red' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .bar(subset=list(bar_cols.keys()), vmin=0, vmax=1) \
          .format({col: '{:,.4f}'.format for col in z_score_cols}) \
          .format({col: '{:,.4f}'.format for col in ant_metrics_cols}) \
          .format({col: '{:,.2%}'.format for col in bar_cols}) \
          .applymap(lambda val: 'font-weight: bold', subset=['Ant']) \
          .set_table_styles([dict(selector="th",props=[('max-width', f'70pt')])]) \

Table 1: RTP Per-Antenna Metrics Summary Table¶

This admittedly very busy table incorporates summary information about all antennas in the array. Its columns depend on what information is available when the notebook is run (i.e. whether auto_metrics, ant_metrics, and/or redcal is done). These can be divided into 5 sections:

Basic Antenna Info: antenna number, node, and its a priori status.

Flag Fractions: Fraction of the night that an antenna was flagged for various reasons. Note that auto_metrics flags antennas for the whole night, so it'll be 0% or 100%.

auto_metrics Details: If auto_metrics is included, this section shows the modified Z-score signifying how much of an outlier each antenna and polarization is in each of four categories: bandpass shape, overall power, temporal variability, and temporal discontinuities. Bold red text indicates that this is a reason for flagging the antenna. It is reproduced from the auto_metrics_inspect.ipynb nightly notebook, so check that out for more details on the precise metrics.

ant_metrics Details: If ant_metrics is included, this section shows the average correlation-based metrics for antennas over the whole night. Low "dead ant" metrics (nominally below 0.4) indicate antennas not correlating with the rest of the array. Negative "crossed ant" metrics indicate antennas that show stronger correlations in their cross-pols than their same-pols, indicating that the two polarizations are probably swapped. Bold text indicates that the average is below the threshold for flagging.

redcal chi^2 Details: If redcal is included, this shows the median chi^2 per antenna. This would be 1 in an ideal array. Antennas are thrown out when they they are outliers in their median chi^2, usually greater than 4-sigma outliers in modified Z-score.

In [15]:
HTML(table.render())
Out[15]:
Ant Node A Priori Status Auto Metrics Flags Dead Fraction in Ant Metrics (Jee) Dead Fraction in Ant Metrics (Jnn) Crossed Fraction in Ant Metrics ee Shape Modified Z-Score nn Shape Modified Z-Score ee Power Modified Z-Score nn Power Modified Z-Score ee Temporal Variability Modified Z-Score nn Temporal Variability Modified Z-Score ee Temporal Discontinuties Modified Z-Score nn Temporal Discontinuties Modified Z-Score Average Dead Ant Metric (Jee) Average Dead Ant Metric (Jnn) Average Crossed Ant Metric
0 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% 28.831360 27.473113 64.386309 61.733278 29442.425620 28070.770321 32664.883802 30839.419471 nan nan nan
1 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
2 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
3 1 RF_maintenance 0.00% 100.00% 100.00% 0.00% 0.377684 0.655370 -0.316620 -0.593897 -0.700682 -0.559868 -0.849260 0.666711 0.033407 0.032609 0.001854
4 1 RF_maintenance 0.00% 100.00% 100.00% 0.00% -0.029510 1.071673 0.789683 1.813402 0.710532 0.805385 2.253695 0.760763 0.030906 0.036177 0.001262
5 1 digital_ok 0.00% 100.00% 100.00% 0.00% 0.354289 -0.400585 1.397681 -0.658039 -0.538475 1.944927 0.060525 -0.604904 0.029873 0.038742 0.001105
7 2 digital_ok 100.00% 100.00% 100.00% 0.00% 3.532637 2.304935 3.295106 2.385931 2.349647 9.354277 9.767285 46.580569 0.093559 0.088889 0.017368
8 2 RF_maintenance 100.00% 0.00% 0.00% 0.00% 29.083545 30.401048 60.268714 62.495253 53.994590 50.012295 68.181949 57.389697 0.644493 0.613416 0.466528
9 2 digital_ok 0.00% 100.00% 100.00% 0.00% 0.052236 -0.852510 -0.876198 -0.278981 1.222064 -0.526292 -0.557004 -0.060525 0.076730 0.088406 0.012288
10 2 digital_ok 100.00% 100.00% 100.00% 0.00% 1.567515 2.266347 -0.167150 1.958288 14.374472 18.724343 63.922056 67.025729 0.030318 0.030615 0.000745
11 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
12 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
13 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
14 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
15 1 digital_ok 0.00% 100.00% 100.00% 0.00% -0.844654 0.098615 0.657196 1.178435 -0.366429 0.317776 -0.778150 0.682271 0.030770 0.032110 0.001988
16 1 digital_ok 0.00% 100.00% 100.00% 0.00% -0.650118 0.072285 -1.041364 -0.500560 0.070266 0.023362 2.785373 -0.452263 0.030754 0.031977 0.001297
17 1 digital_ok 100.00% 100.00% 100.00% 0.00% 0.278432 0.251019 2.217124 2.047271 18.250869 17.431774 137.333595 144.881437 0.029131 0.029402 0.000325
18 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% 6.443985 3.607589 13.507650 30.393521 41.710981 4.177505 189.994639 16.115371 0.033331 0.035426 0.003022
19 2 digital_ok 100.00% 100.00% 100.00% 0.00% 1.845901 3.066802 1.823301 4.079419 1.259801 17.952114 18.660910 15.512476 0.031844 0.032429 0.000802
20 2 digital_ok 0.00% 100.00% 100.00% 0.00% 1.650810 0.120663 3.593427 0.886764 1.124219 -0.251036 2.735987 -1.721092 0.031520 0.032281 0.001649
21 2 digital_ok 100.00% 100.00% 100.00% 0.00% 0.117676 -0.683961 -0.432040 0.586089 46.026905 44.921806 53.041934 78.114772 0.030711 0.029521 0.000764
23 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
24 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
25 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
26 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
27 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% 11.993898 5.827875 8.018508 21.068367 0.378666 9.578910 8.008653 91.177049 0.031751 0.030053 0.005521
28 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% 5.133105 2.119587 19.527506 2.836454 0.680705 -0.774072 1.809158 1.877624 0.029235 0.036087 0.001469
29 1 digital_ok 0.00% 100.00% 100.00% 0.00% -0.382441 0.625464 0.012218 0.570430 3.087984 -1.145216 0.867512 -1.183056 0.032816 0.038909 0.003377
30 1 digital_ok 100.00% 100.00% 100.00% 0.00% 2.620064 2.171732 2.061583 1.548395 3.569139 5.201288 31.507257 18.971904 0.033342 0.033641 0.000940
31 2 digital_ok 100.00% 100.00% 100.00% 0.00% 5.886975 -0.567572 4.238528 -0.183131 4.814591 4.527818 6.547373 3.335597 0.027819 0.028273 0.000610
32 2 RF_maintenance 100.00% 100.00% 100.00% 0.00% 1.596800 0.365906 1.115898 -0.474596 5.224710 3.272787 10.202987 10.097801 0.027814 0.028370 0.000426
33 2 RF_maintenance 100.00% 100.00% 100.00% 0.00% -0.387053 7.589371 -0.918742 25.179757 45.538938 47.508036 49.837540 68.045893 0.070291 0.038550 0.004377
36 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% 2.553197 0.070486 3.939342 8.005758 0.989996 2.261420 2.527548 5.000948 0.027672 0.028113 0.001092
37 3 digital_ok 100.00% 100.00% 100.00% 0.00% 3.331676 9.487989 4.936520 10.185100 3.086582 6.780351 2.110298 32.398040 0.028802 0.029630 0.004266
38 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% 2.424992 7.675897 7.896984 9.712496 46.349369 59.928433 194.271907 267.306925 0.027095 0.031320 0.003219
39 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
40 4 digital_ok 100.00% 0.00% 0.00% 0.00% 29.984582 31.129020 49.146870 50.386806 55.104482 42.415091 14.529561 16.687884 0.688487 0.661835 0.458499
41 4 digital_ok 0.00% 100.00% 100.00% 0.00% -1.070796 0.233648 -1.023618 -0.036876 1.760935 -0.923294 -0.114350 -0.590058 0.037779 0.033812 0.000807
42 4 digital_ok 0.00% 100.00% 100.00% 0.00% 1.523247 0.498730 -0.206712 -0.731654 0.639003 3.295423 -0.306247 -1.063008 0.049831 0.069371 0.005165
45 5 RF_maintenance 100.00% 100.00% 100.00% 0.00% -0.937069 18.764853 -1.048664 13.398535 174.398470 442.831054 187.833436 489.792914 0.027739 0.027414 0.000919
46 5 digital_ok 100.00% 100.00% 100.00% 0.00% 2.809615 2.144659 7.521617 5.528038 11.571527 9.023586 6.442291 6.281712 0.028116 0.027496 0.000981
50 3 digital_ok 100.00% 100.00% 100.00% 0.00% 3.885971 3.588791 5.968495 2.449795 2.473774 -0.526652 2.777107 -0.287158 0.026975 0.027703 0.000906
51 3 digital_ok 100.00% 100.00% 100.00% 0.00% 5.420062 7.870292 1.059484 7.038082 3.202173 9.422715 11.562544 4.258328 0.030816 0.035215 0.004571
52 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% 1.480781 0.852074 7.122875 6.735456 4.715389 0.309292 9.736884 5.201339 0.028079 0.027066 0.000979
53 3 digital_ok 100.00% 100.00% 100.00% 0.00% 4.274617 2.041571 0.768528 2.024674 5.495390 5.515851 49.668534 59.691433 0.031845 0.033961 -0.000916
54 4 digital_ok 100.00% 100.00% 100.00% 0.00% -0.772896 0.124437 -0.764798 1.612226 1.524563 -1.108342 1.708178 6.298748 0.049185 0.073817 0.002488
55 4 digital_ok 0.00% 100.00% 100.00% 0.00% -1.217501 0.515151 -0.014632 -0.714394 -0.069245 1.792693 -0.407996 3.417760 0.034303 0.041003 0.001591
56 4 digital_ok 100.00% 100.00% 100.00% 0.00% -0.327354 1.049542 0.293458 3.205204 4.462191 2.870682 7.006190 5.584282 0.039633 0.037726 0.000443
57 4 digital_ok 100.00% 100.00% 100.00% 0.00% 2.561451 2.066703 2.905326 2.347676 14.551302 4.585388 0.287942 1.448176 0.041661 0.036502 0.004359
65 3 digital_ok 100.00% 100.00% 100.00% 0.00% 6.810986 4.360797 2.237712 2.004059 1.395225 4.765216 1.748430 3.291572 0.029908 0.031046 0.000874
66 3 digital_ok 100.00% 100.00% 100.00% 0.00% 8.832476 5.310517 18.697931 10.021180 38.486215 32.837731 227.523711 211.919519 0.029226 0.029276 0.000713
67 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% 2.740298 0.106795 7.304845 13.837269 2.126501 1.920470 5.872635 12.931158 0.029204 0.031020 0.001733
68 3 digital_ok 100.00% 100.00% 100.00% 0.00% 8.013856 3.593000 2.222805 5.000403 4.057125 1.099900 1.157331 0.455803 0.029874 0.031526 0.001609
69 4 digital_ok 100.00% 100.00% 100.00% 0.00% 1.209982 0.419164 1.169262 -0.623061 2.603683 12.588263 1.500498 5.183421 0.038606 0.039252 0.006178
70 4 RF_maintenance 100.00% 0.00% 0.00% 0.00% 34.976295 32.011888 38.027047 34.458162 74.098697 54.549385 28.924404 49.697355 0.716014 0.688674 0.434493
71 4 digital_ok 100.00% 100.00% 100.00% 0.00% 3.304784 4.232083 6.835561 9.461505 3.743984 3.749278 8.532183 2.770018 0.036350 0.036612 0.005334
72 4 digital_ok 100.00% 0.00% 0.00% 0.00% 27.188174 31.670913 49.879604 53.893018 55.646505 36.115387 18.495998 11.771577 0.696262 0.686551 0.413363
73 5 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.866835 6.894234 3.981882 2.391458 2.624406 0.912034 -0.777927 -5.218978 0.028112 0.027729 0.000635
81 7 digital_ok 0.00% 100.00% 100.00% 0.00% 2.825661 1.197767 2.048413 2.372869 -0.875705 -0.383405 -1.379967 0.417568 0.047812 0.033074 0.004588
82 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% 4.823179 5.264483 1.407843 0.520644 1.265608 1.481252 15.803285 14.730059 0.061018 0.046541 0.012031
83 7 digital_ok 100.00% 100.00% 100.00% 0.00% 18.625143 19.042321 7.237119 8.144995 1.305027 1.582522 8.717916 7.473042 0.062031 0.058748 0.007041
84 8 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
85 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
86 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
87 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% 4.474037 6.134114 6.465107 21.548798 6.542614 13.761406 1.451148 0.277663 0.030688 0.029659 0.000807
88 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
89 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
90 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
91 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
92 10 digital_ok 100.00% 100.00% 100.00% 0.00% 20.183058 -0.138066 12.665761 0.453055 1.743791 0.853587 5.269521 1.366666 0.030263 0.038402 0.002070
93 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 19.430826 18.991159 13.396225 15.536892 1.572820 1.699780 10.766002 14.174764 0.031247 0.048661 0.003985
94 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.347105 4.560509 1.659361 4.937484 0.368544 13.175107 3.243078 14.044940 0.029766 0.051654 0.002446
98 7 digital_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
99 7 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
100 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% 18.995766 18.919602 6.289530 9.214570 2.951669 1.351220 10.867053 11.503702 0.034735 0.045960 0.016675
101 8 digital_ok 100.00% 100.00% 100.00% 0.00% 0.876930 2.515633 5.307296 5.971902 4.176968 1.443021 64.672716 6.164588 0.032536 0.028931 0.002739
102 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
103 8 digital_ok 100.00% 100.00% 100.00% 0.00% 0.210810 2.490625 7.452415 8.263155 2.856603 0.133041 4.570679 3.542970 0.025696 0.026205 0.000407
104 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.502749 47.892857 4.551722 71.834027 1.158025 113.784348 2.622570 637.842175 0.026509 0.019080 0.007955
105 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
106 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
107 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
108 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
109 10 digital_ok 0.00% 100.00% 100.00% 0.00% 0.020526 0.433451 -0.793368 0.182008 -0.102358 0.455712 0.149732 -1.493797 0.033371 0.050686 0.001511
110 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 4.936530 4.867176 4.997087 1.659720 -0.367657 2.402330 1.461602 3.234962 0.027310 0.044307 0.004756
111 10 digital_ok 100.00% 100.00% 100.00% 0.00% 1.012401 0.925746 1.497749 1.538349 0.412569 11.586920 0.174340 5.546292 0.029860 0.043059 0.002402
112 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.965303 17.931331 1.506512 15.013546 -0.646530 1.212230 0.269845 5.020817 0.030715 0.055854 0.004024
116 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
119 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% 18.419893 0.989457 4.892882 3.439212 0.656535 -0.888108 5.575345 0.391845 0.061349 0.046653 0.014689
120 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% 11.372937 6.519517 19.580319 38.962841 1.966484 7.022480 16.944499 8.217646 0.025595 0.029512 0.005371
121 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
122 8 digital_ok 100.00% 100.00% 100.00% 0.00% 1.671003 1.170783 7.594850 4.691500 1.708887 -1.018893 4.875616 2.955572 0.026089 0.028170 0.001878
123 8 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
124 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
125 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
126 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
127 10 RF_maintenance 0.00% 100.00% 100.00% 0.00% 3.341332 2.961601 3.259690 3.071611 -0.663549 3.771172 -0.354801 -0.184555 0.036638 0.070786 0.004631
128 10 digital_ok 0.00% 100.00% 100.00% 0.00% -0.020526 -0.875827 0.403273 -0.205187 0.055893 1.008276 0.184915 -0.271139 0.041152 0.077219 0.005505
129 10 digital_ok 100.00% 0.00% 0.00% 0.00% 29.111296 32.129481 40.907529 50.409698 73.116647 46.072344 25.412042 17.157166 0.735087 0.723801 0.409310
130 10 digital_maintenance 100.00% 100.00% 100.00% 0.00% -0.161552 19.344363 -0.575847 14.897375 3.676665 7.022094 0.460297 14.116148 0.033809 0.090118 0.004408
135 12 digital_ok 0.00% 100.00% 100.00% 0.00% -0.926993 -0.831860 -0.293955 0.194526 -0.114529 -0.182168 1.987464 1.982919 0.034810 0.033703 0.003632
136 12 RF_maintenance 0.00% 100.00% 100.00% 0.00% -0.359875 -0.904436 0.380191 -0.729162 2.581976 0.204576 1.445519 1.439270 0.033428 0.034206 0.001133
138 7 digital_ok 0.00% 100.00% 100.00% 0.00% 3.490010 3.024136 3.599664 2.102563 -0.751382 -0.742026 -0.430636 -0.402313 0.053854 0.052503 0.006718
140 13 digital_ok 100.00% 100.00% 100.00% 0.00% 3.620892 4.181728 13.755262 12.944678 17.486572 14.921143 58.657279 56.967551 0.051073 0.051777 0.004415
141 13 digital_ok 100.00% 100.00% 100.00% 0.00% 0.098538 12.277419 1.263365 11.470324 1.931163 -1.229407 2.638309 5.825156 0.040165 0.050726 0.005146
142 13 digital_ok 100.00% 100.00% 100.00% 0.00% 2.252228 17.510530 3.512595 14.620203 -0.547763 0.160590 3.133324 3.635631 0.049662 0.042442 0.006009
143 14 digital_ok 100.00% 0.00% 0.00% 0.00% 28.272231 31.547435 52.363137 52.491899 52.554171 48.238703 9.985069 12.942674 0.681479 0.678610 0.434891
144 14 digital_ok 100.00% 100.00% 100.00% 0.00% 5.672095 6.897649 4.513651 6.207413 5.587947 12.015803 4.609230 4.083541 0.032727 0.032451 0.000863
145 14 digital_ok 0.00% 100.00% 100.00% 0.00% 2.994062 -1.081102 3.361831 -0.540976 -0.389477 -0.113088 2.460054 2.668527 0.031171 0.033069 0.001091
150 15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 18.369515 18.040105 11.100004 13.606075 2.164759 3.078857 7.904871 11.203331 0.131108 0.140504 0.015729
155 12 RF_maintenance 100.00% 100.00% 100.00% 0.00% 19.830041 20.577306 12.504872 14.093484 1.701063 1.553126 8.779778 11.505134 0.034142 0.032434 0.001239
156 12 RF_maintenance 0.00% 100.00% 100.00% 0.00% -0.287054 -0.460998 -0.484589 -1.032708 -0.685433 0.889822 -0.887005 3.347672 0.032275 0.033110 0.001479
157 12 RF_maintenance 100.00% 100.00% 100.00% 0.00% 1.997106 1.079396 4.306031 0.053927 0.661976 1.572928 3.160564 -0.378928 0.035400 0.031360 0.001105
158 12 RF_maintenance 100.00% 100.00% 100.00% 0.00% 1.036462 0.941937 1.519175 3.225573 0.248970 0.818312 -0.132277 18.289357 0.036292 0.030359 0.001079
160 13 digital_ok 100.00% 100.00% 100.00% 0.00% 2.477564 0.468546 3.066618 -0.349529 2.659672 0.422978 0.204646 13.865612 0.049549 0.050886 0.006071
161 13 digital_ok 0.00% 100.00% 100.00% 0.00% -0.733796 -0.589480 -0.189466 0.690943 -0.272214 -0.607445 0.504589 0.426263 0.062651 0.045172 -0.002544
162 13 digital_ok 0.00% 100.00% 100.00% 0.00% -0.934584 -0.741369 -0.056092 0.076094 0.019309 0.913122 0.101784 0.740441 0.102693 0.041803 0.021754
163 14 digital_ok 100.00% 100.00% 100.00% 0.00% -0.024735 -0.472664 0.684561 0.130711 0.875300 2.345841 8.043970 13.445384 0.038986 0.043021 0.006668
164 14 digital_ok 0.00% 100.00% 100.00% 0.00% 0.683889 0.517999 0.017272 -0.843429 -0.097962 1.874843 0.311881 0.507343 0.042116 0.050564 0.011366
165 14 digital_ok 0.00% 100.00% 100.00% 0.00% -0.665092 -0.833569 0.360196 -0.012218 1.788846 -0.581213 -0.799784 -0.540421 0.030478 0.031929 0.000573
166 14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 2.957015 6.007153 2.280189 4.471122 0.338588 -0.725253 0.483531 0.135627 0.031195 0.033739 0.001649
167 15 digital_ok 100.00% 0.00% 0.00% 0.00% 13.837026 21.675400 58.077651 61.989648 27.957263 19.815228 29.272633 32.833040 0.584828 0.613149 0.221061
168 15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 28.931856 30.149225 61.290382 65.795138 29.148947 14.048318 0.738669 6.591264 0.747621 0.734109 0.360149
169 15 digital_ok 100.00% 0.00% 0.00% 0.00% 28.989985 29.748065 64.653119 63.969299 18.615348 16.143770 1.155563 6.280911 0.728851 0.723623 0.376172
170 15 digital_ok 100.00% 0.00% 0.00% 0.00% 28.621684 29.685082 65.025703 62.336802 19.431784 21.637120 2.148198 12.570610 0.712713 0.725862 0.395755
176 12 digital_ok 0.00% 100.00% 100.00% 0.00% 1.816910 -0.844739 2.510360 -0.869150 1.554600 -1.550987 -1.403634 -1.879753 0.037188 0.033938 0.003074
177 12 digital_ok 100.00% 100.00% 100.00% 0.00% -0.315964 2.180565 0.201638 3.613193 -0.330812 12.453367 1.176705 10.202615 0.040211 0.035335 0.002454
178 12 digital_ok 100.00% 100.00% 100.00% 0.00% 2.377516 3.553768 5.956939 10.496350 19.346469 20.571672 115.226088 130.198813 0.040671 0.035459 0.001361
179 12 digital_ok 100.00% 100.00% 100.00% 0.00% 2.046767 0.278633 1.284039 0.079252 26.968679 -1.445152 4.465585 -0.605208 0.039892 0.033761 0.001893
180 13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.594409 18.460155 -0.695299 15.130172 5.652040 0.512309 32.753135 5.838640 0.042775 0.045009 0.002527
181 13 digital_ok 100.00% 100.00% 100.00% 0.00% 7.977645 2.659282 7.115872 3.803488 -0.266027 -1.079901 1.029183 3.526243 0.039323 0.028138 0.004002
182 13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 26.911203 29.233714 60.365192 5.835846 21.483748 72.714311 11.155572 163.427749 0.639637 0.573179 0.440758
183 13 digital_ok 100.00% 100.00% 100.00% 0.00% -0.150163 0.859673 0.398451 1.799411 -1.125944 -0.227237 -0.141987 10.179601 0.033362 0.032609 0.001509
184 14 digital_ok 100.00% 100.00% 100.00% 0.00% 1.331353 0.620376 3.247660 2.661453 20.022083 20.418531 117.860009 117.987220 0.030927 0.030267 0.001342
185 14 digital_ok 100.00% 100.00% 100.00% 0.00% 3.818289 3.897052 15.206151 19.082409 8.125627 4.661084 103.687546 16.199809 0.038827 0.039185 0.005568
186 14 digital_ok 100.00% 100.00% 100.00% 0.00% 0.119755 1.012464 -0.575754 1.031867 2.666922 -0.968677 7.446945 2.440976 0.035427 0.036090 0.003955
187 14 digital_ok 100.00% 100.00% 100.00% 0.00% 0.201464 0.618635 -0.582523 0.987283 -0.268001 -0.756084 4.513917 9.983237 0.035160 0.033991 0.000812
189 15 digital_ok 100.00% 100.00% 100.00% 0.00% -0.060910 1.302302 -0.847662 1.442728 2.852526 1.596659 8.990064 4.469023 0.031965 0.033067 0.001005
190 15 digital_ok 0.00% 100.00% 100.00% 0.00% -0.370004 -0.192550 -0.283694 2.560457 0.723557 -0.019309 -0.411471 0.558100 0.030770 0.032880 0.001449
191 15 digital_ok 100.00% 100.00% 100.00% 0.00% 1.462426 4.086802 0.197755 5.548850 1.935534 0.709745 1.225501 23.340562 0.032828 0.031699 0.002128
220 18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
221 18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
222 18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
320 3 dish_maintenance 100.00% 100.00% 100.00% 0.00% 16.303995 17.923589 3.271094 3.762355 2.512901 1.006685 13.211567 3.785264 0.032119 0.028680 0.000526
321 2 not_connected 100.00% 0.00% 3.23% 0.00% 29.184103 31.252938 59.180182 60.352250 35.475987 21.698763 4.350645 4.121369 0.533365 0.523399 0.415703
323 2 not_connected 100.00% 100.00% 100.00% 0.00% 7.263852 1.185378 15.895555 27.882051 1.688233 3.312453 6.419678 5.324689 0.083075 0.044079 0.010760
324 4 not_connected 100.00% 100.00% 100.00% 0.00% 5.402035 4.437565 36.400719 37.486975 1.702367 1.321154 -1.450201 -1.473840 0.041626 0.033680 0.001109
325 9 dish_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
329 12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 10.674255 1.757078 14.686973 25.061459 0.450736 5.482516 4.385170 10.501328 0.032732 0.029437 0.000846
333 12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 16.928899 0.729287 11.554395 19.827606 2.825288 9.143316 7.744227 22.872351 0.038221 0.036628 0.000944
In [16]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > .1 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
ex_ants: [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 135, 136, 138, 140, 141, 142, 143, 144, 145, 150, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 220, 221, 222, 320, 321, 323, 324, 325, 329, 333]
In [17]:
# write to csv
outpath = os.path.join(nb_outdir, f'rtp_summary_table_{JD}.csv')
print(f'Now saving Table 1 to a csv at {outpath}')
df.to_csv(outpath)
Now saving Table 1 to a csv at /home/obs/src/H5C_Notebooks/_rtp_summary_/rtp_summary_table_2459740.csv
In [18]:
# Load antenna positions
data_list = sorted(glob.glob(os.path.join(data_path, f'zen.{JD}.?????.sum.uvh5')))
hd = io.HERAData(data_list[len(data_list) // 2])

# Figure out where to draw the nodes
node_centers = {}
for node in sorted(set(list(nodes.values()))):
    if np.isfinite(node):
        this_node_ants = [ant for ant in ants + unused_ants if nodes[ant] == node]
        if len(this_node_ants) == 1:
            # put the node label just to the west of the lone antenna 
            node_centers[node] = hd.antpos[ant][node] + np.array([-14.6 / 2, 0, 0])
        else:
            # put the node label between the two antennas closest to the node center
            node_centers[node] = np.mean([hd.antpos[ant] for ant in this_node_ants], axis=0)
            closest_two_pos = sorted([hd.antpos[ant] for ant in this_node_ants], 
                                     key=lambda pos: np.linalg.norm(pos - node_centers[node]))[0:2]
            node_centers[node] = np.mean(closest_two_pos, axis=0)
In [19]:
def Plot_Array(ants, unused_ants, outriggers):
    plt.figure(figsize=(16,16))
    
    plt.scatter(np.array([hd.antpos[ant][0] for ant in hd.data_ants if ant in ants]), 
                np.array([hd.antpos[ant][1] for ant in hd.data_ants if ant in ants]), c='w', s=0)

    # connect every antenna to their node
    for ant in ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', zorder=0)

    rc_color = '#0000ff'
    antm_color = '#ffa500'
    autom_color = '#ff1493'

    # Plot 
    unflagged_ants = []
    for i, ant in enumerate(ants):
        ant_has_flag = False
        # plot large blue annuli for redcal flags
        if use_redcal:
            if redcal_flagged_frac[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=7 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=rc_color, alpha=redcal_flagged_frac[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot medium green annuli for ant_metrics flags
        if use_ant_metrics: 
            if ant_metrics_xants_frac_by_ant[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=antm_color, alpha=ant_metrics_xants_frac_by_ant[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot small red annuli for auto_metrics
        if use_auto_metrics:
            if ant in auto_ex_ants:
                ant_has_flag = True                
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, lw=0, color=autom_color)) 
        
        # plot black/white circles with black outlines for antennas
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4 * (2 - 1 * float(not outriggers)), fill=True, color=['w', 'k'][ant_has_flag], ec='k'))
        if not ant_has_flag:
            unflagged_ants.append(ant)

        # label antennas, using apriori statuses if available
        try:
            bgc = matplotlib.colors.to_rgb(status_colors[a_priori_statuses[ant]])
            c = 'black' if (bgc[0]*0.299 + bgc[1]*0.587 + bgc[2]*0.114) > 186 / 256 else 'white'
        except:
            c = 'k'
            bgc='white'
        plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color=c, backgroundcolor=bgc)

    # label nodes
    for node in sorted(set(list(nodes.values()))):
        if not np.isnan(node) and not np.all(np.isnan(node_centers[node])):
            plt.text(node_centers[node][0], node_centers[node][1], str(node), va='center', ha='center', bbox={'color': 'w', 'ec': 'k'})
    
    # build legend 
    legend_objs = []
    legend_labels = []
    
    # use circles for annuli 
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgecolor='k', markerfacecolor='w', markersize=13))
    legend_labels.append(f'{len(unflagged_ants)} / {len(ants)} Total {["Core", "Outrigger"][outriggers]} Antennas Never Flagged')
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='k', markersize=15))
    legend_labels.append(f'{len(ants) - len(unflagged_ants)} Antennas {["Core", "Outrigger"][outriggers]} Flagged for Any Reason')

    if use_auto_metrics:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=autom_color, markersize=15))
        legend_labels.append(f'{len([ant for ant in auto_ex_ants if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas Flagged by Auto Metrics')
    if use_ant_metrics: 
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=antm_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum([frac for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants]), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Ant Metrics\n(alpha indicates fraction of time)')        
    if use_redcal:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=rc_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum(list(redcal_flagged_frac.values())), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in redcal_flagged_frac.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Redcal\n(alpha indicates fraction of time)')

    # use rectangular patches for a priori statuses that appear in the array
    for aps in sorted(list(set(list(a_priori_statuses.values())))):
        if aps != 'Not Found':
            legend_objs.append(plt.Circle((0, 0), radius=7, fill=True, color=status_colors[aps]))
            legend_labels.append(f'A Priori Status:\n{aps} ({[status for ant, status in a_priori_statuses.items() if ant in ants].count(aps)} {["Core", "Outrigger"][outriggers]} Antennas)')

    # label nodes as a white box with black outline
    if len(node_centers) > 0:
        legend_objs.append(matplotlib.patches.Patch(facecolor='w', edgecolor='k'))
        legend_labels.append('Node Number')

    if len(unused_ants) > 0:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='grey', markersize=15, alpha=.2))
        legend_labels.append(f'Anntenna Not In Data')
        
    
    plt.legend(legend_objs, legend_labels, ncol=2, fontsize='large', framealpha=1)
    
    if outriggers:
        pass
    else:
        plt.xlim([-200, 150])
        plt.ylim([-150, 150])        
       
    # set axis equal and label everything
    plt.axis('equal')
    plt.tight_layout()
    plt.title(f'Summary of {["Core", "Outrigger"][outriggers]} Antenna Statuses and Metrics on {JD}', size=20)    
    plt.xlabel("Antenna East-West Position (meters)", size=12)
    plt.ylabel("Antenna North-South Position (meters)", size=12)
    plt.xticks(fontsize=12)
    plt.yticks(fontsize=12)
    xlim = plt.gca().get_xlim()
    ylim = plt.gca().get_ylim()    
        
    # plot unused antennas
    plt.autoscale(False)    
    for ant in unused_ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', alpha=.2, zorder=0)
        
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='w', ec=None, alpha=1, zorder=0))
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='grey', ec=None, alpha=.2, zorder=0))
        if hd.antpos[ant][0] < xlim[1] and hd.antpos[ant][0] > xlim[0]:
            if hd.antpos[ant][1] < ylim[1] and hd.antpos[ant][1] > ylim[0]:
                plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color='k', alpha=.2) 

Figure 1: Array Plot of Flags and A Priori Statuses¶

This plot shows all antennas, which nodes they are connected to, and their a priori statuses (as the highlight text of their antenna numbers). It may also show (depending on what is finished running):

  • Whether they were flagged by auto_metrics (red circle) for bandpass shape, overall power, temporal variability, or temporal discontinuities. This is done in a binary fashion for the whole night.
  • Whether they were flagged by ant_metrics (green circle) as either dead (on either polarization) or crossed, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.
  • Whether they were flagged by redcal (blue circle) for high chi^2, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.

Note that the last fraction does not include antennas that were flagged before going into redcal due to their a priori status, for example.

In [20]:
core_ants = [ant for ant in ants if ant < 320]
outrigger_ants = [ant for ant in ants if ant >= 320]
Plot_Array(ants=core_ants, unused_ants=unused_ants, outriggers=False)
if len(outrigger_ants) > 0:
    Plot_Array(ants=outrigger_ants, unused_ants=sorted(set(unused_ants + core_ants)), outriggers=True)

Metadata¶

In [21]:
from hera_qm import __version__
print(__version__)
from hera_cal import __version__
print(__version__)
2.0.2
3.1.1.dev2+g1b5039f
In [ ]: