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 = "2459845"
data_path = "/mnt/sn1/2459845"
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
utc = Time(JD, format='jd').datetime
print(f'Date: {utc.month}-{utc.day}-{utc.year}')
Date: 9-22-2022
In [5]:
# Per-season options
def ant_to_report_url(ant):
    return f'https://htmlpreview.github.io/?https://github.com/HERA-Team/H6C_Notebooks/blob/main/antenna_report/antenna_{ant}_report.html'

Load Auto Metrics¶

In [6]:
use_auto_metrics = False

# find the auto_metrics file
glob_str = os.path.join(data_path, f'zen.{JD}*.auto_metrics.h5')
auto_metrics_file = sorted(glob.glob(glob_str))

# if it exists, load and extract relevant information
if len(auto_metrics_file) > 0:
    auto_metrics_file = auto_metrics_file[0]
    print(f'Found auto_metrics results file at {auto_metrics_file}.')
    
    auto_metrics = load_metric_file(auto_metrics_file)
    mean_round_modz_cut = auto_metrics['parameters']['mean_round_modz_cut']
    auto_ex_ants = auto_metrics['ex_ants']['r2_ex_ants']
    
    use_auto_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping auto_metrics.')
Found auto_metrics results file at /mnt/sn1/2459845/zen.2459845.34531.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 1809 ant_metrics files matching glob /mnt/sn1/2459845/zen.2459845.?????.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.')
Found 181 ant_metrics files matching glob /mnt/sn1/2459845/zen.2459845.?????.sum.known_good.omni.calfits

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])
    startTime = Time(startJD,format='jd')
    stopTime = Time(stopJD,format='jd')
    res = session.get_antenna_status(starttime=startTime, stoptime=stopTime)
    fem_switches = {}
    if len(res) == 0:
        femState = None
    else:
        for antpol in res:
            fem_switches[(antpol.antenna_number, antpol.antenna_feed_pol)] = antpol.fem_switch
    femState = (max(set(list(fem_switches.values())), key = list(fem_switches.values()).count)) 
except Exception as e:
    print(e)
    femState = None

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 (femState == "load" or femState == 'noise') and 80000 < stdev <= 4000000 and antCon[ant] is not False:
                antCon[ant] = True
            elif femState == "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'] = femState
to_show['Antennas in Commanded State'] = 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 2459845
Date 9-22-2022
LST Range 18.507 -- 7.562 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 2185
Total Number of Antennas 158
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 34
digital_maintenance: 8
digital_ok: 97
not_connected: 15
Commanded Signal Source None
Antennas in Commanded State 0 / 158 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 14
Nodes Registering 0s N08, N09
Nodes Not Correlating
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 68 / 158 (43.0%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 135 / 158 (85.4%)
Redcal Done? ✅
Redcal Flagged Antennas 16 / 158 (10.1%)
Never Flagged Antennas 7 / 158 (4.4%)
A Priori Good Antennas Flagged 91 / 97 total a priori good antennas:
3, 5, 7, 9, 10, 15, 19, 20, 21, 29, 30, 31,
37, 38, 40, 41, 42, 45, 46, 51, 53, 54, 55,
56, 65, 66, 67, 68, 69, 71, 72, 73, 81, 83,
84, 85, 86, 88, 91, 93, 94, 98, 99, 100, 101,
103, 105, 106, 107, 108, 109, 111, 112, 116,
117, 118, 121, 122, 123, 124, 127, 128, 140,
141, 142, 143, 144, 147, 156, 157, 158, 160,
161, 162, 165, 167, 169, 170, 176, 177, 178,
179, 181, 183, 184, 185, 186, 187, 189, 190,
191
A Priori Bad Antennas Not Flagged 1 / 61 total a priori bad antennas:
135
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_2459845.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 Flag Fraction Before Redcal Flagged By Redcal chi^2 Fraction 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 Median chi^2 Per Antenna (Jee) Median chi^2 Per Antenna (Jnn)
3 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.946270 -1.019034 -0.152910 -0.903419 0.004717 -0.112114 0.673800 0.602304 0.720167 0.747821 0.379134 6.314345 7.256069
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.757540 5.132063 1.008552 -0.307687 1.199331 1.259335 6.768312 0.752533 0.742661 0.747877 0.372708 0.000000 0.000000
5 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.826463 1.404887 0.462918 6.676464 -0.419961 0.021792 1.039780 -1.174120 0.743710 0.755802 0.371120 3.792628 4.134704
7 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.340604 -1.141851 -0.687183 0.440322 0.333198 0.312294 1.478844 9.213283 0.738933 0.747123 0.373490 5.469141 5.367610
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.526254 5.670887 35.566058 37.766359 3.728280 9.358116 1.167192 -2.820781 0.744243 0.738073 0.375205 6.831370 5.855155
9 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 1.66% 0.244440 -0.964198 -0.192191 1.446214 1.623490 0.304479 -0.619100 -0.770014 0.737721 0.746102 0.380677 1.271183 1.205605
10 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 1.66% -0.658850 -0.529155 0.656920 -0.569334 0.506227 1.045100 0.057052 -0.817350 0.727519 0.734958 0.391863 1.352881 1.301207
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.165230 0.870121 -0.285009 0.006116 -0.324028 0.469776 1.185661 7.965339 0.740702 0.756508 0.370203 5.391535 5.474278
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 0.00% -1.108130 1.240467 -1.002444 0.095449 0.989761 1.298446 0.568966 -0.053987 0.750977 0.756654 0.367525 1.231042 1.226116
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 0.00% -0.077198 0.521443 1.474072 0.160144 -0.228102 -0.755577 2.982156 -0.438618 0.745060 0.759639 0.362124 1.246703 1.185312
18 N01 RF_maintenance 100.00% 0.00% 13.82% 0.00% 100.00% 0.00% 23.374829 33.565416 0.764767 2.079115 19.094028 22.021563 55.416035 59.550873 0.701381 0.535664 0.409476 4.640177 2.682911
19 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.495786 -0.928072 -0.484104 1.695043 -0.768438 1.605240 7.323848 7.614743 0.749356 0.763793 0.369509 4.929755 4.846925
20 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.950831 5.471250 0.350807 -0.262045 1.734198 1.537544 2.278817 0.040390 0.751618 0.746737 0.369597 3.844662 3.028596
21 N02 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 83.98% 0.535604 0.265441 0.022626 -0.106594 -0.045981 -0.669110 0.205978 0.664346 0.737223 0.746065 0.378535 6.783794 4.088376
22 N06 not_connected 100.00% 16.03% 0.00% 0.00% 100.00% 0.00% 43.715293 12.806949 5.727814 17.170396 17.579480 18.719523 27.764048 57.064939 0.522019 0.692918 0.337965 0.000000 0.000000
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 16.962860 18.824379 39.725526 41.055111 10.152963 16.619516 2.930332 1.500911 0.038096 0.043909 0.003716 1.174519 1.225737
28 N01 RF_maintenance 100.00% 46.99% 91.21% 0.00% 100.00% 0.00% 22.449308 44.387077 1.220613 6.054830 10.643303 18.471503 4.470694 38.135900 0.434056 0.212947 0.251104 1.837559 1.177898
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 97.79% 2.21% -0.690131 -0.860710 0.802848 1.947864 -0.998521 -1.251909 -0.821145 -0.159938 0.751018 0.761870 0.355339 0.000000 0.000000
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.975023 -1.157949 2.067629 -0.712601 0.250600 0.211950 13.991537 -0.543906 0.743647 0.766206 0.357239 7.145209 6.324221
31 N02 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.170685 -0.143403 -0.772452 0.330243 1.051174 5.523841 2.297259 1.809551 0.764821 0.765231 0.365678 6.161065 3.790693
32 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 37.265146 20.620394 4.098079 7.067780 7.448025 24.556941 18.807368 53.361523 0.646761 0.712417 0.260310 3.353997 1.491647
33 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.241214 35.501722 1.105762 1.032199 7.618606 23.310903 23.333147 69.368665 0.744795 0.593742 0.448302 7.545280 4.285023
34 N06 not_connected 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 19.540275 3.705230 12.631284 14.952011 10.103377 3.448940 0.583008 -1.311327 0.048412 0.733277 0.582468 0.000000 0.000000
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.461504 0.582340 2.158273 14.908804 4.279218 1.648105 2.112420 -1.265090 0.662119 0.730137 0.409692 0.000000 0.000000
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 14.667972 11.764045 0.473286 1.206371 2.406114 1.576475 0.527508 0.500959 0.737231 0.752873 0.380561 2.059244 1.686060
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.439618 2.005244 1.300837 -0.683265 0.245171 -0.139655 0.100519 9.688585 0.740028 0.763005 0.381650 2.118203 1.771286
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.329092 1.568385 2.889708 -0.105851 1.966792 5.820669 5.632367 0.966648 0.743614 0.766238 0.379436 2.607421 1.758962
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 83.98% 0.408613 0.044094 -0.839763 -0.903083 -0.149193 0.064586 -0.742082 -1.441271 0.740174 0.760240 0.370000 5.872930 7.096247
41 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.685253 0.105105 7.889314 0.021866 2.478299 -1.290004 -0.472237 -0.634255 0.752316 0.756708 0.358405 5.037384 5.617432
42 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.271444 3.394798 4.277667 0.627580 -0.216240 -0.555999 0.009207 -1.303006 0.761530 0.759991 0.369098 3.137707 2.982014
44 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 15.773370 3.322278 1.465044 0.408462 11.951355 0.786401 46.175614 17.629941 0.725724 0.763836 0.358809 5.761107 6.933267
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.247311 -0.151229 -0.873511 0.096950 1.509809 1.537592 -0.363344 14.004415 0.756747 0.766509 0.360200 5.291789 4.898833
46 N05 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% -0.888199 19.570064 2.924736 41.149453 0.211475 16.516572 -0.075566 2.004190 0.755739 0.047007 0.618159 8.207091 1.245983
47 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.880047 3.683946 15.720460 14.078483 4.023316 14.316240 2.343624 3.632231 0.726613 0.734155 0.370168 0.000000 0.000000
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.599176 3.884000 28.685894 30.209084 2.852849 3.243865 -1.361721 -2.842054 0.730418 0.749375 0.381079 0.000000 0.000000
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.536242 3.834000 18.630521 30.519871 1.599675 5.813627 -0.666902 -2.540325 0.705276 0.736155 0.385872 0.000000 0.000000
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.174080 37.550199 -0.286650 3.370726 3.387133 6.558047 4.577224 22.775282 0.729856 0.673995 0.349461 4.287515 3.230055
51 N03 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 39.098269 4.277114 52.687000 -0.492953 191.794377 3.101555 381.776115 8.233860 0.053190 0.759675 0.504657 1.054132 4.884089
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 11.924296 10.856385 1.345797 0.159094 16.580859 -0.183193 25.786917 3.759216 0.743214 0.765154 0.371414 3.794448 4.233953
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.524167 4.643750 -0.007541 0.168833 -0.687214 -0.524081 2.035038 4.205134 0.748772 0.769020 0.373474 0.000000 0.000000
54 N04 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 16.905537 -0.315897 39.432344 0.139502 10.115741 -0.204663 1.564699 0.307908 0.058973 0.763601 0.651426 1.174578 9.984699
55 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.972048 5.118086 1.311674 -0.417707 8.539411 -0.539460 0.527739 -1.169679 0.739747 0.755148 0.353449 5.844570 7.142165
56 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.352372 1.587075 2.098172 4.438850 -0.042579 2.841831 0.375830 5.496223 0.751651 0.772407 0.357746 4.503416 5.661796
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 48.164072 0.941380 14.439773 1.981042 5.123085 0.778799 3.601151 0.231211 0.593365 0.765801 0.365500 4.877142 9.150308
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 16.114651 19.409549 39.380954 41.847648 10.218570 16.732479 3.183368 2.014713 0.043609 0.039836 0.002406 1.132520 1.127421
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 23.526629 5.538594 2.335410 2.737583 3.733709 1.254090 22.658554 10.241235 0.717053 0.753007 0.349267 4.915205 5.549201
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 5.558595 5.730449 9.085153 10.747069 13.078277 5.707816 7.976880 14.806757 0.715773 0.729127 0.361865 0.000000 0.000000
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.187996 5.245375 24.916510 30.470559 1.801563 6.397499 -0.199698 -2.874586 0.740962 0.754169 0.367453 0.000000 0.000000
63 N06 not_connected 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 4.701579 19.944503 23.647151 13.767791 0.912837 16.568872 -0.639916 0.901511 0.703423 0.053961 0.618627 0.000000 0.000000
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.870934 2.934540 18.145875 26.208122 2.136500 3.459146 0.583282 -2.241951 0.689757 0.723068 0.398013 0.000000 0.000000
65 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.350711 1.769240 0.918019 0.794503 3.708045 0.464286 0.568509 0.040045 0.726505 0.746385 0.389811 -0.000000 -0.000000
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 83.98% 1.931345 3.103888 -0.492395 1.811661 2.664914 0.451592 -0.668933 0.331688 0.735688 0.755613 0.378125 4.539539 6.671874
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.146415 0.422307 4.267918 1.476871 -0.354077 -1.009179 0.420663 0.912021 0.733650 0.758263 0.372170 4.534524 5.406399
68 N03 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 4.156174 44.773307 0.442027 58.100232 0.013559 15.905683 1.217242 10.233780 0.733814 0.038295 0.494845 3.638665 0.823177
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 83.98% -0.122381 -0.706538 1.591845 -0.854878 2.864249 2.412726 -0.531056 -0.518960 0.741051 0.763439 0.366908 5.956157 5.107822
70 N04 RF_maintenance 100.00% 0.00% 0.55% 0.00% 100.00% 0.00% 11.820838 -1.290675 0.268154 -0.118307 12.502613 0.840959 0.673972 2.232043 0.759166 0.756559 0.368649 7.337793 4.915965
71 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 83.98% -0.227829 -0.784062 -0.573537 1.419512 0.055493 -0.330809 -0.616525 -1.278998 0.745338 0.768346 0.371478 6.965322 1.542130
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.511194 0.305396 0.541800 3.469741 1.598021 0.992584 10.237398 -0.467183 0.740247 0.763968 0.360087 16.251941 36.304866
73 N05 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 15.726110 2.221477 38.997963 -0.257497 10.134117 2.579899 3.091900 2.811094 0.050445 0.750843 0.590592 1.090277 25.381838
75 N05 digital_maintenance 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 10.123022 19.931788 14.221943 42.140894 6.072763 16.803081 19.322635 2.472191 0.720998 0.055529 0.585912 0.000000 0.000000
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 30.499633 33.095393 26.231513 22.260447 6.510995 11.050399 8.830239 6.261732 0.632905 0.626704 0.208127 0.000000 0.000000
78 N06 not_connected 100.00% 2.21% 0.00% 0.00% 100.00% 0.00% 46.929114 1.328376 20.842908 23.773703 5.653696 1.046493 0.502191 -1.474708 0.574624 0.734664 0.359518 0.000000 0.000000
81 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 98.34% 1.66% 1.111563 0.836613 -0.801668 -0.561620 -0.483703 2.157544 -0.493887 -1.678846 0.695996 0.721661 0.388917 0.000000 0.000000
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.690694 1.454357 7.875264 5.696692 2.083352 0.692794 0.748907 -0.462204 0.723276 0.724189 0.384498 8.733431 12.889860
83 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.030750 1.490352 9.017231 4.296850 -0.712575 0.755041 -0.737789 -1.034129 0.732070 0.747274 0.371423 8.377589 13.472851
84 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
85 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 388.825925 388.347279 inf inf 7552.255304 8082.448152 6650.939724 7871.138679 nan nan nan 0.000000 0.000000
86 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
87 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 388.638219 388.503553 inf inf 7486.328750 7486.079883 5908.976358 5872.397742 nan nan nan 0.000000 0.000000
88 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
89 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 388.611999 388.545622 inf inf 7931.099459 7826.840117 7634.443352 7302.348639 nan nan nan 0.000000 0.000000
90 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
91 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
92 N10 RF_maintenance 100.00% 75.18% 82.92% 0.00% 100.00% 0.00% 63.024283 75.449586 8.172630 10.043578 9.442351 16.708129 0.103622 4.304184 0.377821 0.333050 0.126962 0.000000 0.000000
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.039962 1.902155 14.444302 0.661214 1.895965 -0.128212 3.254506 -1.281809 0.730553 0.755315 0.364182 0.000000 0.000000
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.079024 -1.201600 0.477540 0.244585 0.670400 3.086600 6.269844 3.547003 0.753000 0.750850 0.365518 0.000000 0.000000
98 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
99 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
100 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
101 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
102 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 7.831733 3.463202 0.627182 3.394561 258.757716 290.808287 5754.073317 5747.463920 nan nan nan 0.000000 0.000000
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
104 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
105 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
106 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 388.589887 388.722430 inf inf 7848.040183 7755.053472 7341.827114 7206.079902 nan nan nan 0.000000 0.000000
107 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 388.877457 388.666127 inf inf 7563.594508 7606.722842 6486.872668 6663.367085 nan nan nan 0.000000 0.000000
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
109 N10 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 0.614112 19.452638 0.729516 40.264456 -0.204533 16.551647 1.185537 0.510105 0.763923 0.045714 0.518623 0.000000 0.000000
110 N10 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 40.610875 36.656268 6.539096 3.991094 10.477332 20.059067 6.700520 64.034108 0.676118 0.698324 0.255908 3.406866 3.222357
111 N10 digital_ok 100.00% 0.00% 79.60% 0.00% 100.00% 0.00% -0.055685 18.338506 0.058032 40.012042 -0.169935 15.824160 6.181769 1.217300 0.756473 0.284397 0.501960 5.503702 1.485396
112 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.943233 -0.263012 4.922098 2.533464 1.471939 3.117453 0.949774 -1.462172 0.733657 0.751875 0.372432 4.367654 3.735261
116 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
118 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
119 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
120 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
121 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 388.559443 388.623641 inf inf 7543.195495 7776.542745 6488.387056 7115.777023 nan nan nan 0.000000 0.000000
122 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
123 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
124 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
125 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 2.21% 0.080446 -0.502212 -0.212668 0.106455 0.972039 0.246709 0.106820 1.964174 0.757583 0.759479 0.360878 0.865316 0.942191
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.271773 6.675045 0.113606 5.419665 -0.228331 2.633829 -0.233328 -0.926419 0.760387 0.754950 0.354489 6.313538 6.395690
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 0.00% 1.156435 -1.260589 2.671053 0.014710 0.255516 -0.613303 0.111174 -1.376803 0.756674 0.754780 0.362990 1.266744 1.209387
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 0.00% 3.910957 0.569972 0.882139 0.849527 0.695155 -0.183603 0.166643 1.987302 0.733747 0.743910 0.365705 1.329934 1.209296
135 N12 digital_maintenance 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.625575 -0.120796 -0.039788 -0.919268 0.293951 -0.274348 2.057112 0.329851 0.688885 0.715858 0.396620 0.000000 0.000000
136 N12 digital_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.624866 13.580232 -0.487421 1.332015 0.091568 2.528913 0.871439 3.149206 0.695056 0.702650 0.381899 0.000000 0.000000
137 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
138 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 16.880637 20.168537 38.457853 41.230885 10.082971 16.497656 1.374965 1.180978 0.040957 0.042305 0.003481 0.000000 0.000000
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.725836 4.042788 1.022961 11.363612 2.328536 3.123032 2.226000 15.172467 0.718974 0.712708 0.371492 0.000000 0.000000
142 N13 digital_ok 100.00% 76.29% 100.00% 0.00% 100.00% 0.00% 54.867141 19.223455 4.516228 41.703158 9.717360 16.660257 5.812903 1.370584 0.355406 0.043511 0.239739 0.000000 0.000000
143 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 7.145533 8.445160 37.363659 41.712267 5.134960 12.468398 -1.967905 -3.649958 0.739145 0.743369 0.373186 11.835949 17.431853
144 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 97.79% 2.21% -1.162102 -0.637590 0.365486 -0.213804 -0.161980 1.718762 2.185641 3.609500 0.736847 0.748925 0.375967 0.000000 0.000000
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 17.591885 20.063396 39.973771 41.970501 10.160841 16.701029 2.110989 3.212976 0.039162 0.029254 0.006314 1.288063 1.197049
147 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 22.280276 0.280738 8.589821 6.642143 9.548395 -0.741888 43.196789 -1.071246 0.723418 0.758919 0.354987 3.615278 2.755432
148 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.944893 1.806102 13.285457 7.396275 2.096875 0.300381 1.809976 4.424653 0.762724 0.761593 0.361013 3.683038 2.756438
149 N15 RF_maintenance 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 4.215028 20.370865 6.318411 41.766232 0.276986 16.663546 1.201566 1.993686 0.751263 0.043467 0.554599 0.000000 0.000000
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 18.031091 19.490244 39.654233 41.654400 10.142497 16.679151 2.687607 2.091355 0.025985 0.032150 0.002508 1.253537 1.218047
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 16.885533 18.105091 38.625401 40.829597 10.066521 16.572141 2.803124 2.404866 0.042439 0.029951 0.004547 1.326835 1.306899
156 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.453959 3.708216 -0.509910 -0.562281 -0.467543 10.479349 0.332234 40.650747 0.694574 0.702327 0.387357 0.000000 0.000000
157 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.047398 -0.604928 -0.416150 3.401573 0.185927 -0.489691 0.112285 0.679983 0.704257 0.725944 0.397994 2.594000 2.544351
158 N12 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 17.240560 -1.050679 39.981753 -1.011788 10.205546 1.839949 1.341952 3.591626 0.051932 0.732532 0.515958 1.230852 3.632731
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 18.404256 20.987188 39.394164 41.369757 10.126320 16.539877 2.293192 2.825822 0.044641 0.048488 0.005274 1.362318 1.366602
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.227927 43.870884 0.235940 5.906438 -0.032053 4.511321 0.912775 -0.049169 0.722229 0.623945 0.366330 4.885812 3.942792
162 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.845491 0.927123 -0.232841 3.518342 2.079739 0.190132 2.911626 -0.326927 0.726786 0.749025 0.389349 5.376714 5.693739
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 0.00% 0.781907 0.273222 0.692061 -0.572595 -1.294675 -0.329542 0.030173 0.945489 0.733323 0.747103 0.384500 1.223938 1.221412
164 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 0.00% -0.447771 -0.794395 0.465701 -0.735519 -0.679872 1.055400 -0.217233 1.619202 0.732478 0.747240 0.378848 1.248510 1.196752
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.127285 0.783895 9.959909 -0.080182 2.735736 -0.644022 3.213462 -0.433139 0.746987 0.747334 0.379229 6.155086 5.663294
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 44.360422 44.345930 3.588024 3.842704 9.225765 6.640936 44.860619 29.830850 0.636223 0.641988 0.222888 2.755086 1.343868
167 N15 digital_ok 100.00% 7.74% 2.21% 0.00% 100.00% 0.00% 71.863648 66.766401 9.527705 7.357551 17.869823 11.679544 80.898419 78.590893 0.572956 0.612251 0.179940 3.358195 3.840393
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.607374 2.827016 2.751217 10.375021 1.977122 0.624467 1.248808 0.844170 0.751134 0.753264 0.371585 4.823689 6.253309
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.966350 6.549649 2.788926 3.390579 -0.598354 1.966251 2.398696 7.471288 0.751554 0.737880 0.379352 3.325694 3.849223
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.107359 2.507345 11.206499 0.020633 -0.451260 -0.443804 11.891099 3.082946 0.743887 0.742878 0.386840 8.229951 8.600551
176 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 1.66% 0.704930 -0.246480 -0.384592 0.892915 -0.762799 0.045981 -0.030173 1.162628 0.687483 0.710201 0.403560 1.245382 1.245763
177 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 2.21% 1.384666 2.667116 1.060977 -0.378383 -0.052034 0.765172 1.956680 3.452684 0.696561 0.707128 0.402424 1.287894 1.332929
178 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 1.10% 0.814863 -0.044094 -0.609715 0.027315 -0.860867 -0.318417 -0.682443 -1.534884 0.702997 0.725277 0.407073 1.285322 1.253517
179 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.849836 -0.500071 -0.387599 0.131923 4.502215 -1.573581 6.491174 -1.288290 0.707745 0.730099 0.409272 4.635185 5.101200
180 N13 RF_maintenance 100.00% 0.00% 70.76% 0.00% 100.00% 0.00% 0.912308 17.011969 2.700366 40.054909 -0.120443 14.266041 -0.477035 1.341121 0.723425 0.378636 0.516351 10.911107 2.690750
181 N13 digital_ok 100.00% 100.00% 87.89% 0.00% 100.00% 0.00% 18.006330 68.606850 40.230917 12.402455 10.121049 17.617778 2.151433 8.997816 0.053511 0.265496 0.167707 1.275239 1.910309
182 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 6.067371 19.961318 36.028998 41.047376 3.632353 16.470240 -1.321810 2.019811 0.729565 0.065536 0.587886 7.814439 1.240979
183 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.329805 -0.871866 -0.465115 0.352671 -0.592790 -0.373656 0.012475 10.727753 0.726084 0.733441 0.393144 5.509934 3.392134
184 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 25.41% 74.59% 0.330814 -1.012410 -0.014710 -0.924981 0.439540 -1.377093 0.664242 -1.382901 0.728475 0.737941 0.385512 1.220933 1.810715
185 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 16.02% 83.98% 1.327739 -0.259134 2.742575 -0.936403 -1.271866 -1.092047 -0.375717 0.680048 0.740890 0.742412 0.383579 9.669439 8.079166
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.484171 0.178649 0.071552 -0.679352 3.781761 -0.479084 2.627168 -1.231130 0.738814 0.743586 0.383090 7.353402 6.978152
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.224756 0.547321 -0.042945 1.127616 0.071905 -0.408674 6.856228 1.109678 0.734963 0.747942 0.371856 6.421176 5.955468
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.720218 3.414785 0.554330 -0.173870 0.101983 2.945502 0.781380 7.245660 0.732072 0.739729 0.381999 0.000000 0.000000
190 N15 digital_ok 100.00% 6.63% 100.00% 0.00% 100.00% 0.00% 76.277383 19.517990 7.276756 42.030342 8.274474 16.858872 46.688283 2.190686 0.530549 0.042995 0.377716 3.457892 1.176819
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.152058 0.441072 -0.934135 -0.433291 0.094496 -0.190197 8.715838 3.651902 0.729412 0.735903 0.402531 -0.000000 -0.000000
320 N03 dish_maintenance 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 2.278848 21.519765 24.573150 24.322225 1.040574 16.530195 4.093365 2.383987 0.737192 0.064339 0.515645 0.000000 0.000000
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.819266 2.551443 22.687271 23.762501 3.086949 2.891921 2.980920 0.586966 0.623778 0.618498 0.410134 0.000000 0.000000
322 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.185298 5.309109 25.166145 34.547848 2.025796 8.414303 3.030138 -2.062769 0.610043 0.607728 0.404965 0.000000 0.000000
323 N02 not_connected 100.00% 65.17% 0.00% 0.00% 100.00% 0.00% 34.176063 4.094495 4.240427 32.291379 10.856290 6.839853 116.561418 4.221066 0.388169 0.601986 0.380766 0.000000 0.000000
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.475794 5.472365 28.929430 32.047890 1.640734 5.695455 0.539237 -2.568964 0.608518 0.621508 0.408773 0.000000 0.000000
325 N09 dish_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
329 N12 dish_maintenance 100.00% 5.53% 0.00% 0.00% 100.00% 0.00% 6.777603 -0.647454 1.781283 21.089161 2.372582 2.000960 4.319044 -0.252757 0.561676 0.661060 0.429669 0.000000 0.000000
333 N12 dish_maintenance 100.00% 12.16% 0.00% 0.00% 100.00% 0.00% 8.002774 1.175854 0.322537 18.841711 3.243953 2.343396 1.064040 -0.096216 0.538336 0.643880 0.423650 0.000000 0.000000
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 4, 5, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 77, 78, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 320, 321, 322, 323, 324, 325, 329, 333]

unflagged_ants: []

golden_ants: []
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_2459845.csv
In [24]:
# Load antenna positions
data_list = sorted(glob.glob(os.path.join(data_path, f'zen.{JD}.?????.sum.uvh5')))
hd = io.HERAData(data_list[len(data_list) // 2])

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Metadata¶

In [27]:
from hera_qm import __version__
print(__version__)
from hera_cal import __version__
print(__version__)
2.0.4.dev8+g8ce4cac
3.1.5.dev74+gf9d2808
In [ ]: