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 = "2460008"
data_path = "/mnt/sn1/2460008"
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-4-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/2460008/zen.2460008.21308.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 1850 ant_metrics files matching glob /mnt/sn1/2460008/zen.2460008.?????.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/2460008/zen.2460008.?????.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 2460008
Date 3-4-2023
LST Range 5.355 -- 15.311 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1850
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
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 113 / 198 (57.1%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 150 / 198 (75.8%)
Redcal Done? ❌
Never Flagged Antennas 48 / 198 (24.2%)
A Priori Good Antennas Flagged 69 / 93 total a priori good antennas:
3, 7, 9, 10, 15, 16, 17, 19, 20, 21, 29, 31,
37, 38, 40, 41, 42, 45, 54, 55, 56, 65, 66,
69, 70, 71, 72, 81, 85, 86, 93, 94, 101, 103,
109, 111, 112, 121, 122, 123, 124, 127, 136,
144, 147, 148, 149, 150, 151, 158, 160, 161,
165, 166, 167, 168, 169, 170, 173, 181, 182,
184, 187, 189, 190, 191, 192, 193, 202
A Priori Bad Antennas Not Flagged 24 / 105 total a priori bad antennas:
22, 35, 43, 46, 48, 61, 62, 64, 73, 74, 82,
89, 125, 137, 179, 220, 221, 222, 237, 238,
239, 240, 241, 329
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_2460008.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% 100.00% 100.00% 0.00% 14.177344 19.315977 14.282526 15.384078 6.585775 7.744829 4.475085 5.442940 0.029344 0.032542 0.003852
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 1.847130 2.599958 6.899249 -1.397306 -0.227279 0.282698 5.332709 0.271373 0.579546 0.614844 0.350254
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.256901 -0.021033 0.560709 0.261010 0.097289 1.506485 1.891471 2.197138 0.618738 0.623620 0.344296
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% 100.00% 100.00% 0.00% 14.533435 18.963917 13.505696 14.576858 6.593683 7.756393 4.502430 5.369379 0.027266 0.026333 0.001692
16 N01 digital_ok 100.00% 100.00% 0.00% 0.00% 14.536687 -0.786442 14.238769 1.174279 6.585728 1.937926 4.432744 2.108433 0.034286 0.630810 0.494092
17 N01 digital_ok 100.00% 0.00% 100.00% 0.00% 1.511257 18.304887 0.979908 15.381855 0.547444 7.763794 0.821584 5.304577 0.624381 0.044460 0.533778
18 N01 RF_maintenance 100.00% 100.00% 34.65% 0.00% 15.425626 23.301894 14.233600 0.060157 6.660378 3.303770 4.430303 7.315141 0.030921 0.230805 0.174639
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 268.706919 268.976257 inf inf 2902.224554 2885.959481 3677.127205 3617.060150 nan nan nan
20 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 278.949234 279.865119 inf inf 3300.650138 3300.664938 3780.064722 3808.632031 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 0.00% 0.00% 0.00% 0.00% -0.750383 -0.263718 0.270010 -0.326683 0.543325 0.540591 -0.185580 -0.732421 0.608324 0.621491 0.324151
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 13.654959 18.065544 14.302310 15.120092 6.652344 7.796839 5.018526 5.643500 0.037164 0.041391 0.005784
28 N01 RF_maintenance 100.00% 0.00% 75.84% 0.00% 10.918486 31.467380 0.467310 4.412635 4.800927 4.120470 2.110180 9.402184 0.386919 0.170151 0.276416
29 N01 digital_ok 100.00% 100.00% 100.00% 0.00% 14.586801 18.684476 13.774161 14.599124 6.647766 7.785809 4.474612 5.149168 0.031082 0.039611 0.008761
30 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.993800 -0.071940 0.009989 -1.717440 3.162341 0.308150 0.314698 -1.443608 0.633391 0.648342 0.343171
31 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan 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% 16.644499 20.231345 6.997018 7.663810 6.615199 7.748528 4.452129 5.199637 0.037357 0.048771 0.007837
35 N06 not_connected 0.00% 0.00% 0.00% 0.00% 0.246115 -0.542801 1.158099 -1.494295 0.413019 -0.736238 -0.251377 0.290377 0.621697 0.628882 0.318820
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 10.803511 10.617940 1.380723 1.166532 0.960013 1.692781 3.748891 4.487980 0.622931 0.629602 0.345581
37 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 0.102338 33.267506 -0.746301 18.950433 -0.481365 7.736113 -1.161596 5.918804 0.626149 0.033733 0.480967
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.910820 0.228307 -1.704522 3.935251 -0.437776 0.306930 -0.413772 8.019540 0.630435 0.628199 0.342292
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.309607 0.148658 -0.443525 1.002985 1.679569 1.026468 -0.369919 1.040439 0.645222 0.654441 0.340098
44 N05 digital_ok 0.00% 0.00% 0.00% 0.00% -1.233950 0.651106 -1.577474 0.423811 -0.785256 0.753190 -1.263189 0.434928 0.652582 0.665990 0.337647
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 0.791386 5.841299 0.582981 0.843529 -0.481249 2.122530 0.387805 2.619768 0.648123 0.651264 0.318850
46 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -1.060988 -0.590766 -0.752686 -1.303264 -0.660283 -0.368490 0.177551 -1.506616 0.649637 0.667784 0.330537
47 N06 not_connected 100.00% 100.00% 100.00% 0.00% 15.450245 19.749382 6.865368 7.154480 6.634051 7.723250 5.221077 5.256826 0.031879 0.059533 0.019713
48 N06 not_connected 0.00% 0.00% 0.00% 0.00% 0.091841 1.291554 -0.339463 1.907531 -0.721738 1.869974 -0.668772 0.474583 0.622873 0.639799 0.323715
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 0.294732 -0.243133 0.673994 -0.547681 4.460753 -0.187556 1.219008 0.195715 0.587229 0.627432 0.319490
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.659780 1.611484 -0.020726 2.518933 -0.470733 1.296366 2.415471 6.328185 0.621199 0.630251 0.340546
51 N03 dish_maintenance 100.00% 0.00% 0.00% 0.00% 7.750122 2.017569 -0.023234 -0.091244 1.602641 1.495115 15.628826 1.101181 0.627091 0.641360 0.337620
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 9.753758 7.658918 0.325106 0.309595 0.582522 1.276011 1.039865 0.873088 0.636815 0.650089 0.336137
53 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.794333 1.957121 -0.477823 -0.677630 1.236877 1.152176 2.766870 -0.522112 0.639496 0.651391 0.343396
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% 13.608193 18.530150 14.156684 15.269532 6.586029 7.726655 4.644155 5.316046 0.040553 0.039549 0.002482
59 N05 RF_maintenance 100.00% 100.00% 0.00% 0.00% 15.167852 0.765378 14.232451 1.558723 6.514058 1.804084 4.347322 2.086780 0.051000 0.671797 0.530781
60 N05 RF_maintenance 100.00% 0.00% 91.73% 0.00% 0.014746 18.488821 -1.203527 15.312180 2.564931 7.715746 0.893621 5.621983 0.656830 0.108633 0.515201
61 N06 not_connected 0.00% 0.00% 0.00% 0.00% 2.710339 0.056473 0.199191 -1.414098 0.220184 -0.679024 -0.348871 -0.750460 0.609009 0.645413 0.316999
62 N06 not_connected 0.00% 0.00% 0.00% 0.00% 0.603181 1.237196 -0.000622 1.322426 2.160280 0.682478 -0.068928 0.358329 0.601604 0.641984 0.323506
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 2.350657 19.203778 -0.629445 7.706726 0.241236 7.804694 -0.346738 5.995659 0.613617 0.049127 0.459457
64 N06 not_connected 0.00% 0.00% 0.00% 0.00% 0.021033 0.331100 -0.977220 -0.768266 -0.391168 -0.906547 -0.016260 1.118681 0.608082 0.615378 0.314764
65 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 31.661936 30.211714 18.280907 18.579914 6.695802 7.806454 5.487439 6.744117 0.022860 0.030608 0.008009
66 N03 digital_ok 100.00% 0.00% 0.00% 99.73% 0.741762 0.147496 -1.766950 5.498909 1.592803 2.406589 1.867143 4.734125 0.306159 0.296629 -0.259777
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% -0.749243 -1.156978 -1.600465 1.314111 -0.685893 1.337187 1.051861 2.909004 0.638807 0.653355 0.333880
68 N03 dish_maintenance 100.00% 100.00% 0.00% 0.00% 34.113380 0.389740 18.444213 0.883324 6.575204 -0.126653 5.683719 0.115681 0.037415 0.651068 0.513275
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% 302.852083 303.331882 inf inf 3298.738609 3300.833093 4430.591319 4439.856800 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 0.00% 0.00% 0.00% 0.00% -0.664636 1.032944 -1.750449 -0.110952 0.090405 0.242285 -1.056310 -0.119505 0.669540 0.680908 0.323707
74 N05 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.876225 0.079943 -0.019112 -0.570351 -0.769493 2.183490 -0.688498 0.503253 0.667185 0.684782 0.321440
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 68.989114 31.374389 0.803177 -0.631616 3.978584 2.761654 1.686106 0.316197 0.385786 0.527419 0.224971
78 N06 not_connected 100.00% 0.00% 0.00% 0.00% 36.472311 0.900688 -0.511619 1.636686 1.989233 1.261497 1.422714 0.852838 0.481490 0.642469 0.320158
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.598001 19.539289 0.267255 13.450041 -0.233422 7.578997 2.317253 5.633502 0.602257 0.042731 0.436539
82 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.510952 0.424210 -1.202763 -1.154428 0.121551 2.095656 -0.611560 -1.311569 0.623963 0.639991 0.338269
83 N07 digital_ok 0.00% 0.00% 0.00% 0.00% -0.592165 0.370899 0.502267 1.013803 -0.117772 0.204336 0.113972 1.494542 0.632263 0.642573 0.326769
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.631927 1.459979 0.626981 1.590525 -0.399332 -0.259689 0.368379 1.522977 0.659395 0.676603 0.314500
89 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 1.496121 0.350533 0.538151 1.527819 -0.631872 0.203279 0.016260 1.385121 0.668813 0.684132 0.311212
90 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.451247 -0.692127 -1.224125 -1.625948 35.596983 3.838784 3.949383 0.261032 0.662712 0.689607 0.312824
91 N09 digital_ok 0.00% 0.00% 0.00% 0.00% -0.801490 -0.065241 0.853774 0.848624 -0.242105 0.245806 0.109187 0.509399 0.659340 0.686526 0.311172
92 N10 RF_maintenance 100.00% 100.00% 0.00% 0.00% 14.330900 0.057128 14.163751 0.442495 6.678149 0.875798 4.312210 1.024945 0.038769 0.685246 0.427690
93 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 14.778888 18.812773 14.325589 15.406158 6.568971 7.709592 5.030815 5.606525 0.032918 0.025082 0.003637
94 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 15.624595 19.128607 14.478495 15.139389 6.744299 7.742385 5.645334 5.222515 0.025345 0.025407 0.001266
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% 276.296902 276.662635 inf inf 2459.522425 2360.240655 2825.649028 2480.063728 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.202406 -0.147725 0.230611 1.608828 0.929087 0.312229 -0.060331 1.367529 0.665000 0.680849 0.313286
106 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 1.916995 1.755103 -0.872633 -0.130231 3.453674 -0.424731 0.833503 -0.308676 0.669285 0.688708 0.307472
107 N09 digital_ok 0.00% 0.00% 0.00% 0.00% 1.209375 3.367501 -1.754129 -1.154915 2.750577 -0.008880 -0.734805 -0.495146 0.671301 0.689414 0.304597
108 N09 RF_maintenance 100.00% 100.00% 0.00% 0.00% 14.416774 52.233314 14.222627 1.618064 6.629123 3.165025 4.750974 2.725348 0.036876 0.359084 0.187642
109 N10 digital_ok 100.00% 95.03% 100.00% 0.00% 14.043323 18.551006 14.263774 14.967222 6.601021 7.796471 4.291776 5.608137 0.090357 0.038492 0.034423
110 N10 RF_maintenance 100.00% 0.00% 0.00% 0.00% 13.464846 5.424194 8.026122 -0.108038 7.167855 0.182751 4.593125 -0.328543 0.606670 0.664976 0.304286
111 N10 digital_ok 100.00% 0.00% 96.92% 0.00% 39.220689 18.397062 1.743373 15.090011 3.010867 7.785815 2.442355 5.657914 0.533310 0.082897 0.328782
112 N10 digital_ok 100.00% 28.70% 91.08% 0.00% 2.183092 17.884694 9.976949 15.176664 0.436051 7.538610 6.675718 4.769873 0.288593 0.104678 -0.059535
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% 15.490811 20.530039 14.374555 15.749785 6.555302 7.743666 4.577766 6.235539 0.028857 0.034588 0.003688
118 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.483487 1.819579 0.270056 0.984244 -0.375000 1.019661 0.606244 1.696557 0.633496 0.652462 0.331309
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% 14.563669 0.544181 14.573600 1.156637 6.545104 0.799582 4.371451 1.355697 0.046730 0.690292 0.456246
125 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.292313 0.461314 1.234248 1.683739 0.055395 -0.075471 0.430446 1.427494 0.676444 0.688325 0.302753
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 19.864916 0.235896 -0.208026 1.514536 4.670633 1.104200 3.668635 1.470176 0.618722 0.696462 0.306075
127 N10 digital_ok 100.00% 100.00% 0.00% 0.00% 13.855876 0.479801 14.144747 0.716347 6.657147 1.775876 4.305924 1.908833 0.037524 0.690481 0.431336
128 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.562284 -0.346508 -1.343270 0.318897 -0.886190 -0.780567 -1.030205 1.105511 0.663135 0.671504 0.328905
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% 0.022188 -1.134052 -1.752927 -1.575476 0.945816 16.555338 1.853052 3.382924 0.601976 0.630711 0.341149
136 N12 digital_ok 100.00% 100.00% 0.00% 0.00% 13.142418 0.562724 13.734156 -0.879095 6.660834 0.815606 4.725490 1.155816 0.045147 0.637256 0.433299
137 N07 RF_maintenance 0.00% 0.00% 0.00% 0.00% -0.651105 -0.899355 0.148776 -1.831752 0.788547 -0.133132 1.236635 -0.415308 0.623516 0.648965 0.331931
139 N13 RF_maintenance 100.00% 0.00% 1.03% 0.00% 2.279673 -0.057864 1.828603 -1.607545 0.919097 16.454656 0.399431 1.964236 0.631225 0.616042 0.328835
140 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.684345 -1.501617 -0.671352 -0.498631 2.074915 -0.773081 0.777733 -0.366396 0.652849 0.669893 0.320342
141 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -1.404129 -0.810288 -0.363192 0.583347 0.622855 0.008880 -0.068588 -0.330787 0.658925 0.672974 0.318742
142 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 1.320421 18.568174 -1.035015 15.321342 1.038117 7.756742 6.047427 5.559762 0.666695 0.053640 0.519209
143 N14 RF_maintenance 100.00% 92.11% 100.00% 0.00% 15.345234 18.492904 14.051937 15.282599 6.156066 7.724189 4.206563 5.638860 0.126073 0.032961 0.072153
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.475240 0.758967 -1.440182 4.724440 -0.339818 4.217566 -0.614109 5.412192 0.681119 0.690161 0.305933
145 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.173577 -0.600199 2.529756 0.602222 0.322312 2.542085 1.932510 0.154200 0.676179 0.689615 0.315198
146 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.225819 -0.442418 -1.251945 -0.598182 -0.400027 -0.411412 -1.177498 -1.174720 0.653090 0.674619 0.316449
147 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 303.909651 304.452515 inf inf 2896.735344 2899.789733 3679.696419 3709.247529 nan nan nan
148 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 261.666252 262.412100 inf inf 2385.634413 2387.439486 2974.869154 2908.339095 nan nan nan
149 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 247.350090 248.547511 inf inf 1787.632853 1829.620102 3024.134992 2917.260310 nan nan nan
150 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 293.889706 294.049890 inf inf 2674.843667 2724.949982 3212.657822 3312.483255 nan nan nan
151 N16 digital_ok 100.00% 0.00% 0.00% 0.00% 29.269419 1.437865 -0.527056 0.995674 2.173241 -0.400982 0.480078 -0.035583 0.477775 0.588128 0.306875
155 N12 RF_maintenance 100.00% 100.00% 0.00% 0.00% 13.686399 -1.427748 13.941213 -1.328994 6.673825 6.452484 4.906924 2.740000 0.046188 0.635901 0.443857
156 N12 RF_maintenance 100.00% 13.78% 100.00% 0.00% 6.069154 18.232810 11.984394 15.022878 12.712571 7.805355 5.074015 5.699244 0.440686 0.043182 0.304824
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 0.767449 0.694074 0.250444 1.109394 -0.030886 1.759902 1.349141 2.660255 0.627699 0.653052 0.332522
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 0.284193 -0.511516 -0.284983 -0.338498 1.229621 1.552819 1.651801 4.898170 0.640306 0.665469 0.332588
159 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 0.840760 35.105396 -1.623795 -0.630179 -0.805760 2.006933 -0.720644 0.434725 0.614816 0.529230 0.286939
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.494606 38.642167 0.226225 -0.157597 -0.086493 0.981128 0.561972 0.548686 0.662252 0.578318 0.279723
162 N13 digital_ok 0.00% 0.00% 0.00% 0.00% -0.576348 -1.689873 0.265981 -1.486247 -0.833602 0.755788 -0.458999 -1.676653 0.673562 0.693667 0.314981
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 1.203269 2.698651 -0.026733 0.794580 -0.131027 1.595517 0.036697 1.186483 0.683949 0.699124 0.310968
164 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.719911 0.221299 0.763061 2.025376 0.918242 1.947826 0.625939 2.667612 0.681009 0.691081 0.304030
165 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 305.870556 305.321656 inf inf 2422.547218 2434.938120 2699.030499 2741.053815 nan nan nan
166 N14 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
167 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 254.050369 255.616524 inf inf 2368.529861 2379.128491 3101.028264 3121.622310 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% 1.082106 2.112158 -1.177038 0.682890 -0.902540 -0.256374 -0.776253 -0.331329 0.581611 0.584928 0.325412
173 N16 digital_ok 100.00% 100.00% 100.00% 0.00% 17.109317 19.154550 6.162332 7.199142 6.679488 7.791843 5.547774 7.066934 0.042257 0.048160 0.004794
179 N12 RF_maintenance 0.00% 0.00% 0.00% 0.00% 3.643593 -1.151764 -0.370159 -1.628008 0.729131 1.307658 0.020746 -0.853902 0.631631 0.665808 0.334035
180 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 285.721738 285.652846 inf inf 2887.518079 2792.838826 3650.127055 3368.798730 nan nan nan
181 N13 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
182 N13 digital_ok 100.00% 0.00% 100.00% 0.00% -0.000568 18.234719 0.547089 14.953364 1.866638 7.788855 -0.218604 5.640240 0.671092 0.057188 0.468912
183 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.070906 1.444018 -0.632039 0.541552 -0.009784 0.373757 0.309102 0.393745 0.671348 0.688587 0.303448
184 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 31.338582 -0.447973 8.921483 -1.459665 5.431829 0.716946 2.358713 -1.067768 0.514896 0.692549 0.319515
185 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
186 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -1.002856 -1.177995 0.639598 -0.560903 -0.684738 -0.586306 -0.254117 -1.079118 0.670432 0.680428 0.319604
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.167490 -0.900824 6.692185 -0.201541 60.789412 -0.116928 3.666956 -0.464013 0.545148 0.666159 0.357531
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% 7.563619 7.987742 5.380993 5.509034 4.495282 6.498589 2.397094 3.905906 0.552703 0.559993 0.347189
193 N16 digital_ok 100.00% 0.00% 0.00% 0.00% 8.965732 1.157933 5.980655 1.702450 5.470174 1.796586 2.983176 0.889670 0.537744 0.591130 0.372046
200 N18 RF_maintenance 100.00% 100.00% 14.00% 0.00% 16.645593 47.597800 6.714265 -0.066071 6.680300 3.702000 4.858801 6.050452 0.044574 0.270964 0.171483
201 N18 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.133457 5.755238 3.815329 4.726761 3.068849 5.465718 1.838267 3.280525 0.636813 0.641053 0.323888
202 N18 digital_ok 100.00% 0.00% 0.00% 0.00% 0.905402 0.797408 1.903557 -1.640638 1.032538 -0.373939 0.505734 12.568642 0.657297 0.667788 0.312475
204 N19 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.381250 17.989565 1.893594 -1.235403 -0.229223 0.029073 7.913632 -0.885049 0.664395 0.681786 0.318792
205 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 12.291803 -1.411267 4.897266 -0.880717 4.643445 -0.720786 30.262440 0.277991 0.429988 0.665223 0.407802
206 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 0.342868 6.722762 -0.437116 3.858035 1.805189 1.990328 -0.568644 0.907227 0.615931 0.568234 0.312491
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -0.730261 0.291022 -0.900206 -1.784567 -0.530792 5.775700 1.779137 -1.006499 0.627532 0.636096 0.322930
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% -1.149961 -0.899139 0.569559 -0.685523 -0.265950 -0.722386 0.581890 -1.479719 0.645202 0.653976 0.315293
221 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -0.090061 -0.256969 0.000622 -1.124679 1.891503 -0.819953 0.619104 -1.501129 0.643707 0.660416 0.315246
222 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -0.187252 -0.136896 -0.103924 0.013472 -0.778312 -0.233693 0.176105 -0.921072 0.645477 0.661284 0.319491
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -1.608065 -1.327396 -1.643242 -1.143361 -0.729114 29.926970 -0.875303 1.741663 0.636604 0.639638 0.315143
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 9.064041 7.167131 6.200212 5.366999 5.700842 6.240157 3.165479 3.824402 0.593091 0.613847 0.330183
225 N19 RF_ok 100.00% 0.00% 60.00% 0.00% -0.243510 18.489187 1.030575 7.390569 -0.477237 7.496037 -0.142141 4.898718 0.632430 0.199138 0.491068
226 N19 RF_ok 100.00% 0.00% 0.00% 0.00% -0.399527 25.445202 -0.671406 0.698498 -0.708343 3.302006 -0.791690 1.060792 0.615400 0.539731 0.315854
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.796474 -0.276571 0.199241 -1.815059 -0.659505 -0.504676 -0.284131 -1.470057 0.595239 0.636551 0.327651
238 N18 RF_ok 0.00% 0.00% 0.00% 0.00% 0.132082 -0.048882 1.148449 0.492289 0.105533 -0.603181 -0.267290 -0.817730 0.636017 0.645794 0.328079
239 N18 RF_ok 0.00% 0.00% 0.00% 0.00% -1.285654 -0.925517 -0.222293 0.137222 -0.145172 -0.059215 -0.680210 -0.165738 0.635983 0.646120 0.326657
240 N19 RF_maintenance 0.00% 0.00% 0.00% 0.00% -1.028549 0.321917 -0.490182 -1.352781 -0.733318 -1.007854 1.110327 -0.476295 0.634315 0.642792 0.326286
241 N19 RF_ok 0.00% 0.00% 0.00% 0.00% 0.068528 -1.381879 -0.463020 0.037598 -0.677803 -0.373232 -0.315006 -0.921138 0.619767 0.641302 0.335993
242 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 26.180313 1.243026 0.308387 1.855514 2.476532 1.578935 0.441188 0.860965 0.494441 0.627749 0.338042
243 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 26.050259 -1.132771 1.230757 -1.716936 2.540372 -0.741322 0.567949 -1.358280 0.490515 0.615981 0.338635
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.752548 1.248696 3.185663 1.417909 1.755655 0.730441 0.758081 0.071478 0.491125 0.505322 0.353278
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.860597 -0.610209 1.431016 -0.964973 0.717737 5.472211 -0.512316 2.328230 0.515191 0.521248 0.348790
329 N12 dish_maintenance 0.00% 0.00% 0.00% 0.00% 2.010133 0.247761 0.309053 -1.453793 3.131692 -0.671179 1.391695 1.484412 0.495745 0.518913 0.335598
333 N12 dish_maintenance 100.00% 0.00% 0.00% 0.00% 4.389317 3.437412 -1.116640 -1.647481 -0.551489 -0.605659 2.938008 2.262184 0.467236 0.498104 0.325392
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 4, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 27, 28, 29, 31, 32, 34, 36, 37, 38, 40, 41, 42, 45, 47, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 63, 65, 66, 68, 69, 70, 71, 72, 77, 78, 79, 80, 81, 84, 85, 86, 87, 90, 92, 93, 94, 95, 96, 97, 101, 102, 103, 104, 108, 109, 110, 111, 112, 113, 114, 115, 117, 120, 121, 122, 123, 124, 126, 127, 131, 132, 133, 134, 135, 136, 139, 142, 143, 144, 147, 148, 149, 150, 151, 155, 156, 158, 159, 160, 161, 165, 166, 167, 168, 169, 170, 173, 180, 181, 182, 184, 185, 187, 189, 190, 191, 192, 193, 200, 201, 202, 204, 205, 206, 207, 208, 209, 210, 211, 223, 224, 225, 226, 227, 228, 229, 242, 243, 244, 245, 246, 261, 262, 320, 324, 325, 333]

unflagged_ants: [5, 22, 30, 35, 43, 44, 46, 48, 53, 61, 62, 64, 67, 73, 74, 82, 83, 88, 89, 91, 105, 106, 107, 118, 125, 128, 137, 140, 141, 145, 146, 157, 162, 163, 164, 171, 179, 183, 186, 220, 221, 222, 237, 238, 239, 240, 241, 329]

golden_ants: [5, 30, 44, 53, 67, 83, 88, 91, 105, 106, 107, 118, 128, 140, 141, 145, 146, 157, 162, 163, 164, 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_2460008.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 [ ]: