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.

Contents:¶

  • Table 1: Overall Array Health
  • Table 2: RTP Per-Antenna Metrics Summary Table
  • Figure 1: Array Plot of Flags and A Priori Statuses
In [1]:
import os
os.environ['HDF5_USE_FILE_LOCKING'] = 'FALSE'
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 h5py
from copy import deepcopy
from IPython.display import display, HTML
from hera_notebook_templates.utils import status_colors
from hera_mc import mc
from pyuvdata import UVData

%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_'
# good_statuses = "digital_ok,calibration_maintenance,calibration_triage,calibration_ok"
# 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
# os.environ["GOOD_STATUSES"] = good_statuses
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']
good_statuses = os.environ['GOOD_STATUSES']
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}"')
print(f'good_statuses = "{good_statuses}"')
JD = "2459876"
data_path = "/mnt/sn1/2459876"
ant_metrics_ext = ".ant_metrics.hdf5"
redcal_ext = ".known_good.omni.calfits"
nb_outdir = "/home/obs/src/H6C_Notebooks/_rtp_summary_"
good_statuses = "digital_ok,calibration_maintenance,calibration_triage,calibration_ok"
In [4]:
from astropy.time import Time, TimeDelta
utc = Time(JD, format='jd').datetime
print(f'Date: {utc.month}-{utc.day}-{utc.year}')
Date: 10-23-2022
In [5]:
# Per-season options
def ant_to_report_url(ant):
    return f'https://htmlpreview.github.io/?https://github.com/HERA-Team/H6C_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/2459876/zen.2459876.25284.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 1862 ant_metrics files matching glob /mnt/sn1/2459876/zen.2459876.?????.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/2459876/zen.2459876.?????.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 and also LST range
data_files = sorted(glob.glob(os.path.join(data_path, 'zen.*.sum.uvh5')))
hd = io.HERAData(data_files[0])
unused_ants = [ant for ant in hd.antpos if ant not in ants]    
hd_last = io.HERAData(data_files[-1])

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}

Get FEM switch states¶

In [14]:
HHautos = sorted(glob.glob(f"{data_path}/zen.{JD}.*.sum.autos.uvh5"))
diffautos = sorted(glob.glob(f"{data_path}/zen.{JD}.*.diff.autos.uvh5"))

try:
    db = mc.connect_to_mc_db(None)
    session = db.sessionmaker()
    startJD = float(HHautos[0].split('zen.')[1].split('.sum')[0])
    stopJD = float(HHautos[-1].split('zen.')[1].split('.sum')[0])
    start_time = Time(startJD,format='jd')
    stop_time = Time(stopJD,format='jd')

    # get initial state by looking for commands up to 3 hours before the starttime
    # this logic can be improved after an upcoming hera_mc PR
    # which will return the most recent command before a particular time.
    search_start_time = start_time - TimeDelta(3*3600, format="sec")
    initial_command_res = session.get_array_signal_source(starttime=search_start_time, stoptime=start_time)
    if len(initial_command_res) == 0:
        initial_source = "Unknown"
    elif len(command_res) == 1:
        initial_source = initial_command_res[0].source
    else:
        # multiple commands
        times = []
        sources = []
        for obj in command_res:
            times.append(obj.time)
            sources.append(obj.source)
        initial_source = sources[np.argmax(times)]
    
    # check for any changes during observing
    command_res = session.get_array_signal_source(starttime=start_time, stoptime=stop_time)
    if len(command_res) == 0:
        # still nothing, set it to None
        obs_source = None
    else:
        obs_source_times = []
        obs_source = []
        for obj in command_res:
            obs_source_times.append(obj.time)
            obs_source.append(obj.source)

    if obs_source is not None:
        command_source = [initial_source] + obs_source
    else:
        command_source = initial_source
    
    res = session.get_antenna_status(starttime=startTime, stoptime=stopTime)
    fem_switches = {}
    right_rep_ant = []
    if len(res) > 0:
        for obj in res:
            if obj.antenna_number not in fem_switches.keys():
                fem_switches[obj.antenna_number] = {}
            fem_switches[obj.antenna_number][obj.antenna_feed_pol] = obj.fem_switch
        for ant, pol_dict in fem_switches.items():
            if pol_dict['e'] == initial_source and pol_dict['n'] == initial_source:
                right_rep_ant.append(ant)
except Exception as e:
    print(e)
    initial_source = None
    command_source = None
    right_rep_ant = []
name 'command_res' is not defined

Find X-engine Failures¶

In [15]:
read_inds = [1, len(HHautos)//2, -2]
x_status = [1,1,1,1,1,1,1,1]
s = UVData()
s.read(HHautos[1])

nants = len(s.get_ants())
freqs = s.freq_array[0]*1e-6
nfreqs = len(freqs)

antCon = {a: None for a in ants}
rightAnts = []
for i in read_inds:
    s = UVData()
    d = UVData()
    s.read(HHautos[i])
    d.read(diffautos[i])
    for pol in [0,1]:
        sm = np.abs(s.data_array[:,0,:,pol])
        df = np.abs(d.data_array[:,0,:,pol])
        sm = np.r_[sm, np.nan + np.zeros((-len(sm) % nants,len(freqs)))]
        sm = np.nanmean(sm.reshape(-1,nants,nfreqs),axis=1)
        df = np.r_[df, np.nan + np.zeros((-len(df) % nants,len(freqs)))]
        df = np.nanmean(df.reshape(-1,nants,nfreqs),axis=1)

        evens = (sm + df)/2
        odds = (sm - df)/2
        rat = np.divide(evens,odds)
        rat = np.nan_to_num(rat)
        for xbox in range(0,8):
            xavg = np.nanmean(rat[:,xbox*192:(xbox+1)*192],axis=1)
            if np.nanmax(xavg)>1.5 or np.nanmin(xavg)<0.5:
                x_status[xbox] = 0
    for ant in ants:
        for pol in ["xx", "yy"]:
            if antCon[ant] is False:
                continue
            spectrum = s.get_data(ant, ant, pol)
            stdev = np.std(spectrum)
            med = np.median(np.abs(spectrum))
            if (initial_source == 'digital_noise_same' or initial_source == 'digital_noise_different') and med < 10:
                antCon[ant] = True
            elif (initial_source == "load" or initial_source == 'noise') and 80000 < stdev <= 4000000 and antCon[ant] is not False:
                antCon[ant] = True
            elif initial_source == "antenna" and stdev > 500000 and med > 950000 and antCon[ant] is not False:
                antCon[ant] = True
            else:
                antCon[ant] = False
            if np.min(np.abs(spectrum)) < 100000:
                antCon[ant] = False
for ant in ants:
    if antCon[ant] is True:
        rightAnts.append(ant)
            
x_status_str = ''
for i,x in enumerate(x_status):
    if x==0:
        x_status_str += '\u274C '
    else:
        x_status_str += '\u2705 '

Build Overall Health DataFrame¶

In [16]:
def comma_sep_paragraph(vals, chars_per_line=40):
    outstrs = []
    for val in vals:
        if (len(outstrs) == 0) or (len(outstrs[-1]) > chars_per_line):
            outstrs.append(str(val))
        else:
            outstrs[-1] += ', ' + str(val)
    return ',<br>'.join(outstrs)
In [17]:
# Time data
to_show = {'JD': [JD]}
to_show['Date'] = f'{utc.month}-{utc.day}-{utc.year}'
to_show['LST Range'] = f'{hd.lsts[0] * 12 / np.pi:.3f} -- {hd_last.lsts[-1] * 12 / np.pi:.3f} hours'

# X-engine status
to_show['X-Engine Status'] = x_status_str

# Files
to_show['Number of Files'] = len(data_files)

# Antenna Calculations
to_show['Total Number of Antennas'] = len(ants)

to_show[' '] = ''
to_show['OPERATIONAL STATUS SUMMARY'] = ''

status_count = {status: 0 for status in status_colors}
for ant, status in a_priori_statuses.items():
    if status in status_count:
        status_count[status] = status_count[status] + 1
    else:
        status_count[status] = 1
to_show['Antenna A Priori Status Count'] = '<br>'.join([f'{status}: {status_count[status]}' for status in status_colors if status in status_count and status_count[status] > 0])

to_show['Commanded Signal Source'] = ', '.join(command_source if hasattr(command_source, '__iter__') else [str(command_source)])
to_show['Antennas in Commanded State (reported)'] = f'{len(right_rep_ant)} / {len(ants)} ({len(right_rep_ant) / len(ants):.1%})'
to_show['Antennas in Commanded State (observed)'] = f'{len(rightAnts)} / {len(ants)} ({len(rightAnts) / len(ants):.1%})'

if use_ant_metrics:
    to_show['Cross-Polarized Antennas'] = ', '.join([str(ant) for ant in ants if (np.max([dead_ant_frac[ap][ant] for ap in antpols]) + crossed_ant_frac[ant] == 1) 
                                                                                 and (crossed_ant_frac[ant] > .5)])

# Node calculations
nodes_used = set([nodes[ant] for ant in ants if np.isfinite(nodes[ant])])
to_show['Total Number of Nodes'] = len(nodes_used)
if use_ant_metrics:
    node_off = {node: True for node in nodes_used}
    not_correlating = {node: True for node in nodes_used}
    for ant in ants:
        for ap in antpols:
            if np.isfinite(nodes[ant]):
                if np.isfinite(average_dead_metrics[ap][ant]):
                    node_off[nodes[ant]] = False
                if dead_ant_frac[ap][ant] < 1:
                    not_correlating[nodes[ant]] = False
    to_show['Nodes Registering 0s'] = ', '.join([f'N{n:02}' for n in sorted([node for node in node_off if node_off[node]])])
    to_show['Nodes Not Correlating'] = ', '.join([f'N{n:02}' for n in sorted([node for node in not_correlating if not_correlating[node] and not node_off[node]])])

# Pipeline calculations    
to_show['  '] = ''
to_show['NIGHTLY ANALYSIS SUMMARY'] = ''
    
all_flagged_ants = []
if use_ant_metrics:
    to_show['Ant Metrics Done?'] = '\u2705'
    ant_metrics_flagged_ants = [ant for ant in ants if ant_metrics_xants_frac_by_ant[ant] > 0]
    all_flagged_ants.extend(ant_metrics_flagged_ants)
    to_show['Ant Metrics Flagged Antennas'] = f'{len(ant_metrics_flagged_ants)} / {len(ants)} ({len(ant_metrics_flagged_ants) / len(ants):.1%})' 
else:
    to_show['Ant Metrics Done?'] = '\u274C'
if use_auto_metrics:
    to_show['Auto Metrics Done?'] = '\u2705'
    auto_metrics_flagged_ants = [ant for ant in ants if ant in auto_ex_ants]
    all_flagged_ants.extend(auto_metrics_flagged_ants)    
    to_show['Auto Metrics Flagged Antennas'] = f'{len(auto_metrics_flagged_ants)} / {len(ants)} ({len(auto_metrics_flagged_ants) / len(ants):.1%})' 
else:
    to_show['Auto Metrics Done?'] = '\u274C'
if use_redcal:
    to_show['Redcal Done?'] = '\u2705'    
    redcal_flagged_ants = [ant for ant in ants if redcal_flagged_frac[ant] > 0]
    all_flagged_ants.extend(redcal_flagged_ants)    
    to_show['Redcal Flagged Antennas'] = f'{len(redcal_flagged_ants)} / {len(ants)} ({len(redcal_flagged_ants) / len(ants):.1%})' 
else:
    to_show['Redcal Done?'] = '\u274C' 
to_show['Never Flagged Antennas'] = f'{len(ants) - len(set(all_flagged_ants))} / {len(ants)} ({(len(ants) - len(set(all_flagged_ants))) / len(ants):.1%})'

# Count bad antennas with good statuses and vice versa
n_apriori_good = len([ant for ant in ants if a_priori_statuses[ant] in good_statuses.split(',')])
apriori_good_flagged = []
aprior_bad_unflagged = []
for ant in ants:
    if ant in set(all_flagged_ants) and a_priori_statuses[ant] in good_statuses.split(','):
        apriori_good_flagged.append(ant)
    elif ant not in set(all_flagged_ants) and a_priori_statuses[ant] not in good_statuses.split(','):
        aprior_bad_unflagged.append(ant)
to_show['A Priori Good Antennas Flagged'] = f'{len(apriori_good_flagged)} / {n_apriori_good} total a priori good antennas:<br>' + \
                                            comma_sep_paragraph(apriori_good_flagged)
to_show['A Priori Bad Antennas Not Flagged'] = f'{len(aprior_bad_unflagged)} / {len(ants) - n_apriori_good} total a priori bad antennas:<br>' + \
                                            comma_sep_paragraph(aprior_bad_unflagged)

# Apply Styling
df = pd.DataFrame(to_show)
divider_cols = [df.columns.get_loc(col) for col in ['NIGHTLY ANALYSIS SUMMARY', 'OPERATIONAL STATUS SUMMARY']]
try:
    to_red_columns = [df.columns.get_loc(col) for col in ['Cross-Polarized Antennas', 'Nodes Registering 0s', 
                                                          'Nodes Not Correlating', 'A Priori Good Antennas Flagged']]
except:
    to_red_columns = []
def red_specific_cells(x):
    df1 = pd.DataFrame('', index=x.index, columns=x.columns)
    for col in to_red_columns:
        df1.iloc[col] = 'color: red'
    return df1

df = df.T
table = df.style.hide_columns().apply(red_specific_cells, axis=None)
for col in divider_cols:
    table = table.set_table_styles([{"selector":f"tr:nth-child({col+1})", "props": [("background-color", "black"), ("color", "white")]}], overwrite=False)

Table 1: Overall Array Health¶

In [18]:
HTML(table.render())
Out[18]:
JD 2459876
Date 10-23-2022
LST Range 21.638 -- 7.659 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
Total Number of Antennas 183
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 51
RF_ok: 5
digital_maintenance: 1
digital_ok: 99
not_connected: 23
Commanded Signal Source None
Antennas in Commanded State (reported) 0 / 183 (0.0%)
Antennas in Commanded State (observed) 0 / 183 (0.0%)
Cross-Polarized Antennas 146
Total Number of Nodes 16
Nodes Registering 0s
Nodes Not Correlating N09
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 70 / 183 (38.3%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 160 / 183 (87.4%)
Redcal Done? ❌
Never Flagged Antennas 18 / 183 (9.8%)
A Priori Good Antennas Flagged 84 / 99 total a priori good antennas:
7, 10, 15, 16, 19, 20, 21, 29, 30, 31, 37,
38, 42, 44, 45, 51, 53, 54, 55, 56, 59, 65,
66, 67, 68, 69, 71, 72, 81, 84, 86, 88, 91,
93, 94, 98, 99, 101, 103, 105, 106, 107, 108,
109, 111, 116, 117, 121, 122, 123, 124, 127,
128, 129, 130, 136, 140, 141, 142, 143, 144,
146, 147, 158, 160, 161, 162, 164, 165, 167,
169, 170, 176, 178, 181, 183, 184, 185, 186,
187, 189, 190, 191, 202
A Priori Bad Antennas Not Flagged 3 / 84 total a priori bad antennas:
4, 137, 168
In [19]:
# write to csv
outpath = os.path.join(nb_outdir, f'array_health_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.replace({'\u2705': 'Y'}, regex=True).replace({'\u274C': 'N'}, regex=True).replace({'<br>': ' '}, regex=True).to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/array_health_table_2459876.csv

Build DataFrame¶

In [20]:
# build dataframe
to_show = {'Ant': [f'<a href="{ant_to_report_url(ant)}" target="_blank">{ant}</a>' for ant in ants],
           'Node': [f'N{nodes[ant]:02}' 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 2: 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 [21]:
HTML(table.render())
Out[21]:
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
3 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.352892 -1.012774 -0.805133 0.198009 0.437412 1.226059 -0.412579 0.776886 0.697791 0.674338 0.403607
4 N01 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.916730 3.737985 2.707572 -0.356406 0.432315 0.046810 1.157872 -0.733574 0.695094 0.669398 0.391216
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.159234 0.718142 -0.601462 1.493735 0.242409 0.841448 -0.042674 -1.059346 0.700210 0.679305 0.386386
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.667066 -1.025535 0.308807 0.457276 0.364026 12.260282 23.507818 9.981375 0.694929 0.680003 0.390640
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.466127 6.371661 35.009972 36.077309 17.869167 29.051426 -0.788618 -5.427163 0.680589 0.660238 0.381839
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.000046 -1.696794 0.832223 1.097069 -0.003600 -0.482592 2.004048 2.133796 0.689970 0.672371 0.395216
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 1.338488 -0.469088 6.868362 6.870516 3.331964 1.063152 4.904316 0.273346 0.686313 0.670602 0.402885
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 2.575342 0.969082 4.844064 2.660399 -0.932047 -0.678423 3.410464 2.946500 0.695346 0.680554 0.391570
16 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 0.253876 -0.567959 0.588454 -0.627884 -0.803687 0.236606 9.633629 4.954202 0.699722 0.685792 0.383665
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.135188 0.821135 -0.272308 -0.284609 0.146070 -0.061907 3.319382 -0.039546 0.699377 0.688302 0.384674
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 15.635078 23.963007 1.427892 1.440662 7.538675 21.582539 33.980423 61.450782 0.667049 0.461493 0.422105
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.257175 0.481751 6.433644 15.943414 0.029831 8.174826 0.286892 -0.191352 0.702945 0.696403 0.392832
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.434814 4.191120 -0.025399 14.591350 2.566144 5.075541 3.126341 -1.433972 0.700660 0.678452 0.386721
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 1.315618 0.818772 14.088589 17.848631 405.212648 90.134920 29.313131 25.895507 0.526452 0.648709 0.427154
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 41.712310 16.135193 4.136401 13.729031 19.156202 12.400335 6.460652 -0.295599 0.457507 0.621546 0.335546
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 17.115132 18.363346 51.464380 52.601544 29.851168 44.071616 9.242685 6.790639 0.034676 0.039457 0.002943
28 N01 RF_maintenance 100.00% 0.00% 86.79% 0.00% 20.206755 38.646767 6.080021 4.126493 23.077491 43.954118 8.290400 46.718149 0.361110 0.160482 0.221309
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.492443 -0.505077 -0.330050 1.003350 -1.278965 -1.062162 0.426239 9.835207 0.702525 0.684502 0.379309
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.035101 -0.936188 5.777773 -0.337981 1.558652 1.352245 28.005025 1.775092 0.700939 0.689677 0.380101
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.202199 2.513134 1.063126 1.753331 1.693888 3.906864 3.946171 5.743841 0.711780 0.686267 0.388459
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 25.118645 11.236429 5.221253 4.385819 31.167135 41.238380 29.381289 112.598276 0.607253 0.648495 0.311001
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.070892 25.674241 -0.002953 1.632454 -0.478134 14.504482 6.093348 55.272945 0.695489 0.491098 0.466519
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 19.425158 3.935856 22.132724 15.147778 29.787734 8.604252 4.860278 -0.373025 0.044681 0.660973 0.497000
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.427475 1.734333 26.315137 6.746496 199.643400 5.907188 34.382026 0.205339 0.643248 0.644248 0.408468
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 12.448982 11.864793 0.858494 0.674318 3.574514 5.331404 0.665335 3.142285 0.699296 0.678853 0.392283
37 N03 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
38 N03 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.396981 -0.230985 -0.600161 -0.017517 0.003600 -1.273729 -0.313956 -0.731678 0.698931 0.682307 0.386592
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.181158 0.630839 2.235392 0.504376 -0.253782 -0.148575 -0.612169 -0.666130 0.703352 0.682570 0.376596
42 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
43 N05 RF_maintenance 100.00% 100.00% 0.00% 0.00% 16.092287 1.105136 50.878174 -0.607998 29.857303 0.290006 6.429151 7.352520 0.042821 0.693542 0.469568
44 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 3.371340 2.287021 0.364390 -0.415004 2.888386 1.644371 14.725492 10.880322 0.690553 0.690727 0.375194
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -1.035380 4.063726 -0.552776 -0.208700 0.282901 4.643475 1.209844 6.470953 0.700193 0.672579 0.376816
46 N05 RF_maintenance 100.00% 0.00% 100.00% 0.00% -0.795336 19.041100 -0.763502 52.818946 -0.038565 43.989603 2.150716 9.257491 0.698998 0.038649 0.492626
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 18.319964 3.706175 21.154025 11.016265 29.811349 6.403537 4.715281 4.941011 0.040560 0.659781 0.501144
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.284386 3.729940 21.791458 25.249433 6.830588 14.042827 -1.163005 -3.468165 0.669004 0.668785 0.403996
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.434429 3.168171 10.339145 24.494916 5.558253 16.595729 1.193346 -0.605921 0.638181 0.654538 0.408078
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.809784 3.125008 0.342714 1.635986 8.514659 9.050367 23.097279 16.626943 0.681669 0.672280 0.378058
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 36.057012 2.247878 66.001868 0.214989 29.348259 0.893203 26.446306 9.719592 0.041244 0.689797 0.441231
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.668065 9.927043 0.488780 0.527816 3.381572 -1.168838 2.837621 2.388069 0.708967 0.694275 0.384528
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.973999 4.397977 -0.000555 0.148497 -0.360672 -0.520603 6.010163 11.685265 0.711471 0.697314 0.390262
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 2.360110 20.314620 -0.485541 53.355631 20.980115 43.890080 4.454604 9.540216 0.702544 0.036069 0.481671
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 1.553871 1.658191 1.064634 0.690425 1.743110 1.083505 0.285618 10.983461 0.702618 0.693021 0.375658
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 46.444272 0.352157 24.373738 3.480222 19.466392 1.793996 3.825441 4.302258 0.531674 0.695120 0.381642
58 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 16.558132 19.070344 51.195198 53.560443 29.954951 44.157733 9.596541 8.123667 0.038757 0.035784 0.002014
59 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 12.630463 5.848312 1.427183 4.429150 24.240071 1.336716 52.789766 8.911840 0.677666 0.682592 0.377660
60 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 17.820734 18.683057 51.352328 53.456145 29.866361 44.084933 7.532774 9.417741 0.027711 0.028610 0.001542
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 5.924605 5.187051 2.893857 -0.142856 5.053310 10.217527 0.087579 5.676613 0.654507 0.634113 0.377024
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.328750 3.738365 17.396280 24.120250 5.300095 15.661022 -0.016833 -2.848892 0.676085 0.671714 0.393010
63 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
64 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
65 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.017064 1.959712 1.155278 2.296189 4.324605 4.582682 8.900206 4.803593 0.693179 0.686007 0.394887
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.060186 2.431999 10.037008 7.999675 -0.874351 -0.490296 0.517602 4.627344 0.698169 0.688731 0.388758
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.586589 0.094519 10.017341 6.813331 1.068530 0.784264 2.375165 4.277792 0.700361 0.689936 0.378381
68 N03 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
69 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 0.485255 -1.170775 0.597338 0.352083 1.509253 6.230220 1.203854 0.750521 0.704894 0.696101 0.379734
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.830407 -0.553587 1.322725 1.509541 -0.267663 0.410946 -0.310610 0.039546 0.710121 0.699310 0.383043
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 9.958691 -0.174997 2.434388 2.716678 0.128042 0.848815 8.100216 2.316214 0.715203 0.695720 0.382930
72 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 337.704258 337.686339 inf inf 22380.745637 22377.540033 28516.439941 28505.809783 nan nan nan
73 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 16.064013 17.773781 50.589740 51.963693 29.818188 44.022826 9.271701 4.347353 0.027392 0.027383 0.001269
74 N05 RF_maintenance 100.00% 100.00% 1.45% 0.00% 17.668017 16.036268 52.864179 51.755722 30.099282 39.429619 8.277115 54.567887 0.032635 0.306476 0.185877
75 N05 RF_maintenance 100.00% 0.00% 100.00% 0.00% 11.889235 19.418012 7.480354 53.967781 12.840063 44.153537 17.669786 9.591419 0.679347 0.047396 0.483527
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 33.990291 35.450400 18.127210 14.041769 15.231182 24.516166 7.121967 -0.590448 0.559277 0.507365 0.204630
78 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -0.295110 0.272815 -0.146568 18.562414 0.469856 28.582739 0.328273 2.457835 0.673381 0.636036 0.389377
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.064278 0.479244 -0.062398 7.234067 1.398008 1.378082 0.211645 -0.062160 0.686719 0.673664 0.385705
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.809490 -0.349704 -0.750645 -0.636087 -2.179610 0.663367 -0.699791 1.445738 0.697236 0.687297 0.376702
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 8.522090 35.158607 7.092016 68.735414 -1.054110 42.621169 0.188639 15.425517 0.701981 0.041637 0.525189
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.209575 0.000046 -0.209839 -0.000923 -1.425762 0.685615 -0.682852 -0.738703 0.704898 0.690351 0.380399
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 3.208429 8.529049 9.096270 5.891799 4.090318 4.375221 0.523415 40.712516 0.691131 0.655128 0.371672
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 33.988235 10.902410 7.582413 0.472862 10.065219 0.674313 1.952591 1.291371 0.604021 0.704159 0.374988
88 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 1.656771 1.260439 0.786635 1.749008 -0.439942 0.266800 0.360662 -0.246839 0.067018 0.073923 0.010587
89 N09 RF_maintenance 0.00% 100.00% 100.00% 0.00% 1.052820 -0.100481 -0.488733 1.241695 -1.025214 -0.407104 -0.639548 -0.694566 0.062787 0.067365 0.007453
90 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.400377 -0.268359 0.599540 2.586735 0.835720 0.287411 1.509902 8.124254 0.068200 0.074458 0.010590
91 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 0.372208 0.192932 -0.059560 -0.697822 -0.998743 -1.046897 0.404041 -0.317192 0.081650 0.082064 0.022343
92 N10 RF_maintenance 100.00% 0.00% 27.34% 0.00% 57.345385 64.658619 6.600995 7.961143 25.148671 36.465858 1.551520 9.485000 0.283809 0.230639 0.089415
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 4.165413 -0.010541 9.174968 -0.623939 4.957918 0.079553 10.207957 -0.305582 0.693001 0.687534 0.389739
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.259983 -1.782589 0.667255 1.853809 2.960954 9.410174 3.751185 4.563963 0.696285 0.681046 0.397245
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 1.295416 1.883161 -0.322140 1.589272 2.808649 5.656638 7.466221 7.593432 0.669793 0.664586 0.390051
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 6.487426 -0.533421 0.996156 1.362401 -0.566714 7.455190 6.365834 -0.054782 0.675700 0.672938 0.384561
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.340812 -0.895275 1.741060 -0.618152 1.723826 -0.723516 0.616586 0.749847 0.690389 0.680189 0.376928
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 10.177191 13.040811 1.729874 2.135980 0.021686 -0.981565 0.187262 -0.183379 0.710989 0.697344 0.371255
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 7.196413 19.175329 35.955949 50.766436 149.286013 44.254862 4.276946 13.128457 0.523870 0.043950 0.402367
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 34.733324 35.764714 59.004184 60.849687 29.938266 43.820536 27.263162 23.767699 0.028146 0.028634 0.001902
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.351319 81.162652 5.397629 51.564627 1.288161 3.856168 0.773407 1.241151 0.710574 0.620460 0.418593
105 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 0.373357 -0.135449 6.763564 1.265987 0.868199 -0.007044 0.106386 -0.080665 0.068529 0.075746 0.011217
106 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 0.451171 1.430768 4.903369 3.100115 2.237569 -0.340033 1.329228 0.357189 0.059703 0.063586 0.006963
107 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 3.014860 -0.031992 0.836374 -0.018281 1.889178 1.635943 8.142329 13.185574 0.048159 0.056595 0.003793
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 16.238118 3.553817 50.307590 0.225263 27.894859 0.422871 6.716855 4.972446 0.056256 0.070159 0.049698
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.122675 18.947655 1.712049 52.010443 -0.487621 43.980667 2.970914 6.676863 0.703708 0.036024 0.440861
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.861318 37.245435 -0.126861 69.448676 -1.172037 42.642618 0.856028 13.856465 0.713576 0.034219 0.442128
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.110303 18.742413 1.803976 52.562710 -1.112504 43.985753 1.548216 8.466097 0.698004 0.036288 0.434329
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.136460 -0.580702 -0.747524 0.958575 1.314001 0.316302 0.951838 -0.366760 0.687466 0.682490 0.399384
116 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -0.770579 1.502305 0.261211 0.158955 4.435480 7.955492 2.187035 0.316764 0.663989 0.659173 0.389284
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 18.479039 21.037263 51.688106 55.180976 29.935190 44.096823 6.031413 11.804332 0.027820 0.032766 0.004444
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.238459 1.391560 -0.704668 1.630170 2.797354 -0.074702 -0.287785 0.523554 0.691406 0.684574 0.381009
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.137240 5.161566 6.789588 16.983507 -2.075421 10.408247 -0.361394 1.254329 0.704546 0.648987 0.388491
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 4.095467 34.694746 -0.122714 68.479393 -1.032605 43.196392 4.193552 26.030155 0.707243 0.036433 0.536417
121 N08 digital_ok 100.00% 0.05% 0.00% 0.00% 3.470347 7.432106 1.157605 0.227043 50.642079 0.997597 51.311367 49.868494 0.714248 0.699810 0.379027
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 11.174774 10.020298 1.579173 1.308511 9.170060 -0.758380 0.453491 -0.206581 0.721282 0.701765 0.380539
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 8.318228 12.535448 1.501753 2.174178 -0.313276 0.191705 1.301552 2.384053 0.714852 0.701270 0.382805
124 N09 digital_ok 0.00% 100.00% 100.00% 0.00% -0.550496 3.419492 -0.545030 0.651159 1.444851 -0.704871 2.319402 0.960834 0.065272 0.074535 0.008630
125 N09 RF_maintenance 0.00% 100.00% 100.00% 0.00% 2.735425 -0.013617 -0.281866 2.000877 -0.398613 -1.282322 -0.148536 -0.728417 0.063887 0.071828 0.007712
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 44.672032 1.957056 4.349759 2.346659 14.694283 15.214570 15.942251 0.922599 0.082633 0.075741 0.020087
127 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 0.626261 -0.136408 -0.637338 -0.633673 0.050867 4.039185 0.471344 2.072532 0.702769 0.692662 0.399215
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.271185 -0.245023 5.918602 2.114450 0.064794 0.946873 0.379153 0.469074 0.697403 0.689251 0.392542
129 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 1.002629 -0.948245 -0.639308 -0.859632 -0.362748 0.027709 0.640394 9.764636 0.698199 0.687348 0.399134
130 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 3.082301 0.238628 -0.262252 -0.401819 0.997690 1.661177 0.401102 10.229181 0.681581 0.681287 0.394529
135 N12 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
136 N12 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.195547 -1.063835 0.000923 -0.368986 2.224380 -1.404555 2.754469 2.078608 0.674338 0.666002 0.383253
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.757811 -0.391060 -0.424208 2.322873 44.068470 -1.737516 12.741232 0.081394 0.694228 0.680417 0.386352
139 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 5.821285 20.035717 35.350221 53.020475 17.316923 43.831356 -2.403549 8.326238 0.691687 0.053640 0.457521
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.328920 7.399564 1.974056 38.239936 1.722412 33.046724 0.542073 -6.405596 0.707913 0.677826 0.374040
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 2.337322 18.820883 0.856875 53.406299 6.087125 44.073862 1.535766 6.848588 0.701784 0.049336 0.472941
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 17.403330 -1.587082 51.994291 -0.776237 30.008964 0.485561 2.917359 -0.271859 0.039650 0.698856 0.464059
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.539385 -0.947585 -0.077501 18.115588 1.513786 28.612001 0.230077 5.096597 0.703831 0.673078 0.391355
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.641282 5.777064 0.728805 35.931553 8.415702 12.733859 0.874373 3.368253 0.700295 0.603897 0.411714
146 N14 digital_ok 100.00% 0.00% 0.00% 100.00% 4.649231 7.145446 29.695605 35.724585 10.443904 35.229634 -3.177434 -5.970377 0.292994 0.283503 -0.280407
147 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
148 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
149 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
150 N15 RF_maintenance 100.00% 100.00% 0.75% 0.00% 18.157988 3.234096 51.394091 29.770238 29.798145 21.228733 8.126281 -2.799075 0.049436 0.306677 0.063931
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 39.356950 2.722401 14.698940 -0.446715 13.688304 10.907684 -0.888543 0.224186 0.527696 0.624528 0.383733
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 1.919208 2.892148 13.399679 11.027320 45.854244 8.885512 41.391427 31.078007 0.647270 0.644283 0.411769
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 17.801173 1.889611 20.859973 10.524255 29.911546 4.810006 4.899581 -0.540640 0.041889 0.638912 0.487905
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.226716 0.556956 18.943360 17.849078 5.706545 7.893974 -1.457504 -0.299933 0.633645 0.637821 0.418923
155 N12 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
156 N12 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.959860 0.111873 43.496336 1.262623 18.597263 -0.115686 4.321118 1.008161 0.485607 0.667077 0.428079
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -0.077493 -0.488688 0.213378 -0.125280 0.088153 1.218539 0.245361 0.075708 0.679459 0.670798 0.386694
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 1.005801 -0.979910 1.209767 3.654858 -0.960816 12.038826 7.802503 32.589339 0.693236 0.682853 0.393241
159 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.907489 -0.930322 0.988063 4.706635 -0.515086 -0.008934 1.220146 1.777838 0.701388 0.689041 0.377185
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.342140 40.013101 -0.401217 6.418545 -0.828670 15.405593 0.548800 4.409804 0.703663 0.562274 0.348739
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.949792 3.276449 10.100662 23.601598 1.147744 22.714448 0.765294 4.542367 0.712177 0.662073 0.391637
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.742006 -0.935241 0.625936 -0.632835 -0.646231 2.644328 0.319630 1.628183 0.708100 0.689824 0.388565
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.198019 -0.225873 7.138597 2.221149 11.457017 3.632829 1.495578 3.238896 0.694975 0.695710 0.391073
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 27.400357 0.468099 38.199863 2.211516 20.137564 -1.443680 1.169653 0.046607 0.420127 0.692707 0.420136
166 N14 RF_maintenance 100.00% 0.00% 97.91% 0.00% 43.456376 17.514778 9.132190 51.003009 14.669138 43.735410 4.619359 2.838860 0.553588 0.090489 0.345476
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.680576 -1.233114 12.013731 0.948474 -1.311047 2.935821 -0.772474 2.936959 0.705820 0.689323 0.402758
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.571776 -0.794879 -0.770967 3.294788 0.415891 -0.781803 -0.067074 2.957477 0.696559 0.692717 0.405166
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.685212 4.579602 26.247974 31.674483 7.546968 23.261887 -3.531469 -4.871124 0.697564 0.669175 0.405208
170 N15 digital_ok 100.00% 100.00% 0.00% 0.00% 18.116154 -0.575074 52.263552 18.137767 29.941671 4.603505 4.626866 -1.564703 0.044891 0.691295 0.488846
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.154043 4.973025 6.173978 1.561669 2.342340 10.798449 0.948390 1.231536 0.642674 0.602453 0.395276
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 20.112869 20.084527 18.900547 20.987994 29.693842 43.889875 10.727204 19.354592 0.040635 0.044959 0.005557
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.379149 0.187480 -0.693824 -0.454092 1.482383 4.297396 0.681969 15.670508 0.666940 0.655696 0.400839
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -0.858557 -0.748935 0.971146 3.281143 -0.938029 2.765432 -0.180168 3.008118 0.677852 0.669147 0.401656
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 4.896555 -0.070842 0.603657 0.606111 0.731602 0.128058 4.056510 2.600194 0.674307 0.669293 0.395771
179 N12 RF_maintenance 100.00% 100.00% 100.00% 0.00% 18.394904 20.486886 52.299360 55.973854 29.965866 44.174209 4.116003 5.343205 0.050160 0.055913 0.007734
180 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 17.515483 19.728999 51.835015 54.071161 29.911460 44.107806 3.933375 8.400843 0.050674 0.053640 0.005107
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.299409 -1.224671 0.451481 -0.434222 0.301476 1.611205 0.600094 11.453891 0.709367 0.689536 0.383276
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.001883 6.298185 28.660040 35.384932 4.026673 27.628657 7.694084 -3.357303 0.656937 0.682423 0.392976
183 N13 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
184 N14 digital_ok 100.00% 98.87% 100.00% 0.00% 17.077831 19.293128 51.599330 53.449602 29.350529 43.889828 4.058830 4.599841 0.116510 0.050283 0.050193
185 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 16.377730 -0.856056 51.572487 15.610402 29.827769 -0.166476 3.419673 -0.094050 0.038852 0.670951 0.434131
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 1.659968 2.231690 13.218553 10.626396 9.880742 5.843078 4.253963 1.045016 0.690972 0.694863 0.392040
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 4.708556 2.417466 0.727080 24.445494 29.889185 27.849656 2.663594 10.766619 0.686934 0.689199 0.403024
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 1.988811 2.589499 6.378635 1.920975 2.393691 0.492701 1.291556 2.067764 0.676640 0.680209 0.407930
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 64.080035 19.019836 7.031916 53.882163 22.629979 44.247603 57.322546 9.405500 0.486966 0.036995 0.315438
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.598034 0.720183 18.708912 -0.082679 2.298964 -1.720090 36.291754 1.617460 0.658643 0.672754 0.421025
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 9.114982 10.120615 43.012490 43.185626 26.182999 40.181736 -7.865875 -8.161187 0.633511 0.630219 0.407238
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 9.534848 2.251973 42.937356 26.034257 26.033159 16.985320 -7.858508 -1.358243 0.629435 0.650314 0.428450
200 N18 RF_maintenance 100.00% 100.00% 49.95% 0.00% 19.483814 49.939977 21.039842 19.710065 29.712877 40.079811 6.795571 -0.421002 0.048841 0.213890 0.126780
201 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.765384 8.903317 42.906370 40.469357 25.964532 36.004697 -7.458093 -7.264525 0.662868 0.648402 0.381593
202 N18 digital_ok 100.00% 0.00% 0.00% 0.00% 2.732952 4.631873 19.973902 1.698648 5.437161 8.865618 2.747783 5.645961 0.689298 0.635221 0.389339
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 20.194714 21.510944 19.790757 21.528373 29.772561 43.915304 8.888361 11.096351 0.035648 0.043779 0.002044
219 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.817556 7.762708 43.709613 35.959410 27.171180 28.735850 -8.082959 -5.960792 0.627436 0.646016 0.391558
220 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.598415 7.006203 35.829331 35.880649 18.631754 28.195155 -1.362503 -6.289377 0.686907 0.663102 0.394819
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 4.704442 2.118850 1.935516 15.286682 6.795405 6.047945 8.803303 -0.286808 0.649786 0.659781 0.396342
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 6.914754 7.717500 37.411105 36.452747 20.663587 29.923408 -3.401865 -6.235668 0.674457 0.657733 0.397911
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.286831 3.568200 0.962692 11.943125 6.916656 6.555810 0.846019 -1.110024 0.634344 0.638139 0.402460
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.571300 0.827792 22.982431 22.024119 7.315081 12.814282 -2.466572 -3.055578 0.684582 0.658603 0.401255
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.338449 7.013551 19.124711 36.323987 4.824842 30.339642 -0.230839 -5.512615 0.677105 0.649365 0.400088
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 1.221382 19.720208 0.867249 34.168530 0.559692 43.992402 54.337710 9.291965 0.681782 0.050955 0.461322
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.539148 1.830045 14.648169 16.514297 6.264768 8.896936 11.177344 7.976514 0.601043 0.580655 0.408009
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 3.018943 4.534813 17.829902 29.122180 6.056678 20.726783 0.268839 -3.772561 0.591351 0.574270 0.403620
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 35.946075 3.160889 3.375628 26.656838 17.953613 16.340666 38.804703 1.842789 0.382055 0.567346 0.373331
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 2.820955 4.667988 23.053344 26.269146 8.562308 15.633508 -1.180948 -3.441121 0.589137 0.567067 0.391313
325 N09 dish_ok 100.00% 100.00% 100.00% 0.00% 1.093257 -0.041772 23.385069 11.293535 8.347944 6.190773 -2.037808 0.536882 0.082511 0.085901 0.033262
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 2.050374 0.275625 12.840329 13.982196 9.501355 6.110330 9.778979 -0.023936 0.583526 0.576848 0.401182
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 5.388220 2.644165 3.908592 10.760333 6.634757 7.701209 3.311090 0.264263 0.555461 0.563448 0.394940
In [22]:
# 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] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [7, 8, 10, 15, 16, 18, 19, 20, 21, 22, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 77, 78, 81, 82, 84, 86, 87, 88, 89, 90, 91, 92, 93, 94, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 116, 117, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 164, 165, 166, 167, 169, 170, 171, 173, 176, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 200, 201, 202, 203, 219, 220, 221, 222, 237, 238, 239, 320, 321, 322, 323, 324, 325, 329, 333]

unflagged_ants: [3, 4, 5, 9, 17, 40, 41, 70, 83, 85, 100, 112, 118, 137, 157, 163, 168, 177]

golden_ants: [3, 5, 9, 17, 40, 41, 70, 83, 85, 100, 112, 118, 157, 163, 177]
In [23]:
# write to csv
outpath = os.path.join(nb_outdir, f'rtp_summary_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/rtp_summary_table_2459876.csv
In [24]:
# 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 [25]:
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 [26]:
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 [27]:
from hera_qm import __version__
print(__version__)
from hera_cal import __version__
print(__version__)
2.0.4.dev44+g3962204
3.1.5.dev171+gc8e6162
In [ ]: