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 = "2459861"
data_path = "/mnt/sn1/2459861"
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-8-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/2459861/zen.2459861.25297.sum.auto_metrics.h5.

Load Ant Metrics¶

In [7]:
use_ant_metrics = False

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

# if they exist, load as many of them as possible
if len(ant_metrics_files) > 0:
    print(f'Found {len(ant_metrics_files)} ant_metrics files matching glob {glob_str}')
    ant_metrics_apriori_exants = {}
    ant_metrics_xants_dict = {}
    ant_metrics_dead_ants_dict = {}
    ant_metrics_crossed_ants_dict = {}
    ant_metrics_dead_metrics = {}
    ant_metrics_crossed_metrics = {}
    dead_cuts = {}
    crossed_cuts = {}
    for amf in ant_metrics_files:
        with h5py.File(amf, "r") as infile: # use h5py directly since it's much faster than load_metric_file
            # get out results for this file
            dead_cuts[amf] = infile['Metrics']['dead_ant_cut'][()]
            crossed_cuts[amf] = infile['Metrics']['cross_pol_cut'][()]
            xants = infile['Metrics']['xants'][:]
            dead_ants = infile['Metrics']['dead_ants'][:]
            crossed_ants = infile['Metrics']['crossed_ants'][:]        
            try:
                # look for ex_ants in history
                ex_ants_string = infile['Header']['history'][()].decode()
                ex_ants_string = ex_ants_string.split('--apriori_xants')[1]
                ex_ants_string = ex_ants_string.split('--')[0].strip()
            except:
                ex_ants_string = ''
                    
            # This only works for the new correlation-matrix-based ant_metrics
            if 'corr' in infile['Metrics']['final_metrics'] and 'corrXPol' in infile['Metrics']['final_metrics']:
                ant_metrics_dead_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corr'][ant][()]
                                                 for ant in infile['Metrics']['final_metrics']['corr']}
                ant_metrics_crossed_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corrXPol'][ant][()]
                                                    for ant in infile['Metrics']['final_metrics']['corrXPol']}                       
            else:
                raise(KeywordError)
        
        # organize results by file
        ant_metrics_xants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in xants]
        ant_metrics_dead_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in dead_ants]
        ant_metrics_crossed_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in crossed_ants]
        ant_metrics_apriori_exants[amf] = [int(ant) for ant in ex_ants_string.split()]
    
    dead_cut = np.median(list(dead_cuts.values()))
    crossed_cut = np.median(list(crossed_cuts.values()))
        
    use_ant_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping ant_metrics.')
Found 1862 ant_metrics files matching glob /mnt/sn1/2459861/zen.2459861.?????.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/2459861/zen.2459861.?????.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 2459861
Date 10-8-2022
LST Range 20.655 -- 6.676 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 N14
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 64 / 180 (35.6%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 118 / 180 (65.6%)
Redcal Done? ❌
Never Flagged Antennas 58 / 180 (32.2%)
A Priori Good Antennas Flagged 60 / 98 total a priori good antennas:
3, 7, 19, 21, 30, 31, 37, 38, 45, 46, 51, 53,
54, 55, 68, 71, 72, 73, 81, 83, 84, 86, 93,
94, 100, 101, 103, 108, 109, 111, 117, 121,
122, 123, 140, 142, 143, 144, 147, 156, 158,
161, 162, 163, 164, 165, 167, 169, 170, 176,
178, 179, 183, 184, 185, 186, 187, 189, 190,
191
A Priori Bad Antennas Not Flagged 20 / 82 total a priori bad antennas:
4, 48, 49, 61, 89, 90, 125, 136, 154, 171,
202, 221, 237, 238, 321, 322, 324, 325, 329,
333
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_2459861.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% 3.791438 -0.395894 -0.421539 0.312928 -0.938334 1.204274 0.069127 5.424877 0.694061 0.675296 0.418753
4 N01 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.067765 3.327192 0.923906 0.854555 0.330544 0.649750 1.002475 -0.353171 0.709715 0.666703 0.416161
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.449799 -0.490917 0.361875 -0.258500 -0.415875 0.571569 0.912022 0.182576 0.712718 0.678214 0.409716
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.099446 -0.751942 0.604471 0.578197 -0.614074 0.427473 0.716083 15.755682 0.706294 0.675724 0.412100
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.624453 -1.195699 -1.473471 -1.500416 -0.734690 -1.139674 6.216195 -0.381319 0.716124 0.675139 0.409394
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.223882 -1.241123 0.530653 0.411299 0.710966 0.796711 -0.163597 0.957430 0.699896 0.669581 0.416497
10 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 3.147452 0.621795 1.473307 0.770012 0.299371 -1.096501 -2.078696 -2.461831 0.696803 0.669435 0.426755
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.280842 0.082209 -0.783172 0.105169 0.564116 1.266104 0.625501 1.098486 0.720592 0.684162 0.412320
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.200353 -0.440607 0.897828 1.040866 -0.622815 -0.169106 0.789205 2.179860 0.718034 0.678106 0.409374
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.110560 0.286580 0.374523 0.548162 -0.475354 0.329528 2.416644 1.479502 0.708089 0.685241 0.401197
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.914741 10.069289 -0.021302 0.162439 0.699264 0.149411 10.657612 16.314763 0.703048 0.460901 0.464248
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.317563 -1.644065 0.520603 0.074434 -0.398976 0.139021 12.178884 12.747586 0.706297 0.688455 0.411872
20 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.429595 2.054862 -2.282396 1.845265 -0.446836 -0.115802 0.686631 -3.806330 0.721586 0.669492 0.415875
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.193498 0.021748 -0.470958 -0.560664 0.322429 0.342048 2.148313 6.894325 0.703231 0.673702 0.414467
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 29.634336 10.213586 -1.523120 -1.510424 1.146190 0.175961 4.803483 1.224708 0.476509 0.617320 0.347749
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 10.126242 11.399989 8.214404 8.919202 2.560982 3.246567 3.030764 1.809333 0.031720 0.036203 0.002710
28 N01 RF_maintenance 100.00% 0.00% 87.11% 0.00% 14.467557 28.367454 -0.023476 -0.046331 5.658676 4.918592 9.251892 12.703279 0.363278 0.155469 0.236824
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.234767 -0.373029 0.233605 0.352502 -0.384868 0.210630 -0.037123 2.022223 0.715885 0.686893 0.397676
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.440334 -1.137825 0.780401 0.874187 -0.026758 0.411667 14.301028 0.944300 0.705004 0.687600 0.396399
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.453047 -1.255219 -0.126100 -0.298346 0.992833 4.049433 1.294079 3.395552 0.729792 0.697911 0.407420
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.666432 25.853558 -0.535740 -0.786880 5.899780 -0.454384 9.759158 1.586984 0.679393 0.607576 0.332779
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.222458 12.645755 0.259836 0.947453 -0.232931 0.520403 1.181315 19.422236 0.705533 0.496114 0.481903
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 11.830891 1.122095 2.886264 -1.894759 2.546711 3.270494 1.024776 -0.354363 0.039701 0.657715 0.506834
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.051869 -0.088833 -0.556281 -2.065407 -1.749952 -1.665314 5.952491 -0.237775 0.620044 0.641050 0.436065
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.089268 6.737148 0.514920 0.420242 0.931396 1.069311 0.245630 0.382363 0.711174 0.676954 0.422558
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.091632 0.071966 0.470914 1.079200 0.186152 1.211126 0.038301 11.353072 0.714369 0.688701 0.423908
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.099841 0.175955 0.405251 0.951332 1.282485 1.669972 7.460405 2.325156 0.720823 0.693912 0.422416
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.201380 -0.074021 0.312307 0.952064 0.878722 0.206866 -0.372673 -0.553185 0.713837 0.685453 0.408859
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.290036 -0.687152 -0.805392 -0.239375 0.771039 0.514716 -0.319230 -0.651694 0.723130 0.692624 0.399928
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.271591 2.138785 -0.217287 0.591581 0.049173 -0.019818 0.052769 -0.598730 0.728827 0.687189 0.407746
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 9.359568 1.595040 8.113863 0.127491 2.555280 0.247699 1.831366 1.329353 0.037271 0.692979 0.461738
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 10.350318 1.325506 0.557843 0.707513 5.575758 0.405788 17.401400 4.292763 0.675636 0.689087 0.383685
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -0.566652 -0.125953 0.398322 1.024401 0.635855 -0.644898 0.093811 24.430089 0.715968 0.681961 0.399045
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -0.836066 11.897196 -0.406776 8.962353 1.104298 3.190852 0.103260 3.055279 0.712483 0.034714 0.507303
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 11.334471 0.888465 2.713514 -2.392302 2.560198 0.277926 0.951263 2.472570 0.037502 0.661945 0.511628
48 N06 not_connected 0.00% 0.00% 0.00% 0.00% 3.109155 3.716508 2.833104 2.473712 0.585942 0.217655 -3.900575 -4.402133 0.686760 0.663649 0.429374
49 N06 not_connected 0.00% 0.00% 0.00% 0.00% 3.594983 3.811430 2.664947 2.572216 0.555941 0.825127 -3.306516 -4.100727 0.679643 0.648287 0.425087
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.899965 11.885136 0.514908 -0.080418 1.526823 5.485809 5.024219 28.230616 0.700542 0.630360 0.395748
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 24.553203 1.426947 10.861194 1.502990 2.359271 0.112909 10.966939 5.684099 0.034682 0.684449 0.465861
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.908544 7.180518 -0.360268 0.187028 1.958827 1.236446 1.127194 -0.155700 0.724071 0.697533 0.412754
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.079439 2.332682 -0.460709 -0.086489 0.940578 0.687378 3.639113 7.283450 0.727754 0.703797 0.414799
54 N04 digital_ok 100.00% 100.00% 0.00% 0.00% 10.138583 2.693680 8.218768 0.405787 2.581709 1.880914 2.312558 1.266933 0.042715 0.680174 0.489063
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 0.209383 12.614292 0.041561 9.057897 4.171598 3.219797 2.744435 0.804339 0.717391 0.032893 0.485812
56 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.689717 0.144762 -0.153356 -0.424220 0.611983 2.119845 -0.007130 3.693006 0.723455 0.703385 0.388656
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 26.281573 0.197462 3.241604 0.853170 5.356109 0.845550 32.631318 0.703756 0.599717 0.700311 0.396318
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 9.736722 11.900785 8.171341 9.099159 2.602209 3.300136 3.024032 2.498928 0.034365 0.032146 0.001762
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 25.855451 1.532222 -0.720041 0.810004 0.120019 1.529031 2.064155 3.220936 0.634900 0.689967 0.390559
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 10.640920 11.671165 8.200552 9.080429 2.563785 3.266038 2.077862 2.672264 0.026800 0.026377 0.001436
61 N06 not_connected 0.00% 0.00% 0.00% 0.00% 2.572145 2.591776 -1.989100 -0.850394 1.327379 -2.307717 -0.292970 2.290710 0.669848 0.635263 0.399664
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.577011 4.209099 2.745863 2.537770 0.403358 0.958682 -3.423381 -4.139777 0.699107 0.668886 0.419509
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 2.250622 12.013264 -0.646912 3.528958 -1.502343 3.222734 0.403520 2.880384 0.660858 0.041511 0.549429
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 0.727338 -0.255224 -2.010120 -0.771108 -1.441047 -2.220423 4.605614 -1.660065 0.646842 0.639958 0.436683
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.471699 0.188859 -0.869086 -0.106059 1.747251 0.833464 0.677050 -0.152488 0.706285 0.677597 0.434620
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.227030 0.869452 1.040049 0.785259 1.227177 1.235264 -0.142228 0.592664 0.709065 0.684771 0.423460
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -0.849971 -0.796329 0.109220 0.260678 0.862843 0.722604 0.942326 3.239707 0.715584 0.692091 0.416077
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 2.071888 27.568734 0.852956 12.276736 0.502467 3.028632 0.309285 10.925065 0.711923 0.028506 0.470645
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.143344 -0.853443 -0.274800 1.102843 1.024982 0.643602 -0.234114 1.193865 0.718942 0.696009 0.401462
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.123328 -0.590501 -2.262538 0.480277 0.123098 0.011568 0.061437 -0.047098 0.731103 0.704643 0.400213
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 5.620183 -0.619198 2.672637 0.652672 1.597291 1.414781 -0.125256 0.305276 0.722644 0.705564 0.396064
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 2.890450 -0.004186 0.057098 -0.130105 -0.069698 1.786504 4.335575 -0.450969 0.716195 0.702600 0.385984
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 9.390223 11.164705 8.062492 8.812317 2.512683 3.215218 3.019610 0.664727 0.026638 0.026659 0.001168
74 N05 digital_maintenance 100.00% 100.00% 3.97% 0.00% 10.498998 9.894711 8.460067 8.786591 2.717062 2.403102 2.583239 18.940856 0.029970 0.309909 0.184221
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 5.749152 12.169708 4.562258 9.172729 2.318989 3.358461 8.206161 3.208180 0.647746 0.039447 0.449528
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 21.026536 24.543967 -0.413833 -1.566538 2.476946 0.501349 17.323525 2.594812 0.595861 0.523987 0.265211
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 32.848785 -1.033042 -1.137934 -1.182018 0.698423 -1.747924 -0.616144 -0.860206 0.501582 0.655554 0.388789
81 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
82 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
83 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 7.238852 24.239051 0.297178 11.843128 0.285021 2.997226 -0.368621 5.539950 0.715830 0.035655 0.552577
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.127130 0.044320 -0.405856 0.137611 -0.106178 -0.349168 -0.515652 -0.691611 0.715092 0.686666 0.408302
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.038720 6.230803 -1.071581 0.321577 4.678731 -1.349854 0.862362 15.755386 0.714798 0.650019 0.404935
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.649699 7.577765 -2.265001 0.777190 12.118363 2.190484 9.457316 1.890140 0.695192 0.710346 0.389511
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.068287 1.469932 -0.701798 -0.342101 -0.577930 2.252702 0.367446 -0.171902 0.716904 0.700410 0.391441
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.013081 0.811201 -1.255216 -0.397948 1.084203 1.009397 -0.561008 -0.639330 0.723642 0.700388 0.394447
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.463693 -0.648152 0.351690 1.107815 -1.000643 -0.013601 0.567275 1.615685 0.710408 0.685195 0.395396
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.357158 0.230423 -1.062363 -0.893572 -0.122486 1.098537 0.567191 0.186213 0.717180 0.702467 0.410811
92 N10 RF_maintenance 100.00% 0.00% 23.63% 0.00% 38.827738 49.338572 -0.916229 -0.401790 2.140019 3.531365 -0.138081 6.864414 0.300225 0.240242 0.116800
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 0.949341 0.324292 1.059260 0.771718 1.830576 0.129454 8.221129 -0.659485 0.706727 0.686773 0.416206
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.812291 -0.451699 0.205225 0.611222 0.436863 1.504717 1.810107 5.457173 0.705063 0.672920 0.418706
98 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.262574 -0.326827 0.086774 0.801962 -0.702172 -0.679766 0.323165 1.899853 0.664197 0.642446 0.423669
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 1.381788 -0.203527 -0.106521 -0.316147 -0.754412 2.491036 1.856271 -0.671932 0.679355 0.665039 0.427785
100 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 8.037950 8.118995 -1.814957 -0.076133 0.672824 0.518564 0.291245 -0.524106 0.720983 0.683924 0.412452
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 8.500976 12.099711 7.329301 8.574436 1.578207 3.342148 0.873559 4.471793 0.376531 0.038548 0.287111
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 23.480075 24.604914 9.561320 10.398123 2.764883 3.510306 10.752362 9.821206 0.026269 0.027130 0.001938
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.466744 57.575081 -0.369826 8.052145 1.020848 0.706976 -0.147166 -0.169057 0.724996 0.633982 0.434981
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.238146 0.018631 -0.327914 -0.380594 -0.390217 0.756944 0.050874 -0.632366 0.718303 0.695077 0.391999
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.164426 0.421546 -0.375844 -0.118023 2.105270 1.564841 1.139912 -0.371244 0.713340 0.689336 0.394111
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 3.886475 0.149745 1.170909 1.360268 -0.512456 -0.291913 1.346109 3.000619 0.694568 0.680994 0.392599
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 1.646339 3.650215 5.339823 -0.063856 9.359126 0.871275 2.781680 0.438349 0.620413 0.693934 0.444601
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -1.223471 11.765827 0.078943 8.809840 0.263129 3.192744 0.690754 1.881958 0.716536 0.032873 0.481948
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 8.093543 26.105702 -0.851301 11.995187 9.047116 2.986384 15.212732 5.013580 0.681641 0.029784 0.435513
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.054654 11.701939 0.660076 8.930576 0.425724 3.191742 0.374641 2.625911 0.709610 0.032645 0.473904
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -1.092488 -0.660131 0.389973 0.527415 -0.292019 -0.114600 0.843931 -0.572067 0.699742 0.675079 0.427780
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.301535 0.004207 -1.073863 -1.128188 0.297174 -0.613829 0.345915 -0.457380 0.675289 0.655130 0.422567
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 11.148989 13.360104 8.240079 9.369622 2.636432 3.329967 1.585610 4.139161 0.027550 0.030505 0.002589
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.082936 0.661810 -0.455346 0.388705 1.394171 2.133143 0.979111 1.953738 0.697380 0.673409 0.419851
119 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 2.435404 23.955897 -0.311837 11.783028 1.006649 3.181439 0.496094 9.760436 0.717063 0.032547 0.566893
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.569151 5.609231 -0.596832 -0.112350 0.342016 1.514659 51.099499 14.353707 0.726588 0.693173 0.411460
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 8.208916 7.116566 0.456171 1.239418 1.451525 0.017070 -0.016019 -0.684853 0.728012 0.691623 0.407203
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 7.025123 9.525082 -0.771784 0.655614 0.022649 1.607419 -0.329606 -0.202206 0.731233 0.700003 0.406203
124 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.661830 0.322405 -0.671236 0.342910 0.859612 0.797620 0.103585 0.463721 0.725399 0.696642 0.406075
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.717449 -0.873882 0.318937 -0.453252 -0.405903 1.108630 -0.095745 -0.547878 0.700696 0.688300 0.406420
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.808342 1.136089 -1.575476 0.523008 4.068729 -0.172149 1.537317 -0.446257 0.717776 0.685699 0.411686
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.585849 -0.174872 1.135070 0.677746 -0.135211 0.313109 -0.045588 1.584295 0.708223 0.690589 0.419169
128 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.702388 3.697821 -0.022234 0.061608 0.555889 -0.562629 -0.226077 -0.511228 0.715280 0.677492 0.417976
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.484663 -1.350403 0.207478 0.564659 0.615284 1.186731 -0.538756 -0.451666 0.709135 0.683670 0.428139
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 1.319561 -0.116199 0.200827 0.780004 0.522348 0.702436 1.519118 2.692735 0.691889 0.672078 0.423730
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -1.037484 11.820376 -0.184644 9.125779 -0.550795 3.336062 0.437808 1.145737 0.677244 0.035947 0.453295
136 N12 digital_maintenance 0.00% 0.00% 0.00% 0.00% 1.808587 0.569648 -0.230573 -0.322152 -0.520528 0.492803 0.164409 -0.123289 0.670334 0.652898 0.418676
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.214622 -0.833338 -0.156617 -0.138543 0.162571 5.292618 0.634578 0.239578 0.678255 0.655961 0.419179
138 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 2.971138 12.574079 2.554399 8.994287 0.149799 3.191288 -1.563909 2.795010 0.710811 0.046449 0.483848
141 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.986815 3.612219 -1.699301 2.688404 0.625094 0.896248 0.007130 -4.448018 0.722107 0.665076 0.404538
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 0.763081 11.713984 -0.798321 9.065611 0.574750 3.280515 2.285530 1.778139 0.715613 0.044418 0.492391
143 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 10.364008 -1.457813 8.301048 3.363141 2.691252 -1.330168 0.190920 -0.790646 0.028318 0.063725 0.036862
144 N14 digital_ok 0.00% 100.00% 100.00% 0.00% -1.311475 -0.743534 1.124135 -1.783556 -0.256452 -0.868955 -0.119092 0.722880 0.050178 0.053722 0.006078
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 2.692752 -0.193782 2.426712 1.028843 -0.742770 14.296566 -3.284089 2.527686 0.061707 0.059605 0.011408
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% nan nan inf inf nan nan nan nan nan nan nan
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 27.646081 0.386461 -1.236930 -0.706375 0.175001 -1.500599 0.743926 -0.427222 0.556460 0.616705 0.406029
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 0.295035 0.080081 -2.512577 -2.285977 -1.170428 -1.276020 16.578512 -0.550184 0.656699 0.643652 0.440296
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 10.580536 -0.137492 2.656283 -2.345612 2.603734 3.528112 1.081415 -0.532508 0.038728 0.637404 0.506864
154 N16 not_connected 0.00% 0.00% 0.00% 0.00% -1.186071 -1.274167 -0.434488 -1.076228 -1.159110 -1.801376 -1.011764 -1.400449 0.657419 0.638260 0.448564
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 9.992827 -0.336737 7.896141 -0.065478 2.511431 1.888976 0.701031 5.581878 0.048429 0.656117 0.453903
156 N12 digital_ok 100.00% 24.01% 0.00% 0.00% 7.999536 0.281605 7.853482 -0.301627 1.991612 0.013081 1.539215 0.147638 0.291221 0.662811 0.471733
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.469097 -0.281000 -0.935326 -0.362763 0.040553 0.592523 -0.235968 0.264703 0.695957 0.667836 0.422708
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.952903 -0.775019 -2.297753 -0.412530 0.200689 0.142559 6.630388 43.650089 0.710830 0.676106 0.422288
160 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 3.492730 1.824765 2.567195 1.837437 -0.113134 -0.011568 -2.937292 -3.191892 0.710869 0.673118 0.407566
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.091106 28.663842 -0.635725 -0.137481 -0.206183 11.437013 0.081412 0.884722 0.717077 0.538925 0.376834
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 6.710177 0.388455 7.340160 4.368264 0.464088 5.203464 -0.023769 0.628091 0.453151 0.638806 0.428265
163 N14 digital_ok 0.00% 100.00% 100.00% 0.00% -0.086301 -0.310411 -1.434320 2.370995 -0.026734 -0.228583 0.014849 1.926283 0.044675 0.057547 0.004014
164 N14 digital_ok 0.00% 100.00% 100.00% 0.00% -1.107507 0.000156 -2.252859 -2.520070 2.574517 0.578258 0.881786 1.289079 0.048262 0.050144 0.005204
165 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 16.932077 0.371190 6.038776 -1.382082 0.339482 0.784328 -0.095791 -0.737569 0.062427 0.052321 0.020434
166 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 54.436396 39.267801 0.455717 0.400687 5.812389 3.975054 5.480782 4.618246 0.058367 0.067359 0.010620
167 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
168 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
169 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
170 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
171 N16 not_connected 0.00% 0.00% 0.00% 0.00% -0.017515 2.907672 -2.166507 -0.445803 -1.194739 -2.142464 -0.543855 -0.507064 0.662390 0.575803 0.429125
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 12.367704 12.661453 2.300276 3.177518 2.495087 3.205847 3.687945 8.261004 0.035242 0.038519 0.003933
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.098479 0.195107 -0.456826 0.012602 -0.249464 0.443008 -0.300465 10.759001 0.680025 0.651879 0.431994
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -1.006845 -1.329363 0.643874 -0.302060 -0.133525 0.219785 -0.244977 3.516324 0.686046 0.655539 0.428932
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 1.662226 -0.549094 1.324106 0.307705 -0.463882 2.065594 6.602557 2.588022 0.676881 0.664474 0.429647
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 11.085114 12.921618 8.363316 9.523222 2.680919 3.389094 0.775212 1.129675 0.040597 0.062748 0.018910
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -0.494072 12.565707 -0.858844 9.181248 -0.124357 3.320185 -0.061853 2.425909 0.714094 0.054609 0.499885
181 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 1.618291 -1.372656 2.135432 -0.393777 -0.669216 -1.418669 -3.331065 2.473790 0.719352 0.686290 0.414663
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.184830 2.818226 4.618230 2.083385 -1.736912 -0.214905 10.530433 10.227835 0.659575 0.675560 0.419806
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 10.430799 -0.589683 7.556497 1.068992 2.540944 0.352760 -0.183009 0.656058 0.036975 0.661999 0.447082
184 N14 digital_ok 0.00% 100.00% 100.00% 0.00% -1.250841 -0.964705 3.223994 -0.440550 2.687328 0.729923 2.435033 0.576156 0.054364 0.056113 0.006950
185 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 1.472939 2.939781 3.351706 6.866184 3.317158 4.035274 33.546697 0.017972 0.050612 0.072864 0.007615
186 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 25.387033 22.387778 0.546281 0.745948 4.882161 4.155192 4.754707 0.081727 0.060169 0.068764 0.011203
187 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 12.701385 14.491312 0.802262 0.620234 7.010310 5.236439 2.204779 3.734985 0.062087 0.069035 0.012876
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.793749 1.519530 -0.582959 -0.405530 0.471334 0.248553 1.086994 5.267288 0.698370 0.664969 0.432160
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 45.295430 11.877703 -1.146679 9.149903 3.575387 3.358868 14.548101 3.103775 0.507758 0.033018 0.345114
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.790872 -0.487972 -1.016059 0.210459 0.293090 0.710802 5.649596 12.108283 0.694630 0.661038 0.436581
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 1.069800 5.459826 2.067922 3.471849 0.530385 2.391197 -1.551723 -5.035455 0.684189 0.626451 0.446949
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 5.430560 -0.450214 3.924463 0.043719 1.770414 -1.417377 -4.612895 -0.543161 0.654580 0.648135 0.451836
200 N18 RF_maintenance 100.00% 100.00% 68.64% 0.00% 11.802616 35.123671 2.687213 -0.182523 2.499090 2.793679 1.984077 9.980680 0.046473 0.196527 0.116005
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.712148 4.469040 3.986472 3.066852 1.835647 1.641846 -4.589196 -4.240326 0.679109 0.641402 0.412974
202 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -0.094983 3.059064 -0.092152 0.022234 -1.683138 -1.537604 1.398799 3.516335 0.704315 0.596566 0.439990
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 12.398548 13.752186 2.464310 3.280431 2.535741 3.217716 2.725194 3.348305 0.034086 0.040368 0.000894
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.476994 3.147639 4.118572 2.249813 2.054450 -0.081081 -4.815160 -3.471002 0.652465 0.655328 0.431097
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% -0.781130 -1.113654 -1.445581 -1.288143 -1.350550 -1.817236 4.170832 -0.296882 0.694584 0.656965 0.422179
221 N18 RF_ok 0.00% 0.00% 0.00% 0.00% 3.479499 -0.406620 -1.752565 -1.394694 -0.420656 -1.405950 2.152569 0.172113 0.656050 0.653563 0.429483
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.411473 0.275306 -0.854805 -1.063698 -1.281974 -1.870413 7.534047 -1.294607 0.690327 0.656262 0.429459
237 N18 RF_ok 0.00% 0.00% 0.00% 0.00% 1.956933 1.131304 -1.576989 -2.238615 -0.644411 -1.539360 -0.083993 -0.618875 0.646888 0.632395 0.429899
238 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -0.072452 -1.200905 0.763723 0.054698 -1.260830 -1.240192 -2.289298 -2.628972 0.696852 0.653574 0.432067
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% -0.974155 2.289793 -0.992548 -0.568097 -1.121314 -1.556656 5.497418 16.785419 0.688014 0.589308 0.448119
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% -0.428195 12.628138 -1.179744 5.571712 -0.804413 3.243017 6.132795 3.140029 0.694049 0.044951 0.504793
321 N02 not_connected 0.00% 0.00% 0.00% 0.00% -0.000156 -0.076359 -1.274309 -1.405955 -0.918582 -1.125190 3.409191 1.743238 0.625341 0.581234 0.440570
322 N05 digital_maintenance 0.00% 0.00% 0.00% 0.00% 0.102176 0.932126 -0.703097 0.877786 -1.240411 -1.224418 -0.655396 -2.781764 0.613866 0.575334 0.433522
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 24.666362 0.203589 -1.143351 0.362292 0.490452 -1.244488 1.640093 -1.443685 0.396207 0.565363 0.382886
324 N04 not_connected 0.00% 0.00% 0.00% 0.00% 0.085278 1.234115 0.267289 0.412364 -1.046687 -1.622707 -0.754863 -1.281180 0.614781 0.571647 0.422121
325 N09 dish_ok 0.00% 0.00% 0.00% 0.00% -0.342297 -1.291535 0.347667 -2.292086 -1.278477 -0.593070 -1.762628 -0.154386 0.650456 0.588346 0.443670
329 N12 dish_maintenance 0.00% 0.00% 0.00% 0.00% 3.737877 -1.498279 -0.470987 -1.882991 -0.245124 -1.337714 3.190641 -0.541989 0.541750 0.577500 0.430660
333 N12 dish_maintenance 0.00% 0.00% 0.00% 0.00% 3.897303 0.609785 -0.580043 -2.469915 -0.741886 -1.514444 2.810725 -0.170691 0.536970 0.561099 0.422149
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, 7, 8, 18, 19, 21, 22, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 43, 44, 45, 46, 47, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 62, 63, 64, 68, 71, 72, 73, 74, 75, 77, 78, 81, 82, 83, 84, 86, 87, 92, 93, 94, 100, 101, 102, 103, 104, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 126, 135, 137, 138, 140, 142, 143, 144, 145, 147, 148, 149, 150, 151, 152, 153, 155, 156, 158, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 173, 176, 178, 179, 180, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 200, 201, 203, 219, 220, 222, 239, 320, 323]

unflagged_ants: [4, 5, 9, 10, 15, 16, 17, 20, 29, 40, 41, 42, 48, 49, 56, 61, 65, 66, 67, 69, 70, 85, 88, 89, 90, 91, 98, 99, 105, 106, 107, 112, 116, 118, 124, 125, 127, 128, 129, 130, 136, 141, 154, 157, 160, 171, 177, 181, 202, 221, 237, 238, 321, 322, 324, 325, 329, 333]

golden_ants: [5, 9, 10, 15, 16, 17, 20, 29, 40, 41, 42, 56, 65, 66, 67, 69, 70, 85, 88, 91, 98, 99, 105, 106, 107, 112, 116, 118, 124, 127, 128, 129, 130, 141, 157, 160, 177, 181]
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_2459861.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 [ ]: