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 = "2459866"
data_path = "/mnt/sn1/2459866"
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-13-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/2459866/zen.2459866.25292.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/2459866/zen.2459866.?????.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/2459866/zen.2459866.?????.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 2459866
Date 10-13-2022
LST Range 20.983 -- 7.004 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
Total Number of Antennas 180
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 35
RF_ok: 9
digital_maintenance: 11
digital_ok: 98
not_connected: 23
Commanded Signal Source None
Antennas in Commanded State (reported) 0 / 180 (0.0%)
Antennas in Commanded State (observed) 0 / 180 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 16
Nodes Registering 0s
Nodes Not Correlating
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 51 / 180 (28.3%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 139 / 180 (77.2%)
Redcal Done? ❌
Never Flagged Antennas 41 / 180 (22.8%)
A Priori Good Antennas Flagged 61 / 98 total a priori good antennas:
3, 7, 19, 20, 30, 31, 37, 38, 45, 46, 51, 54,
55, 56, 66, 67, 68, 71, 72, 73, 81, 84, 86,
93, 99, 101, 103, 108, 109, 111, 117, 121,
122, 123, 128, 140, 141, 142, 143, 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 4 / 82 total a priori bad antennas:
89, 90, 125, 168
In [19]:
# write to csv
outpath = os.path.join(nb_outdir, f'array_health_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.replace({'\u2705': 'Y'}, regex=True).replace({'\u274C': 'N'}, regex=True).replace({'<br>': ' '}, regex=True).to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/array_health_table_2459866.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.467435 -0.879392 -0.111464 0.292447 -0.800000 -1.087046 -0.253755 1.376796 0.690320 0.678118 0.398307
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.307046 4.949780 2.144382 -0.271604 -0.430299 -0.028463 1.356869 -0.613010 0.701217 0.674313 0.395155
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.795754 0.322809 -0.730197 1.170826 -0.012909 0.915058 0.820571 -0.992940 0.708746 0.680617 0.390093
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.821691 -1.467652 0.014643 0.376470 0.202719 -0.165950 0.422243 7.584386 0.702478 0.681695 0.393669
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.318736 1.518077 1.226672 -0.151968 -0.991576 -0.807033 5.438398 -0.491307 0.699276 0.665555 0.384574
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.186066 -1.053618 -0.001921 0.424663 0.296683 -0.525905 -0.294888 0.022871 0.700602 0.672560 0.396930
10 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.019965 -0.603540 2.215374 2.994577 2.269971 2.456912 -0.016273 -0.511639 0.692120 0.668062 0.404731
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 1.321277 0.559696 1.118831 -0.771457 -0.613355 0.660987 0.191075 2.055927 0.711243 0.685398 0.392371
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.661138 1.444650 -0.263098 -0.338447 0.332823 0.943769 1.379890 2.276557 0.712642 0.681633 0.386439
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.679787 0.779072 -0.323442 0.001921 -0.354659 -0.804859 3.173801 -0.075980 0.708610 0.690545 0.384746
18 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.669912 20.876933 1.059419 1.427129 1.005072 11.882907 10.197905 22.162460 0.695399 0.463382 0.446080
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.864544 -1.194335 -0.023089 -0.999296 -0.439903 1.746282 8.534014 5.566285 0.705319 0.690725 0.393648
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% -0.613360 4.750852 0.428489 15.828856 0.748245 1.825281 2.202857 -0.474273 0.709227 0.676525 0.389848
21 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 1.020067 0.892622 -0.603161 -0.629538 1.219557 0.206335 0.344874 2.074886 0.696451 0.673163 0.394775
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% 42.078835 18.470635 4.268309 15.868377 8.976857 5.448839 10.939229 18.642931 0.458549 0.610355 0.329867
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 16.569230 18.538622 52.946047 54.072914 6.383088 11.092462 2.030676 0.996569 0.036369 0.040541 0.002330
28 N01 RF_maintenance 100.00% 0.00% 85.98% 0.00% 20.469465 37.910711 5.866031 4.052287 6.235127 16.922015 4.445190 15.513667 0.361765 0.160716 0.227650
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -1.349958 -0.315434 -0.659297 0.087557 -1.154609 -0.714758 -0.523684 2.253509 0.715263 0.689142 0.379751
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 2.348249 -1.013629 0.907619 -0.837050 1.020974 -0.959317 16.642497 0.863428 0.706415 0.692973 0.380513
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.092745 1.758677 0.589507 0.415484 -0.187913 7.808400 1.987507 2.415602 0.723240 0.689905 0.390871
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 18.843558 30.109827 5.298118 3.631145 14.415151 9.517259 10.052815 60.143143 0.620017 0.609767 0.264902
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.152487 22.821691 -0.615705 1.309475 -0.994842 13.575534 1.752128 16.708155 0.703511 0.497261 0.469540
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 18.907902 4.142633 22.202788 15.232308 6.401771 7.870850 0.588953 -1.175461 0.046414 0.658020 0.534812
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.787394 1.862499 -0.095720 7.107662 1.112116 2.078890 4.094525 -0.828661 0.625936 0.643517 0.412616
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 13.014050 11.690401 0.750285 0.619963 0.421232 1.412974 0.682543 0.261469 0.710869 0.686528 0.397569
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.061243 1.259682 -0.081065 0.564475 -1.051157 -0.416114 0.049922 5.914648 0.714943 0.693413 0.397527
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.103947 0.187063 -0.844378 -0.800753 1.309665 1.089061 4.808580 0.536427 0.718817 0.697932 0.396806
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.532371 -0.088247 -0.790188 -0.676715 1.342827 0.082994 -0.423321 -0.529119 0.711975 0.690692 0.386847
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.667866 0.809193 1.639361 0.857529 1.945177 -1.226773 -0.386970 -0.152056 0.715532 0.689190 0.374246
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% -0.053019 1.405089 -0.183925 1.825882 0.255206 -0.233747 0.629655 0.585188 0.723615 0.701201 0.388546
43 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 15.518874 1.869022 52.358493 -0.623906 6.577656 -0.077383 3.379277 3.140317 0.045398 0.698428 0.489073
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 42.632004 2.145779 4.316515 3.106850 5.160463 0.266316 59.142020 13.207811 0.624035 0.696056 0.363388
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% -0.702951 4.264780 -0.681428 -0.080229 0.790579 2.743840 0.262976 14.241087 0.714571 0.678938 0.380763
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% -0.324943 19.194199 -0.772499 54.285887 -0.307796 10.985257 0.915437 1.950862 0.706915 0.041371 0.532676
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 17.934979 4.480925 21.197769 11.877511 6.477883 0.316871 0.510573 1.472978 0.041920 0.659421 0.533277
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.904472 3.233092 23.091020 27.462191 2.078619 1.527409 -1.184372 -2.249529 0.680958 0.671473 0.408810
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.018339 2.036123 7.578832 23.471885 1.800887 2.445120 0.401124 -1.316279 0.651359 0.657752 0.412568
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.366146 36.067959 -0.408001 5.415360 2.362245 3.888746 6.370677 19.815678 0.703331 0.598385 0.358085
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 35.656074 1.459385 68.113001 0.148058 5.852211 3.329665 7.460282 4.563720 0.045195 0.694480 0.495483
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.699731 9.089347 0.668197 0.259522 2.014571 -0.922956 0.045475 -0.644757 0.718731 0.699744 0.382646
53 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.906893 3.829310 -0.328391 0.209555 -1.325217 -0.534179 1.928732 2.725361 0.723963 0.705683 0.389464
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 16.563423 19.533838 52.964289 55.354501 6.665210 11.292455 3.813055 2.497911 0.049325 0.048832 0.001601
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 3.160747 20.482160 1.538227 54.824602 6.838656 11.093963 4.330843 2.680001 0.710276 0.037974 0.512024
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 0.321621 1.094657 0.239407 -0.056641 1.053822 3.625933 4.707829 13.904629 0.715904 0.700411 0.367036
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 45.515167 1.057018 23.472866 -0.128610 3.614185 0.370998 2.694087 0.666836 0.552278 0.703769 0.367167
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 15.976249 19.236195 52.713924 55.114419 6.678954 11.356949 3.159837 2.522608 0.040410 0.036462 0.002296
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 29.996868 9.280233 4.541576 0.431847 6.393251 3.864548 9.585122 26.936328 0.657359 0.675344 0.364118
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 17.284217 18.841558 52.863759 54.983755 6.609401 11.257394 3.170844 3.409923 0.027737 0.028525 0.001631
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 5.633099 5.576617 3.887161 0.027297 3.102126 2.460561 0.295485 1.012386 0.663050 0.637308 0.381516
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.145316 3.177244 18.730855 25.700238 1.568287 4.163355 0.452793 -1.721922 0.682625 0.674498 0.399229
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 0.909472 19.452807 18.679248 22.950768 -0.395764 11.002620 -0.020858 1.646393 0.664785 0.047863 0.586475
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 3.462096 1.906072 10.832309 21.084326 1.757357 1.839506 8.994982 -1.383462 0.637724 0.638856 0.412990
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.681211 0.933119 0.423416 1.631405 2.374724 1.102544 0.491770 0.145684 0.703658 0.687402 0.402843
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.136978 2.117534 10.817348 6.989893 3.150620 0.462126 -0.244970 0.150579 0.707152 0.693893 0.395996
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.976660 -0.211249 9.997333 7.608080 0.550949 0.314994 0.511353 1.233036 0.710588 0.696383 0.386088
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 3.383737 40.057155 1.681072 73.386632 -0.064361 10.330407 1.253385 7.222649 0.711676 0.035002 0.486098
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 0.546750 -0.959485 -0.269552 0.061268 2.096917 0.856768 0.145737 0.302552 0.715543 0.704800 0.379867
70 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 1.285396 -0.266631 0.998346 1.187122 0.292817 -0.243428 0.327116 0.816023 0.721375 0.709836 0.377882
71 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 10.701472 -0.492969 2.470740 2.008704 1.375613 1.306609 0.412557 -0.212759 0.730110 0.708163 0.374436
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 4.898896 -0.345669 1.726535 1.932205 0.654370 2.040660 6.366242 0.215336 0.712200 0.701910 0.367482
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 15.487626 18.026174 52.022809 53.390171 6.380871 11.078601 3.524969 1.573267 0.027160 0.027165 0.001221
74 N05 digital_maintenance 100.00% 100.00% 0.00% 0.00% 17.155758 15.898536 54.466210 53.039917 7.010444 10.858043 3.345042 18.556090 0.034274 0.330612 0.204320
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 13.003806 19.546483 29.132183 55.563197 10.232414 11.472394 32.130160 2.978468 0.648051 0.049631 0.485386
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 34.893917 36.714032 19.261428 15.232306 3.899965 8.016603 6.624959 3.539827 0.571426 0.510385 0.213985
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 47.958885 0.820108 14.359641 18.637322 5.393010 0.658091 0.328302 -0.973881 0.493983 0.654596 0.373430
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 0.014404 -0.235025 -0.189761 3.596176 1.120506 23.896928 -0.562706 -0.694759 0.683008 0.666858 0.394789
82 N07 RF_maintenance 100.00% 0.00% 100.00% 0.00% 1.734370 19.174987 -0.455855 45.996579 1.223043 11.799648 -0.424284 -0.647021 0.690592 0.064713 0.574837
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.549786 -0.413494 -0.430391 -0.209334 -0.031962 -1.125243 -0.919122 -0.220882 0.704377 0.691491 0.386890
84 N08 digital_ok 100.00% 0.00% 100.00% 0.00% 10.214190 35.708589 7.125877 70.787668 -0.701751 10.333640 -0.587739 3.193241 0.709449 0.045114 0.592581
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.688949 -0.059250 2.949532 3.196698 -1.113679 -0.333134 -0.868712 -1.141438 0.713455 0.695055 0.385800
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 1.836588 12.268084 7.905808 4.539394 7.977294 1.397739 0.138007 11.218281 0.701366 0.656535 0.373220
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.690349 10.549370 3.403475 0.483434 23.654175 1.797422 11.244550 0.679444 0.655752 0.716941 0.368116
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.887891 1.314125 1.108201 1.027296 -0.657508 2.591698 -0.399393 -1.039129 0.712675 0.702631 0.370134
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.495302 0.149263 -0.670587 0.623855 0.250616 0.049900 -0.914215 -1.176551 0.718999 0.701966 0.375818
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.328760 -0.363625 -0.473038 1.262343 -0.561477 -0.471446 -0.148233 0.946799 0.716303 0.699798 0.375091
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.544702 -0.303262 -0.288554 -0.181049 -0.676704 -0.145887 2.124095 -0.242313 0.710295 0.703722 0.388005
92 N10 RF_maintenance 100.00% 0.00% 15.09% 0.00% 55.205000 62.266812 6.379341 7.657935 6.125532 11.406911 0.762869 5.037870 0.299167 0.245974 0.096780
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 3.241403 0.610441 8.537085 -0.673109 4.484825 -0.509237 4.369082 -0.408861 0.701268 0.693305 0.396375
94 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.636775 -1.362867 -0.925788 -1.000826 1.473605 2.222056 1.783555 2.905074 0.702331 0.683124 0.400668
98 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 3.454645 3.818459 -0.184473 -0.425424 0.061234 1.326045 0.881283 1.479273 0.658754 0.661193 0.396546
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 1.135387 -0.673438 0.849006 0.407471 1.643437 4.952964 1.138358 -0.793342 0.683344 0.674134 0.395609
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.669194 -0.923623 -0.343561 2.444428 1.637137 -0.836879 -0.105496 -0.783439 0.697050 0.680750 0.389191
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 10.818989 12.620542 2.310000 2.183906 -0.804088 -1.061984 0.068744 -0.737746 0.717561 0.699375 0.383270
102 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 14.653582 20.310529 51.021148 55.217156 6.461279 11.202053 0.387345 3.185217 0.362833 0.043392 0.288597
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 34.335384 36.595901 60.910417 62.746820 7.068566 11.686982 6.440373 5.752877 0.028862 0.028667 0.002001
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.559069 81.989317 3.731426 50.379098 0.648778 1.627290 -0.495414 -0.724778 0.720919 0.641632 0.412549
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.615000 -0.296897 -0.321061 0.740481 0.316296 -0.470967 -0.362132 -0.866108 0.718582 0.702392 0.370902
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.187350 1.045664 3.866181 2.165692 3.131771 1.599448 -0.241028 -0.521700 0.708596 0.697718 0.374473
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 1.209890 -0.705818 0.817563 3.402132 -0.552530 -1.424453 1.374950 1.292506 0.712731 0.703342 0.376181
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 8.023726 4.332285 43.073639 0.007238 13.307286 0.377427 0.345518 -0.018339 0.543931 0.703664 0.457139
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% -0.086496 19.080512 1.582821 53.417647 -0.722481 11.033231 0.145816 1.212137 0.714823 0.039192 0.494367
110 N10 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.846418 38.124150 -0.349327 71.780815 -0.560294 10.563472 0.094697 3.298841 0.720700 0.036491 0.496976
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 0.252430 18.849808 0.719615 53.991055 -0.307484 10.970986 4.618610 1.428921 0.707643 0.039003 0.490394
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.293681 -0.427347 -0.739739 0.797077 -0.576961 0.823954 1.115385 -0.869293 0.697607 0.685122 0.407036
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.099853 1.051700 -0.831175 -0.220407 0.517207 0.890082 0.852400 -0.371288 0.674668 0.662718 0.396896
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 17.986451 21.231322 53.165985 56.726566 6.815218 11.346878 2.381233 3.778419 0.027838 0.034739 0.005443
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.449557 1.321825 -0.912923 0.104830 1.023489 1.735012 0.587560 0.250083 0.696659 0.686168 0.388153
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.113098 3.239655 3.400842 16.173141 -0.434083 20.981444 1.289662 2.726377 0.708477 0.658511 0.392084
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 3.820244 35.061577 -0.362782 70.584919 0.615650 10.842119 -0.006068 6.379919 0.715241 0.039578 0.602897
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 3.116966 7.519217 0.233627 0.644253 -0.464167 -0.797818 29.602544 12.276202 0.723390 0.704428 0.388509
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 12.332333 10.479645 0.642551 1.205935 3.089217 -0.810267 -0.300847 -1.231161 0.727609 0.708931 0.383508
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 9.246336 12.495589 1.292272 2.090403 -1.294246 0.311605 -0.653473 -0.740637 0.725090 0.709585 0.378827
124 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.634369 0.307030 0.364689 0.198413 -0.713194 -1.267688 -0.138521 -0.573629 0.725200 0.709994 0.382109
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.093349 -0.516318 -0.220810 0.406972 -1.388909 0.709458 -0.719327 -1.080750 0.715932 0.699258 0.377202
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 42.811922 -0.183736 4.468961 1.254652 6.615135 -0.007954 6.147642 -0.643426 0.595674 0.696447 0.364329
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.433679 -0.019965 -0.790634 -0.473706 1.429281 0.013804 1.229852 2.216249 0.716343 0.704045 0.391910
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.749652 9.465198 5.610566 2.756364 -0.130826 2.460565 -0.168283 -0.548119 0.710126 0.679357 0.393710
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.934579 -1.828398 -0.660376 -0.898713 -0.383000 -0.020353 -0.812989 -0.853835 0.709282 0.691991 0.404629
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 1.185023 0.284604 -0.486300 -0.616441 -0.411651 -0.507704 -0.325758 0.873984 0.695131 0.683509 0.402518
135 N12 digital_maintenance 100.00% 0.00% 100.00% 0.00% -1.275219 19.086218 -0.135637 55.290027 0.827240 11.505934 2.725445 3.399228 0.675677 0.044303 0.477625
136 N12 digital_maintenance 100.00% 0.00% 0.00% 0.00% 4.893644 1.562910 0.134007 0.751405 0.360035 0.542015 0.758448 0.033687 0.667187 0.660623 0.392298
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.666296 -1.428109 1.676357 0.363997 3.180965 7.643371 0.934703 0.070672 0.684626 0.667353 0.391858
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.845206 -0.427061 3.847836 5.829987 -1.209945 -0.543290 4.602978 -0.518893 0.700342 0.682017 0.396087
140 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 5.096643 20.142345 37.313760 54.490246 3.745011 11.056388 1.964383 4.617532 0.701989 0.057428 0.498791
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.799513 6.950584 1.762897 40.933152 1.937003 8.389762 4.129493 0.732280 0.712738 0.680876 0.377052
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 1.695785 18.928020 0.862956 54.941099 2.553599 11.395365 4.103666 4.306449 0.709510 0.052821 0.509350
143 N14 digital_ok 100.00% 100.00% 0.00% 0.00% 16.897720 -1.327062 53.520437 -0.952364 6.894722 0.394297 0.445242 -0.749781 0.042716 0.706038 0.516445
144 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.929721 -0.457616 -0.724834 -0.300682 -0.343010 0.012909 -0.564030 -0.097688 0.718784 0.701945 0.384519
145 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.853986 1.929141 -0.501026 22.884550 7.783273 38.605682 0.183482 1.041940 0.716555 0.661232 0.390889
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% 287.815907 287.838744 inf inf 6110.523069 6147.683189 5406.237224 5376.229640 nan nan nan
149 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 300.809746 300.384036 inf inf 6866.187058 6321.928563 5775.960710 5843.024545 nan nan nan
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 17.590918 19.091196 52.925169 54.819144 6.435718 11.136319 1.640045 1.498369 0.026295 0.029100 0.001746
151 N16 not_connected 100.00% 0.00% 0.00% 0.00% 40.128564 2.877280 13.887047 -0.460876 3.419300 3.084040 0.407000 -0.968250 0.539441 0.623410 0.388251
152 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.494376 2.538921 7.684526 12.191822 -0.111101 0.542455 12.730132 -0.796335 0.647186 0.647574 0.420365
153 N16 not_connected 100.00% 100.00% 0.00% 0.00% 17.229298 1.753270 20.899895 11.968171 6.546196 7.018119 0.495489 -1.125720 0.043830 0.641897 0.533647
154 N16 not_connected 100.00% 0.00% 0.00% 0.00% -0.344788 0.172237 20.098008 19.130532 2.433638 0.912481 -0.910086 -1.391924 0.649376 0.642064 0.425665
155 N12 digital_maintenance 100.00% 100.00% 0.00% 0.00% 16.126330 -1.458610 51.081662 -0.581356 6.469344 2.861029 2.650311 3.336692 0.059228 0.664425 0.486533
156 N12 digital_ok 100.00% 14.55% 0.00% 0.00% 13.654817 -0.603476 50.847116 1.388257 5.516948 0.220521 2.369321 1.159869 0.294772 0.672178 0.461303
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.265830 -0.510659 0.119312 0.340081 -0.845126 -0.217346 0.016273 -0.264486 0.689809 0.674727 0.394453
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -1.030825 -0.716124 1.035055 1.620410 3.044469 0.357081 6.147906 16.782018 0.702314 0.685092 0.399210
160 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.691875 -0.965152 2.088392 3.780814 -0.301628 1.195996 2.346388 1.031773 0.710330 0.690221 0.382669
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.409173 41.203578 0.170116 5.430427 -0.063287 4.741923 2.655675 3.365839 0.711812 0.562345 0.350607
162 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 16.818852 0.719522 52.488143 0.488876 6.558275 8.008219 2.380641 3.635721 0.085538 0.697362 0.507335
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.528055 -1.420910 0.857595 -1.017969 -1.550237 -0.156926 -0.383111 -0.157922 0.718063 0.688124 0.389690
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.752084 -0.577662 -0.484000 2.212503 9.900800 0.747843 0.582841 -0.047977 0.714086 0.696687 0.388500
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 26.883530 -0.103654 39.077818 2.778117 3.260047 -1.261973 -0.348627 -1.129149 0.438760 0.696662 0.414211
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 32.074940 10.490988 7.745287 46.236342 11.891905 10.793141 35.485562 -0.774268 0.590350 0.451928 0.345841
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 79.256277 59.023585 10.126006 7.215282 12.015214 10.146537 69.847693 28.735103 0.458684 0.514404 0.184613
168 N15 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.663436 -0.752751 -0.746413 1.489346 0.791909 -0.458184 -0.443861 0.067185 0.710527 0.692785 0.404599
169 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 18.068450 19.199987 52.454389 53.655540 6.231714 11.028509 2.111596 0.811942 0.037418 0.039501 0.001278
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 35.193006 56.163263 3.450403 6.096845 11.832743 8.664190 4.110027 0.592410 0.612097 0.536108 0.276589
171 N16 not_connected 100.00% 0.00% 0.00% 0.00% 2.108443 5.228848 6.648317 0.836164 0.031894 0.916199 -0.491115 -0.106036 0.654676 0.598624 0.400399
173 N16 not_connected 100.00% 100.00% 100.00% 0.00% 19.561121 20.280696 18.781684 20.918137 6.167122 10.931914 2.426180 4.786145 0.037519 0.043585 0.006327
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.584176 -0.294205 -0.698753 -0.719443 0.724756 0.774566 2.216063 8.580348 0.679349 0.661392 0.406214
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% -1.367553 -0.997411 0.672267 1.755457 -0.142772 0.672277 1.525127 2.479727 0.689151 0.671302 0.405808
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 4.238360 -0.925716 0.903119 -0.107015 0.271831 2.545053 4.650215 1.689665 0.684906 0.673225 0.400677
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 17.944624 20.631269 53.898491 57.624579 7.158352 11.513215 3.827880 3.829434 0.052724 0.075891 0.020222
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -1.099602 19.935825 -0.972845 55.632427 3.051884 11.491233 3.536409 4.869662 0.707623 0.057390 0.517802
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.134150 -0.945086 0.403816 -0.971637 -0.057335 1.312871 2.161133 5.184145 0.717351 0.689028 0.388291
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.851786 5.423910 31.599942 37.529161 0.674482 7.326310 7.202596 6.196894 0.654267 0.684482 0.399253
183 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 17.223293 -0.144885 52.127494 0.690999 6.542939 1.690191 3.280711 2.392643 0.044440 0.686791 0.484632
184 N14 digital_ok 100.00% 47.48% 100.00% 0.00% 15.064759 19.556029 51.995303 54.969173 3.699167 10.983264 0.158838 0.105934 0.246985 0.046418 0.168989
185 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 306.132270 306.253243 inf inf 6810.528298 6723.313547 5072.227069 5084.450583 nan nan nan
186 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 320.858226 320.338423 inf inf 6744.746036 6401.923922 6439.348792 5957.544131 nan nan nan
187 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 354.856205 354.766992 inf inf 7997.254194 7996.585356 8275.571702 8273.377864 nan nan nan
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 1.785330 2.019336 1.954065 -0.322593 0.199584 2.997033 16.269730 16.944038 0.694566 0.677077 0.404922
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 79.959115 19.246262 10.891501 55.456298 10.607576 11.411953 28.894805 1.570876 0.454655 0.036474 0.322483
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 0.326112 0.895145 0.682998 4.023174 -0.249605 -1.077844 13.016656 4.508930 0.687331 0.669880 0.414191
192 N16 not_connected 100.00% 0.00% 0.00% 0.00% 4.018885 9.571943 36.135595 45.908519 4.438758 10.632756 -1.525802 -3.598272 0.673110 0.632026 0.420068
193 N16 not_connected 100.00% 0.00% 0.00% 0.00% 9.374343 1.730649 45.594071 27.963016 5.787089 2.271993 -3.246953 -1.173621 0.640321 0.652963 0.433632
200 N18 RF_maintenance 100.00% 100.00% 55.96% 0.00% 18.951152 51.502248 21.023741 21.382744 6.183698 11.158294 1.094889 5.395369 0.051277 0.207490 0.131253
201 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 9.689942 8.323878 45.520232 43.165272 5.756438 9.316385 -3.201428 -3.310082 0.671559 0.649914 0.388395
202 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 2.275584 4.894793 22.115013 1.340330 1.025273 4.119896 0.139991 1.656152 0.698303 0.632545 0.398803
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% 19.724305 21.700891 19.734639 21.494514 6.325541 11.001164 1.825538 2.021072 0.036247 0.047532 0.004606
219 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 9.438582 5.940650 46.281449 38.477686 6.070751 6.657779 -3.213484 -2.836308 0.646062 0.661054 0.409724
220 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 5.440213 6.406320 38.012869 38.318358 3.730776 6.806158 -1.379092 -2.855951 0.696608 0.664382 0.399732
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 6.135271 1.963345 2.340039 17.379634 3.353772 0.307267 1.469946 -0.875771 0.654521 0.660596 0.403986
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 6.572689 7.020090 39.554380 38.674074 4.825756 7.189310 -0.551718 -2.896702 0.685506 0.660759 0.403564
237 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 4.913495 3.399232 1.215652 12.762209 3.307453 2.049503 -0.193561 -0.916805 0.642816 0.639473 0.408237
238 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 1.170082 0.757192 24.456753 23.355780 1.901557 4.826864 -1.293446 -1.723449 0.694005 0.660100 0.405924
239 N18 RF_ok 100.00% 0.00% 0.00% 0.00% 0.949703 4.495498 17.117600 1.458390 0.033750 3.917245 3.476552 12.384174 0.684458 0.611356 0.416832
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 0.987489 19.951147 -0.605065 34.722352 0.528977 11.015616 5.444510 1.929721 0.690086 0.052458 0.524398
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 1.325638 1.474098 15.367033 17.442715 2.605771 2.165662 2.975244 1.314950 0.614557 0.588078 0.413766
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 2.670269 3.819596 18.891665 30.695309 1.932674 5.167513 2.112695 0.322284 0.608516 0.581907 0.407160
323 N02 not_connected 100.00% 0.00% 0.00% 0.00% 35.482773 2.547603 3.346241 27.953407 3.574170 3.901628 3.852915 -1.073574 0.395136 0.574854 0.367666
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 2.109155 3.907365 24.082115 28.140893 1.187744 3.666205 1.171317 -0.861062 0.607512 0.577090 0.397072
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 1.050616 -0.343415 24.879488 12.439317 1.270117 0.370468 -1.257183 -0.783970 0.638876 0.589714 0.404984
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 7.183015 0.188780 -0.025448 17.869104 2.358153 2.938962 8.194462 4.545856 0.538806 0.583887 0.407720
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 6.613378 2.715564 -0.103083 11.306568 2.154465 2.983438 3.730647 2.429664 0.549157 0.568424 0.401154
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 4, 7, 8, 18, 19, 20, 22, 27, 28, 30, 31, 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, 92, 93, 99, 101, 102, 103, 104, 108, 109, 110, 111, 117, 119, 120, 121, 122, 123, 126, 128, 135, 136, 137, 138, 140, 141, 142, 143, 145, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 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, 9, 10, 15, 16, 17, 21, 29, 40, 41, 42, 53, 65, 69, 70, 83, 85, 88, 89, 90, 91, 94, 98, 100, 105, 106, 107, 112, 116, 118, 124, 125, 127, 129, 130, 144, 157, 160, 163, 168, 177]

golden_ants: [5, 9, 10, 15, 16, 17, 21, 29, 40, 41, 42, 53, 65, 69, 70, 83, 85, 88, 91, 94, 98, 100, 105, 106, 107, 112, 116, 118, 124, 127, 129, 130, 144, 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_2459866.csv
In [24]:
# Load antenna positions
data_list = sorted(glob.glob(os.path.join(data_path, f'zen.{JD}.?????.sum.uvh5')))
hd = io.HERAData(data_list[len(data_list) // 2])

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Metadata¶

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