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 = "2460046"
data_path = "/mnt/sn1/2460046"
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: 4-11-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/2460046/zen.2460046.42140.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 360 ant_metrics files matching glob /mnt/sn1/2460046/zen.2460046.?????.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/2460046/zen.2460046.?????.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 'startTime' 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 2460046
Date 4-11-2023
LST Range 12.865 -- 14.800 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 360
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 42, 112
Total Number of Nodes 19
Nodes Registering 0s N15
Nodes Not Correlating N07
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 93 / 198 (47.0%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 130 / 198 (65.7%)
Redcal Done? ❌
Never Flagged Antennas 68 / 198 (34.3%)
A Priori Good Antennas Flagged 63 / 93 total a priori good antennas:
7, 9, 10, 15, 17, 19, 20, 31, 37, 38, 40, 42,
45, 53, 54, 55, 56, 65, 66, 69, 70, 71, 72,
81, 83, 86, 93, 94, 101, 103, 106, 109, 111,
112, 118, 121, 122, 124, 127, 136, 145, 147,
148, 149, 150, 151, 158, 160, 161, 163, 164,
165, 167, 168, 169, 170, 182, 184, 189, 190,
191, 193, 202
A Priori Bad Antennas Not Flagged 38 / 105 total a priori bad antennas:
22, 35, 43, 46, 48, 49, 50, 57, 61, 62, 73,
74, 80, 89, 90, 95, 108, 115, 132, 133, 135,
139, 185, 201, 206, 220, 221, 222, 228, 229,
240, 241, 244, 245, 324, 325, 329, 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_2460046.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
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% -1.177249 14.245131 -0.994369 -0.528602 -0.698759 0.254738 -0.984163 -0.233456 0.644854 0.530203 0.441711
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.457701 0.667302 0.451169 3.714706 0.560484 0.557547 -0.396671 0.943460 0.647309 0.631696 0.447537
7 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
8 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan 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% 0.00% 0.00% 0.00% 13.782819 -0.402998 -0.489450 -0.490101 -0.214174 0.361446 -0.173819 2.436076 0.533025 0.651487 0.421585
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.385399 1.569575 0.712359 1.394826 -0.392782 0.315739 -1.589134 -1.833909 0.651126 0.640660 0.435918
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.030407 3.224355 1.216013 9.936206 1.115347 -0.307538 -0.018857 4.954351 0.646128 0.502766 0.472292
18 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
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% 110.329204 111.113048 inf inf 2894.570298 2929.510863 4250.072695 4448.353127 nan nan nan
21 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 0.408009 0.413597 0.108473 0.439718 -0.363287 0.269913 0.676215 0.521412 0.647153 0.641695 0.427354
22 N06 not_connected 0.00% 0.00% 0.00% 0.00% -1.245563 -1.043449 -0.712588 -0.619592 0.413200 0.029044 -0.559309 -0.141077 0.620895 0.628502 0.429177
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
28 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.873257 -0.268993 -0.048978 0.215143 0.000362 0.388490 1.374063 0.959899 0.678006 0.660295 0.435615
30 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.235450 -0.877316 0.537477 -0.636204 0.592234 0.290493 3.507109 0.179155 0.669729 0.664251 0.427633
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 0.685369 0.000885 1.295695 3.954662 1.530514 0.944193 0.426579 18.851859 0.679470 0.651301 0.437152
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 15.072521 16.137714 -0.042757 0.072478 -0.037189 1.110587 2.018435 5.303080 0.570594 0.579998 0.225459
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 8.593495 -0.484899 6.367977 -0.590245 2.693146 -0.867385 0.601269 0.257177 0.043061 0.640408 0.486644
35 N06 not_connected 0.00% 0.00% 0.00% 0.00% -0.252784 -0.830999 -0.048060 -0.486823 -1.068221 -0.645773 -0.561971 -0.026437 0.636451 0.629489 0.427329
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.703342 4.906856 1.282177 1.050363 1.577604 2.862171 0.059152 0.912761 0.639193 0.636486 0.450784
37 N03 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
38 N03 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
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 0.00% 0.00% 0.00% 0.00% 0.474598 0.796897 1.404847 3.461805 1.396232 0.314953 -0.091991 0.599674 0.665208 0.658403 0.429868
42 N04 digital_ok 100.00% 0.00% 0.00% 100.00% 0.433512 2.577407 -0.248010 -0.519526 0.292689 1.407828 0.102549 5.441017 0.235975 0.219014 -0.324208
43 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.675202 0.210453 -0.956473 1.130206 -0.148638 0.602860 -1.071644 0.832019 0.671932 0.670197 0.428011
44 N05 digital_ok 0.00% 0.00% 0.00% 0.00% -0.455688 0.795595 -0.662791 0.855046 0.635847 1.248038 -0.634998 0.434510 0.687342 0.683236 0.428469
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 1.026399 2.633916 1.186635 0.878068 0.910008 0.509015 0.033966 6.909642 0.672193 0.661521 0.418988
46 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.047386 -0.628571 0.303076 -1.079644 0.956513 0.102680 0.136652 -0.109333 0.664185 0.672874 0.422339
47 N06 not_connected 100.00% 100.00% 100.00% 0.00% 8.088755 10.726013 6.278650 6.453082 2.904641 2.285920 2.452083 1.551719 0.031423 0.054095 0.016397
48 N06 not_connected 0.00% 0.00% 0.00% 0.00% -0.717623 0.031598 -0.873851 0.310481 -0.938453 -0.334493 3.247730 -1.165269 0.644050 0.644812 0.418642
49 N06 not_connected 0.00% 0.00% 0.00% 0.00% -0.747530 -0.582542 0.209662 -0.527884 -0.633296 -0.554287 -0.225787 -0.013014 0.612004 0.621929 0.413147
50 N03 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.546577 0.800901 0.802009 1.942120 1.564486 2.491656 -0.112067 0.392007 0.632776 0.625856 0.441936
51 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.149787 3.028557 0.154841 -0.016749 1.771331 1.573308 4.780484 0.977874 0.658704 0.652885 0.443319
53 N03 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
54 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 4.782516 1.549012 1.388879 -0.571434 0.528938 3.720210 -1.439082 0.006169 0.363915 0.418735 0.196254
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 0.00% 0.00% 0.00% 0.00% -0.899857 0.239282 -0.729177 -0.270398 -0.255195 0.778162 0.056325 1.011143 0.681621 0.672010 0.423348
58 N05 RF_maintenance 100.00% 100.00% 100.00% 0.00% 7.024396 10.101358 11.216448 11.963325 2.691595 2.119893 0.993073 1.375812 0.037643 0.037175 0.002653
59 N05 RF_maintenance 100.00% 100.00% 0.00% 0.00% 7.818165 0.896132 11.228720 1.322262 2.630697 0.762409 0.394820 11.602987 0.045784 0.677457 0.522178
60 N05 RF_maintenance 100.00% 0.00% 100.00% 0.00% 1.598236 10.026222 0.329475 12.002650 0.785521 2.506476 1.413297 3.969028 0.665700 0.096226 0.544213
61 N06 not_connected 0.00% 0.00% 0.00% 0.00% 1.475528 -0.894250 1.955932 -0.408069 0.509951 -0.192556 0.094354 0.491767 0.614739 0.647426 0.415096
62 N06 not_connected 0.00% 0.00% 0.00% 0.00% -0.331194 0.423952 1.162966 0.254969 -0.567527 -0.519779 1.714144 -1.130671 0.623493 0.649375 0.416207
63 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
64 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
65 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 18.137288 18.022758 14.163199 14.345786 2.683972 2.292116 3.662124 5.255352 0.023675 0.031436 0.008621
66 N03 digital_ok 100.00% 29.44% 100.00% 0.00% 2.732256 18.573652 1.485996 14.496995 0.797844 2.217793 -1.907651 5.345872 0.213303 0.047304 0.107456
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -0.474786 -0.031598 -0.523670 1.216771 0.261308 2.089880 3.983783 2.209794 0.646298 0.640815 0.433334
68 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
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% 0.00% 100.00% 0.00% 0.648608 10.282778 2.917856 12.103560 1.124713 1.515944 9.854258 1.418216 0.271632 0.088064 0.003117
73 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.571427 1.431255 -0.654135 2.423295 0.874964 1.470979 -0.039094 1.460633 0.694522 0.679023 0.432457
74 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.986738 0.058093 -0.594423 0.061166 0.626885 1.887937 -0.627534 1.600082 0.692247 0.682347 0.426657
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 33.128398 9.601313 0.462001 -0.711832 4.381565 0.160435 -0.085427 -0.090743 0.426890 0.575398 0.320372
78 N06 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
79 N11 not_connected 100.00% 0.00% 100.00% 0.00% -0.073200 10.581129 -0.435483 6.808310 -0.575438 2.079387 -0.026502 0.489855 0.633825 0.039273 0.501660
80 N11 not_connected 0.00% 0.00% 0.00% 0.00% -0.748969 1.565399 -0.485519 1.442888 -1.188837 0.581395 -1.246640 -1.613988 0.642360 0.628835 0.432175
81 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 43.309306 36.127451 23.827129 22.924336 20.822204 14.057813 256.512685 227.220717 0.018020 0.016828 0.001239
82 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 43.227605 51.989018 32.539319 28.174116 66.090361 33.933307 775.313941 434.578796 0.016268 0.016219 0.000798
83 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 22.456591 35.425684 22.487384 23.029008 21.923878 25.462528 255.613131 319.376277 0.016662 0.016528 0.000795
84 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 2.558260 20.083879 1.087965 14.571040 -0.534250 2.036401 -1.968577 4.337452 0.647442 0.052576 0.500656
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% -0.621197 -0.036307 -0.422580 -0.197028 0.299871 0.957267 -0.274019 0.195474 0.663177 0.658485 0.432852
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 0.737719 0.820225 1.377939 0.345510 1.465058 0.868979 -0.033729 10.139774 0.664863 0.656288 0.419665
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.655251 1.334316 1.030152 1.893573 1.173463 1.386847 -0.216882 0.390207 0.677767 0.668567 0.413947
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.083008 0.646281 1.079757 1.465075 0.912133 -0.064609 -0.358861 0.351655 0.676396 0.669446 0.414728
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.256081 -0.762718 0.009040 -0.855479 -0.392489 -0.913072 0.199746 -0.112052 0.674652 0.680971 0.416835
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.127754 0.592843 1.197466 0.997974 1.349313 0.916047 -0.097724 0.226772 0.668334 0.676403 0.414984
92 N10 RF_maintenance 100.00% 100.00% 0.00% 0.00% 7.457687 0.154398 11.258772 0.684413 2.735813 0.758019 0.301359 0.987199 0.035191 0.679428 0.466737
93 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 7.656623 10.281621 11.315018 12.042112 2.691841 2.118341 1.794908 2.180852 0.030729 0.025030 0.002351
94 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 8.139823 10.500547 11.436670 11.881426 2.688973 2.124392 0.705949 1.133589 0.025436 0.025228 0.001246
95 N11 not_connected 0.00% 0.00% 0.00% 0.00% 1.230167 0.653673 -1.047751 -0.059088 3.055724 2.538809 -0.891776 -0.873406 0.653805 0.625323 0.271068
96 N11 not_connected 100.00% 0.00% 0.00% 0.00% 0.448187 13.878347 0.539950 -0.584242 -0.549726 1.954361 -1.288608 2.137931 0.650442 0.565002 0.419488
97 N11 not_connected 100.00% 0.00% 0.00% 0.00% -1.131132 1.627861 -1.127874 0.729232 -0.964199 0.103216 0.452098 9.313323 0.629665 0.618070 0.424590
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% 0.00% 0.00% 0.00% -0.684658 0.760923 -1.029717 -0.083841 -0.227300 0.902325 -0.777850 10.737616 0.671563 0.664126 0.429363
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% 169.612518 169.178928 inf inf 4006.884285 4007.323310 7367.568570 7369.579937 nan nan nan
105 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.128759 0.727147 0.573889 1.531212 1.515316 0.895106 0.021372 0.314261 0.682854 0.677415 0.418980
106 N09 digital_ok 100.00% 99.72% 99.72% 0.00% nan nan inf inf nan nan nan nan 0.075530 0.141002 0.043428
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 0.328332 1.472324 -0.038476 -0.530071 0.337402 -0.051798 0.712236 0.844771 0.670562 0.670859 0.409581
108 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.740582 2.131465 1.637968 2.763026 0.994135 0.749400 3.167688 0.718576 0.670150 0.677648 0.418954
109 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 7.285271 10.209815 11.333984 11.794416 2.695162 2.176634 0.413125 1.962753 0.072246 0.036967 0.026556
110 N10 RF_maintenance 100.00% 0.00% 0.00% 0.00% 21.605107 0.009460 0.428849 0.216937 1.825164 0.930670 2.480948 2.050563 0.581294 0.685457 0.355161
111 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 18.834268 10.137814 1.917671 11.874374 0.641613 2.152372 1.248607 2.371570 0.573629 0.075286 0.380674
112 N10 digital_ok 100.00% 0.00% 0.00% 100.00% -0.346275 5.000647 1.565932 10.342131 0.443533 0.062526 1.061080 1.104322 0.233820 0.148488 -0.276666
113 N11 not_connected 100.00% 100.00% 100.00% 0.00% 8.719725 11.022549 5.994646 6.796317 2.631510 2.081798 1.089295 1.277551 0.033790 0.030775 0.001740
114 N11 not_connected 100.00% 100.00% 0.00% 0.00% 9.330229 0.087892 6.139163 -0.824745 2.624713 -0.193280 0.223939 -0.349311 0.043958 0.639995 0.485662
115 N11 not_connected 0.00% 0.00% 0.00% 0.00% -1.261339 -1.014679 -0.740642 -0.579332 -0.694835 -0.831542 -0.347442 0.200295 0.628678 0.629803 0.420855
117 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 27.668183 44.599461 24.806350 30.175937 22.695615 43.045131 320.770191 513.352202 0.017300 0.016197 0.001343
118 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 23.392391 44.593677 23.683998 30.968605 29.441251 40.605609 368.524699 602.514083 0.016560 0.016142 0.000841
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% 0.00% 0.00% 0.00% 1.865578 2.456591 1.537167 6.297104 0.674513 1.159910 0.581164 8.622749 0.663060 0.654844 0.417974
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 0.00% 0.00% 0.00% 0.00% 3.634669 2.088437 2.249422 0.656564 1.461634 -0.333074 -2.633352 -1.329514 0.655988 0.673283 0.416343
124 N09 digital_ok 100.00% 100.00% 0.00% 0.00% 7.475358 0.631000 11.458544 1.056191 2.649042 0.638668 0.470922 1.034496 0.042819 0.684836 0.485602
125 N09 RF_maintenance 100.00% 99.72% 99.72% 0.28% nan nan inf inf nan nan nan nan 0.318709 0.322849 -0.209725
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
127 N10 digital_ok 100.00% 100.00% 0.00% 0.00% 7.448968 -1.075375 11.256050 -0.922707 2.761036 0.425920 0.294726 -0.057367 0.035312 0.683443 0.468891
128 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.368778 -0.800475 -0.426800 -0.498488 0.509018 -0.736284 3.222549 1.756052 0.675390 0.673627 0.429634
131 N11 not_connected 100.00% 0.00% 0.00% 0.00% -1.043928 9.791532 -0.650416 6.697535 -0.921613 0.989273 -1.161817 0.840507 0.667140 0.320601 0.493931
132 N11 not_connected 0.00% 0.00% 0.00% 0.00% -0.976438 -0.592467 -0.627469 -0.652795 -0.398073 -0.159462 -1.005975 0.013014 0.641470 0.637470 0.422471
133 N11 not_connected 0.00% 0.00% 0.00% 0.00% -0.445224 -1.297918 -0.616106 -1.110683 -0.367722 -0.852989 0.032840 0.142067 0.633342 0.638398 0.421682
134 N11 not_connected 100.00% 100.00% 100.00% 0.00% 8.374911 11.404802 6.126297 6.795101 2.689508 2.140301 0.320200 1.203008 0.031211 0.034317 0.001841
135 N12 RF_maintenance 0.00% 0.00% 0.00% 0.00% 2.106749 -1.241696 -0.685620 -0.987531 2.375279 0.997081 0.330686 0.375871 0.616115 0.622142 0.424847
136 N12 digital_ok 100.00% 100.00% 0.00% 0.00% 6.807820 -0.112960 10.982876 0.102806 2.744501 0.871358 0.860217 1.174894 0.039544 0.620319 0.450355
137 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 29.409158 48.384243 27.359974 24.359339 45.996751 23.471961 612.429664 270.473212 0.016231 0.016449 0.000834
139 N13 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.929078 -0.111928 0.417657 -0.854908 -0.861404 -0.332722 -1.617101 1.171914 0.655936 0.647811 0.416470
140 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.720276 -1.026324 0.430084 -1.070765 -0.428679 -0.420270 0.892957 2.683337 0.670256 0.666909 0.411184
141 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.123854 -0.829563 0.294407 -0.380866 -0.068292 -1.146803 -0.060392 -0.829437 0.678959 0.671942 0.414786
142 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -0.153339 10.142847 -0.318283 12.014496 0.403129 2.136530 12.388097 2.121898 0.682440 0.047098 0.566901
143 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 8.028480 10.220598 11.051981 11.981284 1.932826 2.102912 0.248179 1.709988 0.137254 0.031670 0.087429
144 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.412896 -0.172069 -0.329923 -0.559305 -0.251393 0.056525 -0.324675 0.428407 0.682714 0.680426 0.421455
145 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
146 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.638723 -1.040622 -0.792635 -1.112396 -1.067241 -0.939196 -0.672767 -0.180205 0.667430 0.673404 0.424045
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% nan nan inf inf nan nan nan nan 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% 11.703172 -0.754407 -0.620696 1.354865 0.315590 -0.346620 -0.814018 5.698895 0.550216 0.631192 0.364350
155 N12 RF_maintenance 100.00% 100.00% 0.00% 0.00% 7.144916 -0.733014 11.133077 -0.121879 2.758056 0.692933 1.629148 0.984279 0.040942 0.628501 0.467899
156 N12 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.013482 10.063396 7.984457 11.846135 0.963899 2.172780 6.638392 2.250264 0.560468 0.039952 0.436111
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.790207 0.250932 0.798941 1.227122 0.827307 1.346818 -0.314806 0.347686 0.632343 0.645122 0.424229
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% -0.914338 -1.155383 -1.131583 -1.124075 0.535701 0.137639 2.552943 14.297579 0.641659 0.655837 0.425983
159 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.229875 14.455067 0.264362 0.157875 -0.713831 0.783900 -0.223596 1.290511 0.626267 0.542261 0.389767
160 N13 digital_ok 100.00% 100.00% 0.00% 0.00% 7.872498 -0.675990 11.223435 -0.283595 2.692586 0.909362 0.477591 0.107290 0.047340 0.667257 0.524554
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 0.393962 22.255902 0.706753 0.675439 1.039862 -0.120590 -0.243452 0.081609 0.667897 0.566582 0.384458
162 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.672206 -1.346691 -0.294118 -1.134028 -0.980012 -0.189970 3.026341 -0.446741 0.688104 0.687324 0.412212
163 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
164 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 16.712613 -0.156490 0.897156 -0.050520 0.687233 0.739256 1.955478 0.342503 0.576998 0.684987 0.381976
166 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.196279 -0.428675 1.424039 -0.077501 2.216167 -1.160856 -0.038357 -0.980378 0.683024 0.677175 0.415577
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.425174 -1.410141 1.411756 -0.777037 -0.926812 -0.839975 -0.147695 -0.017043 0.625059 0.641788 0.422989
172 N16 digital_ok 0.00% 0.00% 0.00% 0.00% 2.879750 0.616418 1.853343 0.452115 1.171322 -0.413713 -2.356714 -0.825001 0.640408 0.637494 0.431275
173 N16 digital_ok 0.00% 0.00% 0.00% 0.00% 3.953787 3.045034 2.453879 2.305615 1.820974 1.484792 -2.784855 -2.015648 0.610660 0.601058 0.420944
179 N12 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.148509 -0.601413 1.275453 -0.204609 0.387695 0.371101 -0.145508 4.783857 0.645790 0.653040 0.421345
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% -0.218541 10.629007 -0.734337 12.103773 -0.104182 2.118103 15.750345 2.376811 0.670748 0.056532 0.558409
181 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 1.506821 0.763387 2.158269 1.586852 0.165244 0.829758 -0.080242 2.637987 0.673434 0.677409 0.416832
182 N13 digital_ok 100.00% 0.00% 100.00% 0.00% -0.356129 10.001377 -0.765473 11.780949 -1.032507 2.163990 3.020143 2.251550 0.673613 0.050147 0.524892
183 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.299981 0.238669 0.695207 1.390114 1.516369 1.744770 0.136190 0.840891 0.679671 0.680547 0.403708
184 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 10.735301 -0.055422 9.311487 0.025094 1.061783 -0.295068 1.576885 0.136618 0.438808 0.685996 0.432314
185 N14 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.137532 0.098897 -1.060604 0.422286 -0.000362 -0.268985 -0.780420 0.336519 0.685566 0.684437 0.415282
186 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.684272 -1.064482 -0.310730 -1.101566 -0.744622 -0.726641 -1.165085 -0.461895 0.689893 0.695583 0.414325
187 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.187282 -0.473227 -0.136392 -0.285315 0.980275 -0.655044 0.629768 -0.699454 0.680735 0.674508 0.422291
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 0.00% 0.00% 0.00% 0.00% 3.386976 3.322084 2.227345 2.476487 1.278716 1.471260 -2.565979 -2.430667 0.613951 0.600756 0.416409
193 N16 digital_ok 100.00% 0.00% 0.00% 0.00% 4.353043 2.693428 2.688412 2.168715 1.922635 1.238940 -2.877881 -2.219998 0.605891 0.600269 0.421455
200 N18 RF_maintenance 100.00% 100.00% 0.00% 0.00% 8.591588 24.146334 6.218695 0.401547 2.749412 1.483019 1.090041 1.225399 0.040834 0.302229 0.210666
201 N18 RF_maintenance 0.00% 0.00% 0.00% 0.00% 2.030640 2.486171 1.421690 2.086332 0.417408 1.014067 -2.099390 -2.225324 0.651377 0.631424 0.424356
202 N18 digital_ok 100.00% 0.00% 0.00% 0.00% 0.236596 -0.277291 0.400025 -0.463686 -0.728154 1.319286 -1.558556 40.553460 0.656343 0.655680 0.406206
204 N19 RF_maintenance 100.00% 0.00% 0.00% 0.00% 7.909257 8.482641 2.214836 -0.586158 0.181600 0.877177 12.742109 0.872285 0.676311 0.682906 0.407245
205 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 5.030527 -0.936087 4.307100 -1.017153 0.632776 -0.737706 1.672515 5.690691 0.507204 0.675920 0.465338
206 N19 RF_ok 0.00% 0.00% 0.00% 0.00% 0.819434 2.750360 2.155943 3.763517 -0.903864 -1.042876 -0.148343 0.933188 0.600232 0.583760 0.382677
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 1.317732 -1.215226 -1.067427 -1.008168 -0.394558 -0.820196 6.494089 -0.374810 0.643979 0.663712 0.412133
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% 0.00% 100.00% 0.00% -0.566685 10.437611 -0.612769 6.837792 0.047728 2.096165 0.410622 1.407458 0.629028 0.038306 0.523903
220 N18 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.929406 -1.203710 -0.352641 -0.948878 -1.078278 -0.264420 0.052785 -0.318735 0.657947 0.638595 0.428935
221 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -1.033091 -0.952195 -1.137961 -1.149434 -0.586555 0.332339 3.404445 -0.466578 0.656635 0.657448 0.419956
222 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -0.634432 -0.672348 -0.534966 -0.616925 -0.656358 -1.208360 3.108762 -0.612647 0.654338 0.659107 0.410898
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -1.091543 0.421404 -0.228617 2.620137 -0.751964 -0.367130 -0.360506 12.080133 0.664405 0.624070 0.429058
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 4.726299 3.074111 2.922509 2.419561 2.230814 1.407512 -3.043344 -2.289994 0.635092 0.638783 0.407278
225 N19 RF_ok 100.00% 0.00% 39.17% 0.00% -0.114044 9.922377 0.132330 6.615587 -1.090896 1.938120 -1.481252 1.757747 0.666337 0.214936 0.540116
226 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -1.166692 11.233363 -1.109860 -0.512709 -1.229951 0.480733 -0.696333 -0.405979 0.660351 0.580418 0.410918
227 N20 RF_ok 100.00% 0.00% 0.00% 0.00% 0.904819 -0.706519 2.745291 -1.068198 -0.095585 -0.548940 17.154454 1.001530 0.591424 0.645837 0.431796
228 N20 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.178233 -0.411784 0.024306 -0.611417 -1.097234 0.221118 0.713279 0.921227 0.636723 0.642367 0.419174
229 N20 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.184752 0.143112 -0.071809 0.340350 -0.746765 -0.736133 1.377559 -1.258143 0.628650 0.628846 0.423145
237 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
238 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
239 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
240 N19 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.633220 -0.520583 0.816216 -1.051180 0.080062 -0.207739 1.285596 0.371518 0.627143 0.643922 0.417401
241 N19 RF_ok 0.00% 0.00% 0.00% 0.00% -1.131953 -1.118436 -0.845272 -0.663361 -1.088858 -0.994273 -0.107604 -0.747194 0.654093 0.651095 0.427417
242 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 10.762346 -0.163495 -0.635082 0.075148 -0.280096 -0.920146 -0.826922 -0.935444 0.541461 0.653355 0.405987
243 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 8.906050 -1.061080 0.178600 -0.711099 1.157763 -0.668286 1.562157 -0.066626 0.576375 0.647729 0.411111
244 N20 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.225513 -0.397621 0.358654 0.528929 -0.388862 -0.437303 1.739991 3.984394 0.621875 0.640590 0.415342
245 N20 RF_ok 0.00% 0.00% 0.00% 0.00% 0.179989 -0.673601 0.210720 -1.046778 -0.873604 -0.692624 -1.595034 1.381108 0.642192 0.638856 0.424431
246 N20 dish_maintenance 100.00% 0.00% 100.00% 0.00% -0.593600 10.834493 -1.104253 6.420100 0.135142 2.126094 -0.419967 0.774933 0.626672 0.038400 0.520315
261 N20 RF_ok 100.00% 0.00% 0.00% 0.00% -0.116875 -0.668349 -0.281791 -0.845335 -1.089263 -1.015421 4.247371 -0.462136 0.626812 0.622914 0.422135
262 N20 dish_maintenance 100.00% 0.00% 0.00% 0.00% 7.690196 9.777983 0.430360 0.795227 1.537379 1.865124 -0.062730 1.695481 0.641435 0.636489 0.436007
320 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
324 N04 not_connected 0.00% 0.00% 0.00% 0.00% 1.526034 1.391587 0.346305 0.431897 -0.323801 -0.020445 -1.337066 -1.235404 0.495883 0.504857 0.387712
325 N09 dish_ok 0.00% 0.00% 0.00% 0.00% 0.751044 -0.970996 0.235534 -0.565219 -0.952018 0.285978 -1.565434 0.076580 0.543250 0.549416 0.422972
329 N12 dish_maintenance 0.00% 0.00% 0.00% 0.00% 0.673780 -0.214905 -0.496939 -0.880590 -0.079613 -0.122924 0.581640 -0.238611 0.493150 0.513934 0.389374
333 N12 dish_maintenance 0.00% 0.00% 0.00% 0.00% 1.175937 0.255774 -0.009040 -0.482109 0.511803 0.210661 2.740417 0.480842 0.495566 0.517096 0.388590
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: [4, 7, 8, 9, 10, 15, 17, 18, 19, 20, 27, 28, 31, 32, 34, 36, 37, 38, 40, 42, 45, 47, 51, 52, 53, 54, 55, 56, 58, 59, 60, 63, 64, 65, 66, 68, 69, 70, 71, 72, 77, 78, 79, 81, 82, 83, 84, 86, 87, 92, 93, 94, 96, 97, 101, 102, 103, 104, 106, 109, 110, 111, 112, 113, 114, 117, 118, 120, 121, 122, 124, 125, 126, 127, 131, 134, 136, 137, 142, 143, 145, 147, 148, 149, 150, 151, 155, 156, 158, 159, 160, 161, 163, 164, 165, 167, 168, 169, 170, 179, 180, 182, 184, 189, 190, 191, 193, 200, 202, 204, 205, 207, 208, 209, 210, 211, 223, 224, 225, 226, 227, 237, 238, 239, 242, 243, 246, 261, 262, 320]

unflagged_ants: [5, 16, 21, 22, 29, 30, 35, 41, 43, 44, 46, 48, 49, 50, 57, 61, 62, 67, 73, 74, 80, 85, 88, 89, 90, 91, 95, 105, 107, 108, 115, 123, 128, 132, 133, 135, 139, 140, 141, 144, 146, 157, 162, 166, 171, 172, 173, 181, 183, 185, 186, 187, 192, 201, 206, 220, 221, 222, 228, 229, 240, 241, 244, 245, 324, 325, 329, 333]

golden_ants: [5, 16, 21, 29, 30, 41, 44, 67, 85, 88, 91, 105, 107, 123, 128, 140, 141, 144, 146, 157, 162, 166, 171, 172, 173, 181, 183, 186, 187, 192]
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_2460046.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.1.1.dev3+gb291d34
3.2.3.dev158+gd5cadd5
In [ ]: