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 = "2459873"
data_path = "/mnt/sn1/2459873"
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-20-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/2459873/zen.2459873.25254.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/2459873/zen.2459873.?????.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/2459873/zen.2459873.?????.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 2459873
Date 10-20-2022
LST Range 21.433 -- 7.455 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
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 57 / 183 (31.1%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 145 / 183 (79.2%)
Redcal Done? ❌
Never Flagged Antennas 38 / 183 (20.8%)
A Priori Good Antennas Flagged 67 / 99 total a priori good antennas:
3, 7, 10, 17, 19, 20, 21, 29, 30, 31, 37, 45,
46, 51, 53, 54, 55, 56, 66, 67, 68, 71, 72,
73, 81, 84, 86, 93, 98, 101, 103, 108, 109,
111, 117, 121, 122, 123, 128, 140, 141, 142,
143, 144, 146, 147, 156, 158, 161, 162, 164,
165, 167, 169, 170, 176, 178, 179, 181, 183,
184, 185, 186, 187, 189, 190, 191
A Priori Bad Antennas Not Flagged 6 / 84 total a priori bad antennas:
8, 89, 90, 125, 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_2459873.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% 6.194477 -0.923907 -0.278591 -0.093302 -0.442384 -0.279101 1.546350 2.846463 0.687660 0.670994 0.388320
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.260962 4.566193 1.472432 -0.376945 0.691833 0.230511 1.855354 -0.172926 0.694663 0.667906 0.384910
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.005844 0.025825 -0.802886 0.536452 0.096210 1.205794 0.979775 -0.306398 0.704326 0.672203 0.382004
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.995158 -1.388076 0.274148 -0.107346 0.288676 0.590756 1.482281 8.871229 0.698048 0.672969 0.382679
8 N02 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.966721 1.410702 0.777498 -0.329518 -0.440171 -0.566275 3.701449 -0.009963 0.691600 0.656744 0.376792
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.174857 -1.918072 -0.389542 0.265045 1.270110 -0.511480 -0.342085 0.614118 0.690855 0.664577 0.387352
10 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 23.650542 -1.122120 12.108983 4.337450 7.117657 3.424247 0.848877 -0.191101 0.655649 0.661321 0.393715
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.727057 0.281017 0.772538 -0.769933 -0.047493 -0.394690 3.393450 1.770619 0.703820 0.676869 0.382165
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.618426 1.091958 -0.730444 0.024251 -0.014886 1.315318 1.990532 3.716676 0.705710 0.672395 0.378399
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.764335 0.956364 -0.064955 -0.267632 -0.065609 -0.114452 5.329539 3.394954 0.702914 0.681964 0.374560
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.557237 24.472641 0.921120 1.330199 0.444640 6.951351 13.712827 36.275085 0.690284 0.459412 0.438546
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 4.562421 -1.014951 -0.417696 11.077017 0.685221 2.761676 2.361087 4.523367 0.694718 0.665855 0.380310
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -1.477532 4.394550 0.011565 13.419051 -0.216525 1.050509 4.458740 -1.025807 0.701153 0.670315 0.381688
21 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 1.896469 -0.006687 -0.635346 -0.361589 0.252063 0.469985 0.491406 5.706764 0.685388 0.665165 0.384790
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 50.549918 19.316913 4.482488 15.177631 6.543735 4.158675 4.648365 8.684433 0.468248 0.610201 0.319746
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 19.115791 20.503286 45.416372 46.346713 7.320063 11.220437 3.104200 2.391139 0.034736 0.039248 0.002564
28 N01 RF_maintenance 100.00% 0.00% 87.54% 0.00% 23.556097 45.436747 5.532460 3.648999 6.273338 11.921637 4.787973 25.299930 0.367233 0.156874 0.230265
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -1.599148 -0.471167 -0.771214 0.381138 -0.822608 -0.565651 -0.383848 4.356711 0.709283 0.679273 0.370557
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 0.775701 -1.381342 -0.730442 -0.758362 0.057395 -0.698710 12.464391 0.386240 0.703637 0.684098 0.369594
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.095153 0.055640 0.697941 -0.755001 -0.021246 2.410773 1.231202 6.075631 0.716626 0.684764 0.381280
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 19.765948 36.621271 3.405770 3.241585 10.422293 7.320303 18.925114 39.407733 0.627345 0.592590 0.272736
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.524046 30.990339 0.146298 1.380343 -0.640393 6.951979 2.402556 28.536702 0.693172 0.481072 0.464204
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 21.877539 4.548126 18.435347 16.216598 7.299633 3.351863 1.242744 -0.790463 0.045860 0.649797 0.542291
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.908887 2.313096 1.107321 9.130762 1.465692 2.460655 0.685008 0.432893 0.607430 0.629240 0.396992
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 14.603479 13.876696 0.600271 0.505541 0.579359 0.984662 0.062421 0.428837 0.705292 0.678703 0.386032
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.041983 1.386765 2.919743 3.801436 0.131615 -0.121125 -0.414917 5.017929 0.708884 0.685178 0.385802
38 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -0.343125 0.232233 -0.834123 -0.753184 1.006301 0.037755 2.879129 1.665632 0.713688 0.690374 0.385379
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.331249 0.269710 -0.644532 -0.739574 1.052624 -0.766011 -0.855838 -0.623129 0.707407 0.681666 0.374431
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.651106 1.270081 0.681146 0.431660 1.077834 -1.001391 -0.652880 0.009963 0.710812 0.680895 0.363793
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.232243 1.532264 -0.154403 1.605739 -0.244304 -0.629682 -0.453613 -0.770309 0.718880 0.692665 0.377249
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 17.918572 2.618845 44.913428 -0.575441 7.328409 0.038093 2.056006 2.866954 0.043899 0.688729 0.486745
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 3.314682 3.231342 1.523293 2.551944 1.717694 0.292962 22.082332 10.307629 0.699131 0.684593 0.357269
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -0.888353 3.861616 -0.863715 0.419547 0.005557 2.281806 -0.315057 13.214774 0.708321 0.668564 0.369896
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -0.595747 21.333986 -0.867921 46.522132 -0.235856 11.178551 0.386862 3.494327 0.698695 0.039747 0.511065
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 20.577976 5.040093 17.566118 10.485826 7.308510 1.056907 1.228534 2.136299 0.040860 0.646238 0.538051
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.670312 3.472202 20.070802 24.506025 1.416702 2.781658 -0.472880 -1.943213 0.666768 0.660351 0.399080
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.674348 1.936135 6.361335 20.627051 0.734390 2.671806 0.069753 -0.319563 0.634767 0.647066 0.403552
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.108956 33.823229 -0.630099 3.514243 1.546608 8.016825 8.674884 27.389821 0.696895 0.610635 0.355625
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 40.447101 2.137078 58.660650 -0.591379 7.180994 2.932460 11.072161 6.741293 0.042290 0.688634 0.500625
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.984147 11.498885 0.745719 0.260346 0.987707 -0.733092 0.358698 0.404565 0.715398 0.693818 0.373461
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.666895 4.604782 -0.575426 -0.182972 -0.271762 0.326554 2.431385 4.743049 0.719362 0.698990 0.376885
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 19.112203 21.674790 45.454964 47.497964 7.340720 11.221003 2.389908 1.244367 0.047432 0.046563 0.001641
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 3.705690 22.841690 -0.178555 47.030235 7.151910 11.197290 8.131335 3.193276 0.708449 0.037250 0.496741
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 1.189124 1.574230 0.134737 -0.339858 0.250239 1.782933 0.298767 10.354847 0.712821 0.694421 0.358147
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 54.283079 -0.357169 22.078712 2.544471 3.770074 0.276791 1.306842 0.265736 0.545100 0.695561 0.361287
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 18.541291 21.471293 45.245849 47.297259 7.356572 11.274908 3.214762 2.796873 0.038339 0.036194 0.001621
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 44.184611 5.865128 4.340407 -0.264776 2.893506 0.902472 5.033104 14.678896 0.626507 0.675590 0.356379
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 19.948464 21.080249 45.359461 47.162520 7.320222 11.221709 2.250440 3.001471 0.028042 0.028276 0.001566
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 6.555984 6.177347 4.538383 -0.072271 3.214072 2.844641 -0.566820 1.866139 0.654868 0.622234 0.374466
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.112697 3.265814 16.169114 22.433129 1.013025 3.906835 0.738869 -1.482417 0.671611 0.663073 0.388273
63 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
64 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.738892 0.624838 0.096075 1.794735 1.519195 0.938291 -0.483053 -0.314237 0.698120 0.676936 0.388305
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.444969 2.622569 10.847927 6.285216 2.509027 0.207636 -0.617042 0.444596 0.700457 0.686164 0.382662
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -1.338589 -0.543514 5.182676 3.208036 0.117478 -0.209759 0.256303 2.081858 0.708196 0.690446 0.374006
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 4.404991 44.619784 0.938576 63.179300 -0.585555 10.758555 1.805414 10.899534 0.707641 0.033721 0.472847
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.532126 -1.268195 -0.601809 0.435959 1.099596 1.322470 -0.805415 -0.642667 0.711745 0.697039 0.367021
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 1.342468 -0.469098 0.352694 0.688061 0.000263 0.745521 -0.218824 0.141100 0.717262 0.701862 0.366470
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 11.668281 -0.231505 1.835850 1.533692 0.553772 0.618674 0.207565 0.114465 0.727052 0.700967 0.362877
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 6.011308 -0.062633 1.506294 1.198959 0.664940 0.965994 3.024258 -0.282636 0.706989 0.694931 0.355517
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 17.733272 19.811927 44.585620 45.738241 7.359604 11.184575 3.406107 1.113717 0.027525 0.027744 0.001266
74 N05 digital_maintenance 100.00% 100.00% 0.21% 0.00% 19.800917 18.849115 46.847671 46.113290 7.402472 10.114462 2.918881 22.213963 0.032753 0.292017 0.178774
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 14.062913 21.818642 14.977476 47.713866 3.483865 11.351267 21.050572 3.695685 0.670729 0.049628 0.491826
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 40.889034 42.584681 16.959821 13.834420 3.238345 6.397869 12.622010 4.177150 0.559254 0.498416 0.209074
78 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% -0.386900 -0.405574 -0.707629 3.513291 0.057541 20.097759 -0.502402 0.262439 0.676218 0.657119 0.382337
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.791607 0.064822 -0.033785 6.581037 0.065086 0.133498 -0.465904 -0.523779 0.687685 0.668212 0.379372
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.984877 -0.491303 -0.745985 -0.196434 -0.220011 -0.337026 -0.952372 0.448110 0.699203 0.684542 0.373284
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 10.580983 39.386725 6.406479 61.107216 -1.108784 10.718203 -0.636631 5.743592 0.705294 0.043207 0.572300
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.324438 -0.076515 2.572831 2.973468 -1.067269 -0.864687 -0.928388 -0.843179 0.707775 0.690033 0.373151
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 3.231094 7.653837 5.278231 4.085318 6.002873 2.038291 0.300571 20.189872 0.699977 0.662055 0.365826
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.675446 12.517963 0.763908 0.561740 16.206538 2.933447 0.353083 0.819188 0.689877 0.711569 0.363134
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.692120 1.294800 0.684027 0.190952 -0.266774 1.381116 -0.561869 -0.675083 0.707608 0.696062 0.358903
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.400574 0.061489 -0.568471 0.352055 0.535610 -0.719466 -0.938936 -0.716482 0.713262 0.694816 0.365177
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.169383 -0.172100 -0.024251 1.210835 -0.743036 -0.318480 0.249640 3.287309 0.708853 0.692447 0.365375
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.283889 -0.882551 -0.292374 -0.169445 -0.933317 -0.519073 1.486293 0.305253 0.704172 0.698207 0.380487
92 N10 RF_maintenance 100.00% 0.00% 14.61% 0.00% 63.506122 71.349301 5.468472 6.493129 7.007111 11.234370 0.334277 6.496657 0.298176 0.245189 0.091942
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 3.904467 0.854542 7.457209 -0.733607 2.691277 -0.352032 3.214497 -0.608089 0.693367 0.686125 0.385787
94 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.994072 -1.716742 -0.688784 -0.782212 0.903129 2.596027 3.178339 1.920008 0.694013 0.673742 0.392703
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 2.144237 11.235671 -0.205293 0.122964 -0.156117 1.348707 0.496019 3.481799 0.673751 0.650338 0.378355
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 1.448196 -0.999634 0.880119 -0.804784 0.359438 3.519243 3.177596 -0.745397 0.678126 0.669518 0.379654
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.435118 -1.435101 0.606176 -0.935483 1.181046 -0.903573 -0.402055 -0.675879 0.691765 0.676393 0.373671
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 12.360926 14.920270 1.883564 2.104311 -0.882422 -0.319046 -0.008745 -0.319054 0.715491 0.694344 0.370292
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 6.381476 22.665508 31.425356 47.411221 32.104012 11.222826 0.855284 5.556511 0.604292 0.043126 0.504352
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 39.273643 40.586111 52.551598 54.187020 7.424480 11.295480 10.855258 9.533787 0.028152 0.028478 0.001898
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.774120 94.415095 3.449492 44.147972 0.963739 1.601372 -0.182622 -0.010184 0.716006 0.632373 0.404046
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.376924 -0.279305 -0.149920 0.416495 -0.186034 -0.426345 -0.616071 -0.631417 0.713165 0.696708 0.360458
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.005844 1.286782 2.597686 1.353869 2.148011 0.911911 -0.344479 -0.429417 0.703504 0.691831 0.364033
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 2.381699 0.590291 0.261395 3.095816 -0.156040 0.598039 1.221562 2.278185 0.705552 0.693726 0.362656
108 N09 digital_ok 100.00% 14.07% 0.00% 0.00% 17.009658 4.631267 43.660509 -0.226058 6.732050 0.862023 2.071553 1.926263 0.298109 0.698021 0.534830
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.666642 21.231805 0.993259 45.779616 -0.860901 11.187411 0.540767 2.279104 0.708391 0.037348 0.473498
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.756615 42.274366 -0.620625 61.891581 -0.759290 10.770540 -0.273146 5.219239 0.716661 0.035125 0.477375
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.426629 20.939683 0.670092 46.282721 -0.587699 11.150833 5.413935 2.514689 0.698630 0.037487 0.466945
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.193726 -0.342590 -0.667835 0.059689 -0.081995 0.944612 0.292701 -0.733825 0.686576 0.678388 0.395520
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -1.157678 0.656862 2.893009 0.834309 1.996107 0.760827 3.323447 -0.265615 0.669709 0.656698 0.383148
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 20.702037 23.677447 45.707292 48.745898 7.374684 11.270164 2.343982 5.066059 0.028260 0.032886 0.003773
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.311553 0.969177 0.052766 0.438131 1.386626 0.124450 1.205782 2.076091 0.693977 0.679620 0.373028
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.629085 3.695808 5.850116 12.597634 -0.793349 8.798506 0.682663 3.291973 0.706003 0.650193 0.379077
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 4.024702 39.122592 -0.420973 60.915184 0.769199 10.972684 0.732636 9.812001 0.710296 0.037509 0.585832
121 N08 digital_ok 100.00% 0.21% 0.00% 0.00% 3.357697 8.251870 -0.239627 0.331696 0.492104 -0.168454 29.478825 20.805468 0.713491 0.699823 0.374147
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 13.588360 11.559874 0.409752 1.135505 2.812452 -0.352986 -0.404813 -0.789333 0.723112 0.701478 0.371713
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 10.250099 15.226107 1.245036 1.520562 -1.141935 0.772341 -0.534611 -0.329831 0.720829 0.705971 0.370137
124 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -1.067411 3.306391 -0.074201 0.061339 -0.592956 -1.141845 0.470528 -0.117874 0.718346 0.695263 0.371906
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 2.962931 1.880071 -0.286395 -0.089650 -0.235886 1.692893 -0.140096 0.252698 0.705670 0.690394 0.368571
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.799788 -0.788928 5.288441 0.809471 5.650800 -0.555614 3.132975 -0.465905 0.710840 0.690887 0.377274
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.147751 0.054799 -0.455546 -0.810261 0.600542 -0.370647 0.673899 2.536453 0.710671 0.698808 0.385288
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.763728 8.683849 4.685339 2.792539 -0.563074 1.862042 -0.644234 -0.233739 0.703787 0.678764 0.380227
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.190965 -2.224897 -0.685060 -0.742953 -0.000263 -0.272611 -0.738982 -0.525348 0.701987 0.689979 0.393013
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.968455 0.115935 -0.499963 -0.712824 -0.014488 -0.331786 0.877623 2.654799 0.685609 0.679504 0.389087
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -1.868855 21.236551 -0.225711 47.456079 -0.199566 11.301023 0.031098 1.649257 0.669465 0.041612 0.451590
136 N12 digital_maintenance 100.00% 0.00% 0.00% 0.00% 6.732868 1.280950 0.195404 0.616902 0.225997 0.229472 0.138736 -0.369749 0.660768 0.654459 0.379190
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.880439 -1.091862 -0.727398 -0.816135 2.910730 0.629855 0.440653 -0.562706 0.675035 0.662172 0.380169
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.003592 -0.730817 0.744019 1.495809 -1.286436 -0.221428 6.103577 -0.243307 0.694668 0.677559 0.382756
139 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.836192 3.746421 36.046747 30.543727 4.428622 5.636161 -3.344711 -2.668343 0.691495 0.680112 0.376252
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 6.270289 22.401655 33.471661 46.686608 3.742544 11.123261 -1.407275 3.214671 0.696521 0.054135 0.487340
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -2.005197 7.886021 1.141185 36.478587 1.441417 7.862760 0.189336 -3.112922 0.708410 0.676663 0.364535
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 2.147637 21.151581 1.329730 47.117531 2.152010 11.225807 0.107495 2.154246 0.703795 0.050184 0.492537
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 19.477361 -1.606582 46.053701 -0.662867 7.374100 0.903011 0.412149 -0.820779 0.040519 0.697526 0.522221
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -1.145488 -0.808886 -0.292133 9.910796 -0.347024 -0.528122 -0.628643 -0.576558 0.712148 0.683608 0.379743
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% -2.053629 2.423407 1.018837 22.402489 2.305900 22.670854 -0.470460 0.800237 0.709895 0.646662 0.389301
146 N14 digital_ok 100.00% 0.00% 0.00% 100.00% 4.988978 7.218835 27.824572 33.605619 2.237567 9.191835 -1.990780 -3.041155 0.319304 0.315390 -0.291724
147 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 31.506149 31.700581 9.930296 10.985776 8.102550 9.764717 2.048455 1.222473 0.350823 0.350088 0.154396
148 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.056020 -0.561881 14.572985 6.052399 0.452024 -0.581401 -0.051358 -0.315699 0.683499 0.688240 0.390851
149 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.814207 1.881792 8.707590 25.970416 -0.937232 3.496831 -0.586471 -1.725405 0.700455 0.690626 0.396416
150 N15 RF_maintenance 100.00% 100.00% 0.00% 0.00% 20.370713 5.080397 45.395607 31.627603 7.318817 7.764768 2.555715 -1.606463 0.052629 0.309622 0.118453
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 47.530633 3.134737 13.636990 -0.534817 3.589816 2.229339 1.516558 -0.501663 0.525009 0.612225 0.380924
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 3.246202 2.748907 5.775375 10.641487 0.311223 1.159047 6.848876 -0.599713 0.628740 0.637271 0.410277
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 19.978451 1.758426 17.317623 12.227928 7.332744 2.721978 1.209883 -0.632179 0.043051 0.634708 0.533711
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.658103 -0.256412 17.370661 16.942166 1.228677 1.156629 -0.786089 -0.766064 0.635718 0.631573 0.413146
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 18.505738 -0.801226 43.742068 -0.301773 7.292768 1.812638 0.882900 3.591282 0.065088 0.657871 0.487343
156 N12 digital_ok 100.00% 9.29% 0.00% 0.00% 15.784729 -0.129466 43.594186 0.678728 6.451047 0.429502 1.258619 0.236967 0.288596 0.664784 0.458555
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -0.036485 -0.574240 -0.084088 -0.036984 -1.014545 0.100502 -0.482969 0.179417 0.686939 0.668356 0.381206
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.511561 -0.716301 0.005757 1.464330 1.625031 0.424879 1.468673 30.847435 0.698115 0.679291 0.383781
159 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 2.579334 41.376401 25.322557 20.790276 1.829200 7.312243 -1.979578 -0.818346 0.693261 0.526065 0.357173
160 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -1.054721 -0.889157 1.125572 3.139837 -0.827983 1.935408 0.119449 0.768332 0.706508 0.683069 0.367129
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.473997 46.327908 -0.301757 6.009883 -1.162151 3.712061 -0.426017 1.516455 0.706906 0.557266 0.338345
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 3.083894 1.125592 9.746225 14.226157 7.246287 20.804459 0.008902 2.313265 0.712391 0.668329 0.373872
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.300624 -1.597231 0.535072 -0.879886 -1.239407 0.053643 -0.468242 0.724918 0.712438 0.679829 0.383107
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.640980 -0.357123 2.107542 1.578375 10.725218 0.435521 0.177288 1.282616 0.704348 0.687525 0.380842
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 31.990577 0.342784 33.408126 2.169503 4.773904 -0.971192 0.469866 -0.744943 0.429497 0.686002 0.416099
166 N14 RF_maintenance 100.00% 0.00% 87.33% 0.00% 48.677147 18.702200 6.932672 44.405954 6.617363 9.900146 45.183717 0.399633 0.572591 0.163108 0.395127
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% -0.581295 -1.399313 10.235325 2.648888 0.426202 1.100491 -0.844466 4.754259 0.714194 0.685202 0.394895
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.728634 -0.420855 -0.495445 1.035985 0.323567 -0.538740 -0.878994 0.093237 0.703273 0.686200 0.393050
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 2.656485 5.195646 24.206147 29.720625 0.992141 7.498918 -2.124597 -0.470841 0.704135 0.655941 0.399265
170 N15 digital_ok 100.00% 100.00% 0.00% 0.00% 20.348327 -0.637675 46.297237 6.839872 7.356623 20.891905 1.175757 3.115802 0.044871 0.686421 0.554891
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.677823 5.636171 8.793994 0.773685 0.991227 2.408041 -0.386079 0.468840 0.638502 0.594015 0.390786
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 22.644717 22.631555 15.389148 17.228144 7.289301 11.149784 4.231800 8.196613 0.036612 0.041575 0.004981
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.279639 -0.103433 -0.840130 -0.746674 -0.108676 0.440143 -0.411568 9.472733 0.672194 0.651260 0.390893
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -1.212563 -0.781747 0.529694 2.289512 -0.719127 0.221083 -0.471208 2.071484 0.683944 0.662840 0.392624
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 5.422547 -0.989948 0.427973 -0.459018 -0.377542 1.799641 5.496730 1.894986 0.680889 0.665689 0.387975
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 20.689846 23.172710 46.360466 49.601279 7.373072 11.264148 0.979947 1.622613 0.050207 0.064494 0.013065
180 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 19.670043 22.249482 45.877123 47.771824 7.346190 11.261481 0.871018 3.037165 0.051046 0.053490 0.004552
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.190228 -1.295396 0.294491 -0.901927 -0.711238 0.141518 -0.249629 6.900726 0.711919 0.681406 0.376030
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.425491 6.558041 26.225284 33.562954 0.965677 6.297792 4.651037 -1.142138 0.651765 0.676370 0.385322
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 19.555454 -0.813108 42.088715 3.648477 7.312637 0.020954 0.166845 -0.218518 0.047319 0.677006 0.487337
184 N14 digital_ok 100.00% 96.89% 100.00% 0.00% 19.137113 21.717594 45.606549 47.142978 7.265269 11.158695 0.921629 1.266075 0.117983 0.045549 0.058478
185 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
186 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
187 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
189 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
190 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
191 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 3.042502 10.993571 28.974765 40.714824 3.832073 10.161673 -0.965724 -4.018528 0.664694 0.626970 0.410329
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 10.724909 1.195713 40.417573 22.774727 6.192315 2.179806 -3.951083 0.109015 0.625889 0.645005 0.419988
200 N18 RF_maintenance 100.00% 100.00% 50.43% 0.00% 21.923245 59.722894 17.349895 18.538789 7.299440 10.728214 2.094329 7.105237 0.049761 0.213715 0.146422
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 11.433584 9.642905 40.790935 38.563456 6.287778 8.880893 -3.880057 -3.382527 0.663289 0.639412 0.378127
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 2.756907 5.678482 19.041945 0.925218 0.436284 3.633705 1.591487 2.808102 0.686950 0.615702 0.394533
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 22.812983 24.317675 16.250906 17.738984 7.297983 11.187629 3.045559 3.748321 0.035652 0.044033 0.002595
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 11.079451 6.959957 41.306046 34.438039 6.534673 6.924714 -4.075275 -3.130332 0.636448 0.649083 0.399130
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 6.110767 7.462508 33.904808 34.259457 4.047056 6.368871 -0.881385 -3.242851 0.686628 0.651139 0.396520
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.989232 1.871163 1.564287 15.244205 2.314279 0.951298 2.281036 0.334323 0.640450 0.645081 0.398841
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 7.537560 8.159987 35.165881 34.630909 4.737524 7.611300 -1.229571 -3.154041 0.677125 0.646942 0.398463
237 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
238 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
239 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 1.890074 21.897233 0.110594 29.328501 -0.312417 11.188588 16.363844 3.476002 0.684530 0.050618 0.514453
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.586517 1.668260 13.164831 15.194584 1.636318 2.067200 5.053969 3.718432 0.605675 0.577428 0.400396
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 3.133570 3.980772 16.465957 27.175337 0.781790 4.336601 7.813037 2.999608 0.593775 0.571134 0.394717
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 42.260323 2.541705 2.951295 24.633310 4.154493 3.909816 11.395414 0.590480 0.382037 0.564336 0.364731
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 2.299448 4.139111 21.404808 24.894489 1.276301 3.627558 0.876736 -1.213576 0.594782 0.564854 0.384168
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 1.085971 -0.809916 21.973776 10.976119 1.339587 0.901304 -1.403330 -0.099730 0.629917 0.578548 0.396613
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 4.747313 -0.379464 5.683662 13.016441 0.539830 1.366971 5.040068 0.282227 0.570783 0.573323 0.392632
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 6.573315 3.042091 3.216324 9.860950 1.131878 1.376738 1.152302 0.532835 0.554387 0.556778 0.384226
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, 10, 17, 18, 19, 20, 21, 22, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 71, 72, 73, 74, 75, 77, 78, 81, 82, 84, 86, 87, 92, 93, 98, 101, 102, 103, 104, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 126, 128, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 161, 162, 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, 8, 9, 15, 16, 38, 40, 41, 42, 65, 69, 70, 83, 85, 88, 89, 90, 91, 94, 99, 100, 105, 106, 107, 112, 116, 118, 124, 125, 127, 129, 130, 137, 157, 160, 163, 168, 177]

golden_ants: [5, 9, 15, 16, 38, 40, 41, 42, 65, 69, 70, 83, 85, 88, 91, 94, 99, 100, 105, 106, 107, 112, 116, 118, 124, 127, 129, 130, 157, 160, 163, 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_2459873.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 [ ]: