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 = "2459867"
data_path = "/mnt/sn1/2459867"
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-14-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/2459867/zen.2459867.25287.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/2459867/zen.2459867.?????.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/2459867/zen.2459867.?????.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 2459867
Date 10-14-2022
LST Range 21.047 -- 7.068 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
Total Number of Antennas 180
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 35
RF_ok: 9
digital_maintenance: 11
digital_ok: 98
not_connected: 23
Commanded Signal Source None
Antennas in Commanded State (reported) 0 / 180 (0.0%)
Antennas in Commanded State (observed) 0 / 180 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 16
Nodes Registering 0s
Nodes Not Correlating
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 52 / 180 (28.9%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 138 / 180 (76.7%)
Redcal Done? ❌
Never Flagged Antennas 42 / 180 (23.3%)
A Priori Good Antennas Flagged 62 / 98 total a priori good antennas:
3, 7, 10, 15, 19, 20, 21, 30, 31, 37, 38, 45,
46, 51, 53, 54, 55, 56, 66, 67, 68, 71, 73,
81, 84, 86, 93, 101, 103, 108, 109, 111, 117,
121, 122, 123, 128, 140, 141, 142, 143, 147,
156, 158, 161, 162, 164, 165, 167, 169, 170,
176, 179, 181, 183, 184, 185, 186, 187, 189,
190, 191
A Priori Bad Antennas Not Flagged 6 / 82 total a priori bad antennas:
89, 90, 125, 136, 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_2459867.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 100.00% 0.00% 0.00% 0.00% 5.412364 -0.774587 -0.288920 -0.338938 -0.560672 -0.680655 0.004755 3.765757 0.691451 0.677037 0.404660
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.377624 4.578089 2.104993 -0.237828 -0.265230 -0.465156 1.168317 -0.522790 0.701960 0.673753 0.402558
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.641740 0.067745 -0.847508 1.151155 -0.221812 0.768488 -0.186733 -1.111460 0.709064 0.679533 0.398054
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.104869 -1.438328 -0.048619 0.608036 -0.022964 -0.407353 1.387857 19.882904 0.702098 0.680048 0.400264
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.038503 1.223361 1.370170 -0.125777 -0.563832 -0.083002 8.986097 0.594865 0.698397 0.662829 0.393528
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.396010 -1.304322 -0.389817 0.099893 0.599946 -0.936637 -0.147752 -0.658142 0.699302 0.670503 0.404635
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 8.039504 -0.883769 2.313034 2.366390 5.614932 1.916598 1.261155 -0.408391 0.685318 0.665703 0.409440
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 0.613166 0.290145 4.827627 2.147908 -0.384115 -0.611592 3.685883 2.565505 0.711022 0.682238 0.399233
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.809494 1.129737 -0.525076 -0.466888 0.155573 1.347119 1.628355 3.473836 0.712882 0.677784 0.396070
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.633993 0.703548 -0.994989 0.144176 -0.181496 -0.170418 0.422223 0.817271 0.708379 0.686919 0.390439
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.371005 14.688202 0.988351 0.883166 0.924374 5.363576 14.130820 29.660138 0.698017 0.459028 0.458817
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.640659 -1.132644 -0.232630 -1.181317 -0.153747 2.493087 12.513598 17.157151 0.703460 0.686667 0.399812
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.655150 3.819619 0.327013 17.161173 -0.105650 2.084812 0.742281 -1.633795 0.707440 0.674470 0.398374
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.739733 -0.138653 -0.830592 -0.985287 0.826313 0.553595 1.347256 6.743057 0.693777 0.672801 0.403344
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 39.986739 13.264548 5.059069 18.488647 4.630510 3.845745 6.908499 3.289622 0.459875 0.611242 0.345778
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 14.287390 16.268004 56.171782 57.155996 5.785917 9.947092 4.874449 2.728143 0.033566 0.038353 0.002559
28 N01 RF_maintenance 100.00% 0.00% 87.33% 0.00% 17.899336 35.115387 6.049827 4.335609 6.155671 13.109696 7.683825 23.023164 0.361628 0.154501 0.234791
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.106579 -0.150862 -1.005133 -0.480768 -0.803548 -1.022339 -0.145471 3.146308 0.715567 0.686172 0.387282
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 1.904421 -1.078022 0.679145 -1.182588 0.238550 -0.876967 10.998923 0.735630 0.706227 0.688551 0.385796
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.198784 1.330698 0.455792 -0.358146 -0.469589 4.516967 1.990902 3.395929 0.723160 0.687466 0.399896
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.127935 21.809575 2.768883 4.843382 9.898829 9.286629 5.359626 6.865613 0.662607 0.624325 0.360468
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.096022 17.886136 -0.755009 1.109354 -0.737359 8.435215 3.452079 23.004311 0.700677 0.490335 0.479156
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 16.397319 3.674863 23.127158 17.729572 5.786883 2.741686 2.186982 -0.748065 0.043687 0.654360 0.551112
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.084464 1.801454 1.593788 11.508011 0.952131 2.611249 4.988054 -0.307232 0.620584 0.639012 0.420370
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.870346 10.333174 0.683785 0.469956 0.037163 0.447918 2.441298 0.740446 0.710511 0.684598 0.405282
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.398678 1.181634 3.785643 4.395887 -1.237462 -0.560400 0.104957 12.123326 0.714753 0.690520 0.403807
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.056396 0.396515 -0.995373 -0.974310 1.004564 -0.414457 9.466837 2.892688 0.719694 0.696755 0.402946
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.550854 -0.297479 -0.951008 -1.068625 0.652559 -0.408985 -0.232662 -0.504425 0.713729 0.687023 0.391084
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.537760 -0.132365 1.367434 1.192011 1.319132 -1.239876 -0.378279 -0.456463 0.720060 0.691053 0.384626
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.064168 1.163576 -0.098632 1.558534 -0.378552 -1.092027 -0.110025 -0.951615 0.725722 0.699594 0.394030
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 13.386597 1.670569 55.540704 -0.769096 5.797070 -0.252852 3.258565 0.683794 0.041404 0.695081 0.496296
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 40.057074 2.243273 4.832839 3.607619 2.137590 -0.443894 12.686950 4.128043 0.621949 0.692258 0.366296
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -0.411142 3.796639 -1.016113 -0.249931 -0.237731 2.683358 0.375091 30.146865 0.714776 0.675404 0.388178
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -0.403245 16.872255 -1.022203 57.389233 -0.316254 9.871084 0.119059 4.095089 0.705369 0.038826 0.534314
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 15.694963 3.890295 22.059793 13.066495 5.813030 0.981070 2.112227 3.988954 0.039898 0.653637 0.550584
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.540360 2.856464 24.768026 29.921406 1.715940 1.820169 -0.241210 -2.804013 0.674496 0.666695 0.417396
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.592619 2.234459 11.883304 28.402778 1.574138 3.368921 0.817929 -1.290844 0.644621 0.652567 0.422561
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.464686 25.683942 -0.742514 2.931921 1.400313 9.465817 2.892504 22.403431 0.704134 0.601357 0.383769
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 31.387178 1.686644 72.434246 -0.193840 5.481187 2.973544 14.621306 5.777145 0.039554 0.692253 0.502416
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.804211 8.125804 0.570614 0.116933 1.563220 -0.996922 0.662102 -0.019976 0.720216 0.698454 0.389356
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.033271 3.349537 -0.774532 0.013438 -0.316677 -0.077360 4.345759 7.890929 0.724637 0.704330 0.395422
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 14.295183 17.162688 56.196456 58.535133 5.851157 9.996999 4.052465 1.803147 0.045691 0.044860 0.001774
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 1.768125 18.089238 0.694590 57.972863 7.022871 9.924622 4.838170 3.938188 0.713233 0.036171 0.515339
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 0.117515 1.823647 -0.028680 -0.430714 -0.225916 1.458641 0.924765 7.551025 0.718661 0.698093 0.372219
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 41.106577 -0.208978 24.646445 -0.710658 2.585251 -0.141984 3.332743 0.365816 0.551898 0.701204 0.372148
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 13.787187 16.973451 55.929408 58.285720 5.871565 10.036196 4.787894 3.434607 0.036550 0.033221 0.002375
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 33.553926 5.385534 5.355625 -0.300764 2.976811 0.164865 0.782694 1.197260 0.631855 0.681449 0.366157
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 14.952105 16.575467 56.086599 58.136483 5.793077 9.988247 3.469072 3.906823 0.027378 0.027080 0.001526
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.664239 4.849130 5.056754 0.123216 1.377596 2.720143 0.448724 3.636077 0.660505 0.630465 0.389010
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.694454 2.711765 20.066500 27.758832 1.260353 4.177637 0.494430 -2.161629 0.678100 0.668721 0.406600
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 0.00% 0.00% 0.00% 0.00% 0.411614 0.778665 0.082979 1.492707 2.162375 0.433265 -0.186545 -0.664010 0.703681 0.685378 0.411276
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.062871 1.993711 11.951677 7.032485 2.110459 -0.198893 -0.037370 1.022416 0.707160 0.692237 0.403115
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -1.133546 -0.312120 10.410237 7.802004 0.104804 -0.467133 1.456577 2.337402 0.711506 0.695080 0.392451
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 2.858313 35.580084 1.539058 77.822820 -0.487141 9.387904 0.518751 14.518866 0.713427 0.032594 0.485979
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.442025 -0.770877 -0.666030 -0.393601 1.255516 0.480824 -0.039099 0.087588 0.716893 0.702981 0.384360
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.961604 -0.249535 0.760367 1.276646 0.181138 0.234365 -0.068879 -0.607777 0.722925 0.708119 0.382712
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 9.646035 -0.571492 2.476399 1.596568 0.733761 0.689013 0.104168 0.502830 0.732405 0.706102 0.380481
72 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 3.942395 -0.510441 1.248550 1.379885 0.382318 0.447591 3.034243 -0.596310 0.714588 0.697972 0.371396
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 13.348176 15.774404 55.190877 56.430255 5.722277 9.876462 4.706161 1.202936 0.027111 0.027292 0.001248
74 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 14.832366 14.156740 57.788253 56.012854 6.057653 9.519563 4.120748 35.433444 0.031796 0.326459 0.205673
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 9.509385 17.254943 16.063512 58.764815 5.161859 10.128420 6.967244 4.225110 0.683763 0.045786 0.516691
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 30.736637 32.475114 20.847715 16.724209 2.469251 6.504920 7.771342 1.285075 0.565636 0.501231 0.214322
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.003835 -0.445463 -0.459306 4.050493 0.606525 18.906243 0.245587 -0.258546 0.681898 0.662422 0.402032
82 N07 RF_maintenance 100.00% 0.00% 100.00% 0.00% 2.111944 16.754237 -0.399298 48.424909 0.117687 10.373210 0.302457 0.096936 0.692102 0.080810 0.577836
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.629020 -0.424011 -0.516833 0.314206 -0.131883 -1.120597 -0.453368 0.056949 0.704792 0.690943 0.392427
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 9.011371 31.559379 7.463264 75.169073 -0.871911 9.436928 -0.121239 7.406890 0.711354 0.040414 0.591690
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.736544 0.204466 -0.780248 -0.727420 -1.024386 -0.684113 -0.392299 -0.988662 0.714516 0.696041 0.392247
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.643320 11.124097 7.316085 4.072342 5.572858 2.564453 2.270593 28.638499 0.703354 0.654849 0.378529
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.572505 9.216628 1.968378 0.684752 17.506910 2.836157 15.698135 1.504397 0.679396 0.715526 0.372667
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.892963 0.958409 1.022606 0.279454 -0.869833 1.297701 -0.177911 -0.742734 0.713506 0.700945 0.376352
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.510082 0.005838 -0.647230 0.038564 0.299939 -0.452574 -0.317390 -0.737744 0.719329 0.700061 0.381383
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.265728 -0.338838 -0.671428 0.738767 -0.784209 -1.012262 0.876028 3.912455 0.715722 0.696906 0.380615
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.341628 -0.491430 -0.646628 0.230857 -0.370090 -0.928573 0.854602 -0.437602 0.708836 0.701741 0.396223
92 N10 RF_maintenance 100.00% 0.21% 19.07% 0.00% 48.936223 55.692314 6.607385 7.988424 5.754735 10.279803 0.761952 9.091275 0.292790 0.239232 0.098580
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 2.596727 0.578614 8.655671 -0.721336 1.881143 -0.357377 6.462062 -0.930784 0.699262 0.690025 0.403755
94 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.698902 -1.077320 -1.131716 -0.722965 0.952098 1.639389 2.735952 3.184768 0.698197 0.679109 0.411071
98 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 2.815107 2.885704 -0.177055 -0.658749 0.045755 1.224230 0.932132 3.414312 0.657152 0.659609 0.406045
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.432102 -0.844650 0.730778 -0.164449 0.624557 2.049331 2.549260 -0.779993 0.682325 0.672309 0.402349
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.897029 -0.901887 1.369901 -1.002019 1.469785 -0.622352 0.353692 -0.771551 0.697072 0.680386 0.395486
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 9.917063 11.211419 2.530039 2.083478 -0.619416 -0.304903 0.231271 -0.724745 0.719400 0.699111 0.388128
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 12.447078 17.034313 50.875921 55.035283 5.055571 10.122814 1.387595 6.262214 0.369648 0.040716 0.298538
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 30.185759 32.287590 64.702888 66.514083 6.126009 10.306704 14.546444 12.143638 0.027060 0.027905 0.001914
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.599249 73.947077 3.561186 53.207796 0.385967 0.923585 0.281962 -0.093033 0.721774 0.639521 0.420070
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.420288 -0.320517 -0.521484 0.083663 0.101549 -0.830247 0.357735 -0.808978 0.719175 0.701768 0.375893
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.333460 1.012794 3.532669 1.583633 2.237491 0.420969 0.598573 -0.814850 0.709774 0.696751 0.379644
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.866784 -0.710882 0.097959 0.120309 -0.148452 -0.638444 0.795424 2.833872 0.712267 0.701609 0.378970
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 7.665187 3.755888 46.904164 0.008767 2.446344 0.408609 1.633010 0.862875 0.532715 0.702054 0.466972
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.490810 16.765589 1.335018 56.453364 -0.915749 9.885551 0.010725 2.827207 0.715153 0.036523 0.494015
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.596956 33.790219 -0.481280 76.167075 -0.870436 9.507609 -0.100748 6.810520 0.721285 0.033467 0.496769
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.250858 16.566444 0.654264 57.073521 -0.370153 9.859661 1.439766 3.545397 0.704304 0.037010 0.489832
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.475424 -0.544904 -0.967711 0.676791 -0.637188 0.664869 2.136723 -0.955329 0.693894 0.682016 0.415320
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.022368 0.981763 2.335527 1.549816 1.621130 0.788088 1.978955 -0.678971 0.673785 0.661883 0.405254
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 15.562909 18.663192 56.403070 59.981774 5.923497 10.050600 2.733114 5.839415 0.027617 0.031718 0.003335
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.650079 0.939628 -0.964739 -0.106302 0.693316 0.710614 0.032610 -0.078415 0.697037 0.684970 0.393848
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.089850 3.063761 7.450114 13.622817 -0.824011 8.304857 -0.237484 0.855247 0.709047 0.658854 0.398059
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 3.187630 31.219529 -0.592508 74.865479 0.448790 9.726386 1.479282 12.840794 0.715714 0.035673 0.601748
121 N08 digital_ok 100.00% 0.21% 0.00% 0.00% 2.620329 6.444257 0.120330 0.723949 0.119345 -0.718142 48.721737 25.003991 0.722015 0.704727 0.393268
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 11.211932 9.231576 0.528094 1.054720 3.458733 -0.321903 0.205004 -0.901822 0.728648 0.708912 0.388530
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 8.445053 11.133306 1.246180 1.741574 -1.097742 -0.138680 0.002332 -0.220903 0.726182 0.709427 0.384612
124 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.630978 0.117796 0.326382 -0.264144 -0.909565 -1.298232 0.790110 0.321427 0.726009 0.709577 0.387442
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.107205 0.179914 -0.319546 -0.377873 -0.953005 0.159960 -0.217577 -0.670010 0.718208 0.696834 0.382128
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 38.342872 -0.296919 4.772103 0.985723 8.611365 -0.195989 9.733705 -0.694056 0.600292 0.696187 0.374231
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.319431 -0.005838 -0.906741 -0.628092 1.141452 -0.045755 1.051293 2.400049 0.716407 0.702249 0.398791
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.800005 8.559694 5.547582 2.733898 -0.323463 2.445320 -0.073000 -0.471744 0.709037 0.677528 0.399943
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.934615 -1.662624 1.847146 1.812304 -0.336396 -0.605403 -0.369798 -0.797460 0.706597 0.689448 0.412052
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.821771 0.225577 -0.537787 -0.666399 -0.053798 -0.307293 -0.154238 3.174924 0.692199 0.680833 0.409945
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -1.206566 16.787783 -0.168272 58.458910 0.370357 10.121392 0.374553 2.002811 0.672111 0.039095 0.473674
136 N12 digital_maintenance 0.00% 0.00% 0.00% 0.00% 3.733381 1.064299 0.012755 0.477000 -0.135292 -0.400566 0.302737 -0.292326 0.666388 0.658383 0.399728
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.346235 -1.375603 1.447395 -0.592232 2.361813 3.958306 1.188224 0.017262 0.682725 0.666539 0.400938
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.709346 -0.148480 -0.002758 1.746713 -1.033879 -1.029667 9.607988 -0.685390 0.700132 0.682793 0.404566
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 4.924068 17.719115 40.314217 57.590451 3.265052 9.785423 -1.498852 4.025575 0.701922 0.050677 0.506902
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.736380 6.264781 1.672861 44.499524 0.978394 7.341843 0.479545 -4.650887 0.713525 0.681624 0.383720
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 1.174636 16.678097 0.623134 58.070680 1.308944 9.958665 1.370562 2.729928 0.711156 0.047378 0.516849
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 14.607472 -1.295607 56.808144 -1.183520 6.009768 0.589983 1.094369 -0.939887 0.039223 0.706100 0.531920
144 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -1.304127 -0.261804 -0.894212 -0.380108 -0.243486 0.847892 -0.240485 1.970590 0.719908 0.702631 0.389548
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.510837 1.832691 0.063339 25.329590 5.716580 19.644125 0.493576 1.296976 0.717889 0.660104 0.398963
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% 100.00% 0.00% 15.225504 16.769055 56.164788 57.969196 5.767494 9.970593 3.879631 3.854826 0.026755 0.029630 0.001533
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 36.354120 2.543560 15.112683 -0.540444 2.540614 2.560919 1.354639 -0.589882 0.534598 0.618586 0.394942
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.028946 2.369316 8.616516 13.454135 0.221003 0.973469 12.861074 0.350812 0.642787 0.642310 0.427104
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 14.932275 1.443225 21.727601 13.784221 5.877768 4.075967 2.188993 -0.924364 0.042401 0.639725 0.544825
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.421571 -0.011057 21.611013 20.965866 1.700804 1.100814 -0.718541 -1.183668 0.645540 0.639364 0.433560
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 13.908861 -1.359557 54.164084 -0.485216 5.726156 1.301188 1.662445 3.923228 0.052156 0.661098 0.492990
156 N12 digital_ok 100.00% 18.53% 0.00% 0.00% 11.830092 -0.557230 53.995033 1.342742 5.085979 -0.291441 2.389259 -0.020419 0.283926 0.670541 0.470599
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.380024 -0.607191 -0.012755 0.209214 -0.983051 -0.122814 -0.017262 0.091305 0.690215 0.673956 0.402479
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.502421 -0.567497 0.558995 1.619648 1.784454 0.100166 4.390692 42.410914 0.702787 0.685071 0.406272
160 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.335433 -0.963820 2.169178 3.806334 -0.800021 0.860718 1.401174 1.271498 0.712171 0.690801 0.389173
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.469208 36.692978 0.103240 6.517662 -0.835670 2.337289 0.094470 2.332941 0.713472 0.562419 0.356659
162 N13 digital_ok 100.00% 75.51% 0.00% 0.00% 14.175932 0.521752 55.310625 4.409336 7.818123 16.659019 2.271600 1.585682 0.145426 0.693559 0.501196
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.435177 -1.536490 0.810231 -1.165841 -1.260890 0.133082 0.357787 1.274293 0.720649 0.690636 0.395350
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.943593 -0.603389 -0.657285 2.333860 7.078045 0.960944 1.475711 1.562301 0.716043 0.699506 0.391888
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 23.974358 -0.039457 41.302864 3.088428 3.285576 -1.184750 0.356189 -0.915009 0.439309 0.699302 0.416409
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 38.433996 8.636079 9.304266 48.352697 2.492691 5.595034 6.777029 -0.423540 0.569862 0.461526 0.326290
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 31.809087 57.827882 4.975151 8.419508 8.209207 6.543558 48.675888 36.845424 0.622153 0.512036 0.307320
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.821176 -1.024083 -0.913566 1.621651 0.626780 0.063809 -0.240192 2.154448 0.709783 0.695245 0.410256
169 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 15.592635 16.878911 55.642067 56.710970 5.690078 9.890907 4.418230 1.950134 0.033858 0.036214 0.001218
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 6.081153 42.905880 -0.106663 5.717081 9.740025 8.277708 3.946101 17.138750 0.683637 0.565491 0.378503
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 1.781389 4.539614 10.918191 0.795694 0.361868 1.445325 0.071505 -0.300717 0.650657 0.597070 0.407464
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 16.929706 17.846397 19.432359 21.498552 5.724581 9.897911 5.805763 10.203554 0.035730 0.040326 0.004942
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.645356 -0.265587 -0.845943 -0.592229 -0.130009 0.171190 -0.071029 16.693071 0.677667 0.658132 0.416112
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -1.174354 -0.953482 0.519599 1.795590 -0.715791 0.119777 -0.046852 2.902625 0.687828 0.669474 0.415459
178 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 3.640703 -0.806174 0.672190 -0.613536 -0.341597 1.889001 3.833752 2.687815 0.684941 0.671714 0.408532
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 15.520432 18.124969 57.199013 60.935223 6.011376 9.895593 1.838066 1.886256 0.045510 0.073388 0.024210
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.296550 17.695744 -1.122896 58.842780 1.422923 10.065486 0.045318 3.441891 0.708756 0.051466 0.526514
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.193659 -0.924563 0.304513 -0.993700 -0.769034 0.138519 0.072749 7.795533 0.718722 0.689963 0.395503
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.195346 4.760997 33.612698 40.730209 0.518454 6.230581 7.593850 14.531333 0.654448 0.686418 0.406127
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 14.681142 -0.183130 52.093857 4.971484 5.722437 -0.533542 0.585484 -0.307339 0.041899 0.689231 0.499168
184 N14 digital_ok 100.00% 52.42% 100.00% 0.00% 13.414848 17.172207 55.522520 58.083272 4.671243 9.956719 1.539397 1.564769 0.220088 0.037895 0.147001
185 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 13.730711 -0.981680 56.295494 17.383695 5.850538 0.185221 1.340130 -0.384568 0.039538 0.673978 0.494585
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 1.788765 1.492847 2.607797 13.124841 7.150020 -0.244284 3.285302 1.147422 0.715082 0.699134 0.399514
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 3.444569 2.378702 4.403149 31.563287 30.439268 3.929868 1.603841 0.833856 0.705646 0.692816 0.409108
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 1.537486 1.996004 2.118094 -0.100450 -0.791478 1.957432 1.063734 5.974478 0.693454 0.678417 0.412951
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 61.264511 16.956620 8.701951 58.651129 6.731482 10.167035 34.993527 4.118148 0.494717 0.035140 0.362606
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.330735 0.951164 0.636199 4.043797 -0.716958 -0.690260 12.613277 14.442617 0.684226 0.668362 0.421968
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.789289 8.563426 37.070576 49.413503 3.293715 9.320972 -2.080976 -5.695136 0.673560 0.633413 0.429508
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 8.497590 1.056352 48.862249 27.892358 5.127659 1.383337 -4.968604 -0.234554 0.639051 0.651885 0.441964
200 N18 RF_maintenance 100.00% 100.00% 59.08% 0.00% 16.432612 46.141239 21.843513 23.360242 5.684970 9.838308 3.350580 12.874569 0.047312 0.202923 0.132247
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 9.002891 7.580016 49.280035 46.916400 5.214434 8.245132 -4.915024 -4.957140 0.671470 0.648642 0.394245
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.889680 4.256606 23.773410 1.421314 0.530081 3.845186 2.049053 5.902532 0.699307 0.631166 0.405025
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 17.084345 19.136563 20.468281 22.126727 5.753871 9.907834 4.614824 5.091356 0.034201 0.043273 0.002669
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 8.714526 5.418339 50.083193 41.834113 5.417749 6.326393 -5.237873 -4.145264 0.646213 0.660179 0.415576
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 4.956144 5.858159 41.039967 41.622587 3.322602 6.664710 -1.047670 -4.524457 0.697370 0.663398 0.406317
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.031062 1.601478 2.343207 18.981775 2.764059 0.699323 3.931213 0.155297 0.653259 0.660012 0.408479
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.926534 6.262375 42.668609 41.858839 4.040187 6.531745 -0.066156 -4.322829 0.687481 0.661203 0.408899
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 4.279937 3.063574 1.083620 13.820125 2.054573 2.057572 0.145226 -1.213844 0.639240 0.636344 0.415585
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.870916 0.486007 26.271984 25.145121 1.289269 4.042856 -1.637017 -2.370570 0.694122 0.658545 0.412296
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.602545 4.204266 15.108559 -0.456851 -0.574623 2.902184 6.523793 21.523511 0.684893 0.606514 0.425714
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 0.511850 17.529504 -0.782988 36.331230 0.168525 9.908765 7.454743 4.375554 0.689413 0.047932 0.532264
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.342371 1.407298 16.410455 18.851317 2.143788 2.231371 4.426572 3.026622 0.612636 0.584917 0.421829
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 2.242988 3.423579 20.224208 33.259978 1.281484 4.810863 -0.317432 -2.790350 0.603046 0.577827 0.416783
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 32.012790 2.776924 4.229411 32.531626 3.046933 4.882329 1.798829 -1.675091 0.389645 0.568951 0.373985
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 1.974385 3.523000 26.418568 30.407428 1.492535 3.450037 0.199340 -2.476084 0.603631 0.572454 0.405782
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 1.386268 -0.469093 26.851631 13.663850 1.404071 1.013863 -1.604762 -0.095977 0.636429 0.586337 0.412889
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 5.987448 -0.141272 -0.223202 19.234727 1.485410 1.848755 2.729069 -0.823063 0.534247 0.580971 0.415162
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 5.739857 2.490633 -0.268071 11.977313 1.717728 2.171255 2.205406 -0.050447 0.544050 0.564086 0.406713
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: [3, 4, 7, 8, 10, 15, 18, 19, 20, 21, 22, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 71, 73, 74, 75, 77, 78, 81, 82, 84, 86, 87, 92, 93, 101, 102, 103, 104, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 126, 128, 135, 138, 140, 141, 142, 143, 145, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 161, 162, 164, 165, 166, 167, 169, 170, 171, 173, 176, 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: [5, 9, 16, 17, 29, 40, 41, 42, 65, 69, 70, 72, 83, 85, 88, 89, 90, 91, 94, 98, 99, 100, 105, 106, 107, 112, 116, 118, 124, 125, 127, 129, 130, 136, 137, 144, 157, 160, 163, 168, 177, 178]

golden_ants: [5, 9, 16, 17, 29, 40, 41, 42, 65, 69, 70, 72, 83, 85, 88, 91, 94, 98, 99, 100, 105, 106, 107, 112, 116, 118, 124, 127, 129, 130, 144, 157, 160, 163, 177, 178]
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_2459867.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.dev20+g17344e9
3.1.5.dev171+gc8e6162
In [ ]: