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 = "2459860"
data_path = "/mnt/sn1/2459860"
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-7-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/2459860/zen.2459860.25302.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/2459860/zen.2459860.?????.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/2459860/zen.2459860.?????.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 2459860
Date 10-7-2022
LST Range 20.591 -- 6.612 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
Total Number of Antennas 180
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 35
RF_ok: 9
digital_maintenance: 11
digital_ok: 98
not_connected: 23
Commanded Signal Source None
Antennas in Commanded State (reported) 0 / 180 (0.0%)
Antennas in Commanded State (observed) 0 / 180 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 16
Nodes Registering 0s
Nodes Not Correlating
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 51 / 180 (28.3%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 132 / 180 (73.3%)
Redcal Done? ❌
Never Flagged Antennas 48 / 180 (26.7%)
A Priori Good Antennas Flagged 60 / 98 total a priori good antennas:
7, 10, 19, 20, 21, 30, 37, 38, 45, 46, 51,
53, 54, 55, 68, 70, 71, 73, 81, 84, 86, 93,
98, 99, 101, 103, 108, 109, 111, 116, 117,
121, 122, 123, 140, 141, 142, 143, 144, 147,
156, 158, 160, 161, 162, 163, 164, 165, 167,
170, 176, 179, 181, 183, 184, 185, 186, 187,
190, 191
A Priori Bad Antennas Not Flagged 10 / 82 total a priori bad antennas:
4, 61, 82, 89, 90, 125, 136, 137, 148, 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_2459860.csv

Build DataFrame¶

In [20]:
# build dataframe
to_show = {'Ant': [f'<a href="{ant_to_report_url(ant)}" target="_blank">{ant}</a>' for ant in ants],
           'Node': [f'N{nodes[ant]:02}' for ant in ants], 
           'A Priori Status': [a_priori_statuses[ant] for ant in ants]}
           #'Worst Metric': worst_metrics, 'Worst Modified Z-Score': worst_zs}
df = pd.DataFrame(to_show)

# create bar chart columns for flagging percentages:
bar_cols = {}
if use_auto_metrics:
    bar_cols['Auto Metrics Flags'] = [float(ant in auto_ex_ants) for ant in ants]
if use_ant_metrics:
    if np.sum(list(a_priori_flag_frac.values())) > 0:  # only include this col if there are any a priori flags
        bar_cols['A Priori Flag Fraction in Ant Metrics'] = [a_priori_flag_frac[ant] for ant in ants]
    for ap in antpols:
        bar_cols[f'Dead Fraction in Ant Metrics ({ap})'] = [dead_ant_frac[ap][ant] for ant in ants]
    bar_cols['Crossed Fraction in Ant Metrics'] = [crossed_ant_frac[ant] for ant in ants]
if use_redcal:
    bar_cols['Flag Fraction Before Redcal'] = [redcal_prior_flag_frac[ant] for ant in ants]
    bar_cols['Flagged By Redcal chi^2 Fraction'] = [redcal_flagged_frac[ant] for ant in ants]  
for col in bar_cols:
    df[col] = bar_cols[col]

# add auto_metrics
if use_auto_metrics:
    for label, modz in all_modzs.items():
        df[label] = modz
z_score_cols = [col for col in df.columns if 'Modified Z-Score' in col]        
        
# add ant_metrics
ant_metrics_cols = {}
if use_ant_metrics:
    for ap in antpols:
        ant_metrics_cols[f'Average Dead Ant Metric ({ap})'] = [average_dead_metrics[ap][ant] for ant in ants]
    ant_metrics_cols['Average Crossed Ant Metric'] = [average_crossed_metrics[ant] for ant in ants]
    for col in ant_metrics_cols:
        df[col] = ant_metrics_cols[col]   

# add redcal chisq
redcal_cols = []
if use_redcal:
    for ap in antpols:
        col_title = f'Median chi^2 Per Antenna ({ap})'
        df[col_title] = [cspa[ant, ap] for ant in ants]
        redcal_cols.append(col_title)

# sort by node number and then by antenna number within nodes
df.sort_values(['Node', 'Ant'], ascending=True)

# style dataframe
table = df.style.hide_index()\
          .applymap(lambda val: f'background-color: {status_colors[val]}' if val in status_colors else '', subset=['A Priori Status']) \
          .background_gradient(cmap='viridis', vmax=mean_round_modz_cut * 3, vmin=0, axis=None, subset=z_score_cols) \
          .background_gradient(cmap='bwr_r', vmin=dead_cut-.25, vmax=dead_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .background_gradient(cmap='bwr_r', vmin=crossed_cut-.25, vmax=crossed_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .background_gradient(cmap='plasma', vmax=4, vmin=1, axis=None, subset=redcal_cols) \
          .applymap(lambda val: 'font-weight: bold' if val < dead_cut else '', subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val < crossed_cut else '', subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .applymap(lambda val: 'color: red' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .bar(subset=list(bar_cols.keys()), vmin=0, vmax=1) \
          .format({col: '{:,.4f}'.format for col in z_score_cols}) \
          .format({col: '{:,.4f}'.format for col in ant_metrics_cols}) \
          .format({col: '{:,.2%}'.format for col in bar_cols}) \
          .applymap(lambda val: 'font-weight: bold', subset=['Ant']) \
          .set_table_styles([dict(selector="th",props=[('max-width', f'70pt')])])

Table 2: RTP Per-Antenna Metrics Summary Table¶

This admittedly very busy table incorporates summary information about all antennas in the array. Its columns depend on what information is available when the notebook is run (i.e. whether auto_metrics, ant_metrics, and/or redcal is done). These can be divided into 5 sections:

Basic Antenna Info: antenna number, node, and its a priori status.

Flag Fractions: Fraction of the night that an antenna was flagged for various reasons. Note that auto_metrics flags antennas for the whole night, so it'll be 0% or 100%.

auto_metrics Details: If auto_metrics is included, this section shows the modified Z-score signifying how much of an outlier each antenna and polarization is in each of four categories: bandpass shape, overall power, temporal variability, and temporal discontinuities. Bold red text indicates that this is a reason for flagging the antenna. It is reproduced from the auto_metrics_inspect.ipynb nightly notebook, so check that out for more details on the precise metrics.

ant_metrics Details: If ant_metrics is included, this section shows the average correlation-based metrics for antennas over the whole night. Low "dead ant" metrics (nominally below 0.4) indicate antennas not correlating with the rest of the array. Negative "crossed ant" metrics indicate antennas that show stronger correlations in their cross-pols than their same-pols, indicating that the two polarizations are probably swapped. Bold text indicates that the average is below the threshold for flagging.

redcal chi^2 Details: If redcal is included, this shows the median chi^2 per antenna. This would be 1 in an ideal array. Antennas are thrown out when they they are outliers in their median chi^2, usually greater than 4-sigma outliers in modified Z-score.

In [21]:
HTML(table.render())
Out[21]:
Ant Node A Priori Status Auto Metrics Flags Dead Fraction in Ant Metrics (Jee) Dead Fraction in Ant Metrics (Jnn) Crossed Fraction in Ant Metrics ee Shape Modified Z-Score nn Shape Modified Z-Score ee Power Modified Z-Score nn Power Modified Z-Score ee Temporal Variability Modified Z-Score nn Temporal Variability Modified Z-Score ee Temporal Discontinuties Modified Z-Score nn Temporal Discontinuties Modified Z-Score Average Dead Ant Metric (Jee) Average Dead Ant Metric (Jnn) Average Crossed Ant Metric
3 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 3.987722 -0.945395 -0.407886 -1.118888 1.091972 -0.280360 -0.125782 1.141041 0.700308 0.671970 0.414708
4 N01 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.252854 3.536022 1.791577 0.645297 0.762176 -0.334821 0.943662 -0.702817 0.715742 0.663754 0.416315
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.716007 -0.134730 -0.142466 0.439829 1.254381 0.420127 0.194686 -0.741670 0.718685 0.674817 0.410763
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.279936 -1.224811 0.605373 -0.367049 0.605781 0.687023 0.810766 12.936915 0.712440 0.671589 0.413182
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.771233 -0.535883 9.646737 10.716019 0.573078 2.339948 4.471718 -0.256802 0.720611 0.669997 0.411252
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.277224 -1.487576 0.759742 -0.825510 0.012136 -0.486826 -0.180586 1.134497 0.704337 0.664937 0.416979
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 2.894139 1.829972 18.466351 17.469119 6.786616 9.519988 -1.584057 -2.287632 0.699868 0.663154 0.425574
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.232760 0.259559 -1.218578 0.034986 -0.002030 -0.311065 0.271113 1.050699 0.724977 0.679353 0.409679
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.465617 -0.223390 1.253082 0.631237 0.573628 0.301193 0.884227 1.831830 0.724636 0.675172 0.409931
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.746472 0.334207 -0.000916 -0.563109 0.564716 -0.409070 1.877137 0.435012 0.713388 0.680293 0.400078
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.101965 11.439433 -1.003580 -0.334512 2.845860 7.274006 9.510489 19.095380 0.690583 0.453330 0.455144
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.565441 -1.580832 0.375502 -0.714875 -0.132913 2.147702 10.847856 10.724769 0.711471 0.681604 0.409160
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.187114 3.494468 7.244430 20.489885 2.395399 13.542326 0.228913 -2.962337 0.726145 0.661873 0.421080
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.149282 -1.341462 -0.048584 1.145783 -0.212878 -0.633548 0.821556 3.989221 0.707244 0.674151 0.416729
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 27.071169 7.821696 1.534985 9.361170 3.910646 4.643519 5.000835 3.618376 0.469243 0.608082 0.349111
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 11.203099 12.674631 24.698381 25.828504 14.636747 21.689875 2.772348 1.639251 0.032236 0.036771 0.002934
28 N01 RF_maintenance 100.00% 0.00% 86.25% 0.00% 15.023984 29.434351 0.049456 2.154236 11.728390 17.007664 5.714249 15.605652 0.369536 0.162447 0.236891
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.176736 -1.226703 -0.470405 -0.967758 -0.900494 -1.157756 -0.166680 1.407111 0.722629 0.682707 0.397439
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.034206 -1.233487 0.921410 0.456368 -0.696904 -0.862580 9.026249 -0.475083 0.716155 0.684944 0.396790
31 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.450128 -1.398967 -1.214415 -1.187259 1.289736 0.845632 0.598917 1.819548 0.734817 0.690066 0.408315
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 18.993451 24.164645 0.404340 2.305684 15.218353 6.242322 6.788571 0.727887 0.600535 0.597489 0.240149
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.523687 12.925653 -0.186685 1.274382 -0.869231 5.793878 0.804376 19.837407 0.709715 0.486773 0.488234
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 12.830820 1.959494 8.468623 7.718041 14.681356 2.254181 1.304324 -0.805962 0.040829 0.649255 0.555183
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.473432 -0.365746 1.298447 7.449805 3.132243 3.938525 3.940005 -0.659618 0.627101 0.640175 0.437050
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.842988 7.306042 0.347522 -0.590080 1.118278 1.628816 0.007135 0.122877 0.719742 0.676957 0.417346
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.246689 -0.019897 -1.011680 -0.898724 -1.173942 0.802637 -0.130916 11.273760 0.723245 0.689521 0.416874
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.321924 -0.018000 0.382430 1.190499 1.975276 0.570481 6.802815 2.302336 0.728208 0.692383 0.414394
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.003847 -0.777187 0.143716 0.732858 -0.238872 -0.739849 -0.283476 -0.714435 0.720258 0.681734 0.404932
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.286832 -0.790364 1.321300 0.034917 0.002030 -1.427736 -0.276496 -0.783997 0.730245 0.689645 0.397554
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.176887 1.866186 -0.720241 -0.404236 -1.042392 -0.059821 0.214291 -0.800620 0.735588 0.683641 0.407877
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 10.349112 0.875144 24.378084 -1.070353 14.695023 -0.173043 2.122973 0.583748 0.039207 0.693147 0.507885
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 2.645672 2.203713 0.674122 -0.033240 1.548631 -0.032733 8.633715 2.219245 0.710401 0.684460 0.388559
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -0.420826 0.002227 0.373122 0.555243 0.257826 1.932434 0.074495 21.300498 0.722244 0.677419 0.399477
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -1.317251 13.193576 -0.692480 25.974820 -0.945892 21.558236 -0.062015 2.611801 0.718063 0.035628 0.553627
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 12.223339 1.341833 7.929795 7.334879 14.699365 0.099211 1.249769 2.730437 0.037413 0.654952 0.559639
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.590615 5.097160 22.435510 22.125633 10.323019 14.678188 -2.299890 -3.351786 0.686559 0.656157 0.427151
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.556438 4.941590 21.245834 21.978556 9.355834 15.129637 -2.267920 -3.011488 0.680957 0.642593 0.425876
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.123547 20.958134 0.653161 0.548082 1.778941 15.831374 2.236370 18.605834 0.711892 0.595643 0.395734
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 26.689899 1.758193 32.798230 1.682346 14.026165 1.062754 9.584025 2.173196 0.037137 0.686222 0.503980
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.289893 7.663856 -0.553628 -0.624586 5.001170 -0.884257 0.923410 0.147252 0.731271 0.698314 0.403713
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.361497 2.667449 0.005678 -0.081950 -0.587034 -0.791418 3.166057 5.879804 0.735662 0.704013 0.406671
54 N04 digital_ok 100.00% 100.00% 0.00% 0.00% 11.137241 9.447241 24.693141 -0.394584 14.714843 1.009818 2.372703 -0.431182 0.045317 0.666496 0.519733
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 1.016870 13.964197 0.435804 26.250914 2.585962 21.594107 2.223202 0.784814 0.717412 0.033018 0.523893
56 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.754863 -0.191187 -1.295954 0.131337 -0.073221 0.827077 0.179071 3.002198 0.730005 0.701003 0.385662
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 34.111204 0.393533 7.975365 -1.212157 6.553416 0.646899 3.480158 -0.039734 0.575675 0.697438 0.378457
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 10.662248 13.154097 24.531084 26.347789 14.829581 21.820400 2.975675 2.215078 0.035636 0.032686 0.001952
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 21.904884 2.282970 1.054804 0.774635 7.286083 0.971598 3.163818 2.950127 0.668636 0.683868 0.383166
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 11.676488 12.886550 24.635765 26.306040 14.753183 21.766337 2.492707 2.935253 0.026556 0.026564 0.001358
61 N06 not_connected 0.00% 0.00% 0.00% 0.00% 3.253076 2.969066 2.563993 1.732442 0.405775 3.962284 -0.335846 2.947707 0.669215 0.633612 0.399130
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.992019 5.758023 22.175601 22.515399 9.846846 16.173375 -2.608556 -3.481546 0.699602 0.660129 0.418886
63 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
64 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.390425 0.270292 0.500957 -0.378229 2.331120 1.888801 -0.345092 -0.162713 0.713838 0.681754 0.423674
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.366695 1.024235 1.215642 0.197529 -0.150214 0.123361 -0.217309 0.925649 0.718987 0.687891 0.413982
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -1.026672 -0.637762 -0.585798 -1.251838 0.749434 -0.098979 0.780171 0.774954 0.723345 0.695389 0.404684
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 1.415810 29.864953 1.526006 36.070036 -0.049047 20.789297 0.089986 9.238243 0.721504 0.028638 0.500687
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.156245 -1.291213 -1.219180 0.928311 1.299427 1.645306 0.010840 -0.040009 0.726226 0.698048 0.395447
70 N04 digital_ok 100.00% 0.00% 0.00% 0.00% -0.014388 -1.052100 5.565839 -0.939325 -0.007868 -1.467875 -0.157442 -0.248449 0.737979 0.704649 0.395328
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 6.492629 -0.609447 7.980877 0.104701 1.971564 0.139246 0.099037 0.158478 0.727948 0.703960 0.391267
72 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 2.768844 -0.218449 -0.670461 -0.713387 1.089483 0.439137 1.780107 -0.715737 0.723683 0.701169 0.383433
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 10.371434 12.350774 24.245507 25.506484 14.569804 21.613045 2.936830 0.693692 0.026729 0.026604 0.001184
74 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 11.327727 10.605114 25.348671 25.180500 15.086186 19.422992 2.612269 23.815559 0.030259 0.323764 0.210651
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 6.067678 13.487518 9.634345 26.549770 8.627753 21.895899 4.294399 2.524476 0.681393 0.043094 0.521326
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 23.365500 25.547129 12.744943 9.772867 6.656115 12.610665 4.671543 1.534635 0.595954 0.516789 0.252083
78 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -1.035052 0.329483 0.995853 4.913449 1.316654 7.217092 -0.040172 -0.421295 0.678848 0.632563 0.417434
82 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.494099 0.783089 1.826515 0.348784 1.976414 0.266208 -0.412493 -0.940805 0.707884 0.671934 0.414907
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.100630 -0.238710 2.466294 -0.678521 -0.945707 -1.239426 -0.522368 -0.450807 0.717776 0.684676 0.406581
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 8.056426 26.466725 -0.258168 34.732315 -0.982544 20.888492 -0.269264 4.960068 0.724356 0.038847 0.614266
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.435425 -0.206589 -0.646882 -1.063656 -0.712414 -0.411156 -0.410319 -0.868064 0.723330 0.691062 0.403251
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 0.630349 7.067799 -0.935495 0.625288 5.385738 5.996897 2.933140 14.811590 0.719015 0.654706 0.397108
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 27.162972 8.266606 2.172223 0.371083 7.485068 1.012159 33.596142 1.300729 0.640986 0.711395 0.375632
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.548148 1.198142 0.289371 -0.296191 -0.788470 0.941004 0.024873 -0.796264 0.726591 0.700689 0.387190
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.271642 0.738502 1.673570 0.280680 -0.108998 -0.439871 -0.489730 -0.951438 0.732698 0.701579 0.390175
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.001231 -0.195153 -0.172713 1.403003 -0.005745 -0.046314 0.067330 1.691662 0.721481 0.686329 0.389223
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.001231 0.023950 1.343507 1.813207 -0.450446 -0.950548 1.260582 -0.029161 0.727216 0.702926 0.403071
92 N10 RF_maintenance 100.00% 0.00% 16.97% 0.00% 40.793033 51.501659 3.311210 4.543442 10.136004 16.145869 0.662471 5.844782 0.308405 0.248366 0.117969
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 1.021302 -0.009111 0.505296 -0.926769 3.303974 -0.191653 4.684052 -0.856326 0.713881 0.685984 0.410983
94 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.643186 -1.301658 -0.384446 0.021836 0.092172 2.495788 2.780238 2.797174 0.709861 0.674064 0.417750
98 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
99 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.075122 -1.305806 -0.437581 1.915852 1.188824 0.080790 0.193926 -0.735097 0.700113 0.666242 0.404966
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 8.821615 8.888166 3.583896 -0.072462 0.027716 -0.884973 0.013816 -0.757350 0.729984 0.690946 0.398611
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 8.818693 13.308788 21.458516 24.748095 12.349847 21.857945 0.755016 3.942406 0.434932 0.039216 0.367519
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 25.026168 26.737719 28.658825 30.183886 15.079648 21.774081 9.590161 8.691684 0.026465 0.027119 0.001847
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.569443 61.101026 -0.545376 22.307516 0.599845 -0.365040 -0.072011 -0.489968 0.734322 0.646574 0.428417
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.443283 -0.086059 -0.565266 0.232452 -0.533892 -0.891242 0.228087 -0.908507 0.728917 0.698787 0.386234
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.371307 0.452379 -1.219317 -0.772634 1.426930 -0.600380 0.158761 -0.890436 0.723412 0.694619 0.388550
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 2.867715 -0.304542 2.427917 1.991923 0.987056 0.607959 0.876497 1.976612 0.708497 0.686103 0.385701
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 3.844496 3.710195 18.175484 -0.302465 1.640160 -0.044160 0.875576 0.055957 0.600699 0.699518 0.448457
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -1.231177 13.062916 -0.787711 25.502418 -0.904178 21.615443 0.273870 1.524027 0.726264 0.033360 0.508334
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 13.204842 28.253361 0.559330 35.162849 25.453509 21.006660 6.837963 4.260691 0.668332 0.030221 0.429367
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.239344 13.013576 0.982327 25.818427 -0.870077 21.598354 -0.121058 2.284713 0.716880 0.033145 0.506753
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -1.086797 -0.849846 0.000916 -0.974527 -0.364202 0.215633 1.399786 -0.864949 0.705233 0.675908 0.422369
116 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 12.199482 14.677408 24.712981 27.156191 14.903698 21.803902 1.786339 3.492465 0.027187 0.030416 0.002666
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.637555 0.528878 -0.868314 -0.606471 0.685676 1.465411 1.153395 2.001321 0.706271 0.678398 0.412156
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.453458 2.008251 6.375415 4.981515 -0.495437 8.474951 -0.451224 0.848675 0.719775 0.648022 0.414366
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 2.858581 25.984562 -0.861916 34.527223 1.126613 21.237491 0.186851 8.569822 0.724951 0.033696 0.618556
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.398002 6.301905 0.293823 -0.145049 0.281527 0.472390 39.889788 15.045396 0.733952 0.700076 0.402506
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 9.041969 7.943916 0.327551 1.431139 5.242128 -1.237021 0.002533 -0.849141 0.735905 0.700854 0.399593
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 7.840048 10.279040 0.765243 0.060865 -1.066186 0.011209 -0.313197 -0.532069 0.740411 0.708984 0.397246
124 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.785417 0.543314 0.149301 -1.148190 -0.423792 -1.203652 0.154016 -0.044749 0.736758 0.706343 0.396554
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.214432 -0.721487 -0.612422 0.276282 -0.697731 -0.730934 -0.284009 -0.869459 0.717889 0.700225 0.395142
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 32.028992 1.427507 1.530949 -0.746862 3.615203 2.974117 2.552475 -0.563141 0.614707 0.696520 0.386236
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.787288 -0.442884 1.827462 -0.233382 0.950104 0.947261 0.116725 -0.396989 0.722963 0.699088 0.405017
128 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.930297 3.896155 -1.033636 -0.437316 -0.307797 1.209938 -0.215726 -0.718402 0.727731 0.686189 0.405317
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.587934 -1.525273 -0.794269 -0.642380 -0.663902 -0.900164 -0.443378 -0.823528 0.720298 0.690264 0.416190
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.916972 -0.258627 -0.481175 0.147861 0.557960 0.372984 0.027315 1.855871 0.701507 0.677203 0.416019
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -0.891114 13.099057 -0.992341 26.413211 0.464375 21.873031 0.033229 1.042638 0.682745 0.037808 0.502266
136 N12 digital_maintenance 0.00% 0.00% 0.00% 0.00% 2.483103 0.705796 -0.941973 0.303534 0.420761 -0.354348 -0.022967 0.121803 0.676143 0.655235 0.417927
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.265066 -0.936553 -0.857308 -0.600315 1.076848 2.622156 0.616023 -0.139538 0.687472 0.656157 0.414474
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.132676 -0.111123 0.346755 0.061303 -1.053881 -0.869904 4.347106 -0.721646 0.705430 0.673413 0.417161
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 4.252126 13.953886 21.596164 26.068606 8.996348 21.611588 -1.111160 2.536263 0.716605 0.050804 0.525873
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.483322 5.036391 3.991582 22.888750 0.603210 16.299078 0.019851 -3.375434 0.730009 0.673026 0.399016
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 0.481547 12.968349 1.047134 26.238760 3.811073 21.795812 0.867622 1.600343 0.725681 0.047381 0.535802
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 11.368019 -1.598648 24.870771 7.739175 15.040676 1.850837 0.577637 -0.834595 0.039816 0.680527 0.521834
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.427408 -0.540524 2.400005 10.122154 0.410237 1.616018 -0.134974 1.508343 0.721105 0.706854 0.403386
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.869032 0.157684 21.043202 2.175401 6.979349 17.075770 -2.204750 0.396069 0.725283 0.690055 0.398920
147 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 5.055883 -0.722930 0.568896 -1.273741 8.037354 -0.931854 18.945822 -0.766795 0.712233 0.692802 0.401563
148 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.257183 0.236638 -0.551803 0.449552 0.685079 -0.454746 -0.228525 -0.843991 0.712396 0.685767 0.402312
149 N15 RF_maintenance 100.00% 0.00% 100.00% 0.00% 2.353764 13.706034 1.401062 26.282395 0.020262 21.754018 0.281653 2.171336 0.704973 0.032027 0.541448
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 11.899613 13.109387 24.674068 26.209761 14.699867 21.776247 2.514414 2.234824 0.026319 0.028321 0.000887
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 28.343318 0.395440 9.929600 1.487337 4.876794 5.335082 0.226024 -0.531567 0.564106 0.627561 0.405270
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 0.098407 0.462450 6.356476 8.203108 1.007079 1.935807 15.487045 -1.036933 0.666204 0.648572 0.439669
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 11.549778 0.121104 7.752079 6.983817 14.837369 -0.250575 1.320329 -0.520589 0.038923 0.638218 0.551640
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.273048 -0.205483 12.944867 11.764391 4.047809 3.292940 -1.046181 -1.181880 0.663667 0.640132 0.447327
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 10.898972 -0.073959 23.735257 -0.799632 14.535854 3.556459 1.065396 1.670720 0.054600 0.656713 0.491555
156 N12 digital_ok 100.00% 13.53% 0.00% 0.00% 8.717497 0.110053 23.499180 0.452018 12.981225 -0.744851 1.446164 -0.178701 0.310618 0.664267 0.465687
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.374833 -0.626473 1.049609 0.444880 -0.898242 -0.165724 -0.322985 -0.731306 0.702699 0.670033 0.417493
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -1.322426 -1.326849 7.929610 0.943835 1.084864 0.535932 5.933038 22.544171 0.718217 0.678721 0.420377
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 4.631690 3.326829 21.559562 20.588667 8.505609 13.547299 -2.072152 -2.712395 0.716260 0.677271 0.403448
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.231026 30.374194 0.288075 1.749527 -0.740828 15.828286 -0.024621 0.197517 0.724266 0.544963 0.375524
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 5.212219 0.472984 19.658894 9.441970 10.889287 2.451053 0.155414 -0.197630 0.570096 0.663999 0.419448
163 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.041704 -0.154607 2.512600 4.994955 -0.968250 1.076944 0.134091 0.216010 0.733825 0.678689 0.412733
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.557133 -0.136424 7.667696 7.766096 0.121560 1.255328 0.482466 0.837783 0.735734 0.704380 0.409749
165 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
166 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 42.065609 45.982375 3.936037 2.723847 10.636686 11.992260 21.445553 9.554755 0.552981 0.529165 0.220966
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.896431 1.220032 1.107126 -1.071093 0.636636 0.362984 -0.010840 -0.647172 0.709338 0.680797 0.409219
169 N15 digital_ok 0.00% 0.00% 0.00% 0.00% 0.229232 3.698872 0.431819 0.668138 -0.704087 -0.051340 -0.272316 0.217440 0.711482 0.660688 0.411933
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 1.762336 1.072967 -0.350356 -0.871545 1.491201 -1.016090 12.291261 2.804558 0.703177 0.674958 0.419374
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 0.427463 3.288814 7.626267 0.058157 1.262290 4.523127 -0.171642 -0.564387 0.672790 0.588802 0.426153
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 13.447815 13.951901 6.733614 8.378125 14.511439 21.609203 3.404458 8.250327 0.035166 0.039144 0.004477
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.212697 0.306219 -0.186830 -0.797995 0.264663 1.063761 -0.206850 6.521951 0.686514 0.653750 0.428661
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -1.221878 -1.501611 0.902812 0.522631 -0.950677 1.354303 -0.329400 0.701809 0.692637 0.657565 0.425848
178 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 1.941477 -0.491253 3.057586 -0.842208 -0.819155 -0.419526 3.103795 0.729491 0.685076 0.665888 0.426386
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 12.102162 14.112921 25.060279 27.554969 15.043384 21.921026 1.258045 1.235359 0.040827 0.078713 0.030479
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -0.915794 13.902931 1.307038 26.583274 -0.790570 21.849200 0.159835 2.208468 0.721572 0.060068 0.542307
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 2.706845 -0.581650 20.331596 13.876195 7.441272 2.448081 -2.306496 2.263337 0.724310 0.690844 0.409745
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.519001 4.351551 13.271884 21.177549 2.935568 14.033579 6.901476 9.108404 0.671615 0.681226 0.414170
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 11.668177 -0.148165 24.266412 3.207300 14.617965 -0.004713 0.514164 1.154223 0.033928 0.670486 0.475637
184 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
185 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.956602 5.521019 9.071516 21.379193 0.181916 12.045094 0.170923 -0.430506 0.692991 0.494165 0.450798
186 N14 digital_ok 100.00% 0.21% 0.00% 0.00% 27.453920 23.855390 1.188833 0.796939 10.272254 14.249743 3.916397 -0.217261 0.323400 0.320305 0.154738
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 12.978021 15.336205 1.248744 0.261261 14.225011 14.766832 2.789016 1.761653 0.367896 0.352611 0.183512
189 N15 digital_ok 0.00% 0.00% 0.00% 0.00% 1.083593 1.756875 -0.121178 1.159386 -0.181444 0.916868 0.178866 2.927349 0.714056 0.680890 0.418957
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 43.841227 13.130320 4.401392 26.477090 9.825556 21.939770 9.482048 2.723697 0.537433 0.034809 0.407971
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.654530 -0.789872 1.084491 -1.252795 2.446543 -0.754711 6.850864 6.477881 0.704117 0.670255 0.427197
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.992149 7.076721 21.259901 25.413765 11.528766 20.077160 -2.138666 -4.106959 0.687953 0.630371 0.438683
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 6.947070 0.771349 25.752949 16.177223 13.221566 6.671216 -3.597355 -1.057142 0.657788 0.651998 0.450059
200 N18 RF_maintenance 100.00% 100.00% 57.04% 0.00% 12.811866 36.233776 7.908440 12.745242 14.554448 16.236271 1.981036 5.325468 0.045789 0.202839 0.134083
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 7.126407 5.975498 25.682482 23.977077 12.847704 17.959270 -3.419047 -3.588112 0.685510 0.643835 0.406569
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.773257 3.212274 13.786352 -0.644779 1.838469 6.269693 0.210562 2.531490 0.711834 0.609351 0.429319
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 13.439004 15.023891 7.203665 8.680683 14.655435 21.635212 3.040495 2.869524 0.034019 0.041917 0.001793
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 6.859494 4.465136 26.082602 21.557155 13.452210 13.618225 -3.631071 -2.999348 0.658428 0.655335 0.427529
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% -0.674689 0.258492 9.809663 11.292717 1.486715 3.343761 4.405559 -1.386755 0.701111 0.659360 0.412802
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 3.332494 0.356676 3.718066 10.762599 4.378280 2.096147 2.252855 -0.429028 0.671191 0.657132 0.421409
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.618171 1.087436 11.751927 11.865276 3.010455 2.349597 6.712163 -1.056158 0.703201 0.661999 0.420356
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 2.162016 1.330334 3.117686 8.607397 3.042920 3.828282 1.105612 -0.761514 0.659641 0.635597 0.425846
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.762470 -0.563968 15.167671 14.326943 4.048510 7.268102 -1.338003 -2.020414 0.706254 0.656824 0.424837
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% -0.539959 2.360226 9.618130 -0.908378 -0.246697 3.958766 5.522683 18.317471 0.699400 0.597295 0.444229
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% -0.528966 14.085096 1.860575 15.656081 1.125515 21.616216 6.340744 2.492908 0.704488 0.046757 0.545437
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 0.749486 0.753543 10.539350 11.060342 3.440201 3.975277 2.918849 0.848754 0.633381 0.582842 0.436657
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 1.118043 2.452490 12.201327 17.813002 3.752809 10.839927 -0.275705 -2.180978 0.620896 0.574629 0.428578
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 25.292565 2.099271 3.167510 17.400858 8.852642 10.289122 1.178528 -1.735545 0.409328 0.563383 0.375713
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 1.002963 2.636926 14.955907 16.260261 5.351990 8.076414 -1.025666 -2.220279 0.621778 0.570938 0.417576
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 0.899119 -0.589074 15.165074 8.129675 4.929493 3.389965 -1.344758 -0.292069 0.657719 0.590808 0.440505
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 3.648325 -1.082034 1.437762 11.016232 5.345144 4.410339 4.256070 -0.943907 0.558384 0.579312 0.427114
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 3.966490 0.424429 -0.117109 7.920661 4.810600 3.987412 1.307356 -0.368316 0.551499 0.564472 0.419041
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [7, 8, 10, 18, 19, 20, 21, 22, 27, 28, 30, 32, 33, 34, 35, 36, 37, 38, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 62, 63, 64, 68, 70, 71, 73, 74, 75, 77, 78, 81, 84, 86, 87, 92, 93, 98, 99, 101, 102, 103, 104, 108, 109, 110, 111, 116, 117, 119, 120, 121, 122, 123, 126, 135, 138, 140, 141, 142, 143, 144, 145, 147, 149, 150, 151, 152, 153, 154, 155, 156, 158, 160, 161, 162, 163, 164, 165, 166, 167, 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: [3, 4, 5, 9, 15, 16, 17, 29, 31, 40, 41, 42, 56, 61, 65, 66, 67, 69, 72, 82, 83, 85, 88, 89, 90, 91, 94, 100, 105, 106, 107, 112, 118, 124, 125, 127, 128, 129, 130, 136, 137, 148, 157, 168, 169, 177, 178, 189]

golden_ants: [3, 5, 9, 15, 16, 17, 29, 31, 40, 41, 42, 56, 65, 66, 67, 69, 72, 83, 85, 88, 91, 94, 100, 105, 106, 107, 112, 118, 124, 127, 128, 129, 130, 157, 169, 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_2459860.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 [ ]: