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 = "2460011"
data_path = "/mnt/sn1/2460011"
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: 3-7-2023
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/2460011/zen.2460011.21269.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 1852 ant_metrics files matching glob /mnt/sn1/2460011/zen.2460011.?????.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/2460011/zen.2460011.?????.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 2460011
Date 3-7-2023
LST Range 5.542 -- 15.510 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1852
Total Number of Antennas 198
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 10
dish_ok: 1
RF_maintenance: 50
RF_ok: 19
digital_ok: 93
not_connected: 25
Commanded Signal Source None
Antennas in Commanded State (reported) 0 / 198 (0.0%)
Antennas in Commanded State (observed) 0 / 198 (0.0%)
Cross-Polarized Antennas 66
Total Number of Nodes 19
Nodes Registering 0s N02, N04, N08, N11, N15, N20
Nodes Not Correlating
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 106 / 198 (53.5%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 167 / 198 (84.3%)
Redcal Done? ❌
Never Flagged Antennas 31 / 198 (15.7%)
A Priori Good Antennas Flagged 79 / 93 total a priori good antennas:
3, 5, 7, 9, 10, 15, 16, 17, 19, 20, 21, 29,
30, 31, 37, 38, 40, 41, 42, 45, 53, 54, 55,
56, 65, 66, 67, 69, 70, 71, 72, 81, 85, 86,
93, 94, 101, 103, 106, 107, 109, 111, 112,
121, 122, 123, 124, 127, 128, 136, 140, 144,
145, 147, 148, 149, 150, 151, 158, 160, 161,
162, 164, 165, 167, 168, 169, 170, 173, 181,
182, 184, 187, 189, 190, 191, 192, 193, 202
A Priori Bad Antennas Not Flagged 17 / 105 total a priori bad antennas:
35, 43, 46, 49, 50, 64, 74, 82, 89, 137, 139,
220, 237, 238, 239, 241, 333
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_2460011.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% 100.00% 0.00% 13.762229 15.658167 -0.361735 15.327583 10.510953 15.890223 0.595657 2.235214 0.313183 0.040477 0.246153
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.760046 7.500685 2.552636 3.196337 6.134378 8.895138 -1.308917 -1.856430 0.291480 0.295054 0.131849
5 N01 digital_ok 100.00% 100.00% 100.00% 0.00% 12.567267 15.437908 14.469671 14.944384 13.556882 16.078114 1.188661 0.927857 0.041633 0.036382 0.002764
7 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 238.552474 238.356908 inf inf 5283.494519 5297.776291 10408.780613 10469.773824 nan nan nan
8 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 243.452748 243.301737 inf inf 4199.305220 4244.124215 7055.337169 7278.887047 nan nan nan
9 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
10 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
15 N01 digital_ok 100.00% 7.40% 30.35% 0.00% 35.134543 34.503089 3.889784 4.877483 6.430597 5.574844 5.047892 5.657558 0.264203 0.234159 0.108983
16 N01 digital_ok 100.00% 100.00% 100.00% 0.00% 12.269621 15.589994 14.355232 15.282769 13.000102 15.818319 1.515739 1.521184 0.079032 0.034785 0.026940
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.937989 7.713855 0.730487 13.614943 1.131000 6.446114 0.398067 3.491702 0.572440 0.341572 0.437020
18 N01 RF_maintenance 100.00% 100.00% 0.00% 0.00% 12.772999 8.707106 14.513651 0.577991 13.501062 6.213203 1.447148 57.829174 0.036333 0.353788 0.279893
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
20 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 231.720824 231.712148 inf inf 5307.797796 5228.739270 10536.546416 10301.179798 nan nan nan
21 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
22 N06 not_connected 100.00% 0.00% 0.00% 0.00% -0.708703 -0.172075 -0.142580 -0.567203 1.187708 6.361116 -0.214727 -0.979002 0.544187 0.552779 0.348875
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 11.335149 14.623823 14.585936 15.064884 13.448213 16.045572 3.305630 2.795375 0.030679 0.033083 0.000612
28 N01 RF_maintenance 100.00% 100.00% 91.31% 0.00% 11.821106 29.017285 14.262077 4.395259 13.494841 7.050133 0.975386 26.897379 0.029211 0.140141 0.095998
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.875593 -0.324542 3.451029 0.491017 -0.199988 2.170241 5.532759 1.965434 0.563248 0.579659 0.363760
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 0.755052 -0.465765 0.342181 -1.956483 13.967794 -0.249232 3.206404 -0.259023 0.576984 0.597614 0.375321
31 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 199.872852 199.707318 inf inf 4092.358853 4007.462471 7878.135586 7569.957868 nan nan nan
32 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
34 N06 not_connected 100.00% 100.00% 100.00% 0.00% 13.748288 16.334222 7.170082 7.497576 13.344121 15.925464 1.662270 1.218655 0.035391 0.046789 0.008037
35 N06 not_connected 0.00% 0.00% 0.00% 0.00% 0.996108 -0.851401 1.496028 -1.407054 1.274221 -1.648183 -2.147571 -0.805824 0.557612 0.555875 0.343467
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.423899 8.795114 1.179919 0.680645 3.079052 3.790193 0.336763 1.021857 0.563633 0.567067 0.376839
37 N03 digital_ok 100.00% 0.00% 100.00% 0.00% -0.072559 27.362850 -0.956774 18.981429 0.528268 16.040400 -0.649210 5.086146 0.577647 0.032112 0.444902
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.894880 0.285499 -1.973098 3.626209 -0.514629 -0.656463 3.695974 15.906928 0.579937 0.563183 0.371472
40 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
41 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
42 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
43 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.410225 -0.037455 -1.293675 0.556651 -0.805273 2.105800 -0.900255 0.607231 0.593053 0.597266 0.368352
44 N05 digital_ok 0.00% 0.00% 0.00% 0.00% -1.501589 0.318341 -1.125737 -0.811241 -0.920547 0.600161 -0.906751 -0.537964 0.598380 0.608808 0.366152
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 0.744725 5.392045 0.576476 0.462835 -0.257067 6.476406 0.797765 10.926092 0.588423 0.590259 0.351378
46 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.874364 -0.570346 -0.809434 -1.227347 -0.681473 -1.301953 0.077168 -0.777561 0.589900 0.609058 0.363537
47 N06 not_connected 100.00% 100.00% 100.00% 0.00% 12.670249 15.976399 7.034995 6.978045 13.323485 15.803823 3.633582 0.859801 0.031831 0.055265 0.016774
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 0.583132 1.419286 -0.550002 1.981599 -1.516517 4.673606 -0.795635 -2.246321 0.556694 0.577034 0.349334
49 N06 not_connected 0.00% 0.00% 0.00% 0.00% -0.260992 -0.091766 -0.027486 -0.385621 -0.574581 -0.710068 0.105853 2.352533 0.518835 0.557451 0.349078
50 N03 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.459813 1.232759 -0.040192 2.024035 -0.332959 2.767245 0.040791 -0.143885 0.566460 0.566134 0.373175
51 N03 dish_maintenance 100.00% 0.00% 0.00% 0.00% 3.378137 1.598410 -0.318380 -0.413058 3.073921 4.495495 85.620513 2.196587 0.574919 0.580970 0.369357
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.766365 6.518540 0.207470 -0.188190 3.072988 2.585930 3.474724 0.737159 0.581547 0.590474 0.367839
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.605513 2.033361 -0.734102 -0.265066 3.660216 0.773657 12.488092 11.241018 0.583093 0.594795 0.374629
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
55 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
56 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
57 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
58 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 11.272365 14.989398 14.432210 15.213143 13.230495 15.836341 2.117099 1.573466 0.038629 0.038184 0.002795
59 N05 RF_maintenance 100.00% 100.00% 0.00% 0.00% 12.318612 0.595189 13.804629 0.208768 12.945360 6.112983 0.849502 3.572869 0.049579 0.608842 0.486511
60 N05 RF_maintenance 100.00% 0.92% 100.00% 0.00% 0.517455 14.891704 -0.334255 15.257099 19.488829 15.857849 4.250996 3.397269 0.583200 0.076465 0.478640
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 2.718858 -0.063128 0.374757 -1.917269 5.217799 -1.853279 0.260836 1.426082 0.536163 0.577411 0.346137
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 0.262724 1.499298 -0.530915 1.458714 4.649694 0.636662 1.560720 -1.280094 0.537513 0.579691 0.351439
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 1.963049 15.498758 -0.899803 7.544129 0.957828 16.071305 -0.371915 3.511126 0.544985 0.046879 0.424305
64 N06 not_connected 0.00% 0.00% 0.00% 0.00% 0.019707 -0.098690 -1.308561 -1.178651 1.011227 -0.361483 1.223132 1.211418 0.536309 0.537002 0.341012
65 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 26.543196 24.725632 18.658014 18.613437 13.740578 16.210966 6.037885 7.499853 0.022770 0.028630 0.006293
66 N03 digital_ok 100.00% 0.00% 0.00% 100.00% 0.616255 0.039224 -1.938024 5.823270 2.922218 0.988799 -0.265985 1.594514 0.211702 0.193853 -0.281364
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.623153 0.501673 -1.428653 1.719985 -0.294435 2.112303 7.698851 2.230252 0.586826 0.581785 0.363200
68 N03 dish_maintenance 100.00% 100.00% 0.00% 0.00% 28.441808 0.961736 18.810359 1.285416 13.312501 -0.470758 7.239848 -0.942888 0.034828 0.595736 0.466809
69 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
70 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
71 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
72 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
73 N05 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.388941 1.030604 -1.886159 -0.252712 2.168336 7.089166 0.028812 -0.077674 0.613950 0.621734 0.357175
74 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.893261 0.000327 -0.232350 -1.061868 -0.667508 2.257342 -1.207976 2.460746 0.616026 0.627873 0.352932
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 57.584179 20.464664 0.706280 -0.634297 8.032099 2.831852 3.844834 0.104127 0.316714 0.489572 0.288748
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 29.406095 1.243843 -0.703949 1.736691 3.166819 2.280510 2.711680 0.313560 0.403557 0.580337 0.344708
79 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
80 N11 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% 100.00% 0.00% -0.822453 15.881623 0.191242 13.377499 0.591149 15.681560 0.679097 2.689978 0.538136 0.040879 0.411109
82 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 3.235730 0.859131 -1.287460 -0.302196 -0.175511 0.024967 -0.110946 -0.538971 0.571661 0.580566 0.367992
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.294749 -0.172432 0.427767 0.547464 0.655269 0.023444 -0.152431 0.587078 0.575208 0.577373 0.360128
84 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
85 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
86 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
87 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
88 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.291666 1.198886 0.573242 1.331127 0.125945 -0.086396 0.297516 0.086343 0.598361 0.611757 0.349536
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.796796 0.445268 0.506794 1.083601 -0.401821 0.512194 -0.264550 -0.168543 0.608552 0.622827 0.347617
90 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.252594 -0.361491 -0.033874 -1.543498 15.310026 20.380791 1.075436 4.716339 0.610732 0.632265 0.345844
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.741456 -0.251375 0.813705 0.447856 -0.011290 -0.352644 0.311040 0.025444 0.596084 0.621370 0.343459
92 N10 RF_maintenance 100.00% 100.00% 0.00% 0.00% 11.875173 0.095193 14.442029 0.026565 13.559771 3.794683 0.928530 1.137715 0.036820 0.619933 0.404212
93 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 12.214121 15.213806 14.600897 15.346447 13.159103 15.758880 3.463832 2.696231 0.031531 0.024958 0.003106
94 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 13.052661 15.477190 14.776028 15.079683 13.312039 15.886214 4.169020 1.305733 0.025276 0.025431 0.001239
95 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
96 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
97 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
101 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
102 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
104 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.359218 0.284422 0.161319 1.241450 2.635956 0.071216 0.114682 -0.217240 0.606213 0.617173 0.349954
106 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 0.642716 1.332423 0.786769 -0.496833 26.918030 -0.838760 1.296698 -0.068893 0.607600 0.629350 0.344493
107 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 3.062062 1.949912 0.077563 -0.854349 1.643541 -0.016198 10.580533 6.437548 0.615762 0.636664 0.337772
108 N09 RF_maintenance 100.00% 100.00% 0.00% 0.00% 11.966306 43.918599 14.499333 1.260022 13.361749 6.567569 2.639359 5.309213 0.036155 0.307344 0.169475
109 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 11.687725 15.024185 14.556766 14.910564 13.516470 16.049356 1.097869 2.492858 0.058890 0.035770 0.014268
110 N10 RF_maintenance 100.00% 0.00% 0.00% 0.00% 19.533062 11.217625 8.314730 -0.393356 10.753979 -0.423341 1.906762 -0.308923 0.503134 0.575360 0.316664
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 29.733152 14.919263 1.389425 15.033005 7.081074 16.042275 14.169607 3.007048 0.472900 0.061712 0.325031
112 N10 digital_ok 100.00% 70.95% 99.84% 0.16% 2.633536 14.504097 10.083010 15.120330 0.617660 15.554099 0.488658 1.177277 0.178432 0.068060 -0.107195
113 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
114 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
115 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
117 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 12.813418 16.700492 14.639360 15.691182 13.002244 15.713684 1.951933 4.738224 0.028573 0.032874 0.002820
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.730073 1.313109 0.210980 0.613636 -0.211007 0.604059 1.481293 1.351280 0.575295 0.586485 0.364337
120 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
121 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
122 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
123 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
124 N09 digital_ok 100.00% 100.00% 0.00% 0.00% 12.055543 0.519337 14.847876 0.712452 13.072494 1.341124 1.212333 1.002162 0.044950 0.630666 0.453772
125 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.381141 -0.187759 0.856269 1.341256 3.471997 0.473313 2.058442 1.191598 0.620241 0.631584 0.338385
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 16.827529 7.255860 -0.119551 1.901636 10.737187 1.410132 21.423223 1.646173 0.560496 0.633764 0.337660
127 N10 digital_ok 100.00% 100.00% 0.00% 0.00% 11.524467 0.360713 14.427314 0.865710 13.519940 2.360931 0.870229 3.696552 0.035101 0.629408 0.405912
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 0.180852 -0.409823 -1.719423 -0.142735 -0.554200 -0.168276 1.389276 6.666393 0.606867 0.616096 0.358315
131 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
132 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
133 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
134 N11 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
135 N12 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.029512 -1.232749 -1.792409 -1.703238 3.289400 -0.391099 4.457028 0.605723 0.543030 0.568746 0.376079
136 N12 digital_ok 100.00% 100.00% 0.00% 0.00% 10.893576 0.405338 14.014249 -1.276142 13.514940 0.324917 2.267179 0.512638 0.042301 0.568992 0.403684
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.555242 -0.317489 -0.021381 -1.924609 2.947531 -1.336915 0.979829 1.570817 0.562958 0.585568 0.366105
139 N13 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.627420 1.563619 1.582888 -1.330092 1.786612 -0.307521 -1.646835 -0.190701 0.582139 0.579308 0.354157
140 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.551213 -1.155198 -0.877653 -0.475764 -0.420364 0.091451 4.484615 5.000467 0.595450 0.612763 0.357353
141 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.865680 -0.305261 -0.551698 0.663601 2.940193 0.559006 0.651630 -1.602039 0.601529 0.620285 0.354536
142 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.837499 15.015946 -1.212796 15.267489 4.235617 15.939945 26.224172 2.536847 0.611826 0.049516 0.483409
143 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 12.830681 14.959350 14.299210 15.230374 12.154231 15.961528 0.920318 2.169333 0.104476 0.030817 0.056751
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.468416 3.419604 -1.476803 11.377357 -0.162840 1.052257 -0.389005 1.058141 0.631523 0.520929 0.382747
145 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 0.177206 -0.186176 2.718754 0.171372 1.031596 16.177954 0.531426 -0.723215 0.622406 0.644331 0.343707
146 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.055040 -0.274679 -1.490794 -0.839113 -0.546580 -1.894870 -0.297885 -0.697352 0.597882 0.617996 0.341589
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 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
149 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 262.769378 262.522707 inf inf 5766.398060 5764.667099 11842.261321 11833.658981 nan nan nan
150 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
151 N16 digital_ok 100.00% 0.00% 0.00% 0.00% 20.829692 0.788704 -0.545225 0.525980 4.232477 -0.292086 2.546178 0.129541 0.432721 0.516134 0.334657
155 N12 RF_maintenance 100.00% 100.00% 0.00% 0.00% 11.395831 -0.820177 14.228380 -1.694987 13.569749 -0.222618 3.212138 0.845350 0.043149 0.570567 0.416165
156 N12 RF_maintenance 100.00% 0.00% 100.00% 0.00% 4.769644 14.807534 12.177981 14.974035 6.830977 16.109800 2.247167 2.941230 0.383125 0.041604 0.283968
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.929566 -0.000327 0.117678 0.643974 0.529953 2.264074 0.066021 -0.086317 0.567358 0.586512 0.369103
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.583366 -0.501493 -0.503396 -0.721672 4.602279 4.528075 6.391637 23.169819 0.580993 0.600860 0.369515
159 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.797071 27.514614 -1.579922 -0.875800 -0.173763 3.785980 0.433925 3.178118 0.556628 0.457325 0.319559
160 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.122146 -1.075835 -0.512411 -1.371580 -0.012024 3.302110 -0.212256 0.602980 0.596344 0.618007 0.357105
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.045104 32.278314 0.108334 -0.511003 1.350221 1.620070 0.068283 0.598891 0.607027 0.502778 0.315252
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.346001 -1.363310 0.024361 -1.190140 2.695779 1.098761 4.682252 -0.278857 0.622949 0.640560 0.347340
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.679872 1.738516 -0.108189 0.362595 0.639175 1.875962 0.076797 1.838829 0.631175 0.644515 0.345631
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.052302 0.424050 0.501962 1.474103 12.095821 4.878589 0.487351 2.077949 0.629813 0.636338 0.335831
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 28.509084 0.285080 -0.250632 -1.299932 4.319132 0.283522 2.108272 -0.032449 0.500284 0.639547 0.332085
166 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -1.042593 0.403270 1.047020 0.897081 0.474296 0.645385 0.278558 -1.713547 0.618825 0.631230 0.335317
167 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
168 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
169 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
170 N15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
171 N16 digital_ok 0.00% 0.00% 0.00% 0.00% 0.845237 1.594763 -1.278782 0.324869 -1.590570 0.815401 -0.103395 0.563102 0.518796 0.512851 0.348673
173 N16 digital_ok 100.00% 100.00% 100.00% 0.00% 14.210938 15.667696 6.332067 7.035993 13.605275 16.116769 4.228158 7.466068 0.037684 0.044233 0.004517
179 N12 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.149710 -1.174321 -0.731009 -1.867842 4.323204 13.076769 -0.157748 1.342961 0.572159 0.603070 0.368910
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -0.033605 15.716819 -1.974218 15.441394 1.728016 15.764820 22.719977 3.232038 0.600511 0.058617 0.482492
181 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 1.288049 0.366576 1.424595 0.786640 0.353495 -0.804857 0.235391 6.871764 0.608243 0.624190 0.357171
182 N13 digital_ok 100.00% 0.00% 100.00% 0.00% -0.109760 14.756647 0.237551 14.894403 6.550481 16.101765 6.719311 2.823063 0.623201 0.053145 0.464160
183 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.077323 1.160485 -0.713601 0.127135 3.035375 -0.321341 0.361048 -0.025444 0.618151 0.632801 0.333522
184 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 23.276759 -0.309762 9.469507 -1.890413 14.948254 2.023900 13.544462 -0.285934 0.450396 0.641655 0.356081
185 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.435180 0.681375 4.625718 1.591616 8.064188 2.449025 -2.109868 -1.083849 0.598235 0.635845 0.348148
186 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.807518 -0.592215 0.441290 -0.446700 -0.779459 0.080102 -0.854818 -1.093140 0.627243 0.633897 0.345851
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 2.364385 -0.247592 1.537915 0.008216 54.418877 1.091225 13.085341 -0.549927 0.592741 0.617122 0.351513
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 digital_ok 100.00% 0.00% 0.00% 0.00% 3.768425 6.986265 3.694917 5.609194 3.259415 13.137002 -1.376749 -3.806382 0.521142 0.504050 0.363806
193 N16 digital_ok 100.00% 0.00% 0.00% 0.00% 7.435939 1.207305 5.729109 1.757072 10.895575 4.452881 -3.808314 -0.070909 0.493333 0.532872 0.379970
200 N18 RF_maintenance 100.00% 100.00% 46.65% 0.00% 13.727623 40.210898 6.890611 -0.130602 13.566892 5.760855 2.463019 11.017816 0.043358 0.229982 0.147346
201 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.396438 5.157529 3.591553 4.827588 5.854797 11.043593 -1.261623 -3.163434 0.589068 0.591214 0.341270
202 N18 digital_ok 100.00% 0.00% 0.00% 0.00% 0.650522 0.552024 1.654019 -1.667344 2.431098 0.728950 -1.011438 60.822202 0.609084 0.608530 0.335825
204 N19 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.533821 14.982535 1.871330 -1.406044 0.318607 0.492208 23.478389 1.919856 0.617806 0.634052 0.345334
205 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 9.541534 0.212588 4.758439 -0.793340 7.910881 -1.195284 70.312792 4.058176 0.391089 0.608601 0.412774
206 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 0.536022 6.205030 -0.198219 3.615931 5.846941 4.562714 0.296871 0.761988 0.555903 0.491686 0.341067
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -0.669884 0.506802 -1.124879 -1.763870 -1.577747 11.974447 8.469683 -0.006611 0.573887 0.570882 0.346425
208 N20 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
209 N20 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
210 N20 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
211 N20 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
220 N18 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.959338 -1.089869 0.343963 -0.701305 -0.502513 1.210988 3.068948 -1.273613 0.595135 0.596463 0.339847
221 N18 RF_ok 100.00% 0.00% 0.00% 0.00% -0.229427 -0.447682 -0.684260 -1.043160 12.343925 -0.902694 6.739104 -0.668883 0.590985 0.606284 0.340327
222 N18 RF_ok 100.00% 0.00% 0.00% 0.00% -0.201560 -0.047741 -0.306483 0.018150 -0.257755 0.114677 4.933863 -1.116589 0.597906 0.611364 0.342120
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -1.218971 -1.317730 -1.701449 -0.341322 -1.759015 24.722641 0.963285 15.738501 0.587245 0.573164 0.338539
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 7.641302 6.317290 5.968519 5.469764 11.235052 12.616028 -3.703141 -3.234663 0.553750 0.571750 0.342800
225 N19 RF_ok 100.00% 0.00% 87.53% 0.00% -0.161415 14.975919 0.847489 7.221505 -0.884636 15.408933 -1.359581 2.297698 0.582752 0.144499 0.478471
226 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -0.325519 19.942313 -0.881137 0.729375 -1.764584 6.700996 -0.696880 -0.406265 0.559940 0.488975 0.340289
227 N20 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
228 N20 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
229 N20 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
237 N18 RF_ok 0.00% 0.00% 0.00% 0.00% 2.266495 -0.555380 0.051469 -1.801445 -0.702921 -0.943210 0.147103 -0.804597 0.532263 0.574756 0.357084
238 N18 RF_ok 0.00% 0.00% 0.00% 0.00% 0.095880 -0.286097 0.929314 0.685380 -0.119448 -1.194463 -1.599519 -1.992138 0.584280 0.591654 0.350429
239 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -1.228121 -0.669110 -0.417927 0.021381 0.011290 1.617366 -0.045849 1.908119 0.587263 0.594110 0.349816
240 N19 RF_maintenance 100.00% 0.00% 0.00% 0.00% 3.211470 -0.107888 -1.185502 -0.544796 18.587594 -1.173076 7.560288 4.427351 0.536913 0.589693 0.364308
241 N19 RF_ok 0.00% 0.00% 0.00% 0.00% 0.073138 -1.123146 -0.628379 0.146858 -1.451509 0.064331 1.325772 -1.285125 0.570912 0.590013 0.362711
242 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 23.432230 0.783188 -0.507970 1.433489 3.564755 2.923098 -0.740613 -0.509184 0.439540 0.578248 0.363284
243 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 15.577355 -1.109976 1.453064 -1.948931 7.994876 -0.600949 20.339347 -0.047541 0.476584 0.555853 0.366043
244 N20 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
245 N20 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
246 N20 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
261 N20 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
262 N20 dish_maintenance 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% 0.00% 0.00% 4.017159 1.575167 2.974086 1.557714 2.873765 1.926422 -1.095561 0.634678 0.465204 0.476993 0.356267
324 N04 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
325 N09 dish_ok 100.00% 0.00% 0.00% 0.00% 1.557660 -0.700159 1.202077 -1.720998 1.354055 12.406028 -1.401047 3.617319 0.478713 0.473237 0.353565
329 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 1.917796 0.091975 -0.480495 -1.247065 30.743282 -1.658258 3.906272 1.423435 0.442907 0.463060 0.343185
333 N12 dish_maintenance 0.00% 0.00% 0.00% 0.00% 3.383476 1.297865 -1.266680 -1.934321 -1.555381 -1.603304 1.337117 1.096582 0.432351 0.454833 0.334088
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, 5, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 27, 28, 29, 30, 31, 32, 34, 36, 37, 38, 40, 41, 42, 45, 47, 48, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 77, 78, 79, 80, 81, 84, 85, 86, 87, 90, 92, 93, 94, 95, 96, 97, 101, 102, 103, 104, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 117, 120, 121, 122, 123, 124, 125, 126, 127, 128, 131, 132, 133, 134, 135, 136, 140, 142, 143, 144, 145, 147, 148, 149, 150, 151, 155, 156, 158, 159, 160, 161, 162, 164, 165, 167, 168, 169, 170, 173, 179, 180, 181, 182, 184, 185, 187, 189, 190, 191, 192, 193, 200, 201, 202, 204, 205, 206, 207, 208, 209, 210, 211, 221, 222, 223, 224, 225, 226, 227, 228, 229, 240, 242, 243, 244, 245, 246, 261, 262, 320, 324, 325, 329]

unflagged_ants: [35, 43, 44, 46, 49, 50, 64, 74, 82, 83, 88, 89, 91, 105, 118, 137, 139, 141, 146, 157, 163, 166, 171, 183, 186, 220, 237, 238, 239, 241, 333]

golden_ants: [44, 83, 88, 91, 105, 118, 141, 146, 157, 163, 166, 171, 183, 186]
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_2460011.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.5.dev13+gd6c757c
3.2.3.dev121+gc95c57f
In [ ]: