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 = "2459874"
data_path = "/mnt/sn1/2459874"
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-21-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/2459874/zen.2459874.25249.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/2459874/zen.2459874.?????.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/2459874/zen.2459874.?????.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 2459874
Date 10-21-2022
LST Range 21.498 -- 7.519 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: 37
RF_ok: 9
digital_maintenance: 11
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 62 / 183 (33.9%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 158 / 183 (86.3%)
Redcal Done? ❌
Never Flagged Antennas 21 / 183 (11.5%)
A Priori Good Antennas Flagged 79 / 99 total a priori good antennas:
3, 7, 10, 15, 19, 20, 21, 29, 30, 37, 38, 45,
46, 51, 53, 54, 55, 56, 66, 67, 68, 71, 72,
73, 81, 84, 86, 88, 91, 93, 94, 98, 99, 101,
103, 105, 106, 107, 108, 109, 111, 117, 121,
122, 123, 124, 128, 129, 130, 140, 141, 142,
143, 144, 146, 147, 156, 158, 160, 161, 162,
163, 164, 165, 167, 169, 170, 176, 178, 179,
181, 183, 184, 185, 186, 187, 189, 190, 191
A Priori Bad Antennas Not Flagged 1 / 84 total a priori bad antennas:
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_2459874.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% 8.809751 -1.365833 -0.433820 -0.444541 0.651548 -0.327590 0.364568 4.433320 0.680448 0.670844 0.391447
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.644678 6.374418 1.198667 -0.568816 0.242645 -0.008175 1.813279 0.282601 0.687660 0.668810 0.383254
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.084590 0.388419 -0.772563 0.713573 0.663753 0.834693 0.036509 -1.161903 0.697363 0.674589 0.379041
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -2.250453 -1.845852 -0.365833 -0.174725 0.766121 1.276394 5.760517 16.594495 0.691534 0.674840 0.384286
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.701132 2.185363 0.381414 -0.364015 0.478701 0.211922 10.159575 1.644546 0.685054 0.658982 0.376502
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.210494 -2.436008 -0.236570 0.027933 -0.061799 -0.265934 0.167053 1.189769 0.687238 0.667522 0.389560
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 31.841784 -1.505700 8.471093 3.877162 10.994358 2.176974 3.963867 0.483163 0.655230 0.664168 0.394613
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 4.352367 1.269052 0.257089 -0.820306 -0.386391 -0.674703 8.641259 2.479650 0.696426 0.678125 0.383114
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.794415 1.340099 -0.130704 -0.702455 -0.162074 -0.225089 2.696452 2.617671 0.698271 0.676181 0.377005
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.489379 1.615547 -0.867592 -0.337352 0.321943 -0.386159 0.899923 0.861766 0.695775 0.683887 0.376873
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 16.588908 31.672208 0.293501 0.541952 6.668105 15.365068 31.330102 47.000782 0.669585 0.456450 0.417044
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.348986 -0.259374 -0.862867 2.179322 5.340206 165.535383 3.657210 9.900155 0.693947 0.675691 0.385594
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.945018 6.234303 -0.077325 10.102020 0.951376 3.276558 7.110810 -1.251692 0.697471 0.673411 0.381696
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 2.450192 1.589415 -0.575356 -0.763108 0.866391 0.368178 2.393198 7.904702 0.684586 0.667649 0.386828
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 63.516694 21.829431 2.474942 10.077104 8.312336 9.003464 6.660312 6.259613 0.452891 0.607084 0.332060
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 25.453848 27.610930 35.136938 35.910771 18.180258 27.492813 6.883288 4.748040 0.033514 0.038214 0.002996
28 N01 RF_maintenance 100.00% 0.00% 86.63% 0.00% 31.889465 59.286036 3.601180 2.477961 14.860643 28.743580 8.319074 33.695419 0.363805 0.164570 0.218813
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -2.315715 -0.382039 -0.639702 0.180953 -0.862420 -0.881235 0.223453 6.510277 0.700520 0.681033 0.371749
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.742884 -1.252705 -0.287057 -0.897628 4.509754 -0.585243 26.819840 0.603120 0.697659 0.687008 0.375632
31 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.077745 -0.335931 0.197907 0.219212 1.135821 2.272162 0.485088 1.091300 0.708420 0.686901 0.383075
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 45.692904 18.574674 3.803323 2.991325 12.732157 24.799334 27.577895 54.003876 0.587041 0.637880 0.298032
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.129648 34.091421 -0.355228 0.509851 1.193551 14.199253 2.830044 69.085842 0.690218 0.494891 0.454620
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 29.020477 6.281401 14.620284 10.592411 18.180354 2.570697 3.476638 -1.201534 0.043249 0.653470 0.495898
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.930717 2.495637 -0.695580 4.523471 16.912245 3.771479 2.383770 0.020542 0.616613 0.637041 0.397200
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 18.462764 17.548939 0.119145 0.036730 2.737811 3.479603 3.154507 1.713714 0.698197 0.676085 0.385401
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.069658 1.698593 -0.868810 0.185486 0.318467 0.144447 0.031100 17.331613 0.705417 0.683953 0.387558
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.712651 0.074682 -0.817695 -0.756607 1.369854 1.585725 14.232501 3.556452 0.708680 0.688726 0.387657
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 1.132941 -0.127520 -0.835505 -0.613323 0.477300 -0.376933 -0.449324 -0.734532 0.698678 0.680769 0.380027
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.447776 2.068675 1.122062 0.253791 -0.108437 -0.924568 -0.603802 -0.721527 0.702019 0.680341 0.369476
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.034217 2.052162 -0.863278 0.860070 -0.890764 -0.744561 -0.369778 0.810046 0.710374 0.692220 0.382182
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 23.884964 2.768957 34.737721 -0.732586 18.199789 -0.284389 4.809502 1.695795 0.041744 0.689560 0.474138
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 29.525917 3.387628 0.672598 -0.492180 18.266713 0.443557 30.551471 4.642318 0.658645 0.687280 0.372238
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -1.511269 4.992418 -0.849487 -0.400107 0.099066 2.700868 0.913988 24.511307 0.699520 0.672762 0.378284
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -0.860845 28.661503 -0.939154 36.063950 -0.147272 27.388034 1.001793 6.451343 0.693651 0.037881 0.500613
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 27.365041 5.487032 13.941955 7.676387 18.263340 3.933252 3.424493 4.848276 0.039302 0.655921 0.501201
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.891246 5.079701 15.143815 17.724990 3.827038 7.593977 -1.799542 -3.225726 0.669571 0.665600 0.398063
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.253943 3.216857 4.769484 15.249643 1.645468 6.226801 1.191163 -0.449840 0.640248 0.652764 0.400352
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 16.440725 5.807452 -0.062919 0.328873 5.023072 5.199378 18.353921 18.365559 0.682153 0.667998 0.367755
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 54.851467 2.609297 45.283891 -0.036171 17.689978 0.746435 19.683970 7.972587 0.040377 0.688341 0.453833
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 15.502713 14.765703 0.045085 -0.086437 2.892422 -0.905290 1.755486 0.841218 0.710954 0.691377 0.374269
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.454949 6.105249 -0.441020 -0.127681 1.009542 0.365820 5.274919 9.710816 0.713756 0.695545 0.381136
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 25.445186 29.134675 35.141150 36.768009 18.227099 27.442775 5.544389 2.891745 0.046406 0.045186 0.001433
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 3.363404 30.697133 0.261626 36.429729 6.289628 27.360641 1.490083 6.584966 0.699360 0.035370 0.485210
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 2.795534 2.259967 -0.106436 -0.234588 1.403532 1.212856 0.357638 4.994743 0.699524 0.688873 0.365266
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 72.028951 0.167398 14.197657 -0.510522 8.918101 1.497947 4.024960 1.198613 0.533267 0.691059 0.371916
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 24.525630 28.588807 34.960322 36.589881 18.317284 27.594968 7.047386 5.863419 0.037665 0.034758 0.001793
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 31.508687 9.515269 1.121121 1.957468 11.106455 1.521864 70.754013 11.295571 0.657628 0.676616 0.375841
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 26.516227 28.118103 35.066650 36.511521 18.245884 27.521149 5.178912 6.635889 0.027349 0.027451 0.001455
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 9.041667 7.891554 1.989279 -0.387388 1.907634 5.578396 0.102167 5.054610 0.649707 0.630046 0.373283
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.081241 5.385920 12.169011 16.777477 3.265725 9.055436 0.129775 -2.578890 0.671208 0.669144 0.387542
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 14.426949 29.940855 29.855156 15.085859 16.318642 27.346189 -5.521346 6.646528 0.595873 0.063633 0.491023
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 14.198058 15.044884 28.914651 30.167485 15.090112 24.928325 -5.246306 -6.404143 0.622586 0.606942 0.390013
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 1.627143 0.778659 0.172293 0.795977 1.015527 1.306833 -0.397279 -0.473668 0.695430 0.675913 0.385271
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.043610 3.414745 6.922684 4.599914 1.140828 0.282379 0.350664 3.404811 0.699388 0.684935 0.379827
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.965271 -0.217341 3.827412 1.954553 0.916213 -0.174867 1.824846 3.060943 0.704056 0.687832 0.372485
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 4.729833 60.247545 0.423461 48.767990 0.388497 26.495868 0.632278 19.618224 0.703678 0.032056 0.430697
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.518008 -1.527335 -0.408508 -0.549806 1.063398 2.709846 0.073930 0.050887 0.706318 0.693315 0.372002
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 1.108800 -0.877479 0.605940 0.754346 -0.577799 -1.030239 -0.444930 -0.740972 0.710300 0.697598 0.376037
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 15.519001 -0.179196 1.271528 1.133044 0.692646 1.371271 0.698135 1.342055 0.715224 0.694302 0.374998
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 8.365911 -0.497943 0.571146 1.005016 4.192565 0.397462 1.944000 -0.251748 0.692342 0.684867 0.370612
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 23.726932 26.570088 34.530138 35.462949 18.089874 27.428009 6.998560 2.659738 0.027099 0.027155 0.001279
74 N05 digital_maintenance 100.00% 100.00% 8.00% 0.00% 25.237238 24.094421 34.107789 33.645757 18.543310 25.346290 5.305143 40.726568 0.032391 0.290742 0.180062
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 16.804186 29.310225 6.255818 36.880942 4.338246 27.635482 13.566033 6.716314 0.672586 0.048248 0.492834
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 50.056485 52.591701 12.662516 10.199426 7.140800 14.482912 8.948847 0.195482 0.561752 0.511539 0.202686
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 14.641217 14.661278 29.164500 29.868210 16.261097 24.439895 -5.067914 -6.014579 0.476210 0.626730 0.358942
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 0.307260 -0.975764 -0.365988 8.284307 1.141994 8.479701 0.176621 0.803969 0.673189 0.646857 0.377760
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.573599 0.311355 -0.437372 4.543854 0.424195 -0.137704 -0.072535 -0.500739 0.688175 0.669273 0.377187
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.862714 -0.708060 -0.524573 -0.310087 -0.923847 -0.685228 -0.651521 1.073913 0.698760 0.683806 0.369607
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 13.851569 53.725025 4.319702 47.146807 -0.500348 26.527306 -0.064163 11.091303 0.703634 0.041500 0.538723
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.640922 0.402329 1.664809 1.700862 -0.715417 -0.168167 -0.626838 -0.940048 0.704855 0.684420 0.372345
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 2.477600 11.622373 5.308121 2.579825 4.185446 6.524609 1.553736 24.488062 0.693000 0.653611 0.367227
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 40.191596 16.275555 3.679979 0.175344 31.335691 4.426205 7.196010 1.399978 0.610894 0.701448 0.368257
88 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 1.676857 1.316600 -0.027933 0.418607 -0.620749 0.705642 -0.210788 -0.790037 0.061900 0.070750 0.007735
89 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
90 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.942332 0.213856 -0.544717 0.807393 -0.747144 0.515645 1.162260 6.445333 0.060792 0.070279 0.006756
91 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 0.549547 -0.405802 -0.646526 -0.585568 -0.134464 -0.378317 0.261921 -0.782324 0.070739 0.072916 0.014834
92 N10 RF_maintenance 100.00% 0.00% 17.88% 0.00% 83.861729 94.649656 3.897358 4.773712 14.838162 22.749728 1.678925 8.225488 0.287885 0.239830 0.092387
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 5.349289 0.759136 5.818784 -0.707935 4.358188 -0.441858 11.142724 -0.608999 0.687597 0.683698 0.385030
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -1.056577 -1.800289 -0.369933 -0.165573 1.475451 4.768184 1.771313 3.876833 0.692372 0.673658 0.388791
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 3.194835 18.036132 -0.390389 0.054322 1.078041 3.447251 0.709362 3.941211 0.673617 0.649498 0.372289
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 5.275546 -1.372536 -0.019649 0.021332 0.942137 1.269491 4.193720 -0.548662 0.676787 0.669112 0.374959
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.108642 -1.544361 0.964655 -0.959716 1.785343 -0.863608 0.595711 0.079468 0.691815 0.675165 0.368283
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 15.829194 19.776850 1.217425 0.939086 -0.004867 -0.786566 0.399072 -0.498078 0.713061 0.692180 0.365721
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 14.103584 30.342986 28.832805 36.696780 32.808741 27.537109 2.017294 10.420306 0.542315 0.041033 0.421700
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 52.483415 54.719670 40.391296 41.657054 18.554475 27.336732 20.396074 17.960855 0.027444 0.028300 0.001970
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 14.905043 124.380926 2.796186 33.770364 0.944277 2.473277 0.393319 0.577260 0.709876 0.621822 0.409438
105 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 0.937790 -0.639200 -0.816286 0.261745 -0.297790 0.106420 0.239311 -1.036205 0.064067 0.072162 0.010505
106 N09 digital_ok 0.00% 100.00% 100.00% 0.00% -0.099829 1.541243 2.496772 1.269061 1.482419 0.182503 0.771854 -0.597437 0.058220 0.063218 0.007218
107 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 5.772202 1.040585 0.332474 2.101885 3.158812 1.121744 7.054590 7.483741 0.047577 0.054794 0.003149
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 23.990476 6.049348 34.294076 -0.016721 16.507812 -0.354020 4.706479 1.648910 0.051550 0.062950 0.035225
109 N10 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
110 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
111 N10 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.180389 -0.451877 -0.908168 0.293568 0.795689 -0.130472 0.978992 -0.697461 0.685606 0.676502 0.394086
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.824495 1.753666 2.754974 0.730218 1.503836 2.295398 -0.166678 -0.756889 0.667519 0.657786 0.379696
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 27.496983 31.817148 35.276841 37.697335 18.355711 27.501217 4.356109 8.600461 0.027475 0.032169 0.004118
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.224238 0.955520 -0.528679 0.385065 2.395296 0.061799 2.107763 1.867415 0.691714 0.679559 0.370823
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.142909 6.060866 4.499664 11.390150 -0.451027 5.960669 0.012014 1.021015 0.704639 0.646713 0.379102
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 5.976273 53.046031 -0.562981 46.971944 0.359804 26.883258 1.139131 18.335171 0.708254 0.035591 0.549137
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 6.323365 11.388501 -0.068626 0.028298 0.752644 0.132063 65.786466 32.214357 0.716826 0.693735 0.372876
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 17.574052 15.604966 0.054629 0.409384 5.545929 -1.153182 0.210689 -0.700660 0.718255 0.695604 0.375517
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 13.440780 19.793135 0.534326 0.863160 -0.787142 0.263113 0.358662 0.690853 0.712678 0.695609 0.379817
124 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
125 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 4.178646 4.704293 -0.369850 0.118131 -0.584810 0.420206 0.364909 0.706230 0.059577 0.065166 0.004939
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 69.042964 9.755561 2.782747 1.502501 8.317462 2.092084 2.028667 3.646833 0.073637 0.064353 0.014120
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.153673 -0.034217 -0.833138 -0.722947 0.063051 0.783642 -0.008020 1.401097 0.700787 0.690041 0.391316
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.951672 1.327956 3.335389 1.127143 0.292694 0.191092 0.155278 -0.212822 0.696112 0.685065 0.382810
129 N10 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
130 N10 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -2.592942 28.456357 -0.589037 36.690214 2.410426 27.626278 0.779373 3.528066 0.663615 0.039719 0.429076
136 N12 digital_maintenance 100.00% 0.00% 0.00% 0.00% 7.511234 2.406937 -0.199735 0.497565 0.125315 0.541470 0.579062 -0.072855 0.658233 0.654898 0.375922
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.860331 -1.912271 -0.178939 -0.666586 1.936823 0.364184 4.172457 0.693967 0.676459 0.664400 0.375494
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.898882 -0.587539 0.159185 1.052628 -0.849509 -1.315706 10.238677 -0.434883 0.695132 0.680189 0.378869
139 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.743167 5.427929 26.537374 22.434743 12.316945 13.265743 -4.909194 -4.143512 0.688482 0.678901 0.373914
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 8.503641 30.188423 24.744050 36.200249 11.296757 27.388003 -1.776354 5.845981 0.692365 0.052833 0.461757
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -2.390512 10.876252 1.141432 26.810997 0.457882 19.956922 0.408153 -5.416488 0.705395 0.672291 0.369954
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 2.896498 28.282500 0.084379 36.476240 3.852063 27.594838 1.900158 4.586978 0.698838 0.048488 0.475009
143 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.918901 -0.959943 -0.379149 7.635709 0.214884 0.962674 0.123206 0.166972 0.699933 0.676181 0.391451
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% -2.431548 6.665468 -0.167261 22.891403 6.185049 31.760531 0.996059 3.186097 0.695783 0.603442 0.406330
146 N14 digital_ok 100.00% 0.00% 0.00% 100.00% 6.874515 10.232680 20.682236 24.971760 5.383243 22.348143 -2.591554 -4.859304 0.294743 0.290375 -0.289496
147 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 42.184516 43.327402 8.068255 8.166150 16.608021 21.476125 3.423841 1.169005 0.340667 0.344567 0.152716
148 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.670025 -0.685415 10.487873 4.028216 0.722068 -0.840452 0.522098 -0.280571 0.679138 0.685076 0.394412
149 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.424392 3.320151 6.677224 19.426531 -0.407897 10.023338 -0.410847 -2.842674 0.695236 0.686035 0.396784
150 N15 RF_maintenance 100.00% 100.00% 0.97% 0.00% 27.059386 4.290874 35.100635 20.564154 18.203232 10.632496 6.061898 -2.651313 0.049371 0.307096 0.063125
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 60.875758 3.783974 10.158881 -0.680014 7.596643 5.714236 1.295033 -0.226395 0.526002 0.617808 0.381216
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 4.817257 3.778893 3.916357 7.660680 1.986858 2.523925 24.023958 -0.954059 0.628362 0.640620 0.410445
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 26.469783 2.787466 13.742515 7.430590 18.291488 4.024300 3.471244 -0.678045 0.040437 0.633717 0.495884
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.332651 0.319439 13.171296 12.480016 4.285347 3.936018 -1.084490 -0.841281 0.634446 0.633890 0.412882
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 24.695515 -0.808936 33.876574 -0.577463 18.090627 5.986167 2.872894 4.501998 0.065259 0.657589 0.455497
156 N12 digital_ok 100.00% 1.24% 0.00% 0.00% 20.612906 -0.111516 33.586959 0.638429 16.218833 0.363314 3.842534 0.150937 0.304232 0.666922 0.454718
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -0.044916 -0.315489 -0.342727 -0.398489 0.246032 0.505046 0.008020 -0.149387 0.683104 0.671349 0.378815
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.761851 -1.049433 0.520802 1.183352 0.623825 -0.163233 9.795048 51.534396 0.696004 0.682095 0.383274
159 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.173398 50.970943 18.769595 15.701239 5.695385 15.143364 -2.245827 -1.919733 0.690760 0.533194 0.359507
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.725800 -0.346305 0.654570 2.741038 -0.477372 0.182700 2.650172 2.090154 0.702435 0.684700 0.368257
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.558311 61.586483 -0.436399 4.236007 -0.109400 8.717268 0.379119 2.546880 0.702476 0.557931 0.344063
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 5.271504 3.632368 5.115869 15.525614 0.976582 6.254011 0.794595 2.178074 0.704171 0.656217 0.383439
163 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
164 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 41.678826 0.484248 25.895891 1.459569 11.984330 -1.168877 0.768166 -0.600489 0.417250 0.686174 0.415235
166 N14 RF_maintenance 100.00% 0.00% 87.92% 0.00% 65.327318 25.605123 5.977577 34.538194 6.816433 27.339570 2.216562 1.462692 0.548182 0.159864 0.355324
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -1.298519 -1.811056 7.985489 2.255746 0.846362 0.986358 -0.491279 4.638582 0.704997 0.683898 0.396944
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -1.978818 -0.337804 -0.975661 0.801333 -0.255410 -1.079773 -0.009490 1.115051 0.696502 0.684914 0.395413
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 4.093381 37.283313 18.093754 21.109359 4.586643 17.977901 -2.775722 -4.051396 0.698144 0.548427 0.393192
170 N15 digital_ok 100.00% 100.00% 0.00% 0.00% 27.010506 -1.490401 35.706787 9.176410 18.392431 29.062253 3.324900 4.955626 0.041775 0.688074 0.495460
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 3.180088 7.154783 4.183762 0.259988 0.871568 6.744663 0.616030 0.281688 0.639797 0.597508 0.389574
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 29.992412 30.263547 12.361091 13.802902 18.061477 27.358204 7.748482 14.865134 0.035846 0.040368 0.004626
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.233536 0.106617 -0.769292 -0.861573 -0.005392 0.782835 0.324060 17.389756 0.668031 0.653245 0.392427
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -1.069889 -0.898515 0.148815 1.897483 -0.553108 3.142819 -0.108763 2.699322 0.680291 0.667183 0.392789
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 6.125152 -0.764760 0.095047 -0.114236 -0.072901 0.191360 6.188329 3.410339 0.678274 0.668680 0.385681
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 27.451901 30.976442 35.724901 38.279822 18.466486 27.676872 2.853232 3.556013 0.052126 0.055221 0.006108
180 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 26.096463 29.889995 35.405084 36.942670 18.371861 27.605095 2.514647 5.691069 0.050011 0.052428 0.004617
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.066898 -1.317881 0.312970 -0.926821 0.007462 0.800368 0.488464 9.555297 0.709995 0.686133 0.378111
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.702483 9.181165 19.794400 24.753064 3.654155 17.108978 12.591633 -2.001646 0.652549 0.679066 0.392259
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 26.024772 -0.488965 32.611171 2.320468 18.182534 -0.910698 1.305955 -0.071346 0.045662 0.680671 0.472358
184 N14 digital_ok 100.00% 95.17% 100.00% 0.00% 25.690454 29.154647 35.321622 36.495897 17.752389 27.421498 2.940025 3.040082 0.096554 0.049486 0.035853
185 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 24.415946 -1.867257 35.203912 10.459609 18.245248 -0.333664 2.285125 -0.335057 0.038482 0.664811 0.442135
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 2.152704 2.799277 7.465991 7.401433 6.837056 1.210848 1.708398 1.210928 0.688724 0.688533 0.392947
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 5.954167 4.212996 1.021584 19.101095 38.884107 11.349649 2.542087 0.936906 0.685557 0.680177 0.396122
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.634757 3.637813 2.749775 0.619787 -0.166846 9.292928 0.802066 3.128110 0.677008 0.673959 0.398111
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 89.656253 28.673532 4.152658 36.811075 9.863985 27.703523 20.079920 6.984357 0.507279 0.036462 0.333689
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.426859 0.866822 12.362070 -0.416576 2.371867 -0.498776 26.024550 1.022747 0.657806 0.669452 0.413997
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 4.286596 14.797297 20.904840 29.950104 20.018913 24.558866 -0.159170 -6.539316 0.660276 0.628101 0.410707
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 14.464054 2.140694 29.737948 16.621577 15.644978 9.444759 -6.048719 0.102853 0.621642 0.647498 0.423924
200 N18 RF_maintenance 100.00% 100.00% 32.98% 0.00% 29.056294 77.243898 13.852837 13.727384 18.066010 24.459061 4.937253 4.810327 0.047970 0.224280 0.138124
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 15.325938 13.168848 30.011967 28.353746 15.870674 22.657202 -5.861520 -5.776645 0.662228 0.645692 0.376294
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 4.026595 6.973323 14.205560 0.804627 2.770252 6.052008 2.258615 6.661194 0.686474 0.628937 0.388099
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 30.125749 32.485419 12.986376 14.180876 18.160846 27.390313 6.470003 7.917536 0.034965 0.042667 0.001915
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 14.831730 9.609611 30.411356 25.242947 16.360240 17.817369 -6.105741 -4.932942 0.636212 0.656367 0.396420
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 8.779508 10.431295 25.018749 25.156119 10.889813 17.730169 -1.647189 -5.170381 0.686011 0.659444 0.390585
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 7.073464 2.753369 1.216850 10.941240 4.916108 3.248869 5.968935 0.453496 0.646051 0.655491 0.393344
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 10.600133 11.203991 26.125317 25.482179 12.480065 18.147898 -1.043218 -5.107335 0.672094 0.654158 0.392709
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 7.898943 5.256603 0.554631 8.191408 4.132207 5.349145 0.539234 -1.052071 0.632625 0.634426 0.396828
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 3.054991 1.439405 17.605474 16.949048 5.684939 9.553066 -2.267627 -3.086869 0.682061 0.653145 0.396106
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.895393 8.581519 13.089100 23.937892 8.076522 17.240303 1.281068 -3.549427 0.674102 0.648085 0.393669
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 1.703825 29.834494 0.222137 23.005599 0.790623 27.418783 20.441798 6.432002 0.683990 0.049196 0.472495
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 2.495892 2.431729 10.072693 11.397689 4.019097 5.056414 8.253150 5.963234 0.602249 0.578076 0.401137
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 4.581356 6.332420 12.321835 20.183089 3.176015 11.789776 -0.012617 -3.197709 0.592526 0.572717 0.396335
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 55.283813 4.133272 1.965595 18.275995 11.911841 9.474907 12.133469 -0.149117 0.383459 0.565644 0.365618
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 3.996465 6.284134 16.018343 18.302812 4.939277 9.255917 0.009902 -2.623368 0.592209 0.566737 0.386513
325 N09 dish_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 5.071636 -0.004950 6.944836 11.516427 12.284702 6.501110 5.391045 -0.439947 0.570638 0.574544 0.394333
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 7.873814 3.804892 2.392434 7.123342 4.728315 3.599046 3.944882 0.215768 0.555006 0.559928 0.387248
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 4, 7, 8, 10, 15, 18, 19, 20, 21, 22, 27, 28, 29, 30, 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, 88, 89, 90, 91, 92, 93, 94, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 124, 125, 126, 128, 129, 130, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 169, 170, 171, 173, 176, 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: [5, 9, 16, 17, 31, 40, 41, 42, 65, 69, 70, 83, 85, 100, 112, 116, 118, 127, 157, 168, 177]

golden_ants: [5, 9, 16, 17, 31, 40, 41, 42, 65, 69, 70, 83, 85, 100, 112, 116, 118, 127, 157, 177]
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_2459874.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 [ ]: