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 = "2459875"
data_path = "/mnt/sn1/2459875"
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-22-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/2459875/zen.2459875.25289.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/2459875/zen.2459875.?????.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/2459875/zen.2459875.?????.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 2459875
Date 10-22-2022
LST Range 21.573 -- 7.594 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
Total Number of Antennas 183
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 51
RF_ok: 5
digital_maintenance: 1
digital_ok: 99
not_connected: 23
Commanded Signal Source None
Antennas in Commanded State (reported) 0 / 183 (0.0%)
Antennas in Commanded State (observed) 0 / 183 (0.0%)
Cross-Polarized Antennas 146
Total Number of Nodes 16
Nodes Registering 0s
Nodes Not Correlating N09
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 64 / 183 (35.0%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 149 / 183 (81.4%)
Redcal Done? ❌
Never Flagged Antennas 27 / 183 (14.8%)
A Priori Good Antennas Flagged 76 / 99 total a priori good antennas:
3, 7, 10, 15, 17, 19, 20, 29, 30, 31, 37, 44,
45, 51, 53, 54, 55, 56, 59, 66, 67, 68, 71,
72, 81, 84, 86, 88, 91, 93, 94, 98, 101, 103,
105, 106, 107, 108, 109, 111, 117, 121, 122,
123, 124, 128, 136, 140, 141, 142, 143, 144,
146, 147, 158, 160, 161, 162, 164, 165, 167,
169, 170, 176, 177, 178, 181, 183, 184, 185,
186, 187, 189, 190, 191, 202
A Priori Bad Antennas Not Flagged 4 / 84 total a priori bad antennas:
4, 8, 137, 168
In [19]:
# write to csv
outpath = os.path.join(nb_outdir, f'array_health_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.replace({'\u2705': 'Y'}, regex=True).replace({'\u274C': 'N'}, regex=True).replace({'<br>': ' '}, regex=True).to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/array_health_table_2459875.csv

Build DataFrame¶

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

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

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

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

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

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

Table 2: RTP Per-Antenna Metrics Summary Table¶

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

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

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

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

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

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

In [21]:
HTML(table.render())
Out[21]:
Ant Node A Priori Status Auto Metrics Flags Dead Fraction in Ant Metrics (Jee) Dead Fraction in Ant Metrics (Jnn) Crossed Fraction in Ant Metrics ee Shape Modified Z-Score nn Shape Modified Z-Score ee Power Modified Z-Score nn Power Modified Z-Score ee Temporal Variability Modified Z-Score nn Temporal Variability Modified Z-Score ee Temporal Discontinuties Modified Z-Score nn Temporal Discontinuties Modified Z-Score Average Dead Ant Metric (Jee) Average Dead Ant Metric (Jnn) Average Crossed Ant Metric
3 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 5.241404 -0.878881 -0.058924 -0.579305 -0.424218 -0.154574 -0.168739 1.445151 0.689908 0.695054 0.402283
4 N01 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.551715 2.695759 3.185073 -0.080841 0.792962 0.682378 3.719663 -0.110281 0.695880 0.694742 0.395301
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.186666 0.222359 -0.686188 2.402065 -0.421074 0.064554 0.365392 -0.786921 0.706151 0.696668 0.390101
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -2.270306 -1.918192 0.510055 0.714941 0.044720 1.272652 3.591543 8.318162 0.699750 0.696465 0.396821
8 N02 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.233547 1.156451 1.482093 0.536057 0.111981 -0.289321 3.200391 0.476826 0.693736 0.682139 0.389664
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.078963 -2.165035 0.560766 0.549496 1.899528 -0.281328 0.048409 2.567364 0.695457 0.691929 0.404391
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 21.937578 -1.376477 18.149452 8.197859 8.066718 2.154102 3.972917 1.133708 0.664651 0.689832 0.409084
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 0.486262 0.379106 6.233955 2.784188 -0.096821 -0.757173 11.213539 2.496014 0.705708 0.702336 0.393510
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.760490 -0.089792 0.071867 -0.625443 -0.083152 0.563716 3.118342 2.122272 0.707839 0.701357 0.387367
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.629232 0.881438 -0.216580 0.605008 -0.168223 -0.342124 7.665173 3.628498 0.706276 0.706106 0.387312
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.049706 21.638199 1.784836 1.915881 4.960902 10.287583 23.153125 37.229723 0.685643 0.489936 0.426683
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 3.346981 -0.094946 -0.327867 6.298184 3.187017 97.778316 3.709530 4.776056 0.700897 0.697437 0.398398
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.418756 3.697056 0.375286 20.283485 1.068049 2.650049 2.189775 -0.011562 0.706985 0.693600 0.396169
21 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.942874 0.627165 -0.481513 -0.709031 0.594579 0.516724 0.573124 2.949363 0.693725 0.691851 0.400632
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 47.135584 17.067326 6.592913 21.617782 7.691615 4.441673 3.222855 1.207428 0.490499 0.647281 0.338253
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 17.888178 19.612655 67.382785 68.293474 13.299165 20.664119 4.780793 9.037249 0.033865 0.038606 0.002949
28 N01 RF_maintenance 100.00% 0.00% 83.51% 0.00% 21.747750 42.986236 8.502808 5.636901 11.528741 22.845943 3.971842 27.020348 0.381381 0.168433 0.237381
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.676128 -0.839254 -0.473518 0.243542 -1.282687 -0.811700 -0.384317 5.089133 0.711743 0.706237 0.380066
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.765213 -1.235999 -0.055159 -0.930336 0.664830 -0.550949 14.477611 -0.124776 0.708879 0.710457 0.384907
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.244651 -0.537810 1.415107 -0.406667 0.431649 4.967766 1.583064 6.577813 0.719866 0.710266 0.391916
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.548332 38.949876 2.660110 5.839770 6.385767 10.249734 7.450644 33.172534 0.675544 0.631178 0.329706
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.677559 25.704170 0.275058 1.878726 -0.099906 10.408787 4.221626 36.783055 0.701232 0.521386 0.467930
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 20.537654 4.115507 28.437740 24.302104 13.297312 4.506714 2.982219 0.839663 0.044388 0.677436 0.536906
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.143786 1.682813 4.429264 14.357663 8.452004 4.168691 0.464676 0.455770 0.634790 0.665901 0.418920
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 14.530393 12.901118 1.296933 0.991557 1.029112 2.443035 -0.368775 1.637008 0.713540 0.708408 0.395948
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.460585 1.006202 -0.809801 0.833550 -1.181866 0.257347 -0.549613 6.100826 0.718004 0.714993 0.396055
38 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -0.099529 0.168573 -0.685518 -0.740541 1.360111 0.142892 3.767194 1.029297 0.720825 0.717523 0.393938
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.179154 0.445989 -0.753671 -0.663463 0.666603 -0.428449 -0.739863 -0.851938 0.711611 0.709143 0.388569
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.339462 0.800980 2.547630 1.464343 0.322188 -1.016594 -0.673084 -0.083856 0.714679 0.708789 0.379648
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.501202 1.407519 -0.485376 2.126183 -0.943387 -0.657146 -0.278876 -0.480175 0.722823 0.720100 0.390387
43 N05 RF_maintenance 100.00% 100.00% 0.00% 0.00% 16.796739 1.085620 66.633341 -0.554076 13.315559 -0.678915 3.819904 0.500252 0.042092 0.716135 0.488607
44 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 2.502398 2.750468 0.183857 0.097997 0.750951 0.011712 10.038300 5.039821 0.700759 0.711466 0.374276
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -1.000820 3.853050 -0.713681 0.222495 -0.311946 3.041651 -0.192394 11.671811 0.712506 0.696231 0.387173
46 N05 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.070871 20.371039 -0.916882 68.545522 0.241028 20.554342 2.451013 10.109195 0.705661 0.038551 0.489995
47 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
48 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
49 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.326874 6.176818 -0.258683 2.541646 2.981858 8.198951 17.384762 41.225419 0.703777 0.690586 0.369025
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 38.630001 1.952987 86.583681 0.540558 12.849445 1.749501 12.182519 6.906422 0.040533 0.718565 0.466723
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.790505 10.962279 1.130250 0.743019 3.289373 -0.772724 0.917963 0.447862 0.723061 0.722112 0.383262
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.453147 4.270877 -0.121110 0.802763 -0.803038 -0.646787 2.221574 3.733916 0.725849 0.724795 0.387614
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 17.935143 20.718301 67.417995 69.935939 13.369407 20.690737 4.069264 8.029332 0.046177 0.045594 0.001305
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 1.813563 21.823408 -0.088985 69.269584 11.119367 20.585128 1.339516 9.922435 0.713355 0.035960 0.481398
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 4.152857 1.124171 0.792087 0.075629 1.782515 1.233768 0.017086 14.844417 0.714047 0.721425 0.374680
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 52.255170 0.009883 27.778534 -0.478278 6.351204 0.895268 2.086627 0.584210 0.549455 0.719719 0.381640
58 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 17.334244 20.513636 67.086226 69.611018 13.411502 20.774108 5.069215 9.423878 0.037756 0.035375 0.001660
59 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 12.679298 7.873988 1.978849 4.176568 8.427066 1.290052 103.667667 24.933401 0.687741 0.702920 0.383198
60 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 18.697902 20.054397 67.268907 69.435355 13.333665 20.694821 3.966157 9.844141 0.028308 0.027851 0.001557
61 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
62 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 13.999859 20.634348 23.663311 28.855942 3.387495 20.609357 0.225746 10.047690 0.625777 0.043643 0.487812
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.322846 1.877911 14.884225 27.465408 1.315610 4.298489 0.497960 0.347475 0.637493 0.659441 0.414892
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.565478 0.330710 1.254956 2.190522 1.861697 2.108310 -0.575008 -0.461392 0.707889 0.709575 0.396094
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.579415 2.441380 14.582394 9.208313 0.650689 0.928950 -0.128311 1.612161 0.711952 0.718105 0.389797
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -1.189999 -0.629975 8.179034 4.174272 0.652886 -0.336857 0.397786 2.112647 0.717582 0.721157 0.382031
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 3.015185 43.043047 1.758890 92.693080 -0.146226 19.735055 5.490609 16.494174 0.716734 0.032423 0.424795
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.078963 -1.415078 0.188146 -0.222602 1.527608 1.824547 -0.528625 -0.741017 0.719361 0.724209 0.379586
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.902405 -0.563514 1.452252 2.447529 -0.021479 -0.045516 -0.191444 1.388026 0.721659 0.726566 0.382727
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 11.441520 -0.060439 3.141645 2.639169 1.313102 1.642241 0.094325 0.202056 0.729346 0.725596 0.381215
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 5.108008 -0.298155 2.707258 2.144301 2.215573 0.536920 7.147198 -0.016070 0.708575 0.718401 0.378973
73 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 16.705059 18.845041 66.202662 67.408354 13.235053 20.604850 4.938332 7.976935 0.027199 0.027197 0.001221
74 N05 RF_maintenance 100.00% 100.00% 0.00% 0.00% 18.555305 16.776151 69.356515 67.048686 13.617767 18.245180 4.673254 27.848723 0.032230 0.371274 0.232403
75 N05 RF_maintenance 100.00% 0.00% 100.00% 0.00% 11.558605 20.858599 11.209935 70.182786 2.900374 20.863005 5.379735 10.133696 0.690730 0.048654 0.483148
77 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 52.829882 0.840733 18.258906 24.192620 8.235354 3.082107 2.024547 3.745369 0.500737 0.671130 0.390664
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -0.381187 -0.710931 -0.200412 10.446178 0.180449 23.565928 -0.321758 0.420484 0.689014 0.691872 0.392360
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.907958 0.022004 -0.093856 9.258739 1.957212 0.900042 -0.210182 -0.481171 0.697481 0.704912 0.388833
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.957149 -0.990202 -0.609270 0.294868 -0.966524 -0.829783 -0.857542 0.675897 0.710994 0.716331 0.378056
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 10.248080 38.260334 9.402999 89.623054 -0.726431 19.778736 -0.524607 11.844815 0.715948 0.040492 0.527915
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.309421 -0.393085 -0.221595 -0.406467 -1.254357 -0.210332 -0.771954 -0.825643 0.717901 0.718664 0.381393
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 0.539513 7.779658 5.666842 0.917879 4.624199 4.185265 0.260441 16.473314 0.708574 0.689968 0.376623
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.137194 11.838047 3.771116 1.283807 33.687940 4.528140 11.166055 0.917575 0.671574 0.732305 0.374452
88 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 0.788042 0.693480 1.034711 1.112274 -0.697666 0.561683 -0.074327 -0.630394 0.064810 0.071793 0.009888
89 N09 RF_maintenance 0.00% 100.00% 100.00% 0.00% 1.060115 -0.246336 -0.613306 0.738146 -0.397888 -0.728530 -0.938582 -0.775884 0.060451 0.065984 0.006909
90 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% -0.093999 -0.213320 0.419218 2.287319 -0.736633 -0.890636 0.359010 4.787700 0.068550 0.072555 0.010768
91 N09 digital_ok 0.00% 100.00% 100.00% 0.00% -0.248256 -0.741493 -0.002316 0.113851 -0.177218 -0.851627 1.078395 0.372927 0.079713 0.077954 0.020317
92 N10 RF_maintenance 100.00% 0.00% 9.56% 0.00% 60.501366 68.071871 8.260494 9.818974 13.039766 19.410951 1.208255 8.975766 0.318828 0.262394 0.098952
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 3.580000 0.154582 11.836398 -0.216115 3.325538 -0.021429 5.213009 -0.503997 0.705563 0.714764 0.398714
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -1.458192 -1.120453 0.719843 1.025789 -0.395233 3.996446 1.829327 1.370017 0.707116 0.706535 0.400970
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 1.958812 10.800982 -0.064794 0.951017 0.329650 3.257414 1.944170 3.279102 0.687927 0.689116 0.388675
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 1.559906 -1.530375 1.372120 -0.077698 -0.960691 3.102744 1.129286 -0.877527 0.691030 0.706166 0.388151
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.952578 -1.912121 -0.061384 3.016724 1.136341 -1.141762 0.032218 -0.423939 0.704199 0.710332 0.380280
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 12.017387 14.420308 2.861128 2.522105 0.074309 -0.980349 -0.389209 -0.664410 0.724357 0.725239 0.374754
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 12.021204 20.602259 56.131868 65.870437 22.952413 20.810973 1.440685 11.486668 0.491146 0.042282 0.366705
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 37.346519 38.973467 77.521193 79.393578 13.667411 20.840644 13.032039 16.201139 0.027465 0.028130 0.001864
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.266052 89.563609 6.277807 64.565304 1.113839 1.718637 -0.490826 2.365463 0.722121 0.669374 0.409463
105 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 0.339081 -0.613890 -0.510085 0.921139 0.021479 -0.799396 -0.394257 -0.779894 0.067568 0.072018 0.010898
106 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 0.197291 1.226281 5.537162 2.846890 1.805490 0.196399 -0.398767 -0.265070 0.056647 0.062218 0.006143
107 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 2.695865 -0.311592 0.949422 0.847248 -0.598843 -0.824813 2.009989 2.798322 0.051129 0.060364 0.005004
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 16.105857 4.617799 65.031739 0.633337 10.906013 0.821459 3.254381 0.880267 0.062739 0.066353 0.045695
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.713783 20.292882 2.061243 67.467572 -0.799647 20.600655 0.954887 8.986285 0.716868 0.036119 0.437627
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.462441 40.628252 -0.023783 90.676749 -1.085301 19.931466 -0.154680 11.216602 0.726671 0.033964 0.441477
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.039010 20.063686 1.692820 68.203258 -0.901673 20.571600 1.817486 9.432020 0.712916 0.036610 0.433396
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.827940 -0.499824 -0.823954 1.740926 0.105236 -0.177159 0.305671 -0.682232 0.702450 0.712910 0.403261
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.621502 0.622260 1.508144 -0.306930 0.943280 1.827154 -0.172533 -0.032218 0.683981 0.695605 0.394646
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 19.464191 22.595902 67.749538 71.732346 13.481554 20.749349 3.575045 11.060534 0.027842 0.032096 0.003942
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.934409 1.078201 -0.184524 0.858233 0.687516 0.529452 0.323669 1.228466 0.707607 0.716705 0.382435
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.813428 3.456833 4.466575 24.968629 -1.288342 7.659924 -0.012936 1.493374 0.717138 0.686602 0.385996
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 3.728343 37.464343 -0.079430 89.289012 0.175171 20.251713 -0.516735 16.092546 0.719899 0.035892 0.545187
121 N08 digital_ok 100.00% 0.21% 0.00% 0.00% 3.543979 7.655258 0.393811 1.002044 1.933951 1.206339 26.046068 22.379763 0.722600 0.727903 0.383283
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 13.104789 11.225913 1.034854 1.669580 6.880883 -0.829420 -0.448105 -0.830341 0.729789 0.730172 0.382571
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 9.935748 14.339033 2.104990 2.443745 -1.248689 0.198955 0.224346 1.378840 0.726311 0.731617 0.386457
124 N09 digital_ok 0.00% 100.00% 100.00% 0.00% -1.284809 2.581776 -0.043676 0.102437 -0.218294 -0.792964 0.705683 0.226270 0.063969 0.073542 0.008078
125 N09 RF_maintenance 0.00% 100.00% 100.00% 0.00% 1.003600 2.916088 -0.072168 0.781927 -0.799027 0.137496 -0.710349 -0.617247 0.061085 0.069994 0.007020
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 29.452237 6.372389 6.146299 4.511621 15.382253 2.279451 29.222641 0.235092 0.078525 0.074371 0.018329
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.318661 -0.125258 -0.729032 -0.198445 0.714214 0.794023 0.417286 3.444973 0.718395 0.724556 0.400873
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.856577 2.762624 7.426895 2.901567 -0.081724 2.077165 -0.516871 -0.122578 0.713822 0.717791 0.392393
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.740252 -1.914791 -0.642370 -0.485512 -0.897742 -0.363385 0.086081 0.234649 0.714235 0.722108 0.399897
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.116194 -0.130895 -0.409636 0.002316 0.052200 0.981927 -0.700749 2.651686 0.702643 0.715272 0.395426
135 N12 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.855967 20.246870 -0.235031 69.829356 0.267436 20.844064 0.013973 8.396639 0.677696 0.040019 0.420552
136 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 5.287483 1.086851 0.651204 0.844445 -0.018635 0.997597 0.287508 -0.247896 0.673197 0.693779 0.388309
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.459662 -1.864096 -0.053318 -0.949590 2.756717 0.051936 1.845246 0.057761 0.689136 0.700993 0.388669
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.646257 -1.176282 6.152514 7.130462 -1.218169 -0.341818 5.697161 -0.173643 0.706710 0.713998 0.390139
139 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.651025 3.569726 51.430332 44.034541 9.123131 11.017697 -1.678565 2.793812 0.696025 0.707571 0.387487
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
141 N13 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
142 N13 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 18.268955 -1.789754 68.203648 -0.754261 13.559721 0.587828 2.164651 -0.809921 0.039291 0.727749 0.493705
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -2.007551 -0.984110 0.245418 16.060563 0.248846 -0.883138 -0.551270 0.246968 0.715187 0.713552 0.395036
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% -2.285268 3.363210 1.872756 38.089531 2.348009 19.410308 -0.104608 1.845440 0.711292 0.670725 0.401504
146 N14 digital_ok 100.00% 0.00% 0.00% 100.00% 4.833955 7.219080 40.104959 48.771853 4.108412 17.715354 -0.725041 4.061925 0.307757 0.301045 -0.285510
147 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 29.408496 30.394788 15.558007 16.190393 12.033383 17.508844 2.408531 6.159082 0.370175 0.372671 0.168384
148 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.843316 -0.499522 21.074570 8.403223 -0.267007 -0.550655 -0.568091 -0.101391 0.699856 0.723352 0.401494
149 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.467867 2.137408 13.369770 38.205017 -0.720023 7.725756 -0.854409 2.378715 0.713136 0.716783 0.403572
150 N15 RF_maintenance 100.00% 100.00% 0.48% 0.00% 19.122962 4.474985 67.332110 44.727187 13.292381 9.559611 4.275396 5.359168 0.050716 0.326000 0.106255
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 43.604524 2.590479 19.727952 -0.267270 6.300229 5.118313 1.111321 0.177067 0.540532 0.661507 0.397623
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.762531 2.563516 7.847874 15.656843 0.990171 2.543874 7.023396 0.316825 0.647239 0.679698 0.426182
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 18.717339 1.106641 26.794518 17.482780 13.407344 2.673220 2.971246 -0.339854 0.042040 0.678509 0.530561
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.637733 -0.300965 25.576205 24.902117 2.783859 2.866305 -0.970802 0.049111 0.652668 0.676750 0.430455
155 N12 RF_maintenance 100.00% 100.00% 0.00% 0.00% 17.348123 -0.648896 64.984399 -0.714264 13.199598 4.847034 2.655174 1.869773 0.062135 0.693633 0.469590
156 N12 RF_maintenance 100.00% 0.00% 0.00% 0.00% 14.340413 -0.032604 64.357022 2.363688 11.632813 -0.017815 2.723964 0.099982 0.318334 0.701711 0.477895
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -0.280246 -0.655502 0.338647 -0.281993 -0.122090 0.651433 -0.408141 -0.270788 0.696556 0.706161 0.392020
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.364631 -1.314705 1.265453 3.364193 1.162777 0.175506 1.998552 28.912380 0.707790 0.715522 0.395361
159 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.799543 37.100992 36.513614 30.772664 4.423075 12.709159 -0.704371 3.656526 0.699278 0.570100 0.357125
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.089770 -0.944971 1.851981 6.278511 -1.201270 1.190601 0.125286 1.344421 0.712159 0.717564 0.381802
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.729418 44.014943 0.043374 9.195177 -0.428853 6.775731 -0.315049 3.910557 0.712756 0.600487 0.339041
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 2.953036 2.755222 13.593516 35.606622 3.457849 5.109621 0.734398 2.922628 0.714693 0.685943 0.393736
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.102040 -1.319783 1.106331 -0.941216 -1.227743 0.785098 -0.349473 0.641401 0.717025 0.718526 0.394942
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.021175 -0.728703 5.020712 3.643790 14.145322 1.548062 0.084885 1.152238 0.708148 0.722486 0.396679
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 29.679458 0.300546 49.895670 3.938114 8.590604 -0.973134 0.773674 0.109240 0.433536 0.720696 0.430266
166 N14 RF_maintenance 100.00% 0.00% 73.68% 0.00% 46.984259 18.246336 11.314254 65.800923 10.702256 19.734613 22.476009 6.980067 0.570340 0.179232 0.375562
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.649132 -1.464874 15.659249 4.727042 -0.309458 1.165391 -0.772375 1.972780 0.719716 0.720070 0.404295
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -1.082880 -0.646261 -0.773896 2.612486 -0.084876 -0.205776 -0.707526 0.219554 0.713368 0.720019 0.401994
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.827650 12.134097 35.214337 43.086601 2.689118 14.974672 -1.396208 4.960619 0.710971 0.651555 0.396327
170 N15 digital_ok 100.00% 100.00% 0.00% 0.00% 19.085712 -1.727207 68.558510 15.032819 13.500688 10.057370 2.902138 2.172546 0.043027 0.722067 0.529297
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.033340 4.972117 13.148363 1.271181 2.158322 5.090951 -0.045336 1.685015 0.656956 0.644215 0.401780
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 21.179888 21.563067 24.075566 26.271550 13.284243 20.570511 6.059973 14.540964 0.036310 0.041164 0.004832
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.066395 -0.281978 -0.771162 -0.813221 -0.009594 0.872557 -0.248877 8.410875 0.679925 0.687664 0.406998
177 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -1.655704 -0.680751 1.343438 5.222955 -0.660164 2.008016 -0.445459 1.838641 0.692028 0.699324 0.406365
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 4.453983 -0.844940 1.000271 -0.195057 -0.238748 1.401509 3.666354 1.133597 0.690171 0.702169 0.399906
179 N12 RF_maintenance 100.00% 100.00% 100.00% 0.00% 19.411563 22.115193 68.631474 72.902910 13.592686 20.956185 2.671863 8.314890 0.048811 0.056898 0.009365
180 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 18.429328 21.267262 67.974807 70.303339 13.475890 20.789111 2.501236 9.515399 0.049043 0.051126 0.004448
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.183995 -1.716757 0.846569 -0.988115 0.305859 0.112483 -0.284915 4.823967 0.717954 0.718018 0.389320
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.484453 6.420142 38.378259 48.416385 1.785546 12.671440 3.370262 4.081682 0.663399 0.702188 0.397317
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 18.336527 -1.152056 62.601408 5.336478 13.240686 0.228435 1.821807 -0.047132 0.045829 0.711607 0.492137
184 N14 digital_ok 100.00% 90.76% 100.00% 0.00% 17.976970 20.697703 67.667408 69.430676 12.412284 20.677995 2.596439 8.052170 0.109815 0.051147 0.045783
185 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 17.163212 -1.751950 67.575800 20.343364 13.377673 0.302988 2.370998 0.541332 0.038886 0.700824 0.462411
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 1.419904 1.742555 12.117260 15.637180 11.942205 1.936397 0.420338 1.654462 0.703840 0.718070 0.396650
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 4.418801 2.732181 9.515302 37.445630 43.271447 8.002011 0.328004 3.692237 0.701649 0.708237 0.403410
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 1.685596 2.503130 6.318160 3.765351 -0.012211 1.634232 0.361542 1.775625 0.692266 0.707824 0.409929
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 65.221964 20.393837 8.886816 70.066226 7.500535 20.939938 37.480459 10.153155 0.529843 0.037685 0.352610
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.247328 -0.025658 24.486348 0.786765 0.363569 -0.451234 17.007976 0.490324 0.675528 0.705830 0.423276
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 4.462738 10.732458 45.635609 58.990048 7.366493 19.189369 -0.670890 3.433536 0.668674 0.653487 0.422431
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 10.525572 1.615870 58.096360 35.955273 11.715658 5.269045 -2.031571 2.549477 0.628826 0.680217 0.443881
200 N18 RF_maintenance 100.00% 100.00% 24.49% 0.00% 20.587759 56.018401 26.927209 27.159488 13.180469 19.426848 3.965422 5.785410 0.048196 0.240130 0.153211
201 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.945903 9.308024 58.051625 55.365358 11.768052 16.831211 -1.840758 3.477164 0.664611 0.665944 0.387632
202 N18 digital_ok 100.00% 0.00% 0.00% 0.00% 2.345839 4.644842 27.694691 2.580522 1.062350 5.991236 1.248544 4.141918 0.692791 0.659637 0.393263
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 21.354472 23.205462 25.305732 27.003415 13.267963 20.607793 4.858877 10.579993 0.033748 0.042713 0.002627
219 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.338815 6.822101 58.324264 49.622694 12.025408 13.772186 -1.989909 3.119667 0.639697 0.675819 0.409499
220 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 6.073451 7.261997 48.449661 49.284663 8.038461 13.449518 0.660309 2.933000 0.689362 0.678647 0.398651
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 4.816038 1.657317 2.809839 21.941658 3.709792 1.928454 3.234338 2.291496 0.651887 0.678978 0.405175
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 7.437505 7.929732 50.461680 49.760662 9.217140 13.905565 -0.286569 3.130662 0.677547 0.672632 0.403044
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.368542 3.698899 1.557855 16.660785 3.487152 3.848671 0.167694 1.525388 0.635327 0.655872 0.411452
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.129932 0.336113 30.976791 30.011009 2.991797 6.273735 -0.745748 1.711672 0.686780 0.674255 0.405313
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.636495 5.290464 22.713409 45.025367 1.187179 11.362190 0.113932 3.814653 0.680796 0.669192 0.404350
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 0.457213 20.987583 0.984299 43.772031 0.537072 20.628234 21.664046 9.998331 0.695494 0.048749 0.459316
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.578889 1.605138 19.466825 22.559988 3.825555 4.179306 6.662846 4.552886 0.603308 0.588300 0.410546
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 3.069516 4.215706 24.246616 39.834850 2.723002 9.665881 4.206379 3.699447 0.592735 0.579894 0.405693
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 38.904698 3.530316 5.088390 39.052907 7.525362 8.863540 15.070321 3.099545 0.386558 0.571376 0.375406
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 2.359537 4.232657 31.381323 36.279975 3.642947 6.663694 6.381928 4.805811 0.592231 0.578178 0.397635
325 N09 dish_ok 100.00% 100.00% 100.00% 0.00% 1.939616 -0.832060 31.706445 16.226078 3.205473 2.279590 -1.027285 0.818713 0.081160 0.084122 0.032618
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 2.729043 -0.574373 11.573926 19.509227 8.428706 3.755001 3.008294 0.535709 0.582317 0.605346 0.418241
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 5.574959 2.552919 5.381128 14.981899 2.185118 2.423077 0.982979 0.502521 0.576730 0.615522 0.419916
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 7, 10, 15, 17, 18, 19, 20, 22, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 71, 72, 73, 74, 75, 77, 78, 81, 82, 84, 86, 87, 88, 89, 90, 91, 92, 93, 94, 98, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 124, 125, 126, 128, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 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: [4, 5, 8, 9, 16, 21, 38, 40, 41, 42, 65, 69, 70, 83, 85, 99, 100, 112, 116, 118, 127, 129, 130, 137, 157, 163, 168]

golden_ants: [5, 9, 16, 21, 38, 40, 41, 42, 65, 69, 70, 83, 85, 99, 100, 112, 116, 118, 127, 129, 130, 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_2459875.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.dev44+g3962204
3.1.5.dev171+gc8e6162
In [ ]: