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 = "2459864"
data_path = "/mnt/sn1/2459864"
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-11-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/2459864/zen.2459864.25257.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/2459864/zen.2459864.?????.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/2459864/zen.2459864.?????.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 2459864
Date 10-11-2022
LST Range 20.843 -- 6.864 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 54 / 180 (30.0%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 154 / 180 (85.6%)
Redcal Done? ❌
Never Flagged Antennas 26 / 180 (14.4%)
A Priori Good Antennas Flagged 76 / 98 total a priori good antennas:
3, 7, 10, 15, 16, 17, 19, 20, 21, 29, 30, 31,
37, 38, 45, 46, 51, 53, 54, 55, 56, 67, 68,
70, 71, 72, 73, 81, 84, 86, 93, 94, 98, 101,
103, 107, 108, 109, 111, 117, 121, 122, 123,
128, 129, 130, 140, 141, 142, 143, 144, 147,
156, 158, 160, 161, 162, 163, 164, 165, 167,
169, 170, 176, 177, 178, 179, 181, 183, 184,
185, 186, 187, 189, 190, 191
A Priori Bad Antennas Not Flagged 4 / 82 total a priori bad antennas:
89, 125, 137, 148
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_2459864.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% 8.487152 -1.187158 -0.879534 -0.746216 -0.345483 -0.438703 0.159052 12.813750 0.686067 0.670018 0.416413
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.506449 7.191824 1.933051 0.782910 -0.117051 -0.448893 1.011532 -0.167599 0.692612 0.663154 0.413878
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.458106 -1.683006 0.435674 -0.600018 0.723513 1.289425 2.418881 1.352128 0.700662 0.672860 0.409212
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.032276 -2.405635 1.151339 -0.145204 -0.093387 0.090465 1.780768 30.546739 0.693539 0.669582 0.411700
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.934635 0.967971 10.069001 11.108828 -0.258693 0.986969 19.510752 1.043864 0.703608 0.666064 0.407772
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.308818 -2.108595 0.773929 -0.711798 -0.007862 -0.672953 0.825506 2.096115 0.692099 0.664157 0.415597
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 5.942855 3.324773 19.961072 19.370720 3.773421 5.426571 -2.482205 -2.594733 0.687588 0.662086 0.425286
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 1.255317 1.319626 -1.236385 0.424304 -0.054094 -0.183033 5.737001 5.691040 0.711123 0.676823 0.410505
16 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.542908 1.641913 2.247648 1.668324 0.776595 1.043723 3.602520 7.824933 0.707984 0.673193 0.409722
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.418574 1.490344 0.567956 -0.095718 0.326839 -0.212585 5.889705 4.068128 0.700587 0.679120 0.402697
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.243763 19.672245 -0.718630 -0.465174 1.139414 4.761214 37.606100 53.290892 0.692256 0.454027 0.462521
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 3.252145 -1.557247 0.869350 -1.496044 0.062214 1.352814 26.843279 27.791452 0.692784 0.680089 0.411862
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.558968 6.682761 7.139856 22.306586 0.084243 7.871348 4.863598 -3.894199 0.710215 0.659830 0.417165
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 1.124031 0.035688 -1.046473 0.389524 0.525020 -0.002471 3.321416 16.419081 0.691168 0.668978 0.414596
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 60.024173 25.510596 3.481548 11.311538 3.770548 3.192496 20.389990 9.308791 0.463123 0.608005 0.340337
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 22.173891 25.335116 25.720811 26.875567 8.212510 13.407343 7.471831 5.236178 0.032055 0.036363 0.002656
28 N01 RF_maintenance 100.00% 0.00% 88.29% 0.00% 28.314050 55.744250 0.139035 2.092071 5.401587 11.126043 17.336001 37.271188 0.354082 0.147573 0.233956
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -2.038916 -0.767954 -0.151448 -0.807436 -0.777821 -0.272969 0.609120 7.272320 0.707309 0.679740 0.396700
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.103454 -1.617171 1.880738 0.870598 -0.130672 -0.281899 25.067023 2.108951 0.700203 0.681916 0.399600
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.234623 1.857025 -1.170745 0.133382 0.286046 3.373676 4.282607 7.548174 0.721724 0.684945 0.409861
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.723619 42.629714 -0.143026 2.636401 -0.720926 14.842638 1.935197 48.231640 0.698501 0.622861 0.380661
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.212768 26.052166 -0.081094 1.844446 -0.370530 5.246557 4.520468 55.523329 0.694664 0.475684 0.490035
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 25.439825 5.421480 8.202844 11.016412 8.239873 1.019112 3.243979 -0.072523 0.040218 0.651526 0.546373
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 5.402308 2.739545 -0.741439 5.458762 2.494369 3.077165 11.484949 1.124569 0.603530 0.632025 0.436157
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 16.773215 15.169881 0.894126 -0.573742 0.744302 0.908044 0.917132 2.230939 0.707393 0.680335 0.417558
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.162108 -0.071559 -1.306636 -0.480855 -0.648997 0.031632 0.357904 18.028328 0.713431 0.687721 0.416200
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.983365 -1.215666 0.322662 0.914935 0.565547 -0.018538 15.157113 5.470304 0.715873 0.690516 0.414271
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.392120 0.027663 -0.044340 1.110847 0.680093 -0.475908 -0.279632 -0.122974 0.706056 0.679209 0.404657
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.054240 0.323603 0.031589 -0.403171 -0.079365 -0.921639 -0.633402 0.028998 0.714546 0.684796 0.395804
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.324066 1.365867 -1.291831 0.025836 -0.487202 -0.743498 -0.358277 -0.440310 0.721298 0.694671 0.405773
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 20.816074 5.839783 25.388393 -1.148175 8.249791 0.481755 5.087568 5.576570 0.037378 0.685666 0.487847
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 5.954607 6.056034 -1.137883 -1.156119 0.327128 0.833459 3.753612 12.597504 0.698858 0.681660 0.388427
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -1.646006 6.108953 0.318750 1.513440 0.248451 2.780514 1.181537 51.907277 0.707089 0.663225 0.399527
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -1.258795 26.249118 -0.784064 26.994872 -0.246392 13.324892 0.695500 7.756898 0.702216 0.034718 0.536346
47 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 7.830430 9.348158 24.431078 24.494026 5.483175 8.947288 -5.934556 -6.272246 0.675078 0.653152 0.429252
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 7.462197 8.653428 23.017429 24.081847 4.663139 9.124256 -4.093192 -5.228618 0.673534 0.643700 0.427631
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 38.316845 1.812694 1.374284 -0.603641 9.034813 1.134888 39.179549 2.822189 0.637847 0.675560 0.395800
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 48.396425 1.994932 34.345229 3.188919 7.802895 1.881053 22.882289 13.117207 0.035048 0.685851 0.497022
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 13.885627 12.067542 -0.451214 -0.822050 2.027097 -0.726094 2.612554 1.219448 0.719324 0.696301 0.402604
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.098066 2.920532 -0.977502 -1.093836 -0.021609 0.138513 7.691037 14.186014 0.721973 0.700970 0.407033
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 22.177391 26.710498 25.742161 27.618374 8.298763 13.440741 6.845442 4.455547 0.041970 0.042308 0.001787
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 4.360721 27.596774 0.418375 27.307195 4.085442 13.358796 9.252792 3.292703 0.706142 0.032235 0.513265
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% -0.220078 1.658005 -1.236792 0.297232 -0.006371 0.512240 1.396566 9.862325 0.713989 0.697056 0.384669
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 63.548423 1.472719 9.248763 -1.234117 3.872391 0.868306 6.443974 1.830348 0.548912 0.693299 0.375873
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 21.446668 26.404103 25.597533 27.477140 8.329402 13.489447 7.315286 6.609157 0.034747 0.032114 0.001769
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 50.450052 6.842178 2.077257 -1.089873 3.677281 0.449751 5.471731 12.050349 0.634281 0.681279 0.385516
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 23.134579 25.820697 25.675546 27.398394 8.275634 13.447906 5.630088 7.332884 0.027189 0.026442 0.001466
61 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 8.167082 9.854640 24.127425 24.608589 5.103558 9.777687 -5.361813 -5.946592 0.684316 0.657243 0.418356
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 0.518336 26.595296 12.802006 9.139679 0.895226 13.382212 1.583766 7.206980 0.671076 0.042625 0.601576
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.456734 2.412444 8.113095 13.538763 1.300031 3.036235 29.062498 -1.681636 0.642850 0.639697 0.435373
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.127127 0.111385 0.604070 -0.945521 1.323114 0.878160 -0.612278 -0.122030 0.703938 0.684421 0.422339
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -0.890002 1.735819 2.808790 0.557066 1.300716 0.182248 -0.262096 1.640773 0.706105 0.691054 0.415565
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -2.026421 -1.333694 -0.500021 -1.173486 0.163740 0.133196 2.619146 6.813633 0.711810 0.695301 0.404892
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 4.268816 54.850120 1.959735 37.849795 -0.485743 12.807226 0.152158 24.073331 0.707628 0.028330 0.494077
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.150610 -0.286510 -1.321310 1.706013 0.676029 1.339193 -0.370518 1.679510 0.713321 0.694718 0.395143
70 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 0.285636 0.237850 4.853248 -0.426552 -0.018837 0.329958 1.243210 1.677954 0.723712 0.701162 0.392956
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 11.616303 -1.380963 7.465394 -0.084366 -0.172384 -0.629946 0.432636 1.790742 0.718220 0.702200 0.391460
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 5.718621 -0.703915 -0.632330 -0.716263 0.433421 0.204950 6.058111 0.282077 0.710015 0.698298 0.383483
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 20.692450 24.817628 25.191727 26.492446 8.151268 13.351934 7.666796 3.244056 0.026684 0.026597 0.001137
74 N05 digital_maintenance 100.00% 100.00% 5.48% 0.00% 22.996990 22.757498 26.595204 26.540638 8.522563 12.215003 6.593673 37.909990 0.029976 0.298794 0.187084
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 16.681248 26.815301 15.797967 27.735403 12.386974 13.564428 13.180912 8.224753 0.617462 0.039913 0.464042
77 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 66.723449 1.178679 10.125732 12.207980 5.286170 1.727024 0.473369 -0.024778 0.495095 0.653251 0.392829
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -1.573478 -1.552366 1.832827 3.448074 1.115788 2.850413 0.104834 0.218054 0.662216 0.646880 0.409416
82 N07 RF_maintenance 100.00% 0.00% 100.00% 0.00% 3.690493 26.061970 0.891015 22.244479 0.007298 13.385681 0.980896 1.724249 0.692787 0.077607 0.581543
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.589776 -1.256093 1.808585 -0.908895 -0.733544 -0.216006 -1.152761 0.943639 0.704164 0.684365 0.404750
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 13.008460 48.707388 0.194208 36.436540 -0.720569 12.851989 -0.213524 12.792118 0.710135 0.035897 0.591549
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% -0.756451 -1.479839 -0.072233 0.637184 -1.010504 0.144141 -0.854448 -0.679520 0.708217 0.688832 0.402976
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.455306 16.585889 -0.661794 1.312618 3.618746 1.841777 1.557042 41.067306 0.708761 0.647098 0.397867
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.798340 13.276161 5.950756 0.518781 1.415664 1.363338 0.384176 4.110579 0.731191 0.711238 0.388637
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.157415 0.626230 -0.139910 -0.053423 -0.538634 -0.240807 -0.761504 -0.578283 0.712845 0.701244 0.386163
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.995359 -0.957507 1.710031 -0.069634 0.207014 -0.845589 -0.920376 -0.408937 0.719411 0.699111 0.391044
90 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.243548 0.449562 0.454489 1.721407 0.005791 -0.091481 1.307511 5.588067 0.705619 0.685361 0.388878
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.961754 -1.310390 0.884533 1.571707 -0.778205 -0.910834 -0.309031 -0.005758 0.713140 0.700554 0.405716
92 N10 RF_maintenance 100.00% 1.13% 25.30% 0.00% 77.007400 89.813703 3.338018 3.752243 5.766124 10.170735 0.685377 13.521290 0.287622 0.240765 0.112425
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 3.565509 1.748660 2.806259 0.660428 1.882173 -0.377935 9.537746 -0.087648 0.694457 0.678671 0.412990
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.701365 -0.395601 0.305761 0.293232 0.371555 1.473589 5.958297 10.158974 0.692495 0.666983 0.420082
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 5.508669 1.024440 -0.420934 0.657230 2.311368 3.161023 20.553337 21.482456 0.645038 0.647870 0.415167
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.441110 -1.882682 -1.104261 0.084232 0.413373 2.437993 3.987643 -0.798538 0.674767 0.672090 0.417090
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.189114 -0.027663 0.729269 2.518937 1.769064 0.790940 0.669462 -0.012040 0.684187 0.666077 0.405713
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 14.630142 16.972299 3.365457 -0.636712 -0.463606 -0.625105 1.407777 0.016847 0.717933 0.696269 0.402067
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 19.431242 27.864844 24.577546 27.537078 8.254005 13.455950 2.883370 12.101410 0.360627 0.036569 0.292945
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 46.786255 49.670062 30.261110 31.862462 8.555351 13.702831 23.147078 20.997418 0.026436 0.026813 0.001839
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 14.020760 113.471246 -0.775290 24.667640 0.250132 -0.223546 0.307974 1.062521 0.721106 0.640088 0.429182
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.515142 -2.153043 -1.464945 -0.097337 -0.283135 -0.683758 -0.116370 -0.556133 0.713737 0.700080 0.387353
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.323755 0.390018 -1.067526 -1.004587 1.237586 0.867695 1.303534 1.155713 0.710010 0.696135 0.389546
107 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 2.386920 0.788832 1.243235 0.383986 0.000824 1.534538 1.410903 4.805880 0.696128 0.683173 0.384710
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 4.459965 4.663878 15.166198 -1.092292 23.960391 0.444281 3.499452 2.137629 0.627638 0.696833 0.433802
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.564455 26.114344 -0.534700 26.569637 -0.637947 13.387348 1.572991 5.499991 0.711854 0.033087 0.505871
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.802507 52.018895 1.452245 36.974254 -0.489861 12.951206 1.740078 11.879381 0.720561 0.030561 0.512091
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.239844 25.852188 1.201997 26.899677 -0.555596 13.359649 1.332438 6.528176 0.699397 0.032766 0.498624
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.493170 -0.048823 0.565467 -0.025836 -0.444753 0.508933 2.976103 -0.406738 0.689348 0.671027 0.427459
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.692730 0.883371 -0.744329 0.174919 -0.291645 0.997129 0.790583 -0.143878 0.669629 0.658824 0.417679
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 24.122932 29.055499 25.856475 28.388254 8.402641 13.472319 4.658406 10.601366 0.027599 0.030394 0.002304
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.352679 0.028685 -0.841527 -0.945934 0.146526 0.159729 0.241449 0.724946 0.693595 0.680371 0.407953
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.927704 3.060743 3.860770 3.452676 -0.805795 8.213050 2.186485 5.215372 0.706821 0.665288 0.408025
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 4.417094 47.972928 -1.093356 36.289453 0.327594 13.148705 2.160303 21.758688 0.712559 0.032583 0.603615
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 3.423544 9.648377 -0.654891 -0.650805 -0.024099 -0.459557 102.549471 33.981466 0.721392 0.701815 0.406826
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 15.200711 12.075219 -0.028070 2.183328 0.776879 -0.107180 0.198576 -0.369924 0.722992 0.701316 0.400382
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 12.076482 15.487307 -0.036870 0.105559 -1.026236 -0.567453 -0.069972 0.630539 0.724153 0.704273 0.396697
124 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -2.354239 0.071277 -0.188426 -0.808029 -0.764779 -0.900645 0.913143 1.167375 0.723275 0.706225 0.398032
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.237858 -1.338045 -0.442623 0.159395 -0.479204 -0.522673 0.005758 -0.476134 0.704210 0.697070 0.394724
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 26.709964 -0.088722 3.311012 -0.357463 10.628846 0.259457 15.975711 0.059127 0.663488 0.694575 0.398961
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.913779 0.322087 2.964648 0.454247 -0.277953 0.523646 1.172253 3.028125 0.703626 0.694126 0.406677
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -1.031913 13.414470 -0.921455 -0.793606 -0.393353 1.741661 0.049918 0.211203 0.710370 0.674357 0.406390
129 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 507.662822 506.983081 inf inf 7051.916023 7045.372838 25759.061634 25726.329451 nan nan nan
130 N10 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -2.741832 26.116967 -1.453630 27.574147 0.058330 13.543348 1.673561 4.528156 0.668165 0.035961 0.482399
136 N12 digital_maintenance 100.00% 0.00% 0.00% 0.00% 5.437217 2.125374 -1.164793 -0.197193 0.052317 -0.213747 0.976143 0.702420 0.660707 0.656072 0.413626
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.722752 -2.579756 -1.131899 0.226539 1.273267 0.812390 1.767675 0.005893 0.671675 0.663584 0.413907
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.120758 -1.323172 3.057337 2.227798 -1.070590 -0.937726 14.725589 0.308492 0.689889 0.673834 0.415876
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 6.379538 27.495298 23.592430 27.099820 4.829542 13.312850 -0.723145 7.133770 0.702367 0.047502 0.512986
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -2.924733 8.880468 2.763136 25.171414 0.522365 9.719278 1.608605 -4.588858 0.713724 0.680884 0.397030
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 2.180498 25.970387 0.079941 27.362647 1.911545 13.462931 4.066111 6.596516 0.709239 0.044813 0.519272
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 22.681883 -0.303642 26.079625 9.144972 8.492661 1.525997 1.618505 -0.318932 0.037947 0.675603 0.514104
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.269477 -0.586585 2.599927 9.853786 -0.137761 0.015093 0.128302 3.065813 0.706818 0.709166 0.404722
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 6.503634 2.347678 23.316980 5.545129 3.824460 15.977444 -4.799643 4.185467 0.712582 0.678625 0.401391
147 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 12.669146 0.527590 0.101751 -1.241461 5.858067 -0.881878 116.492231 0.298549 0.688228 0.688783 0.408482
148 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.800984 0.880349 0.499087 1.242457 0.479657 -0.221662 0.808232 0.669394 0.690443 0.680502 0.408104
149 N15 RF_maintenance 100.00% 0.00% 100.00% 0.00% 5.662802 27.372770 2.214933 27.393948 -0.224105 13.435752 3.420316 6.143522 0.686003 0.031871 0.529117
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 23.542706 26.193926 25.712281 27.306161 8.248780 13.455651 6.395569 7.475627 0.026618 0.028469 0.000966
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 55.939551 4.190685 10.361523 0.907088 2.981164 3.036385 1.940737 0.390234 0.540155 0.615294 0.406189
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.677081 3.681213 6.632979 8.552027 0.629954 1.776199 34.522296 2.969613 0.646723 0.639081 0.438352
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 23.145828 2.115591 7.460182 9.240925 8.334332 1.966554 3.355784 5.545355 0.038878 0.638517 0.543464
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -1.222604 -0.221496 13.340515 12.500962 2.691398 2.236951 0.212992 -0.895957 0.647036 0.635561 0.445922
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 21.555498 -1.662408 24.653738 -0.957636 8.166365 1.806963 2.955507 12.222340 0.046986 0.656809 0.491571
156 N12 digital_ok 100.00% 29.11% 0.00% 0.00% 18.357491 -0.424897 24.581989 -0.413769 7.289148 0.209846 4.564643 2.452093 0.275997 0.663700 0.478419
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.135523 -0.295141 0.548875 -0.096132 -0.469656 0.007862 -0.017018 1.491173 0.688670 0.669899 0.416129
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -1.725382 -1.046142 7.052584 -0.299101 1.096697 0.294238 14.267846 64.192025 0.704929 0.678329 0.418609
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 7.539258 5.363269 23.571863 22.275547 4.087498 7.300410 -2.562137 -2.050611 0.704156 0.683098 0.405756
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.699672 56.336234 -0.494319 2.988932 -0.287913 4.761150 1.593323 4.582923 0.707749 0.553629 0.366341
162 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 22.338962 8.490988 25.466479 18.608449 8.239903 4.107780 2.051184 1.665068 0.060718 0.590607 0.439552
163 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.825983 -1.326628 2.378073 5.595578 -0.827484 1.077088 1.671255 4.228069 0.718246 0.677199 0.409916
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.720638 -0.769875 6.715996 7.466432 2.976787 0.663011 4.182753 4.260560 0.720438 0.699887 0.407722
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 35.495196 -1.219582 18.560560 3.096296 5.332076 -0.834064 0.718812 -0.287868 0.412076 0.691346 0.430827
166 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 22.295456 24.587243 24.854480 25.977962 8.140073 13.443593 1.304541 1.785124 0.030311 0.029879 0.000470
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 69.952584 89.343530 3.382640 3.149806 7.366983 9.049376 57.017941 70.430417 0.543831 0.514477 0.193554
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.726921 2.385145 2.283405 -0.508163 0.340471 0.116129 1.429785 1.343068 0.689972 0.681082 0.416989
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.790953 6.870855 1.256135 1.115526 -0.760152 0.329975 2.260174 5.221111 0.699351 0.663799 0.419157
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.032949 5.863161 -0.877835 -1.165106 -0.554437 -0.293464 18.762683 13.565444 0.687380 0.669472 0.422694
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.823867 9.087409 5.769161 -0.992969 0.395646 4.038380 0.985973 1.243318 0.652316 0.578623 0.423331
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 26.431363 27.723283 6.235400 7.965877 8.119574 13.352090 8.913462 18.566983 0.034655 0.038754 0.004435
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.263251 -1.213412 -1.038925 -1.408006 -0.131997 0.613299 0.794938 26.887941 0.673202 0.651313 0.427744
177 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -2.106682 -1.977369 1.179581 -0.285794 -0.895562 1.185732 1.079267 9.387120 0.678664 0.663070 0.428242
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 4.733472 -1.876996 3.413805 -1.228962 -0.630790 0.718224 12.921761 7.050441 0.671475 0.664736 0.425741
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 24.078470 28.284390 26.281387 28.910371 8.505464 13.594385 3.380002 4.576714 0.041572 0.067285 0.022662
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.685368 27.533643 0.676176 27.766198 0.806128 13.506084 1.700295 8.119318 0.700108 0.055755 0.524049
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 4.473066 -0.612454 22.097550 14.907431 3.431447 1.304263 -3.827742 10.585612 0.714952 0.692815 0.413095
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.278727 6.506598 13.996025 23.121438 1.083517 8.292699 21.951576 24.613951 0.648420 0.683275 0.420817
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 23.124284 1.083482 25.238556 3.499720 8.160104 -0.593061 1.948027 1.581800 0.035752 0.670346 0.481735
184 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.789506 -1.720155 10.386121 -0.065172 2.928389 0.639540 5.881143 3.269274 0.677120 0.689095 0.420155
185 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 50.919527 8.470478 11.326627 19.703331 4.268949 8.228233 13.428818 1.035740 0.531561 0.551952 0.341823
186 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 22.010860 25.132199 24.836024 26.385039 8.169747 13.432161 4.266713 4.736850 0.030173 0.025970 0.002902
187 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 22.452269 25.446725 24.958241 26.937628 8.156982 13.402181 3.122192 2.271297 0.025876 0.025254 0.001136
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 3.047225 4.329951 -0.565442 -0.202849 -0.277065 1.147119 1.767480 10.861488 0.696865 0.676527 0.421793
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 87.602144 26.342467 4.458569 27.675762 5.703633 13.590438 47.331713 8.197170 0.507504 0.033461 0.381723
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.415983 1.310699 0.290815 -1.120042 -0.157505 -0.447094 25.354529 24.848146 0.688917 0.668528 0.430234
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 4.245537 12.442771 22.004610 27.791355 5.100289 12.173700 -2.243385 -7.429314 0.676380 0.631582 0.440297
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 12.138603 1.861974 28.153948 16.361781 7.217470 2.397709 -7.628299 1.015387 0.642681 0.650697 0.451678
200 N18 RF_maintenance 100.00% 100.00% 73.79% 0.00% 25.507938 71.226652 7.511135 13.500627 8.122205 10.974662 5.375575 27.606754 0.046471 0.192361 0.129491
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 12.788229 10.781446 28.370877 26.466307 7.160682 11.071853 -7.519402 -5.984707 0.668799 0.643803 0.409908
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 2.481912 9.815451 14.596239 -0.938582 0.830598 5.249242 5.822362 8.486719 0.695176 0.595009 0.434657
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 26.486043 29.714761 6.791545 8.304763 8.212066 13.373465 6.956328 8.461149 0.034127 0.040281 0.000761
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 12.475831 7.516918 28.802899 23.724171 7.537041 8.182753 -8.096344 -5.430429 0.642100 0.653773 0.434501
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.810633 -0.181525 10.151694 11.866684 0.073357 1.683153 8.900507 -1.529596 0.685596 0.656221 0.421839
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 8.399093 2.595984 3.135126 11.631766 2.669149 1.306924 6.122955 2.323998 0.646542 0.652781 0.429675
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 3.745942 3.749507 12.035659 12.421567 1.486763 2.128992 17.322041 -1.014193 0.684067 0.656008 0.425122
237 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
238 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
239 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 1.433598 27.123694 1.493028 15.840314 0.661153 13.387538 12.777647 8.006930 0.688500 0.043966 0.536390
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.088564 1.124164 10.649422 11.456496 1.984604 2.962799 5.525693 4.065476 0.610494 0.578191 0.435266
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 3.120341 4.456871 12.684878 19.098285 1.357140 6.030240 0.867163 -2.963685 0.603400 0.573312 0.428867
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 49.666395 2.651304 2.059152 17.414739 4.670614 4.786756 8.786425 -0.425748 0.385358 0.564749 0.384729
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 2.168931 4.724758 15.874070 17.621848 1.789569 4.680030 -0.514271 -2.702579 0.604520 0.569128 0.416916
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 1.376653 -0.846242 16.229877 8.684382 1.763092 1.381873 -1.990213 2.032937 0.641768 0.584206 0.437752
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 9.626677 -0.391082 1.381760 11.578224 3.067537 2.449294 6.746881 0.563653 0.530288 0.574626 0.425785
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 10.458485 3.821043 -0.338406 7.794076 2.623215 2.250181 4.725615 2.623802 0.523332 0.556965 0.417003
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, 16, 17, 18, 19, 20, 21, 22, 27, 28, 29, 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, 67, 68, 70, 71, 72, 73, 74, 75, 77, 78, 81, 82, 84, 86, 87, 90, 92, 93, 94, 98, 101, 102, 103, 104, 107, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 126, 128, 129, 130, 135, 136, 138, 140, 141, 142, 143, 144, 145, 147, 149, 150, 151, 152, 153, 154, 155, 156, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 173, 176, 177, 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: [5, 9, 40, 41, 42, 65, 66, 69, 83, 85, 88, 89, 91, 99, 100, 105, 106, 112, 116, 118, 124, 125, 127, 137, 148, 157]

golden_ants: [5, 9, 40, 41, 42, 65, 66, 69, 83, 85, 88, 91, 99, 100, 105, 106, 112, 116, 118, 124, 127, 157]
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_2459864.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 [ ]: