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 = "2459870"
data_path = "/mnt/sn1/2459870"
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-17-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/2459870/zen.2459870.25293.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/2459870/zen.2459870.?????.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/2459870/zen.2459870.?????.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 2459870
Date 10-17-2022
LST Range 21.246 -- 7.267 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 56 / 180 (31.1%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 156 / 180 (86.7%)
Redcal Done? ❌
Never Flagged Antennas 24 / 180 (13.3%)
A Priori Good Antennas Flagged 77 / 98 total a priori good antennas:
3, 5, 7, 10, 16, 19, 20, 21, 29, 30, 31, 37,
38, 45, 46, 51, 53, 54, 55, 56, 66, 67, 68,
71, 72, 73, 81, 84, 86, 93, 94, 98, 99, 101,
103, 106, 107, 108, 109, 111, 117, 118, 121,
122, 123, 124, 128, 130, 140, 141, 142, 143,
144, 147, 156, 158, 160, 161, 162, 164, 165,
167, 169, 170, 176, 177, 178, 179, 181, 183,
184, 185, 186, 187, 189, 190, 191
A Priori Bad Antennas Not Flagged 3 / 82 total a priori bad antennas:
89, 125, 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_2459870.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% 100.00% 100.00% 0.00% 429.304761 429.881970 inf inf 8550.266510 8653.878936 13972.898375 14323.555600 nan nan nan
4 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 427.123641 427.747932 inf inf 7716.598834 8025.402923 14041.893865 14630.391370 nan nan nan
5 N01 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -2.102616 -1.815706 -0.085456 0.329751 0.670051 1.198079 4.336016 21.433106 0.703155 0.679182 0.390282
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.197021 2.652936 0.660017 0.048565 -0.237538 0.169955 15.469011 2.309762 0.695975 0.662835 0.379985
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.026263 -1.915669 0.208972 0.337010 0.349767 0.031511 0.177707 0.659487 0.696248 0.672079 0.392141
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 15.948403 -1.036069 9.573062 5.384775 7.775352 2.683617 6.410907 1.032789 0.672282 0.669908 0.400169
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 1.977073 0.416822 0.941432 -0.620211 -0.252699 -0.498713 2.113897 2.118306 0.705052 0.682735 0.395736
16 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.184594 2.704884 0.253935 -0.601619 0.842075 1.973090 3.909175 4.775845 0.708151 0.676196 0.389315
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.428335 1.201805 -0.681921 0.446011 -0.535365 -0.188147 0.709732 0.382378 0.705947 0.687281 0.386378
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.578005 23.080792 0.791401 0.915113 5.028532 8.531230 31.178508 54.809688 0.683587 0.459715 0.437909
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.545358 -0.899735 -0.735440 9.232381 -0.285877 2.629512 7.368577 20.874908 0.704648 0.678614 0.387395
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.299848 6.216457 0.370438 14.070063 0.806792 2.692770 4.209413 0.425114 0.707485 0.675561 0.385638
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 2.046017 -1.125474 -0.455042 -0.842800 0.917144 -0.328982 3.354306 11.513271 0.694545 0.677198 0.393691
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 56.862377 22.705892 3.647949 13.368149 10.146333 5.764048 10.892370 5.526432 0.459529 0.616337 0.331374
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 22.692270 24.695852 47.307958 48.018061 10.675261 17.962272 6.216236 4.394597 0.032773 0.037447 0.002763
28 N01 RF_maintenance 100.00% 0.00% 85.28% 0.00% 28.091911 53.210353 4.689973 3.629926 9.786317 21.005952 11.479135 37.518682 0.362327 0.166754 0.226498
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -2.032674 -0.322314 -0.610804 0.464763 -1.363762 -0.591980 0.331420 5.705951 0.711264 0.686823 0.379051
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 2.567230 -1.114690 1.340106 -0.860594 0.088729 0.131632 30.249161 0.732076 0.705938 0.690422 0.377648
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.109978 -0.560251 0.643115 1.809722 1.772952 6.819304 0.909311 1.276700 0.720743 0.692920 0.387164
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 31.451099 39.673936 4.830826 4.067393 20.298430 9.119450 10.223153 2.194205 0.613810 0.610856 0.276692
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.089125 26.175271 0.465051 0.876677 -0.205125 10.527099 3.912529 57.728308 0.700011 0.502668 0.458766
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 25.780483 5.631848 20.178374 13.043608 10.752879 11.070318 3.334665 -1.262006 0.041549 0.656437 0.533361
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.663927 2.203663 1.222223 6.601776 1.716244 3.459993 4.222633 -0.296137 0.616742 0.644783 0.409737
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 17.600218 15.998548 0.626383 0.461990 0.311550 1.520946 0.339101 1.063323 0.709351 0.688417 0.391725
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.745679 1.656407 -0.568877 0.437630 -0.835481 -0.227557 0.343853 20.584013 0.713343 0.694565 0.392190
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.664086 0.279760 -0.619605 -0.308922 2.689517 3.342037 14.294892 5.526435 0.716831 0.698511 0.392529
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.307710 0.548822 -0.736584 -0.672153 1.035584 0.127901 0.253024 -0.336618 0.709489 0.690793 0.385950
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.341414 1.560980 1.985934 0.865439 2.357289 -0.447151 -0.549685 -0.797189 0.713514 0.688959 0.371937
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.637421 2.009627 -0.821227 1.269176 -0.656374 -0.353318 -0.195711 -0.857216 0.721781 0.701868 0.386630
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 21.197994 4.813316 46.770637 -0.322255 10.779570 0.624080 5.519359 3.879311 0.041148 0.695277 0.484887
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 33.643903 2.296053 1.861837 -0.063655 14.297071 0.002301 51.236535 3.725812 0.665727 0.694780 0.369931
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -1.232985 7.025409 -0.479585 -0.205067 0.727396 6.257261 1.075774 21.925039 0.714021 0.676250 0.376510
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -0.715641 25.614098 -0.673859 48.234486 0.042484 17.907483 1.399961 7.225427 0.705034 0.036881 0.533374
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 24.489233 5.796396 19.279152 10.247774 10.799510 2.388707 2.835411 5.527917 0.038348 0.658133 0.536263
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.006890 4.499555 20.354109 23.875031 3.140775 3.793053 -2.065614 -3.697725 0.678636 0.670474 0.404094
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.735748 2.922375 6.596331 20.831685 2.501098 5.233741 2.311261 0.251266 0.648632 0.657547 0.407026
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.254638 9.048305 -0.326822 0.908581 3.249992 4.996552 12.196936 23.271124 0.696912 0.674780 0.373141
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 49.507502 2.572147 60.768831 0.822213 10.025913 3.832818 20.280682 6.571909 0.041260 0.699102 0.498601
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 13.694924 12.954085 0.276844 0.219629 4.674499 -1.056648 2.140928 0.437763 0.718644 0.703288 0.380901
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.093396 5.293365 -0.092928 0.700471 -1.240019 -0.235521 6.886149 11.528414 0.722270 0.707553 0.386937
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 22.642240 26.023449 47.312279 49.157627 10.888910 18.120002 6.929324 4.075848 0.046319 0.045354 0.001660
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 3.948709 27.445198 1.178867 48.723104 8.860016 18.018526 11.484938 9.447803 0.710084 0.034566 0.511335
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 0.740523 1.807744 0.375270 0.139955 0.370509 2.499655 1.764904 6.647563 0.716899 0.701995 0.364104
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 62.171702 -0.458307 22.550184 2.567899 4.738402 1.152721 5.989090 3.330254 0.552276 0.704695 0.366330
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 21.850477 25.538555 47.059696 48.905732 11.029413 18.302230 10.378254 9.423895 0.036863 0.033532 0.002232
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 31.278519 21.743216 4.527714 0.926888 3.721819 0.967526 2.844132 6.826344 0.669243 0.662653 0.346690
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 23.579706 25.033441 47.199830 48.809052 10.848953 18.100061 6.507493 8.213560 0.027243 0.026811 0.001456
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 8.026656 7.081788 2.497845 0.041515 4.498326 4.473001 -0.101444 5.292278 0.659394 0.638705 0.377076
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.860113 4.857255 16.492491 22.870231 2.708951 7.334287 1.682588 -2.564368 0.680990 0.674619 0.395453
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 17.953036 25.769527 16.094013 20.595813 1.670378 17.963967 1.773676 6.569452 0.626773 0.042856 0.547459
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.307504 2.669989 10.141631 18.707985 1.800405 4.136542 1.020708 -1.843507 0.635529 0.639158 0.408692
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 1.419675 0.785146 0.882696 1.374543 3.212717 0.692607 -0.044584 0.479352 0.701188 0.686973 0.394492
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.004287 2.917725 9.559625 6.016764 2.790962 0.909312 3.670033 6.858504 0.705548 0.696927 0.389739
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -1.087952 -0.237427 5.594712 2.771501 0.767265 -0.122832 2.545601 3.632567 0.710270 0.700759 0.380998
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 4.621267 54.205340 1.252526 65.062392 0.637405 16.996282 1.621197 20.620712 0.710996 0.031059 0.481510
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.709222 -1.096484 0.106685 -0.564474 2.458420 1.943664 0.003598 0.745128 0.714372 0.707353 0.377283
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 1.071107 -0.593827 1.015160 1.782508 1.051390 -0.130384 0.109111 -0.364686 0.721134 0.712766 0.375332
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 14.064967 -0.257774 2.749427 1.847210 4.425686 2.598194 1.053742 2.484994 0.729752 0.710716 0.369662
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 7.643683 -0.384685 1.200339 1.485455 2.923234 1.825583 2.325722 0.125996 0.711346 0.703702 0.362463
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 21.172230 23.962869 46.517268 47.447535 10.687776 17.934227 8.852624 4.490151 0.027063 0.026731 0.001273
74 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 23.241626 20.863193 48.533784 46.774519 11.257954 17.066625 7.633644 52.383050 0.030906 0.347575 0.215803
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 15.294214 26.122959 13.227508 49.268116 7.231399 18.434555 8.756722 8.064046 0.683711 0.048231 0.510045
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 45.702905 47.203810 17.013861 13.936937 5.451868 10.404207 10.138561 -0.524984 0.569115 0.511757 0.204310
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 64.253286 1.364784 12.507944 16.524392 7.179657 2.724127 -0.433664 2.168139 0.494352 0.654155 0.373453
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 0.091476 -0.111837 0.019359 14.097335 1.290250 38.884264 1.781303 2.345676 0.680666 0.646164 0.388340
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.952291 0.568327 -0.330826 6.147583 1.292364 -0.254260 0.118822 -0.825939 0.691282 0.680758 0.386057
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.653039 -0.578542 -0.364239 -0.145512 -0.812441 0.285261 -1.092154 -0.003598 0.703337 0.695276 0.381597
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 12.531796 48.470235 6.137690 62.933227 -1.129617 17.108013 0.212701 11.509343 0.709780 0.041268 0.597020
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.688870 0.703579 -0.479603 -0.484700 -1.611554 3.181819 -1.179720 0.944824 0.712664 0.699954 0.382485
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 3.001244 9.994113 4.340020 0.494258 8.636513 0.858721 0.817451 31.206482 0.701265 0.671120 0.369098
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 23.650813 14.190490 3.916701 0.701669 31.373939 0.291413 10.726534 1.224441 0.642079 0.719880 0.365812
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 1.911025 1.406092 0.726449 0.836537 -1.343836 3.374176 -0.899869 -1.238386 0.713851 0.705033 0.364006
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 2.082285 0.133838 -0.607206 0.363387 0.644160 -0.498039 -0.943315 -1.087601 0.719275 0.704016 0.369621
90 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.839685 0.471849 -0.465395 1.062047 -0.602187 -0.664225 1.106318 5.964430 0.716599 0.700356 0.370080
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 1.139269 -0.922145 -0.448814 0.100854 -0.471156 -1.282013 0.359935 -0.764167 0.710264 0.705225 0.385533
92 N10 RF_maintenance 100.00% 0.00% 14.82% 0.00% 75.050898 84.738539 5.557102 6.815251 7.678330 18.231848 1.524311 10.469925 0.300732 0.247123 0.093824
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 5.949884 0.679025 7.857595 -0.148566 3.256596 -0.079024 12.274291 -1.023050 0.700069 0.693796 0.393155
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -1.163862 -1.754723 -0.420806 -0.414732 1.390892 2.881186 4.934060 6.066087 0.703981 0.684562 0.398548
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 2.431904 10.095582 -0.301784 0.025746 1.643827 2.844516 2.335736 5.833904 0.677401 0.662961 0.388517
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 3.856250 -1.110560 0.371243 1.134709 -0.056826 7.548266 3.655612 -0.397450 0.680854 0.677048 0.388197
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.221264 -1.438042 -0.499970 1.858263 1.595106 -0.994650 0.020611 -1.006023 0.695789 0.686024 0.383031
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 13.862524 17.313991 1.931727 1.395379 -0.548850 -0.897072 0.724685 -0.622627 0.716956 0.703504 0.378311
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 8.822748 25.876387 30.683509 46.285872 21.227597 18.239091 2.925784 8.702740 0.624066 0.042347 0.542657
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 47.269242 49.375355 54.196434 55.543944 11.232528 18.514856 18.784629 17.844221 0.026735 0.027534 0.001919
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 13.935240 111.102746 4.128519 44.823582 2.401434 6.425330 0.442142 1.518387 0.719888 0.644291 0.404487
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.113968 -0.364597 -0.765908 0.398162 -0.327781 -0.593094 -0.057544 -1.268217 0.720012 0.706917 0.363449
106 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 0.133417 1.614165 3.959844 1.977256 4.059121 1.740704 1.148292 -0.396028 0.709096 0.701390 0.368243
107 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 2.945972 -0.551969 0.917559 3.431621 1.692776 0.959951 1.962350 5.023697 0.711507 0.703183 0.366883
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 17.627251 5.661363 43.956836 0.571729 7.529144 -0.496866 3.840625 2.370433 0.390213 0.702745 0.503309
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.175812 25.425267 1.370022 47.472312 -0.458790 17.903935 0.267078 4.721014 0.713291 0.034711 0.489613
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 1.042260 51.482204 -0.150098 63.632404 0.630874 17.266128 0.983233 10.147680 0.716728 0.032504 0.491132
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.085007 25.264548 1.090316 47.988806 -0.342138 17.864847 0.620475 5.903085 0.705403 0.034894 0.488931
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.008768 -0.660112 -0.751718 1.196189 -0.248288 1.597049 1.196543 -0.919502 0.694257 0.683577 0.403733
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.413647 1.744593 0.754925 -0.501941 2.888839 1.653546 0.779136 0.808789 0.672570 0.665455 0.392324
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 24.474028 28.319430 47.440277 50.345479 11.045006 18.251421 5.113889 8.926039 0.027338 0.031003 0.003061
118 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -0.147069 0.883555 -0.413695 1.194282 2.189510 4.571156 0.385963 0.801443 0.694355 0.686262 0.383983
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.797807 6.385874 3.239671 18.089880 -0.490623 4.098381 0.945709 2.177821 0.707352 0.652252 0.388951
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 5.545241 47.453985 -0.301058 62.617513 1.344528 17.632316 3.394578 18.941482 0.712335 0.034678 0.603983
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 4.620643 10.250943 -0.060382 0.675670 0.756349 -0.018874 79.149366 30.349682 0.721754 0.709082 0.380860
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 15.667059 13.613145 0.490047 0.758605 2.172523 -0.473809 0.020724 -0.949040 0.728213 0.712102 0.375889
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 11.926053 17.392706 0.993875 1.471487 -0.823437 0.247619 -0.182057 0.255988 0.726056 0.712981 0.370665
124 N09 digital_ok 100.00% 0.00% 0.00% 0.00% -0.665394 4.893456 -0.170320 -0.183514 -0.159146 -1.161498 1.184451 1.074626 0.725766 0.705206 0.372165
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.521931 1.903102 -0.047303 0.212845 -0.944463 0.347318 -0.668247 -0.005395 0.718000 0.700583 0.368075
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 60.032537 3.637164 3.924251 1.607352 9.501611 4.213187 5.355865 8.677326 0.596524 0.697112 0.360676
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.091339 -0.324535 -0.687099 0.028053 2.409670 1.193164 -0.256455 0.178056 0.716066 0.705079 0.388974
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -1.127152 11.945372 4.909025 1.397052 0.105168 3.661796 1.069466 0.645458 0.708465 0.681504 0.387623
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.652247 -2.187229 -0.712441 -0.676829 0.235866 -0.224872 -0.680734 -0.662583 0.707215 0.692363 0.400590
130 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 2.914323 0.634215 -0.304262 -0.085581 1.298618 0.821998 0.985899 7.407134 0.690548 0.681039 0.397840
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -2.247080 25.434181 -0.528527 49.032877 1.181215 18.380804 4.629444 7.113501 0.672243 0.039193 0.476824
136 N12 digital_maintenance 100.00% 0.00% 0.00% 0.00% 8.183372 2.336921 0.142516 0.973025 0.769506 5.055494 1.318736 1.309479 0.662011 0.660282 0.391035
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.481339 -1.570058 0.267119 0.690375 4.689016 9.700259 5.541200 1.941144 0.679597 0.667725 0.391072
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.884585 -0.273421 3.534406 4.713137 -1.481100 -0.518443 11.402591 -0.573521 0.697837 0.684665 0.394958
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 7.240868 26.896131 32.717266 48.402403 6.379772 17.759809 1.020292 8.917647 0.697967 0.054006 0.494121
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.844441 9.717946 1.668849 35.806474 1.257204 13.635211 7.251933 1.221265 0.713250 0.683597 0.368910
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 2.742586 25.272513 0.734322 48.752482 3.200700 18.166663 7.434627 9.454247 0.711096 0.049008 0.507077
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 23.084397 -1.977491 47.733981 -0.465037 11.148914 0.977281 1.731690 -0.705150 0.038399 0.710072 0.523588
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.379987 -1.221520 -0.334478 9.154970 0.142456 0.902911 0.447109 1.966097 0.720037 0.696993 0.375717
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% -2.249347 5.493381 -0.269622 30.540090 14.311064 42.298142 1.940210 4.549798 0.715207 0.617254 0.400030
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% 471.168304 471.114598 inf inf 8213.948085 8299.947470 12342.161062 12960.001810 nan nan nan
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 23.991393 25.411482 47.258970 48.657795 10.714618 18.058927 5.576546 5.930721 0.026194 0.028311 0.000996
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 53.784816 3.326091 12.935306 -0.311174 5.517959 6.063031 2.715904 -0.317026 0.536794 0.622048 0.385934
152 N16 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
153 N16 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
154 N16 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 22.028011 -0.558718 45.664980 -0.799743 10.885739 7.155756 8.816363 12.045953 0.065236 0.662723 0.489561
156 N12 digital_ok 100.00% 8.65% 0.00% 0.00% 18.325819 -0.230555 45.279304 1.531917 9.415877 0.473269 6.562614 3.905294 0.302480 0.669846 0.461706
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -0.008768 -0.424237 -0.028053 -0.418696 -1.136679 -0.054454 0.257921 0.086468 0.686280 0.672828 0.396735
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.452861 -1.159013 1.373653 2.545778 3.628477 1.485114 18.638779 56.201699 0.699367 0.683897 0.400404
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.191595 0.040524 1.171975 4.282337 -0.550708 0.859502 5.350777 3.191772 0.708741 0.689868 0.377224
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.647195 55.788755 0.247064 5.989598 -0.650701 5.355011 1.620247 3.083724 0.712044 0.567054 0.342546
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 4.276775 1.168166 4.003801 2.814223 20.725043 2.642579 4.917216 4.203104 0.715596 0.702525 0.374344
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.427475 -1.841286 0.659371 -0.888602 -1.275088 0.409580 1.096237 2.181611 0.719828 0.692707 0.379727
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.723616 -0.674524 4.560485 2.617689 19.543543 0.517445 3.336055 4.871361 0.711127 0.702489 0.379956
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 36.961032 0.382565 34.983613 2.612415 6.125565 -1.116453 1.342263 0.085552 0.443950 0.700621 0.410456
166 N14 RF_maintenance 100.00% 0.00% 41.30% 0.00% 57.881730 21.589911 9.035176 45.657240 4.188337 16.222705 2.714520 1.139082 0.568864 0.228396 0.365522
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 80.661546 84.446200 5.925152 6.451394 21.283929 14.565449 87.088177 46.294757 0.510481 0.516510 0.179041
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -1.178025 -0.305662 -0.816952 2.042965 0.918167 -0.031511 0.326009 1.562224 0.709582 0.692858 0.397347
169 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 24.626069 25.675147 46.893132 47.657547 10.590288 17.885770 6.496955 3.599001 0.033520 0.037240 0.001755
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -1.352042 9.741338 0.296945 6.413017 -0.252296 3.245219 -0.250877 0.336380 0.705334 0.678342 0.400350
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 3.207992 6.824728 8.863296 0.153703 1.680255 2.430574 -0.210716 -0.455092 0.651493 0.599381 0.397265
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 26.744005 26.949836 17.231332 18.813168 10.548902 17.874166 7.388486 16.775615 0.034794 0.039304 0.004839
176 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 360.857563 355.082176 inf inf 4145.517215 4176.761478 12940.395420 15241.904457 nan nan nan
177 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 280.134017 290.116436 inf inf 5357.742442 5581.421650 14562.996512 15119.204801 nan nan nan
178 N12 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 24.432262 27.592784 48.030286 51.084626 11.406907 18.513574 8.102253 8.714807 0.051262 0.061032 0.009808
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.137535 26.766847 -0.847011 49.358770 2.850698 18.403905 7.853925 11.721334 0.706420 0.053944 0.514497
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.003493 -1.406880 0.377136 -0.856007 -0.170738 3.935577 0.881232 8.806259 0.716394 0.692144 0.380487
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.068966 8.279300 27.043226 33.135312 2.205083 11.439163 24.340221 0.530450 0.662518 0.686941 0.387980
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 23.167348 -0.040993 43.964403 3.536003 10.658569 0.602386 2.585898 2.349782 0.045006 0.690781 0.490108
184 N14 digital_ok 100.00% 88.45% 100.00% 0.00% 22.672403 26.061655 47.429758 48.795269 10.024588 17.973705 2.859924 3.088599 0.120906 0.049094 0.060751
185 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 21.762474 -1.634199 47.383573 14.074281 10.795135 -0.143313 2.111928 -0.310455 0.037535 0.677228 0.485524
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 2.183642 2.670568 8.853648 10.678219 15.236114 2.598796 3.302902 1.943346 0.707216 0.701047 0.385833
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 5.131113 4.137403 4.370017 25.779309 62.640593 8.106020 4.432106 0.908324 0.692566 0.693623 0.400115
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.261786 2.719439 1.830105 4.732683 -0.454874 3.129794 1.380775 -0.057558 0.692739 0.683162 0.402616
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 91.578778 25.725145 7.105357 49.182214 11.519742 18.380686 49.660739 6.945793 0.495312 0.033717 0.356771
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.957601 0.846580 0.621194 4.896355 1.180311 -0.024306 22.939900 33.663293 0.682951 0.676311 0.415295
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 3.778268 13.228793 27.583093 39.935610 6.140057 16.886455 1.058951 -7.044003 0.671661 0.631616 0.419630
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 12.574494 2.047497 39.325028 22.286509 9.381376 4.071909 -6.670072 -0.297946 0.630839 0.651726 0.432692
200 N18 RF_maintenance 100.00% 100.00% 42.64% 0.00% 25.802367 69.173484 19.191046 18.757081 10.511671 17.296086 4.632672 0.614260 0.047679 0.218254 0.143432
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 13.363351 11.708652 39.665155 37.848226 9.621465 15.375908 -6.148938 -6.014018 0.670266 0.649895 0.379179
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 3.428729 6.193034 19.092110 1.682652 1.442834 5.670721 1.789146 6.999184 0.698518 0.637859 0.388484
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 26.835842 28.958747 18.027835 19.311051 10.683432 17.886482 7.046143 7.010684 0.034429 0.042390 0.001831
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 13.050745 8.450827 40.310887 33.664810 9.966609 11.055008 -6.742874 -5.329131 0.643516 0.661188 0.402968
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 7.614851 9.354682 33.156976 33.631504 6.569094 11.850722 -2.226429 -5.627435 0.694427 0.664291 0.392580
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 6.027317 2.459012 2.066589 15.027639 4.266428 1.477113 5.467127 0.121562 0.660471 0.662075 0.393487
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 9.185444 7.801997 34.607102 28.970483 7.947498 73.304639 -0.474187 -1.872063 0.686186 0.665410 0.396916
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 6.736543 4.465137 0.973047 11.435460 3.544691 2.980558 1.639390 -0.476910 0.643058 0.640218 0.402457
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.788108 0.760094 21.401003 20.981398 2.858233 7.976253 -1.783318 -2.687517 0.694146 0.661205 0.400524
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.053967 7.083992 13.705311 30.921672 0.317604 10.820928 6.101988 -3.427124 0.685789 0.658169 0.400051
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 1.329662 26.901399 0.460460 31.000694 1.088177 17.898873 12.784129 5.949331 0.691187 0.048392 0.524016
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.895152 2.080232 13.655628 15.755327 3.957105 4.027390 9.590020 6.937608 0.613355 0.587502 0.410249
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 3.965493 5.568014 16.604691 27.225894 2.468111 8.687770 2.261826 -1.612035 0.602290 0.580757 0.403563
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 49.600716 3.671974 3.044529 24.670240 6.534730 6.993230 4.949558 0.249241 0.391408 0.573367 0.368572
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 3.333266 5.632820 21.124008 24.750069 2.629269 6.477310 1.509375 -0.863289 0.601346 0.574356 0.392328
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 1.262610 -0.355666 21.705959 10.855503 2.960910 2.420061 -1.608253 0.886760 0.631953 0.587667 0.401053
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 4.852388 0.192698 9.327614 15.663251 3.229007 4.006559 9.924490 4.963403 0.582006 0.583508 0.402717
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 9.040975 3.262721 -0.118539 10.096990 3.618297 3.980629 8.703384 5.189046 0.546433 0.568699 0.395305
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 4, 5, 7, 8, 10, 16, 18, 19, 20, 21, 22, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 71, 72, 73, 74, 75, 77, 78, 81, 82, 84, 86, 87, 90, 92, 93, 94, 98, 99, 101, 102, 103, 104, 106, 107, 108, 109, 110, 111, 117, 118, 119, 120, 121, 122, 123, 124, 126, 128, 130, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 160, 161, 162, 164, 165, 166, 167, 169, 170, 171, 173, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 200, 201, 202, 203, 219, 220, 221, 222, 237, 238, 239, 320, 321, 322, 323, 324, 325, 329, 333]

unflagged_ants: [9, 15, 17, 40, 41, 42, 65, 69, 70, 83, 85, 88, 89, 91, 100, 105, 112, 116, 125, 127, 129, 157, 163, 168]

golden_ants: [9, 15, 17, 40, 41, 42, 65, 69, 70, 83, 85, 88, 91, 100, 105, 112, 116, 127, 129, 157, 163]
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_2459870.csv
In [24]:
# Load antenna positions
data_list = sorted(glob.glob(os.path.join(data_path, f'zen.{JD}.?????.sum.uvh5')))
hd = io.HERAData(data_list[len(data_list) // 2])

# Figure out where to draw the nodes
node_centers = {}
for node in sorted(set(list(nodes.values()))):
    if np.isfinite(node):
        this_node_ants = [ant for ant in ants + unused_ants if nodes[ant] == node]
        if len(this_node_ants) == 1:
            # put the node label just to the west of the lone antenna 
            node_centers[node] = hd.antpos[ant][node] + np.array([-14.6 / 2, 0, 0])
        else:
            # put the node label between the two antennas closest to the node center
            node_centers[node] = np.mean([hd.antpos[ant] for ant in this_node_ants], axis=0)
            closest_two_pos = sorted([hd.antpos[ant] for ant in this_node_ants], 
                                     key=lambda pos: np.linalg.norm(pos - node_centers[node]))[0:2]
            node_centers[node] = np.mean(closest_two_pos, axis=0)
In [25]:
def Plot_Array(ants, unused_ants, outriggers):
    plt.figure(figsize=(16,16))
    
    plt.scatter(np.array([hd.antpos[ant][0] for ant in hd.data_ants if ant in ants]), 
                np.array([hd.antpos[ant][1] for ant in hd.data_ants if ant in ants]), c='w', s=0)

    # connect every antenna to their node
    for ant in ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', zorder=0)

    rc_color = '#0000ff'
    antm_color = '#ffa500'
    autom_color = '#ff1493'

    # Plot 
    unflagged_ants = []
    for i, ant in enumerate(ants):
        ant_has_flag = False
        # plot large blue annuli for redcal flags
        if use_redcal:
            if redcal_flagged_frac[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=7 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=rc_color, alpha=redcal_flagged_frac[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot medium green annuli for ant_metrics flags
        if use_ant_metrics: 
            if ant_metrics_xants_frac_by_ant[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=antm_color, alpha=ant_metrics_xants_frac_by_ant[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot small red annuli for auto_metrics
        if use_auto_metrics:
            if ant in auto_ex_ants:
                ant_has_flag = True                
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, lw=0, color=autom_color)) 
        
        # plot black/white circles with black outlines for antennas
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4 * (2 - 1 * float(not outriggers)), fill=True, color=['w', 'k'][ant_has_flag], ec='k'))
        if not ant_has_flag:
            unflagged_ants.append(ant)

        # label antennas, using apriori statuses if available
        try:
            bgc = matplotlib.colors.to_rgb(status_colors[a_priori_statuses[ant]])
            c = 'black' if (bgc[0]*0.299 + bgc[1]*0.587 + bgc[2]*0.114) > 186 / 256 else 'white'
        except:
            c = 'k'
            bgc='white'
        plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color=c, backgroundcolor=bgc)

    # label nodes
    for node in sorted(set(list(nodes.values()))):
        if not np.isnan(node) and not np.all(np.isnan(node_centers[node])):
            plt.text(node_centers[node][0], node_centers[node][1], str(node), va='center', ha='center', bbox={'color': 'w', 'ec': 'k'})
    
    # build legend 
    legend_objs = []
    legend_labels = []
    
    # use circles for annuli 
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgecolor='k', markerfacecolor='w', markersize=13))
    legend_labels.append(f'{len(unflagged_ants)} / {len(ants)} Total {["Core", "Outrigger"][outriggers]} Antennas Never Flagged')
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='k', markersize=15))
    legend_labels.append(f'{len(ants) - len(unflagged_ants)} Antennas {["Core", "Outrigger"][outriggers]} Flagged for Any Reason')

    if use_auto_metrics:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=autom_color, markersize=15))
        legend_labels.append(f'{len([ant for ant in auto_ex_ants if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas Flagged by Auto Metrics')
    if use_ant_metrics: 
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=antm_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum([frac for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants]), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Ant Metrics\n(alpha indicates fraction of time)')        
    if use_redcal:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=rc_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum(list(redcal_flagged_frac.values())), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in redcal_flagged_frac.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Redcal\n(alpha indicates fraction of time)')

    # use rectangular patches for a priori statuses that appear in the array
    for aps in sorted(list(set(list(a_priori_statuses.values())))):
        if aps != 'Not Found':
            legend_objs.append(plt.Circle((0, 0), radius=7, fill=True, color=status_colors[aps]))
            legend_labels.append(f'A Priori Status:\n{aps} ({[status for ant, status in a_priori_statuses.items() if ant in ants].count(aps)} {["Core", "Outrigger"][outriggers]} Antennas)')

    # label nodes as a white box with black outline
    if len(node_centers) > 0:
        legend_objs.append(matplotlib.patches.Patch(facecolor='w', edgecolor='k'))
        legend_labels.append('Node Number')

    if len(unused_ants) > 0:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='grey', markersize=15, alpha=.2))
        legend_labels.append(f'Anntenna Not In Data')
        
    
    plt.legend(legend_objs, legend_labels, ncol=2, fontsize='large', framealpha=1)
    
    if outriggers:
        pass
    else:
        plt.xlim([-200, 150])
        plt.ylim([-150, 150])        
       
    # set axis equal and label everything
    plt.axis('equal')
    plt.tight_layout()
    plt.title(f'Summary of {["Core", "Outrigger"][outriggers]} Antenna Statuses and Metrics on {JD}', size=20)    
    plt.xlabel("Antenna East-West Position (meters)", size=12)
    plt.ylabel("Antenna North-South Position (meters)", size=12)
    plt.xticks(fontsize=12)
    plt.yticks(fontsize=12)
    xlim = plt.gca().get_xlim()
    ylim = plt.gca().get_ylim()    
        
    # plot unused antennas
    plt.autoscale(False)    
    for ant in unused_ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', alpha=.2, zorder=0)
        
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='w', ec=None, alpha=1, zorder=0))
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='grey', ec=None, alpha=.2, zorder=0))
        if hd.antpos[ant][0] < xlim[1] and hd.antpos[ant][0] > xlim[0]:
            if hd.antpos[ant][1] < ylim[1] and hd.antpos[ant][1] > ylim[0]:
                plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color='k', alpha=.2) 

Figure 1: Array Plot of Flags and A Priori Statuses¶

This plot shows all antennas, which nodes they are connected to, and their a priori statuses (as the highlight text of their antenna numbers). It may also show (depending on what is finished running):

  • Whether they were flagged by auto_metrics (red circle) for bandpass shape, overall power, temporal variability, or temporal discontinuities. This is done in a binary fashion for the whole night.
  • Whether they were flagged by ant_metrics (green circle) as either dead (on either polarization) or crossed, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.
  • Whether they were flagged by redcal (blue circle) for high chi^2, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.

Note that the last fraction does not include antennas that were flagged before going into redcal due to their a priori status, for example.

In [26]:
core_ants = [ant for ant in ants if ant < 320]
outrigger_ants = [ant for ant in ants if ant >= 320]
Plot_Array(ants=core_ants, unused_ants=unused_ants, outriggers=False)
if len(outrigger_ants) > 0:
    Plot_Array(ants=outrigger_ants, unused_ants=sorted(set(unused_ants + core_ants)), outriggers=True)

Metadata¶

In [27]:
from hera_qm import __version__
print(__version__)
from hera_cal import __version__
print(__version__)
2.0.4.dev20+g17344e9
3.1.5.dev171+gc8e6162
In [ ]: