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 = "2459871"
data_path = "/mnt/sn1/2459871"
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-18-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/2459871/zen.2459871.25287.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/2459871/zen.2459871.?????.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/2459871/zen.2459871.?????.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 2459871
Date 10-18-2022
LST Range 21.310 -- 7.331 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
Total Number of Antennas 180
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 35
RF_ok: 9
digital_maintenance: 11
digital_ok: 98
not_connected: 23
Commanded Signal Source None
Antennas in Commanded State (reported) 0 / 180 (0.0%)
Antennas in Commanded State (observed) 0 / 180 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 16
Nodes Registering 0s
Nodes Not Correlating N09
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 70 / 180 (38.9%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 140 / 180 (77.8%)
Redcal Done? ❌
Never Flagged Antennas 31 / 180 (17.2%)
A Priori Good Antennas Flagged 71 / 98 total a priori good antennas:
7, 10, 15, 17, 19, 20, 30, 37, 38, 45, 46,
51, 54, 55, 56, 66, 67, 68, 71, 72, 73, 81,
84, 86, 88, 91, 93, 94, 98, 101, 103, 105,
106, 107, 108, 109, 111, 117, 121, 122, 123,
124, 128, 140, 141, 142, 143, 144, 147, 156,
158, 160, 161, 162, 163, 164, 165, 167, 169,
170, 176, 177, 179, 183, 184, 185, 186, 187,
189, 190, 191
A Priori Bad Antennas Not Flagged 4 / 82 total a priori bad antennas:
4, 136, 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_2459871.csv

Build DataFrame¶

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

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

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

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

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

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

Table 2: RTP Per-Antenna Metrics Summary Table¶

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

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

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

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

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

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

In [21]:
HTML(table.render())
Out[21]:
Ant Node A Priori Status Auto Metrics Flags Dead Fraction in Ant Metrics (Jee) Dead Fraction in Ant Metrics (Jnn) Crossed Fraction in Ant Metrics ee Shape Modified Z-Score nn Shape Modified Z-Score ee Power Modified Z-Score nn Power Modified Z-Score ee Temporal Variability Modified Z-Score nn Temporal Variability Modified Z-Score ee Temporal Discontinuties Modified Z-Score nn Temporal Discontinuties Modified Z-Score Average Dead Ant Metric (Jee) Average Dead Ant Metric (Jnn) Average Crossed Ant Metric
3 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 3.820160 -0.795809 -0.233951 -0.674190 0.602250 0.242084 1.087444 2.344773 0.687963 0.672697 0.394002
4 N01 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.872088 1.822069 2.720698 -0.130765 1.094691 1.638037 3.117297 0.744612 0.694180 0.671265 0.385490
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.374369 0.169193 -0.795008 2.182318 0.246397 0.097191 1.787927 -0.723820 0.705135 0.675413 0.381516
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.617027 -1.321926 0.186046 0.908945 0.009117 0.764334 2.273905 7.310182 0.700006 0.676621 0.386372
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.410089 0.670186 1.350223 0.565799 0.767000 -0.059878 4.490990 0.323350 0.693640 0.660656 0.378946
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% -0.016765 -1.897502 0.314179 0.142640 0.172331 -0.400532 -0.181036 0.291593 0.695513 0.668620 0.392215
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 21.845715 -1.157806 13.639994 7.965482 8.004599 1.695981 2.174557 -0.144499 0.666233 0.665554 0.395388
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 1.489911 0.346353 1.116596 -0.289029 -0.510116 -0.512257 5.282584 2.992167 0.704200 0.680188 0.386248
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.794629 0.013554 -0.020984 -0.822974 -0.591755 -0.042527 3.075640 2.593967 0.706681 0.678930 0.378359
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.408234 0.657188 -0.723598 0.866283 0.680185 0.372472 5.600416 2.014888 0.704152 0.686291 0.378303
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 6.767998 14.257500 1.511961 1.330596 4.982375 13.115970 17.320573 24.062831 0.679476 0.460448 0.421247
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.231986 -0.696893 -0.786558 13.086575 1.124026 117.232285 1.376508 4.883947 0.702177 0.670853 0.387417
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.287855 2.972690 0.615642 19.192461 -0.358450 2.398440 0.651307 -0.929239 0.707480 0.672878 0.385321
21 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.414744 0.376277 -0.661410 -0.813253 0.999916 0.645198 0.086942 2.611501 0.693635 0.668485 0.389480
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 35.369225 13.770655 5.602033 20.468500 11.567953 7.142921 3.539827 1.939891 0.474012 0.619722 0.324059
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 13.352441 14.943227 62.806353 63.562244 18.112785 26.027818 2.654846 1.437777 0.032316 0.036584 0.002671
28 N01 RF_maintenance 100.00% 0.00% 87.27% 0.00% 16.163631 33.245345 7.665703 5.160892 12.956225 23.338076 3.261422 14.518868 0.364932 0.162085 0.218737
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.231575 -0.906908 -0.296839 -0.069609 -0.654754 -0.672382 -0.392714 3.170758 0.708051 0.682254 0.372580
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 0.132723 -1.202690 0.987720 -0.858481 2.257653 -1.256008 11.933848 -0.023279 0.702515 0.687497 0.374556
31 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.279236 -0.446063 0.898779 0.348120 0.868003 3.168017 1.160914 3.548459 0.717004 0.687680 0.384695
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.122214 30.154478 3.067875 5.406301 7.271038 9.209941 2.503555 26.199168 0.654071 0.603134 0.312854
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.506320 17.056849 0.079818 1.421259 0.223739 9.528695 2.470094 25.244767 0.699206 0.494388 0.457854
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 15.351897 3.311574 26.258991 21.341790 18.061014 2.373579 1.076481 -1.224385 0.041014 0.655541 0.482804
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.548496 1.343420 3.038207 13.473485 12.158494 5.033901 0.547087 0.033591 0.627522 0.637089 0.398068
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.018715 9.933727 1.068991 0.793344 1.919293 2.408856 0.116858 -0.033492 0.708543 0.679993 0.388557
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.501717 0.840806 -0.739415 0.330918 -0.405350 0.998996 -0.342750 4.446482 0.712915 0.686936 0.389429
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.163585 0.198161 -0.850154 -0.780157 0.316425 2.213030 4.595118 1.221580 0.715358 0.690588 0.388816
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.147381 0.186048 -0.840223 -0.830310 0.230023 -1.145019 -0.564637 -0.902041 0.706595 0.682082 0.384373
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.517321 0.412106 2.240271 1.950047 -0.361907 -1.367654 -0.334379 -0.017935 0.709448 0.681877 0.371493
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.287083 1.050832 -0.744624 1.547447 -0.720072 -0.802266 0.100229 -0.986663 0.716828 0.693821 0.385260
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 12.497693 0.782688 62.098585 -0.509328 18.144250 -0.400681 1.771571 0.846852 0.039320 0.691633 0.459151
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 1.188914 2.415319 2.162079 4.267177 1.077239 1.166910 7.410649 9.711910 0.697904 0.685516 0.366478
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -0.582205 2.370803 -0.866671 -0.131113 -0.160818 2.204210 -0.037614 5.476971 0.708604 0.673589 0.380821
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -0.939470 15.527562 -0.962847 63.810777 -0.368591 25.976451 0.552397 2.357166 0.702905 0.036091 0.490061
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 14.406012 3.318974 25.066140 14.831560 18.119974 4.074885 1.036134 1.533930 0.037990 0.654182 0.483483
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.322833 2.523048 27.457858 33.277326 5.144007 6.998424 1.277305 -1.634233 0.678245 0.665975 0.400315
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.512998 1.537163 9.026206 28.573239 3.200257 5.350755 0.494648 -0.682510 0.647138 0.652113 0.402177
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.354451 29.434523 -0.535622 4.775198 1.914122 23.080650 7.070534 30.814202 0.702290 0.593362 0.360256
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 29.261621 1.461172 80.810109 0.588128 17.653915 1.033172 8.774721 7.301868 0.038789 0.689944 0.438029
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.961577 8.192456 1.087811 0.493008 3.140827 -0.363769 0.907605 -0.098269 0.717728 0.693672 0.375671
53 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.449027 3.265315 -0.049591 0.911299 -0.105625 0.059830 2.782279 3.171998 0.719162 0.696641 0.382278
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 13.341216 15.764354 62.842434 65.121530 18.155251 26.008758 2.113742 0.726049 0.044120 0.043940 0.001231
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 2.263489 16.619721 -0.075535 64.511115 5.143647 25.976680 5.873593 3.056661 0.704864 0.034321 0.473674
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 0.145038 0.366760 0.396864 -0.384431 0.279932 0.854966 0.269792 6.954805 0.708273 0.692457 0.368190
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 38.590554 -0.882381 30.126226 3.018835 10.988053 1.835409 1.240114 0.238469 0.538149 0.691384 0.373822
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 12.883596 15.575057 62.520505 64.791737 18.224086 26.106035 2.653746 1.938533 0.036160 0.033605 0.001769
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 14.878328 15.728108 5.891466 1.792797 8.165827 7.799371 12.211704 34.020454 0.669148 0.645004 0.357019
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 13.955354 15.219887 62.693525 64.631933 18.133591 26.050610 1.895050 2.426572 0.027191 0.026893 0.001306
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 4.220185 4.152827 5.297107 0.351659 2.195115 6.482708 -0.456682 1.717534 0.661816 0.629683 0.376631
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 1.573706 2.548446 22.101307 31.082595 3.467876 8.046371 0.685447 -1.584153 0.681285 0.669212 0.391095
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 10.694646 15.737866 22.102949 26.572638 5.794818 25.953480 0.013847 2.241722 0.627594 0.041824 0.483443
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.321783 1.339679 13.881600 25.777342 2.990818 6.087421 0.368512 -1.252904 0.633670 0.632786 0.401411
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.359060 0.359428 0.800240 1.728979 1.371101 1.208581 -0.191954 -0.678873 0.703137 0.679210 0.387333
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.185410 1.843895 13.616362 8.301648 0.565858 0.520583 -0.065796 0.828216 0.705869 0.688037 0.381464
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -1.148552 -0.557226 11.672572 7.746674 -0.130940 0.505792 0.532010 1.587863 0.709295 0.689360 0.372983
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 2.537714 32.868968 1.534548 86.432930 0.528114 25.086338 4.014034 8.603716 0.709318 0.030348 0.421608
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.270230 -0.945457 -0.240985 -0.343199 1.398432 3.131063 -0.248707 -0.675798 0.711090 0.693607 0.374043
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.816105 -0.543472 1.191853 2.379555 -0.259843 -0.636927 -0.229683 -0.539697 0.714252 0.697534 0.378314
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 8.658639 -0.290263 3.065064 2.016078 0.112384 1.199437 2.612836 0.221270 0.720554 0.694206 0.378908
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 3.753046 -0.261367 1.862464 1.434741 1.837636 -0.150283 5.811711 -0.333841 0.698650 0.686520 0.374472
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 12.412259 14.367358 61.696005 62.740455 18.104951 26.015506 2.827022 0.566906 0.026976 0.026882 0.001272
74 N05 digital_maintenance 100.00% 100.00% 1.66% 0.00% 13.825591 13.276513 64.635692 62.812003 18.298906 23.157684 2.256462 18.365481 0.030495 0.298856 0.175733
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 8.523065 15.874706 17.321110 65.328505 2.920174 26.106220 7.665922 2.350122 0.675292 0.046207 0.468011
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 28.858361 30.307111 22.841644 19.229459 7.081976 14.741149 9.436467 4.162465 0.566166 0.502073 0.202842
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 40.236402 0.514694 16.973853 22.787346 10.516640 3.963673 0.104362 0.988490 0.494510 0.647612 0.369607
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -0.190519 -0.731101 -0.305932 10.647954 0.914334 11.948662 -0.181060 -0.573152 0.683023 0.654880 0.381595
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.371255 0.040091 0.086970 8.280197 0.300847 0.169835 -0.373814 -0.704670 0.694703 0.671865 0.380214
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.653683 -0.627645 -0.443151 0.750539 -0.728897 0.038518 -0.577270 -0.182006 0.704579 0.685270 0.371315
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 7.952585 29.296600 8.651888 83.639320 -0.586065 25.108166 -0.275490 4.525525 0.708264 0.038424 0.520524
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.279915 -0.168218 3.597892 3.500022 -0.840811 -0.598365 -0.579719 -0.940408 0.709222 0.685546 0.375431
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.901606 5.328448 9.032240 5.266274 3.042460 0.628984 0.306495 16.025928 0.697170 0.653803 0.372289
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.499514 8.841495 0.947899 0.661468 24.682714 3.241889 0.548966 0.712514 0.693420 0.700015 0.374767
88 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 0.343276 0.784152 0.911474 0.418927 -0.103209 -0.213677 -0.112379 -0.753774 0.078502 0.082405 0.011643
89 N09 RF_maintenance 0.00% 100.00% 100.00% 0.00% 1.015682 -0.212611 -0.693333 0.430241 -0.814042 -0.760448 -0.553827 -0.863676 0.072802 0.075659 0.008108
90 N09 RF_maintenance 0.00% 100.00% 100.00% 0.00% -0.170296 -0.826110 0.210702 1.581350 -0.501849 -1.289774 0.062256 3.348711 0.078692 0.084438 0.011211
91 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 0.047128 -0.826176 -0.439961 0.245229 0.135885 -1.175147 2.643777 0.095457 0.093271 0.089672 0.022665
92 N10 RF_maintenance 100.00% 0.00% 19.44% 0.00% 46.314905 51.879190 7.617725 9.068815 13.383889 18.377211 0.118950 2.636940 0.295288 0.237217 0.092110
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 2.537120 0.045715 10.413038 -0.282498 3.095718 -0.960444 3.254146 -0.685189 0.698926 0.683087 0.387288
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.613590 -1.579602 -0.580059 -0.600113 1.278848 4.991780 2.600777 0.954545 0.704482 0.676753 0.392523
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 2.123131 9.654161 0.088822 1.068280 0.428024 2.790363 0.691719 1.591935 0.679790 0.652340 0.374768
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 1.229553 -1.147776 1.022495 -0.054454 0.620365 0.666150 1.597080 -0.897474 0.682732 0.669896 0.376703
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.054066 -1.386042 1.797382 -0.827492 0.418334 -1.110275 0.068920 -0.722311 0.697497 0.677299 0.371309
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 9.078043 10.853078 2.661945 1.959100 -0.378439 -0.787479 -0.174292 -0.788497 0.717437 0.692390 0.367041
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 6.847695 16.406635 51.677554 64.999961 19.673553 26.106548 0.640486 3.993887 0.562912 0.039204 0.424281
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 28.171390 29.969720 72.317559 73.971425 18.173215 25.782575 8.635240 7.529296 0.026572 0.027786 0.002063
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.901131 68.751891 5.295972 59.222646 -0.072731 0.446489 -0.211601 -0.466112 0.713274 0.624162 0.415150
105 N09 digital_ok 0.00% 100.00% 100.00% 0.00% -0.679387 -0.407262 -0.737503 0.520585 -0.259007 -0.580181 -0.197372 -0.835509 0.080384 0.085121 0.012859
106 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 0.210778 0.815880 4.742720 2.282947 0.810803 -0.655445 -0.177059 -0.120898 0.072729 0.073552 0.008055
107 N09 digital_ok 0.00% 100.00% 100.00% 0.00% 1.168238 -0.822549 0.617468 0.595834 0.390913 -0.828511 1.476711 1.787076 0.057278 0.065968 0.004314
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 8.971406 3.356395 56.386173 1.034464 11.144535 0.344606 0.935487 0.363012 0.084533 0.079147 0.039591
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.643862 15.436156 1.734948 62.791920 -0.942051 25.972618 0.245666 1.451542 0.708099 0.034107 0.431790
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.490092 31.008421 -0.333544 84.550514 -0.749418 25.169787 0.188349 3.899748 0.718508 0.031425 0.434472
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.185598 15.269821 1.570689 63.482912 -0.299728 25.972355 6.201315 1.963405 0.705221 0.034424 0.431402
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.669595 -0.700252 -0.967306 1.640161 -0.115367 -0.855757 0.535766 -0.741761 0.695468 0.675639 0.396902
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.140412 0.419102 1.600806 -0.615961 3.128582 1.179072 0.107325 0.259734 0.677779 0.658660 0.380674
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 14.498911 17.202211 63.124378 66.786059 18.186686 25.999439 1.568660 3.127767 0.027671 0.030908 0.003110
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.759911 0.492332 -0.258964 0.662137 0.942806 0.069924 2.809109 3.148872 0.698767 0.680531 0.373372
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.713369 3.808964 8.555706 20.019115 -0.829154 2.911111 0.023622 0.557922 0.709633 0.642884 0.387845
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 2.682711 28.854257 -0.441076 83.292491 0.826504 25.488341 1.954935 7.942903 0.710450 0.034010 0.536898
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 2.018224 5.882576 -0.031928 0.983822 0.938696 0.932536 25.963795 17.389427 0.719162 0.694520 0.376752
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 10.129896 8.322650 0.885249 1.393559 4.983159 -0.869978 -0.223723 -0.919884 0.721365 0.694253 0.380153
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 7.851535 10.892439 1.789583 1.957000 -1.093527 0.096336 0.089824 0.139838 0.716808 0.695101 0.383817
124 N09 digital_ok 0.00% 100.00% 100.00% 0.00% -1.030052 2.462410 0.022447 -0.114638 -0.499302 -1.363928 0.848186 -0.043653 0.077243 0.085301 0.009944
125 N09 RF_maintenance 0.00% 100.00% 100.00% 0.00% 0.894901 2.163384 -0.040078 0.264271 0.192115 1.590538 -0.470222 -0.654980 0.073861 0.079947 0.007997
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 4.729121 -0.879491 6.377001 0.756429 17.792850 -1.087211 25.156660 -0.556890 0.086103 0.082982 0.016357
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.013554 -0.462970 -0.809059 -0.135395 -0.038518 0.863979 0.137186 1.777793 0.707295 0.686456 0.397341
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.827347 6.613537 6.714298 2.427511 -0.297174 2.077601 -0.347490 -0.572594 0.703839 0.666266 0.391884
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.531206 -1.502616 -0.681096 -0.340401 -1.027186 -0.794365 -0.428635 -0.675269 0.705882 0.682151 0.397038
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.301228 -0.231650 -0.425362 -0.077780 1.194616 1.100482 0.108431 2.049786 0.693654 0.674160 0.390827
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -1.314870 15.401745 -0.223813 64.991657 1.125200 26.092913 0.008252 0.938338 0.675237 0.038293 0.421809
136 N12 digital_maintenance 0.00% 0.00% 0.00% 0.00% 3.943553 0.730292 0.232852 0.020984 0.303565 -0.651746 -0.220266 -0.834806 0.665924 0.656558 0.378571
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.124036 -1.480994 -0.488558 -0.920353 2.047239 -0.739007 1.420607 -0.550778 0.682238 0.663792 0.378194
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.403523 -0.887259 1.104420 1.868307 -0.816363 -1.068654 5.819804 -0.478549 0.700592 0.677952 0.382461
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% 50.38% 0.00% 13.622414 -1.533028 63.554054 -0.704474 18.261604 -0.037211 0.402820 -0.949696 0.032436 0.370770 0.239883
144 N14 digital_ok 100.00% 50.38% 50.38% 0.00% -1.316560 -0.869466 -0.595031 13.958891 0.549871 -0.292352 -0.413445 -0.476996 0.387858 0.364065 0.168892
145 N14 RF_maintenance 100.00% 50.38% 50.38% 0.00% -1.853336 2.662408 1.099649 34.734168 3.044203 22.863050 0.114518 0.018239 0.389526 0.353520 0.177144
147 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
148 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
149 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
150 N15 RF_maintenance 100.00% 100.00% 0.05% 0.00% 14.252724 2.301680 62.750216 40.050105 18.089919 17.354953 2.202508 -2.059292 0.046930 0.312083 0.067366
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 33.322370 1.882201 18.534938 -0.208983 9.453764 6.463191 1.769102 -0.660260 0.534938 0.611221 0.378000
152 N16 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
153 N16 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
154 N16 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 12.924241 -0.505861 60.565766 0.238400 18.012370 6.111825 0.789173 1.706891 0.062200 0.660392 0.431511
156 N12 digital_ok 100.00% 1.99% 0.00% 0.00% 10.690355 -0.159743 60.043574 2.249894 16.147132 -0.075813 1.109964 -0.187435 0.311674 0.666828 0.453340
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.106622 -0.900710 0.096511 -0.788100 -0.676599 0.811553 -0.225271 -0.157703 0.691181 0.670191 0.381421
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.422120 -1.122191 0.929355 3.238547 0.450406 0.049764 3.803993 21.002519 0.701761 0.679725 0.387591
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.606010 -0.836611 1.731769 5.932598 -0.702686 -0.161823 0.477509 1.041830 0.706237 0.681581 0.375790
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.828565 33.659365 0.316634 8.692666 0.117373 8.265343 -0.193984 0.896809 0.706622 0.555574 0.348205
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 2.258996 0.107131 7.585045 2.236958 7.656535 2.376267 0.744889 1.352423 0.707087 0.687936 0.382960
163 N14 digital_ok 0.00% 50.38% 50.38% 0.00% 0.249644 -1.591090 1.050031 -1.057449 -1.117056 3.696496 -0.052815 0.634325 0.388389 0.362770 0.166088
164 N14 digital_ok 100.00% 50.38% 50.38% 0.00% -1.140084 -0.581260 4.466956 3.612026 7.262018 0.320570 0.379091 0.895735 0.388818 0.366374 0.168633
165 N14 digital_ok 100.00% 50.38% 50.38% 0.00% 22.185634 0.135002 46.412700 3.764130 11.798662 -1.069932 -0.209353 -0.902331 0.261507 0.368902 0.187614
166 N14 RF_maintenance 100.00% 50.38% 76.48% 0.00% 35.988780 13.109695 11.071404 60.461703 6.370279 24.343849 9.318668 -0.111801 0.329915 0.132506 0.193265
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 56.535795 51.417219 9.520962 8.057112 27.108554 12.803609 170.961503 62.043777 0.497307 0.498201 0.209085
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.715467 -0.507480 -0.846296 2.616140 0.064090 -0.315347 -0.348543 0.017935 0.702819 0.680286 0.400816
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.124221 13.446977 32.836601 40.108866 3.663404 17.834717 -1.703131 2.348976 0.705989 0.590839 0.405913
170 N15 digital_ok 100.00% 95.06% 0.00% 0.00% 13.994957 -1.558570 63.625667 21.075814 17.452465 4.188634 0.996741 0.530082 0.113306 0.685371 0.507263
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 1.442559 3.732227 12.113700 1.293007 1.950088 6.692150 -0.228472 -0.157914 0.647346 0.593377 0.395430
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 15.872153 16.420047 22.190378 24.143785 18.057070 25.932772 3.281011 6.851677 0.034141 0.038237 0.004171
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.001637 -0.283517 -0.869239 -0.750196 0.323529 1.408811 -0.279864 6.048384 0.676068 0.654537 0.395284
177 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -1.065251 -0.688480 0.814939 4.430263 -0.833301 1.700331 -0.358560 1.688142 0.689290 0.667685 0.395763
178 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 3.473023 -0.723444 0.674791 -0.852867 -0.135960 1.533020 3.765666 0.673713 0.685197 0.669400 0.392055
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 14.472632 16.731712 63.938431 67.789175 18.267733 25.952804 1.036285 1.089989 0.047906 0.070991 0.020968
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.326531 16.129220 -1.043392 65.420508 0.842780 26.063008 0.348054 1.999046 0.705081 0.051095 0.466346
181 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.139533 -1.402396 0.381732 -0.395933 0.070423 1.544425 -0.155719 3.822416 0.713313 0.685611 0.383574
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.404237 4.808201 35.871350 45.626641 4.098329 15.643716 5.201039 -1.538797 0.654320 0.678541 0.393814
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 13.671754 -0.847888 58.291277 5.293996 18.074468 -0.256703 0.214346 -0.477634 0.042771 0.678943 0.452514
184 N14 digital_ok 100.00% 90.76% 100.00% 0.00% 13.268609 15.771624 62.910663 64.619451 17.862926 25.973241 0.819527 0.702350 0.088908 0.035951 0.036469
185 N14 digital_ok 100.00% 100.00% 50.38% 0.00% 12.783092 -1.375031 62.968280 18.877303 18.144551 0.081561 0.556245 -0.750498 0.032627 0.362651 0.216653
186 N14 digital_ok 100.00% 50.38% 50.38% 0.00% 1.258045 1.294268 9.464330 15.245851 7.245572 1.054733 1.147711 0.965470 0.386793 0.366462 0.166459
187 N14 digital_ok 100.00% 50.38% 50.38% 0.00% 3.119741 2.091143 1.589404 34.952755 21.584980 8.018465 0.521930 -0.285574 0.386795 0.371953 0.177255
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 1.191058 1.553228 2.418988 6.545352 -0.544501 1.979126 0.443395 0.141621 0.686830 0.673453 0.403408
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 51.264413 15.533864 8.407884 65.215835 10.883932 26.145977 31.293076 2.442314 0.503634 0.034204 0.318051
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.195359 -0.203635 1.425494 7.079840 -0.191091 1.227545 15.508184 5.360356 0.679417 0.668561 0.412850
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 1.376183 8.133691 33.341366 55.536476 17.770522 23.657181 -0.050452 -3.686326 0.665705 0.623625 0.417677
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 7.963522 1.094925 54.621344 33.754879 16.014037 9.041217 -3.269394 -0.896064 0.626685 0.642855 0.426354
200 N18 RF_maintenance 100.00% 100.00% 39.31% 0.00% 15.372011 42.652945 24.853312 25.658470 17.983599 21.797447 1.713886 -0.396218 0.046133 0.221058 0.131680
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 8.232799 6.975143 54.545417 52.140825 15.652268 21.268787 -3.228018 -3.248317 0.668074 0.645394 0.381020
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.719369 3.609739 25.845922 2.424411 2.521464 5.919777 0.710528 1.623286 0.691133 0.626581 0.395363
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 16.016373 17.671125 23.322743 24.835547 18.048623 25.873249 2.702950 2.540666 0.033559 0.041154 0.001374
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 8.103725 5.065051 55.508653 46.660014 16.385606 16.819436 -3.376214 -2.892995 0.641197 0.656799 0.400216
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 4.503966 5.443124 45.451730 46.325571 11.119167 17.166284 -0.512781 -2.972452 0.691997 0.659177 0.395998
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 3.451949 1.261463 2.502289 20.837337 4.547704 2.763456 2.487348 -0.151588 0.648159 0.653637 0.398222
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.596732 5.941737 47.419157 46.880758 12.629041 16.468258 -0.878060 -2.942817 0.676162 0.652353 0.399203
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 3.796408 2.752685 1.187645 15.606753 4.602088 4.955164 -0.182428 -0.999017 0.635737 0.632850 0.400433
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.753739 0.225108 29.001718 28.127498 4.608457 6.254023 -0.678733 -1.414512 0.687953 0.652706 0.402399
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.354098 3.956078 21.397567 42.323309 2.484458 14.276391 0.269229 -1.465578 0.679897 0.650291 0.401512
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 0.109728 16.073192 0.684778 40.557685 1.137481 25.998911 10.972657 2.330488 0.689696 0.046671 0.446734
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.206868 1.094129 18.173175 21.443831 4.269023 5.378006 3.539918 1.835985 0.610198 0.579039 0.406356
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 2.070557 3.087436 22.607165 37.482542 2.588226 10.789826 5.607385 1.073102 0.600279 0.573407 0.400918
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 29.663694 2.563228 4.661480 36.663195 10.145805 11.567505 10.063091 -0.573426 0.390057 0.564747 0.364961
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 1.691679 3.109741 29.519315 34.162940 5.112318 8.161169 0.718301 -1.246733 0.600729 0.567662 0.390300
325 N09 dish_ok 100.00% 100.00% 100.00% 0.00% 1.141766 -0.711276 29.669335 15.230091 4.726639 2.726280 -1.026556 -0.058219 0.093817 0.094664 0.035024
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 1.887542 -0.320293 10.357849 18.273649 8.834608 4.149895 4.275692 0.350434 0.582610 0.576901 0.398946
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 4.982369 1.766635 -0.055648 14.644435 5.104273 3.905559 0.792050 -0.003507 0.543123 0.561803 0.391321
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [7, 8, 10, 15, 17, 18, 19, 20, 22, 27, 28, 30, 32, 33, 34, 35, 36, 37, 38, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 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, 138, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 160, 161, 162, 163, 164, 165, 166, 167, 169, 170, 171, 173, 176, 177, 179, 180, 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: [3, 4, 5, 9, 16, 21, 29, 31, 40, 41, 42, 53, 65, 69, 70, 83, 85, 99, 100, 112, 116, 118, 127, 129, 130, 136, 137, 157, 168, 178, 181]

golden_ants: [3, 5, 9, 16, 21, 29, 31, 40, 41, 42, 53, 65, 69, 70, 83, 85, 99, 100, 112, 116, 118, 127, 129, 130, 157, 178, 181]
In [23]:
# write to csv
outpath = os.path.join(nb_outdir, f'rtp_summary_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/rtp_summary_table_2459871.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 [ ]: