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 = "2459862"
data_path = "/mnt/sn1/2459862"
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-9-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/2459862/zen.2459862.35509.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 1490 ant_metrics files matching glob /mnt/sn1/2459862/zen.2459862.?????.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/2459862/zen.2459862.?????.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 2459862
Date 10-9-2022
LST Range 23.178 -- 7.197 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1490
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 N14
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 61 / 180 (33.9%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 137 / 180 (76.1%)
Redcal Done? ❌
Never Flagged Antennas 43 / 180 (23.9%)
A Priori Good Antennas Flagged 61 / 98 total a priori good antennas:
3, 7, 10, 16, 19, 20, 30, 31, 37, 45, 46, 51,
53, 54, 55, 56, 68, 70, 71, 72, 73, 81, 84,
86, 101, 103, 108, 109, 111, 117, 121, 122,
123, 128, 140, 141, 142, 143, 144, 147, 156,
158, 160, 161, 162, 163, 164, 165, 167, 169,
170, 176, 179, 181, 183, 184, 185, 186, 187,
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_2459862.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.081028 -0.625736 -0.550608 -1.325855 -0.557072 0.552574 0.199103 1.367909 0.662863 0.690523 0.421822
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.408644 4.344067 1.901279 0.777455 1.250189 -0.634575 2.736202 -0.177938 0.677996 0.685136 0.416085
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.315078 -0.499300 -0.218149 -0.119031 -0.672829 -0.453501 0.663529 -0.843792 0.682239 0.691710 0.415930
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.509441 -1.366690 0.625832 -0.414436 -0.502014 -0.110402 0.176112 8.121194 0.676353 0.688169 0.416192
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 6.662443 5.584016 28.305346 28.257477 6.739428 11.823296 -0.361953 -2.790251 0.676421 0.677831 0.414400
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.017429 -1.647692 0.481636 -1.008006 0.846600 -0.411642 -0.322729 0.621806 0.669903 0.684481 0.421387
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 12.650956 2.316629 24.202251 22.931379 8.184956 8.579861 -0.428354 -2.088920 0.662718 0.686420 0.425429
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 1.149210 0.339745 0.736815 -1.427986 -0.901801 -1.248155 0.912397 0.762454 0.687475 0.699272 0.414624
16 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.423183 0.704929 1.982147 1.384340 0.113383 0.708232 0.992936 3.711667 0.682444 0.691304 0.410611
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.045976 0.683145 -0.112474 -0.363387 -0.715503 0.216548 0.973063 0.369737 0.680524 0.697487 0.407005
18 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.501146 -1.445718 0.453207 -1.712740 0.319850 2.523760 4.598942 7.360953 0.680073 0.702220 0.413550
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.080674 4.551714 9.314995 26.750866 -0.152318 11.303674 0.006047 -2.609671 0.697101 0.687222 0.420936
21 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.343204 0.905392 -0.522557 1.034203 0.933681 0.015270 0.143397 1.368201 0.673953 0.686527 0.417041
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 38.753371 10.056397 5.146123 13.657243 8.647544 10.015469 3.995681 6.970378 0.461993 0.622898 0.348502
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
28 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.121560 -0.606383 -0.673550 -1.209438 -0.743574 -0.362131 -0.467230 1.849087 0.683044 0.700094 0.399582
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.536321 -1.497361 1.380565 0.883851 -0.189457 -0.069729 4.295324 0.073318 0.680267 0.702495 0.404185
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.674912 -1.275674 -1.582264 0.033496 0.657521 4.090483 0.687953 3.205018 0.701441 0.710907 0.414688
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.391496 34.603868 0.465397 3.179761 -0.791451 6.027731 0.385141 0.819411 0.674936 0.610682 0.377263
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.413775 32.078148 -0.528921 1.920715 -0.608316 14.052247 1.024109 26.598395 0.677422 0.511198 0.473502
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 15.339473 2.954082 8.905305 13.356398 12.482944 2.685019 1.017191 -0.780173 0.045456 0.679479 0.527282
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.571587 1.166182 -0.340867 7.000387 4.091352 2.846085 1.312650 -0.153737 0.579914 0.659629 0.439856
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 12.817209 9.243431 0.463237 -0.681730 1.796591 2.064196 -0.109778 0.071558 0.685769 0.700054 0.421545
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.505129 0.109032 0.118243 1.659147 -0.518390 -0.063710 0.099998 5.580293 0.688800 0.710347 0.424619
38 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -0.294230 0.169667 0.067581 1.012795 0.951208 0.462685 3.047087 1.005214 0.695073 0.713545 0.422325
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.396484 -0.462288 -0.298801 1.095689 -0.554305 -0.466326 -0.481135 -0.643481 0.683446 0.702427 0.407604
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.748289 -0.017429 0.913165 -0.346785 0.967919 -1.272103 -0.600381 -0.833543 0.690933 0.705802 0.395191
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.107787 3.705062 -1.379885 -0.333475 -0.320507 -0.513766 0.042497 -0.686117 0.699369 0.702714 0.409052
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 12.156899 1.473495 29.008194 -1.470391 12.526969 -0.429048 1.696439 0.676417 0.042941 0.711153 0.480619
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 3.193451 2.685374 0.390788 0.240077 0.659906 0.400999 5.806440 3.405871 0.675716 0.704309 0.395009
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -0.427989 0.609396 -0.042249 1.411221 -0.221026 2.489502 0.100678 18.598924 0.687995 0.698254 0.400478
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -1.243132 15.987303 -0.521842 31.033219 1.360449 18.988883 0.972072 2.521027 0.687123 0.038514 0.489648
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 14.666940 3.031456 8.237196 10.353668 12.484496 2.513948 1.100137 2.382062 0.040840 0.678375 0.526006
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 5.908738 7.002335 29.464767 29.267047 7.478318 12.620876 -2.536284 -3.092680 0.657949 0.684172 0.429925
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 6.609704 7.079213 28.787217 29.628481 7.345048 13.099840 -2.385243 -2.955205 0.651195 0.669655 0.422288
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.038588 24.393630 0.370714 0.407779 1.975505 14.291700 8.609861 48.617093 0.676387 0.642464 0.398537
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 31.607283 2.283062 39.587339 3.161774 12.480739 1.633804 8.744162 4.678557 0.040756 0.705489 0.507833
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.013704 9.332228 -0.319445 -0.851129 1.320526 -0.773887 0.586364 -0.075421 0.700245 0.719338 0.410624
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.585858 2.860125 -0.300070 -0.909363 -0.538992 -0.069094 1.770879 4.245832 0.701577 0.722979 0.413119
54 N04 digital_ok 100.00% 100.00% 0.00% 0.00% 13.150797 0.220912 29.399171 -0.852015 12.538400 4.386762 1.980821 2.160753 0.048787 0.706980 0.507992
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 1.628959 16.968760 -1.377635 31.406919 6.486710 18.970992 1.482472 0.843797 0.685968 0.035552 0.458038
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% -0.106739 0.802804 -1.564684 0.544301 0.036526 0.546339 0.585003 5.036586 0.693716 0.718377 0.392762
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 43.981025 1.027547 10.108803 -1.451380 5.298866 2.673445 1.940144 0.146458 0.514551 0.716827 0.395589
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 12.596156 16.113958 29.240533 31.578592 12.579681 19.085551 2.808738 2.101927 0.038128 0.035239 0.001815
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 2.631815 10.328683 0.676779 0.657894 4.714494 3.801800 21.662981 14.692303 0.683620 0.691541 0.390190
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 13.762795 15.744755 29.344316 31.493152 12.517758 19.071615 1.926910 2.322570 0.027357 0.027916 0.001515
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.005221 4.937799 6.146257 2.314504 3.493153 4.780650 -0.445826 1.606091 0.643758 0.652116 0.402367
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 6.560160 7.608337 29.083167 29.495201 7.336161 13.355751 -2.357111 -3.057696 0.673391 0.690772 0.421230
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 3.970340 16.147028 15.771334 10.131329 1.885378 19.020257 -0.334137 2.368064 0.629729 0.046202 0.516620
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.943140 1.061154 10.639287 16.383451 1.346357 3.361750 0.759181 -1.301870 0.614528 0.660066 0.434932
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.425008 0.555360 1.211662 -0.651272 2.297593 2.734061 -0.243196 -0.681106 0.683084 0.703499 0.428569
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.358417 1.269277 2.328663 0.483644 1.577725 0.390772 -0.388723 0.131961 0.684617 0.707054 0.421013
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -1.356199 -0.691473 -1.072780 -1.529721 -0.147380 0.418899 0.184460 1.646436 0.690795 0.713153 0.410917
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 3.203216 36.224111 1.735730 43.792677 -0.033656 18.522562 1.702455 9.341844 0.685021 0.031908 0.464678
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.026204 -1.234466 -1.241482 1.722304 -0.694657 1.326928 -0.549525 -0.590865 0.693457 0.715761 0.403243
70 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 0.565885 -0.291700 6.515326 -0.777425 0.014839 -0.270482 -0.304894 0.215605 0.704221 0.721217 0.403148
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 7.980686 -1.022457 8.422603 0.056223 1.122417 -0.638614 0.479714 0.054406 0.694547 0.725170 0.398417
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 3.768848 -0.230605 -1.237033 -0.797454 1.557411 -0.934757 3.399845 -0.302117 0.686045 0.719219 0.391110
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 12.155439 15.123460 28.797450 30.453343 12.576776 19.014903 2.904019 0.925755 0.027202 0.027231 0.001245
74 N05 digital_maintenance 100.00% 100.00% 6.31% 0.00% 13.653311 13.922896 30.382509 30.668141 12.557152 17.523229 2.480310 16.047847 0.032542 0.320545 0.192126
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 8.303082 16.388167 16.496422 31.869062 5.757722 19.076544 10.933530 2.684330 0.614101 0.045322 0.421718
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 33.202397 35.854876 16.243449 12.721044 5.655920 11.614850 5.632853 2.846572 0.545560 0.538908 0.225136
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 44.982962 -0.106306 12.763805 14.692284 6.548921 2.694833 0.440771 -0.513407 0.477841 0.675793 0.417108
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -1.210506 0.542168 1.402216 3.424188 -0.442593 8.389114 -0.435286 -0.501312 0.640139 0.664635 0.408077
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.488802 4.149082 1.933333 15.715852 2.799641 55.565875 0.261872 7.278819 0.671885 0.585718 0.439890
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.275449 -0.071991 2.829848 -0.720905 -0.940557 -0.029381 -0.673592 0.014152 0.684534 0.701805 0.409968
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 9.942837 31.864262 -0.332858 42.123117 -0.719837 18.462480 -0.464559 4.584584 0.689015 0.041331 0.533882
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.463993 -0.489608 -0.654206 0.422146 -0.866886 -1.093685 -0.675389 -0.882031 0.688462 0.706358 0.413532
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.856913 10.074921 -0.744613 0.912209 4.218968 2.746713 0.418686 12.519177 0.686411 0.671264 0.398577
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 6.720845 9.793789 7.363136 0.592917 3.578833 3.928409 1.212049 0.508486 0.707865 0.727685 0.399764
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.519135 1.433675 0.469784 -0.005456 -0.493381 0.018624 -0.197501 -0.690441 0.690634 0.719549 0.396515
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.469327 0.302240 2.504216 0.166009 -0.244122 -0.626261 -0.728021 -0.853399 0.696455 0.718180 0.400407
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.324848 -0.232779 -0.120084 1.754011 0.235341 0.078988 0.055945 1.500286 0.684016 0.702767 0.398363
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.059617 0.030310 1.750936 2.047756 0.026358 -1.302134 1.136229 0.304406 0.692094 0.721129 0.417292
92 N10 RF_maintenance 100.00% 0.00% 20.54% 0.00% 53.168300 66.307951 4.118379 5.249586 11.762564 19.010191 -0.290207 5.060535 0.300499 0.245201 0.118873
93 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 1.554845 0.446460 2.674076 0.528490 1.782683 -0.472000 2.976159 -0.751770 0.681616 0.704239 0.418267
94 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.902390 -0.519929 -0.659013 0.089548 -0.370107 3.500066 0.955508 2.218616 0.677269 0.692136 0.419425
98 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.354247 2.479065 -1.265976 0.239536 0.873170 1.391484 0.151371 0.870070 0.636493 0.666532 0.414642
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 1.110828 -0.599887 -1.541226 -0.051814 0.672502 -0.804600 1.352021 -0.918197 0.654411 0.690052 0.420547
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.584966 -0.578021 -1.238167 0.182482 -0.015270 -0.676152 -0.102493 -0.571513 0.662843 0.684212 0.406256
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 11.110250 10.535678 4.612406 -0.552080 -0.060180 -0.306804 -0.451153 -0.688528 0.699158 0.709900 0.406551
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 11.410621 17.069302 28.087478 31.643410 11.333965 19.066172 0.689228 4.361625 0.338948 0.040580 0.249883
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 30.282165 32.649412 34.674421 36.665824 12.789187 18.832405 8.701463 8.151160 0.028421 0.028239 0.001890
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.333141 78.308769 -0.610155 28.763725 -0.575319 0.224027 -0.277212 -0.023307 0.698772 0.650515 0.431551
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.334233 -0.276524 -1.156140 0.046945 -0.246901 -0.852572 -0.311342 -0.804101 0.690293 0.715158 0.400728
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.781290 0.159806 -0.892858 -0.868870 0.915582 -0.319209 -0.118877 0.003788 0.684569 0.707660 0.399444
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 3.648891 -0.346075 0.662290 0.276376 2.647641 0.627036 1.086962 1.412910 0.667531 0.701360 0.400933
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 2.572287 4.049749 18.026089 -0.799187 19.612768 -1.050811 1.196650 0.241035 0.600335 0.713975 0.454705
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -1.259039 15.919094 -1.255114 30.456135 -0.904714 18.989842 0.756042 1.527741 0.692363 0.036698 0.466057
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 18.472878 34.250076 0.971836 42.735042 20.324072 18.428366 17.062634 4.260512 0.640911 0.033266 0.409285
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.444640 15.694688 0.911886 30.842479 -1.022831 18.987720 -0.200499 2.327386 0.684858 0.036169 0.456853
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -1.182316 -0.864938 -0.089818 -0.579176 0.771151 0.566699 0.555109 -0.826524 0.671226 0.696011 0.427426
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.593022 0.336458 -0.367036 0.691591 1.255441 0.699300 0.003807 -0.749458 0.643546 0.674215 0.418971
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 14.523207 17.897548 29.534118 32.636127 12.499040 19.084122 1.426975 3.296008 0.027721 0.032845 0.003847
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.345924 0.756181 -0.551948 -1.207507 -0.164111 0.218881 0.709946 1.675848 0.673531 0.695894 0.412871
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.473510 2.505815 7.738177 0.746020 -0.963827 2.195015 -0.002203 0.672614 0.687215 0.682115 0.409389
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 3.394711 31.474232 -0.878813 41.927723 0.211241 18.765037 -0.129637 8.000516 0.689636 0.036893 0.547219
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.692677 7.637976 0.059957 -0.428614 0.629475 -0.147993 22.132680 15.502074 0.700438 0.713237 0.414479
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 11.406086 9.115450 0.231079 2.305930 1.050943 -0.977727 -0.283330 -0.806184 0.699541 0.710474 0.412455
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 9.869449 12.369826 0.658128 0.097564 -0.682208 -1.080158 -0.553420 -0.593003 0.703336 0.718685 0.414792
124 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -1.179362 0.684748 0.326314 -1.149922 -0.958932 -1.416862 -0.003788 0.042932 0.695761 0.715793 0.415787
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -1.168619 -0.726062 -1.152676 0.365433 -0.426838 -0.768202 -0.589828 -0.901076 0.674964 0.707313 0.417752
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 24.703981 1.288025 3.733223 -0.737062 18.287993 -0.801102 29.680290 -0.646379 0.620531 0.708541 0.422747
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.526433 -0.214294 2.713162 0.201958 0.344071 0.255485 -0.027991 0.727167 0.684964 0.711359 0.426512
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.783531 6.294983 -1.514381 -1.102185 -0.059653 1.478958 -0.467679 -0.553869 0.690551 0.697119 0.419720
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.812043 -1.886821 -0.989423 0.005456 -1.270849 -1.477120 -0.641698 -0.708117 0.683746 0.704194 0.427137
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 2.564326 0.046007 -0.675432 0.454029 0.152464 0.279638 0.853493 1.679538 0.663153 0.692884 0.420660
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -0.965284 15.929719 -1.462986 31.688931 1.021988 19.116643 0.281181 1.641683 0.645651 0.040824 0.441325
136 N12 digital_maintenance 0.00% 0.00% 0.00% 0.00% 2.773588 0.707308 -1.299444 0.261415 0.057272 -0.631547 -0.189422 -0.568278 0.642543 0.675799 0.412793
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.086237 -1.436813 -1.493502 0.306882 0.748564 3.344747 -0.136576 -0.611409 0.652264 0.680530 0.412540
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.130624 0.058720 0.643211 0.064817 -0.718277 -1.072621 4.340631 -0.400721 0.672347 0.690645 0.414954
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 6.313601 16.892429 28.314693 31.153987 6.768840 18.964326 -0.855224 2.787849 0.683122 0.054195 0.464472
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.494389 6.914883 4.228776 30.122425 0.916239 13.634681 -0.295642 -2.898730 0.693082 0.687064 0.404103
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 1.034590 15.763464 0.914080 31.441089 3.657021 19.048321 0.614944 1.811725 0.684562 0.050132 0.475054
143 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 13.443670 -1.029844 29.772080 10.241263 12.489665 1.397926 0.357535 -0.854486 0.028795 0.067227 0.037622
144 N14 digital_ok 100.00% 100.00% 100.00% 0.00% -1.666187 -0.377595 2.594409 12.106069 -0.289588 -0.459431 -0.326538 -0.502390 0.051652 0.054829 0.005657
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 5.693468 0.763715 28.036900 1.542576 6.171039 14.614578 -1.643091 0.127474 0.061955 0.059984 0.011112
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% 14.045760 15.963033 29.392723 31.386518 12.532280 19.036379 2.163686 2.272045 0.026604 0.031003 0.002130
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 37.763961 1.819456 13.117470 1.609247 8.197579 4.748641 1.886250 -0.603061 0.511889 0.637094 0.410121
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 0.703794 1.498763 8.345987 10.370654 1.157580 2.393875 4.469114 -0.608063 0.621344 0.663550 0.442592
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 13.746814 0.967150 8.022866 11.065514 12.513256 5.880500 1.074642 -0.656708 0.042583 0.657380 0.523693
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.826414 -0.682595 16.610916 15.050276 1.596702 1.949067 -0.879568 -0.888200 0.618943 0.658089 0.447918
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 12.955971 -0.371724 28.177099 -1.027182 12.504946 2.780530 0.950890 1.046809 0.054512 0.674045 0.490881
156 N12 digital_ok 100.00% 14.30% 0.00% 0.00% 10.543868 -0.032599 28.052966 0.045969 11.291729 -0.196346 1.852890 0.153194 0.261470 0.679279 0.501947
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.610254 -0.665837 1.218899 0.119092 -0.818368 0.192240 -0.314108 -0.216754 0.667604 0.685056 0.416085
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -1.338299 -0.970309 9.208840 0.217901 1.177056 -0.433914 1.008120 14.854586 0.684319 0.691112 0.423713
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 6.855195 4.321016 28.393457 26.721303 6.396544 10.417086 -1.287641 -1.886232 0.680351 0.687980 0.411687
161 N13 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
162 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 296.211061 296.461885 inf inf 8511.453815 8459.476529 7031.746809 7002.020998 nan nan nan
163 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 0.456618 -0.832734 3.393703 6.152879 -0.876831 0.006374 -0.163685 0.501307 0.046877 0.060958 0.003930
164 N14 digital_ok 100.00% 100.00% 100.00% 0.00% -1.702327 -0.232173 9.541204 9.218550 1.766693 0.088376 -0.091351 0.148083 0.049137 0.052721 0.004950
165 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 22.830989 0.042078 21.202138 3.988758 8.605225 -1.036716 0.115788 -0.504219 0.062906 0.054991 0.020217
166 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 74.759876 48.876758 5.373270 3.435954 13.390483 16.492702 18.343907 0.253901 0.057188 0.067261 0.010247
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 41.989233 63.468879 5.459109 3.790638 7.988352 9.639465 22.623933 18.983397 0.560341 0.507972 0.253463
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% 2.922661 2.532141 1.950310 -0.860638 1.471588 1.547356 0.235383 0.732628 0.665078 0.687986 0.421412
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.660051 6.164030 0.667708 0.792176 -0.048451 2.055769 -0.069341 1.557321 0.671181 0.673460 0.419887
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.301899 2.828439 -1.173751 -1.367870 0.818070 -0.118674 8.019954 3.042046 0.663612 0.684678 0.430686
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 1.237445 5.381482 9.955387 0.819685 0.658258 6.124185 -0.210676 -0.413593 0.630141 0.599253 0.419985
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 16.054668 17.026201 6.627668 8.768463 12.579491 19.013582 3.212420 6.623062 0.037557 0.041982 0.004762
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.316588 0.384265 -0.472307 -1.258647 0.605261 0.653327 0.064035 8.604601 0.651123 0.668504 0.428970
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -1.564474 -1.025625 0.895718 0.291214 -1.021781 1.004001 -0.432752 0.946073 0.655197 0.668128 0.428605
178 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 2.932271 -0.988686 3.553317 -1.437064 -0.665794 0.129288 1.336811 0.744966 0.645588 0.677457 0.429683
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 14.410239 17.451450 30.013182 33.254873 12.604711 19.097575 1.494620 1.763819 0.046321 0.067354 0.017160
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.008685 16.714342 -0.636692 31.899099 0.910464 19.148834 1.037677 3.514165 0.679748 0.061963 0.485780
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 3.947614 -0.917276 26.670130 17.839675 5.271657 2.613058 -1.739632 2.734430 0.684961 0.697881 0.424953
182 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 13.545006 0.950229 26.867568 1.646087 12.526914 -0.046997 0.536732 0.000882 0.040756 0.673364 0.466974
184 N14 digital_ok 100.00% 100.00% 100.00% 0.00% -0.954663 -1.126379 10.938616 0.128840 4.533225 0.230677 0.543589 -0.072647 0.054601 0.058434 0.005818
185 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 27.821513 4.962730 11.663558 23.463093 13.017735 13.584477 64.123391 -0.463737 0.056301 0.073689 0.008661
186 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 33.914430 31.461259 1.939153 1.403269 15.104004 19.997044 1.881969 -0.006880 0.060205 0.068276 0.011432
187 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 16.474966 19.493363 2.672287 0.824504 9.442514 19.292944 1.118732 2.360979 0.061777 0.068479 0.013087
189 N15 digital_ok 0.00% 0.00% 0.00% 0.00% 1.958325 2.645828 -0.051361 0.381040 -0.437741 1.614705 -0.286125 2.596447 0.671258 0.687904 0.428714
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 57.670298 16.051847 5.841848 31.792002 7.662045 19.126501 13.670361 2.644190 0.506423 0.038124 0.350009
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.347927 0.445400 1.520482 -1.494654 0.029002 -0.184266 5.681059 6.652940 0.665325 0.681267 0.438111
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 3.762159 9.769341 27.800518 33.552504 9.061780 17.112642 -1.844305 -3.685318 0.646039 0.648641 0.436570
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 9.592175 1.130244 34.111932 21.102687 10.693847 5.541681 -3.406624 -0.482516 0.614936 0.667264 0.457598
200 N18 RF_maintenance 100.00% 100.00% 67.52% 0.00% 15.363819 49.723736 8.122559 16.096472 12.486635 18.591203 1.810810 7.772214 0.049189 0.198759 0.121541
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 9.752186 8.259029 34.058585 31.636295 10.554856 15.436247 -3.319956 -3.181353 0.640711 0.656225 0.423433
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.046426 5.668984 17.915201 -0.934200 1.118182 6.153060 0.504463 1.735106 0.663465 0.601642 0.447896
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 16.061578 18.412768 7.273566 9.173976 12.508379 18.979122 2.289867 2.982858 0.035615 0.043866 0.001999
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 9.291552 6.153009 34.579628 28.363468 11.118674 11.813185 -3.477236 -2.655562 0.610597 0.666751 0.440785
220 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
221 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
222 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 3.616254 2.681207 3.872526 10.625960 2.684535 2.284920 -0.244498 -0.847027 0.604182 0.643126 0.440079
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.610097 -0.235220 19.535073 17.774981 2.717445 4.669818 -1.388011 -1.673761 0.656034 0.661432 0.448369
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% -0.250394 4.279279 12.651553 -1.163401 1.030829 4.820936 2.917220 11.311416 0.646696 0.592778 0.456101
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% -0.313192 16.884172 2.529786 17.989384 0.829702 18.975797 4.191294 2.664441 0.666764 0.049973 0.494455
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.508472 1.541774 13.393574 13.897399 1.759492 2.248484 2.954038 1.408120 0.579287 0.586690 0.436271
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 1.262010 3.212020 15.692243 23.006504 1.471618 6.865664 1.393657 -1.541373 0.567449 0.580967 0.432845
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 33.502221 2.019237 2.814341 20.977607 6.502867 5.243458 3.944162 -0.812463 0.351791 0.572831 0.418142
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 1.302825 3.454788 19.553990 21.175321 2.738145 4.941090 2.287310 0.591769 0.567056 0.576165 0.422654
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 1.107721 -0.897353 19.792097 10.578914 1.532230 0.675078 -1.110543 -0.450907 0.610280 0.596321 0.443790
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 4.829559 -1.272472 -0.049469 12.208340 3.055496 1.552650 3.404951 0.685108 0.488673 0.590182 0.438658
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 5.471545 1.659211 0.450727 9.737522 2.695272 2.761604 0.688730 -0.261216 0.492842 0.577576 0.426735
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, 16, 18, 19, 20, 22, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 68, 70, 71, 72, 73, 74, 75, 77, 78, 81, 82, 84, 86, 87, 92, 101, 102, 103, 104, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 126, 128, 135, 138, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 160, 161, 162, 163, 164, 165, 166, 167, 169, 170, 171, 173, 176, 179, 180, 181, 182, 183, 184, 185, 186, 187, 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, 15, 17, 21, 29, 38, 40, 41, 42, 65, 66, 67, 69, 83, 85, 88, 89, 90, 91, 93, 94, 98, 99, 100, 105, 106, 107, 112, 116, 118, 124, 125, 127, 129, 130, 136, 137, 157, 168, 177, 178, 189]

golden_ants: [5, 9, 15, 17, 21, 29, 38, 40, 41, 42, 65, 66, 67, 69, 83, 85, 88, 91, 93, 94, 98, 99, 100, 105, 106, 107, 112, 116, 118, 124, 127, 129, 130, 157, 177, 178, 189]
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_2459862.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.dev18+gec14f8e
3.1.5.dev119+gc6c286f
In [ ]: