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 = "2459851"
data_path = "/mnt/sn1/2459851"
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-28-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/2459851/zen.2459851.31239.sum.auto_metrics.h5.

Load Ant Metrics¶

In [7]:
use_ant_metrics = False

# get a list of all ant_metrics files
glob_str = os.path.join(data_path, f'zen.{JD}.?????.sum{ant_metrics_ext}')
ant_metrics_files = sorted(glob.glob(glob_str))

# if they exist, load as many of them as possible
if len(ant_metrics_files) > 0:
    print(f'Found {len(ant_metrics_files)} ant_metrics files matching glob {glob_str}')
    ant_metrics_apriori_exants = {}
    ant_metrics_xants_dict = {}
    ant_metrics_dead_ants_dict = {}
    ant_metrics_crossed_ants_dict = {}
    ant_metrics_dead_metrics = {}
    ant_metrics_crossed_metrics = {}
    dead_cuts = {}
    crossed_cuts = {}
    for amf in ant_metrics_files:
        with h5py.File(amf, "r") as infile: # use h5py directly since it's much faster than load_metric_file
            # get out results for this file
            dead_cuts[amf] = infile['Metrics']['dead_ant_cut'][()]
            crossed_cuts[amf] = infile['Metrics']['cross_pol_cut'][()]
            xants = infile['Metrics']['xants'][:]
            dead_ants = infile['Metrics']['dead_ants'][:]
            crossed_ants = infile['Metrics']['crossed_ants'][:]        
            try:
                # look for ex_ants in history
                ex_ants_string = infile['Header']['history'][()].decode()
                ex_ants_string = ex_ants_string.split('--apriori_xants')[1]
                ex_ants_string = ex_ants_string.split('--')[0].strip()
            except:
                ex_ants_string = ''
                    
            # This only works for the new correlation-matrix-based ant_metrics
            if 'corr' in infile['Metrics']['final_metrics'] and 'corrXPol' in infile['Metrics']['final_metrics']:
                ant_metrics_dead_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corr'][ant][()]
                                                 for ant in infile['Metrics']['final_metrics']['corr']}
                ant_metrics_crossed_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corrXPol'][ant][()]
                                                    for ant in infile['Metrics']['final_metrics']['corrXPol']}                       
            else:
                raise(KeywordError)
        
        # organize results by file
        ant_metrics_xants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in xants]
        ant_metrics_dead_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in dead_ants]
        ant_metrics_crossed_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in crossed_ants]
        ant_metrics_apriori_exants[amf] = [int(ant) for ant in ex_ants_string.split()]
    
    dead_cut = np.median(list(dead_cuts.values()))
    crossed_cut = np.median(list(crossed_cuts.values()))
        
    use_ant_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping ant_metrics.')
Found 1862 ant_metrics files matching glob /mnt/sn1/2459851/zen.2459851.?????.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 187 ant_metrics files matching glob /mnt/sn1/2459851/zen.2459851.?????.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 2459851
Date 9-28-2022
LST Range 21.428 -- 7.449 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
Total Number of Antennas 156
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
RF_maintenance: 28
RF_ok: 9
digital_maintenance: 11
digital_ok: 82
not_connected: 23
Commanded Signal Source None
Antennas in Commanded State 0 / 156 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 14
Nodes Registering 0s N02, N15, N16, N18
Nodes Not Correlating
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 84 / 156 (53.8%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 123 / 156 (78.8%)
Redcal Done? ✅
Redcal Flagged Antennas 13 / 156 (8.3%)
Never Flagged Antennas 20 / 156 (12.8%)
A Priori Good Antennas Flagged 65 / 82 total a priori good antennas:
7, 9, 10, 17, 19, 20, 21, 29, 30, 31, 37, 38,
41, 45, 46, 51, 53, 54, 55, 56, 65, 68, 69,
71, 72, 73, 84, 86, 93, 94, 101, 103, 109,
111, 121, 122, 123, 127, 130, 140, 141, 142,
143, 144, 147, 156, 157, 158, 160, 161, 162,
163, 164, 165, 167, 169, 170, 176, 177, 178,
179, 181, 189, 190, 191
A Priori Bad Antennas Not Flagged 3 / 74 total a priori bad antennas:
4, 44, 136
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_2459851.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 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 3.875404 -0.324838 -0.480046 0.401817 0.402833 0.715361 -0.317282 1.264174 0.755168 0.742680 0.340348 1.953934 1.500422
4 N01 RF_maintenance 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.653529 3.034228 1.118927 -0.029992 -0.078042 0.718213 -0.123409 -0.399100 0.772645 0.740624 0.340252 5.146842 3.824716
5 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 0.588590 -0.154945 -0.574413 2.162385 1.387941 1.257709 0.679223 0.781174 0.770839 0.744220 0.334755 1.861743 1.532308
7 N02 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
8 N02 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
9 N02 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
10 N02 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
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 1.230071 0.298325 2.366047 1.688404 -0.206171 -0.462081 1.116301 1.750867 0.771245 0.749462 0.332471 2.082221 1.607169
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -1.183048 -0.157267 0.520520 -0.033526 -0.628900 -0.650734 1.662543 2.363029 0.777425 0.747153 0.331908 1.907223 1.551982
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.048527 0.383871 -0.804568 -0.795069 0.207243 -0.125911 4.189108 2.229331 0.766640 0.748672 0.329583 3.740882 3.222793
18 N01 RF_maintenance 100.00% 0.00% 18.26% 0.00% 100.00% 0.00% 12.719930 16.712612 0.451648 0.746529 4.664361 15.997594 19.855457 33.952059 0.734633 0.535909 0.402734 2.705104 1.656345
19 N02 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
20 N02 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
21 N02 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
22 N06 not_connected 100.00% 19.87% 0.00% 0.00% 100.00% 0.00% 28.951698 12.035270 4.562059 11.758201 12.752246 16.367473 9.260936 10.205542 0.548841 0.680654 0.301608 5.240797 5.384461
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 10.228462 20.579512 26.745315 29.618616 21.499591 43.587859 14.565824 20.798783 0.039951 0.055114 0.009582 1.163867 1.165284
28 N01 RF_maintenance 100.00% 43.50% 88.61% 0.00% 100.00% 0.00% 13.763432 34.583330 0.706595 3.075093 16.754179 41.335184 13.053499 39.322713 0.467354 0.263272 0.234713 5.221769 1.851441
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 4.28% -1.042309 -0.687416 -0.568275 -0.383090 -1.220098 -0.597936 -0.873984 0.831640 0.773443 0.753999 0.320838 1.957705 1.740431
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.297935 -0.879476 -0.129911 -0.138644 0.217384 -0.678426 7.818962 -0.033164 0.762039 0.753930 0.329889 3.236996 3.194164
31 N02 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
32 N02 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
33 N02 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
34 N06 not_connected 100.00% 90.23% 0.00% 0.00% 100.00% 0.00% 12.017169 4.397950 8.546470 9.720896 21.468027 10.339538 12.387225 7.504056 0.098840 0.713815 0.494239 0.866643 2.079185
35 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.657644 3.130349 0.275280 8.138906 10.050139 11.891126 5.443827 8.403209 0.668710 0.709785 0.375222 2.264655 2.535631
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.501669 7.825513 0.181968 -0.100073 1.335286 1.539314 0.251767 0.355790 0.769469 0.753597 0.339081 4.592192 3.353756
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.218300 0.813757 1.255444 -0.300347 1.288562 -0.385743 0.083182 12.345258 0.778041 0.765250 0.337486 4.101474 3.558906
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.768246 1.197225 -0.585209 0.848586 1.252452 0.103442 7.100542 3.049480 0.782356 0.766509 0.333893 3.823270 3.343922
40 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 0.007907 -0.299849 -0.789522 0.138172 -0.123821 -1.322934 -0.262421 -1.210279 0.775586 0.756984 0.326987 1.831810 1.568817
41 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 22.46% 0.222990 -0.299406 3.413203 -0.832355 -0.331510 -1.761337 -0.324932 -1.498110 0.783432 0.760520 0.323469 2.033956 1.752250
42 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -0.442875 1.105157 1.262491 -0.741259 -1.209218 -0.787821 -0.065839 -0.408442 0.784349 0.757437 0.332516 1.741809 1.579764
43 N05 digital_maintenance 100.00% 89.69% 0.00% 0.00% 100.00% 0.00% 9.510555 2.714082 26.386509 0.572777 21.505144 -0.166024 13.355778 1.708281 0.116346 0.761819 0.479475 1.221582 3.597149
44 N05 digital_maintenance 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.865332 1.060810 -0.224512 -0.611234 -0.369032 -0.409323 -0.128453 -0.997750 0.756217 0.756470 0.329619 3.206028 3.170841
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.323272 -0.899823 -0.763168 0.194252 -0.262585 1.226943 0.601334 24.768792 0.762876 0.752846 0.341156 3.131784 2.935389
46 N05 digital_ok 100.00% 0.00% 90.23% 0.00% 100.00% 0.00% -0.870982 21.129022 1.192797 29.780782 4.611658 43.523799 4.060301 21.892980 0.758147 0.086780 0.555073 2.821282 1.102008
47 N06 not_connected 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 11.508237 4.719103 7.944133 9.389582 21.493981 10.551269 12.022489 10.409132 0.058454 0.721692 0.521963 0.887513 2.319757
48 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.424535 5.721825 18.290166 18.712407 5.136981 19.531101 2.595111 12.554404 0.738313 0.733241 0.364463 2.947240 2.757466
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.415060 5.431962 9.322171 16.834956 6.194346 16.089970 3.957811 13.724638 0.715399 0.723253 0.365031 2.782572 2.666081
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.873877 15.447149 -0.302678 1.449324 2.378098 14.950698 1.626443 23.708541 0.761980 0.699394 0.329093 5.070336 4.461665
51 N03 digital_ok 100.00% 89.15% 0.00% 0.00% 100.00% 0.00% 25.843231 2.780386 35.876608 1.251025 21.220484 0.978896 22.782487 3.692281 0.119981 0.760929 0.445900 1.190593 3.659384
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.272481 7.230625 2.527672 2.730557 3.074247 0.304081 0.285697 1.675377 0.778710 0.766603 0.326360 3.748794 3.388753
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.016901 3.574503 0.918227 1.445610 -0.747543 0.415967 2.170939 7.937358 0.784326 0.772435 0.324465 3.424715 3.022307
54 N04 digital_ok 100.00% 89.15% 0.00% 0.00% 100.00% 0.00% 10.259317 3.753346 26.749135 -0.494912 21.519771 1.615954 13.841567 0.391203 0.128091 0.748745 0.533712 1.499029 3.247787
55 N04 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 0.630591 21.853997 -0.769818 30.120887 1.429200 43.449230 0.421892 19.598780 0.776978 0.055084 0.561194 4.287659 1.151795
56 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 52.94% -1.033566 0.682006 0.638782 2.078737 0.482191 -0.585655 -0.358088 0.198687 0.779921 0.771363 0.313948 5.058576 3.361738
57 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 32.701876 -0.802285 8.254356 0.024611 11.832305 0.464060 9.110873 -0.164948 0.635034 0.767894 0.326675 5.251339 3.428478
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 9.858340 21.015767 26.550557 30.192701 21.571601 43.618153 14.857156 21.607826 0.060916 0.048318 0.008047 1.187269 1.171732
59 N05 digital_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 21.408526 1.992630 2.651270 0.392886 7.762365 1.898464 5.350345 3.116609 0.707070 0.754160 0.335840 2.799971 2.907872
60 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 10.815498 20.760685 26.675855 30.151158 21.516623 43.596072 13.298725 21.999729 0.027607 0.031229 0.003159 1.062239 1.053452
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.425573 6.279957 4.700033 3.285856 2.174546 9.536356 1.750455 6.402465 0.713551 0.705613 0.340559 2.618152 2.314256
62 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.454775 5.049512 15.656150 18.066987 4.138855 20.610817 2.023042 12.244226 0.743737 0.740101 0.354560 3.161026 2.622893
63 N06 not_connected 100.00% 0.00% 90.23% 0.00% 100.00% 0.00% 2.420804 21.206948 15.493623 11.242062 3.360463 43.505251 2.215031 21.746646 0.712501 0.096332 0.588968 2.821134 1.187340
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.223527 4.909257 11.390641 15.568845 6.224316 14.939788 3.287602 12.207274 0.699643 0.706915 0.367934 2.726109 2.563837
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.53% 1.110128 0.977636 0.459352 -0.735025 1.569866 1.829715 -0.568159 -0.409922 0.755650 0.746668 0.357027 1.462907 1.452551
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 0.760308 1.708326 0.626757 -0.263845 -0.268790 0.821808 -0.666738 0.906455 0.766830 0.758091 0.343560 1.475416 1.428654
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -0.269702 0.168399 -0.433613 0.576951 0.398644 -0.597364 0.647077 2.166846 0.774966 0.764708 0.330826 1.468511 1.460334
68 N03 digital_ok 100.00% 0.00% 92.37% 0.00% 100.00% 0.00% 1.847712 37.572499 0.583386 41.164627 -0.163461 41.952550 0.133063 29.306487 0.773587 0.077065 0.446232 3.372055 1.182180
69 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 59.89% -0.685499 -1.237935 0.749036 0.545512 0.622107 0.998624 0.060924 -0.107096 0.780682 0.768834 0.315345 3.765290 3.241138
70 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 7.800919 0.008172 -0.084279 -0.442252 2.285607 0.667245 0.248455 0.252253 0.790772 0.770814 0.319783 21.865311 15.806733
71 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 88.24% -0.390909 -0.666975 -0.147759 -0.701423 -0.300772 -1.771150 -0.544783 -0.982969 0.780782 0.773025 0.319700 15.099209 14.090612
72 N04 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 72.73% 3.467735 -0.148706 -0.294940 1.219992 1.257718 -0.389554 0.678110 -0.197179 0.769611 0.765431 0.318783 4.923886 3.590139
73 N05 digital_ok 100.00% 100.00% 10.31% 0.00% 100.00% 0.00% 9.586081 9.623261 26.236153 2.978870 21.472529 67.395180 14.625611 1.946302 0.044669 0.647909 0.466912 0.983044 2.958292
74 N05 digital_maintenance 100.00% 100.00% 69.82% 0.00% 100.00% 0.00% 10.726608 17.293452 27.488368 28.775904 21.656110 37.728674 14.045594 41.035138 0.047341 0.422881 0.250826 0.828759 1.113890
75 N05 digital_maintenance 100.00% 0.00% 89.15% 0.00% 100.00% 0.00% 4.677536 21.234729 6.159952 30.418326 4.839390 43.607358 5.866765 22.005824 0.740507 0.124426 0.517489 0.000000 0.000000
77 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 19.530516 29.210251 16.962232 12.716167 12.404738 26.086355 11.659870 10.393128 0.646195 0.612320 0.204469 3.790983 2.635760
78 N06 not_connected 100.00% 7.52% 0.00% 0.00% 100.00% 0.00% 32.101732 3.290501 13.156302 14.152944 10.881534 13.469416 4.689941 11.691461 0.575750 0.721423 0.335707 2.879976 2.611413
84 N08 digital_ok 100.00% 0.00% 89.69% 0.00% 100.00% 0.00% 7.927263 34.173164 -0.082256 39.650657 -0.342417 42.212423 -0.036486 24.089677 0.775099 0.106123 0.590886 3.686608 1.217326
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -0.109370 1.242861 1.548969 0.414581 -1.277085 -0.204649 -1.124276 -0.584310 0.772204 0.757516 0.319414 1.616212 1.515767
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.543180 6.311204 0.310081 0.384794 2.529979 2.399637 0.096920 14.994346 0.776166 0.728929 0.317854 3.599624 2.961166
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.972589 7.626861 7.735737 0.645646 28.492702 0.700482 3.723023 1.022224 0.767619 0.772073 0.311184 3.944644 3.291702
92 N10 RF_maintenance 100.00% 78.95% 87.54% 0.00% 100.00% 0.00% 39.624200 58.744914 4.613288 5.851237 16.829852 35.898817 8.498117 20.131440 0.395682 0.341670 0.101172 2.403719 1.809570
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.394765 0.648860 0.842720 -0.582904 4.168338 1.179269 6.207925 -0.026572 0.760515 0.752226 0.336836 4.185170 3.318546
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.299052 -0.799333 0.255967 0.660195 0.810642 4.883736 2.692665 5.568707 0.761590 0.740025 0.346194 4.136749 3.050132
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.184809 9.150962 6.210847 1.637063 0.152150 -0.811375 0.255570 1.325913 0.777543 0.755326 0.330189 4.299631 3.316018
102 N08 RF_maintenance 100.00% 41.89% 92.37% 0.00% 100.00% 0.00% 8.451256 21.228837 23.388844 28.422034 15.267728 43.610992 9.851724 23.820974 0.495079 0.084733 0.389433 1.751756 1.368121
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 24.311257 34.246545 31.206523 34.510244 21.673764 42.605228 22.291718 28.996207 0.033769 0.054075 0.015093 1.181936 1.187498
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.944284 60.935425 6.555372 23.788075 0.720981 -0.060679 0.031375 2.498419 0.788528 0.717493 0.341599 4.435877 2.974254
109 N10 digital_ok 100.00% 0.00% 91.30% 0.00% 100.00% 0.00% -0.407214 20.947315 -0.287285 29.249028 0.161812 43.512238 0.723526 20.718254 0.765024 0.082467 0.476210 3.877890 1.202535
110 N10 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 30.259083 10.818195 2.613079 0.141536 12.941776 17.569532 9.125928 17.776151 0.676182 0.723572 0.272877 5.579887 3.110578
111 N10 digital_ok 100.00% 0.00% 80.56% 0.00% 100.00% 0.00% -0.753913 19.052239 0.139277 28.699453 0.704014 40.177232 0.803719 20.155337 0.762588 0.329006 0.441387 4.121182 1.385463
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -0.894618 -0.736885 -0.834662 -0.539190 -0.124297 2.324665 1.268352 -0.160277 0.750150 0.741482 0.354405 1.591775 1.395553
120 N08 RF_maintenance 100.00% 0.00% 91.84% 0.00% 100.00% 0.00% 2.929848 33.783654 12.309468 39.410726 0.022107 42.447086 2.066267 29.028976 0.749084 0.078354 0.587398 3.830861 1.110369
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.430618 5.678354 0.646125 1.513323 0.538528 0.731156 37.198004 19.463375 0.778591 0.755612 0.320834 4.006335 2.864139
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.285023 7.868445 0.051219 1.147329 4.351614 0.000699 0.724689 0.160114 0.784381 0.759664 0.313614 3.387234 2.379464
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 7.370721 9.110197 3.050521 0.045670 0.853798 -0.080084 0.593489 0.031703 0.789405 0.764233 0.316040 3.664344 2.604617
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 1.07% -0.201127 -0.064151 1.109002 -0.746004 0.409435 0.801595 0.148773 -0.060924 0.764027 0.752831 0.338518 1.865136 1.543662
128 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -1.276981 3.549983 0.419953 1.205351 0.032805 0.064042 -0.070820 -0.670872 0.764790 0.745089 0.335500 1.560681 1.480982
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 0.210714 -0.651046 -0.809109 -0.888924 -0.936822 -1.195386 -0.631275 -1.146959 0.761163 0.748002 0.345939 1.562618 1.397693
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.53% 1.230375 -0.124760 -0.575617 -0.680780 0.022125 0.782588 1.261554 3.252970 0.744236 0.736226 0.349734 1.518773 1.387159
135 N12 digital_maintenance 100.00% 0.00% 98.28% 0.00% 100.00% 0.00% -1.015484 21.081065 6.623990 30.273206 2.374841 43.619041 1.951506 19.248025 0.706050 0.069371 0.467696 2.824847 1.186150
136 N12 digital_maintenance 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.869637 0.662614 1.791942 0.709968 1.707830 1.333587 1.717404 0.946225 0.713561 0.710465 0.354388 0.000000 0.000000
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 10.178151 21.500972 26.074392 29.909034 21.441886 43.448440 13.582477 21.778363 0.040941 0.055601 0.013919 1.178875 1.178941
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.853024 6.560627 -0.538867 10.255183 2.985618 7.717310 4.076287 24.665452 0.757045 0.705254 0.316159 2.736310 1.962893
142 N13 digital_ok 100.00% 73.04% 100.00% 0.00% 100.00% 0.00% 36.231356 20.767654 2.527160 30.062782 18.466734 43.582327 8.269190 20.789941 0.424198 0.070834 0.240055 1.848445 0.843492
143 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 63.64% 29.41% -0.069726 -0.855599 -0.302117 -0.765032 0.967998 0.454904 1.200745 -0.773414 0.773000 0.757518 0.322274 0.000000 0.000000
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.049300 -0.464799 -0.592197 2.757262 1.276186 103.910739 2.209398 36.054251 0.770294 0.751201 0.330576 0.000000 0.000000
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 10.810431 21.412030 26.943668 30.238637 21.555024 43.568945 13.681489 22.617809 0.060367 0.033479 0.017875 0.000000 0.000000
147 N15 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
148 N15 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
149 N15 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
150 N15 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
151 N16 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.788812 6.503990 -0.677876 1.518583 371.568173 481.077515 7011.270065 6681.696281 nan nan nan 0.000000 0.000000
152 N16 not_connected 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
153 N16 not_connected 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
154 N16 not_connected 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
155 N12 digital_maintenance 100.00% 89.69% 0.00% 0.00% 100.00% 0.00% 10.175134 0.003068 25.691453 1.148619 21.417963 3.049916 12.168307 4.277308 0.129985 0.721938 0.456033 0.936414 2.540516
156 N12 digital_ok 100.00% 88.61% 0.00% 0.00% 100.00% 0.00% 9.580981 -0.312929 26.471802 2.233780 21.261338 -0.103855 11.600261 1.655274 0.192336 0.727107 0.438793 1.091644 2.719478
157 N12 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 73.26% -0.198991 0.131400 0.876118 2.991345 0.472531 1.398645 0.699440 1.676492 0.742311 0.721676 0.352665 3.839891 2.773293
158 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.865516 0.102255 23.880225 3.037842 9.890312 1.801039 6.138597 39.514424 0.754696 0.728240 0.356878 0.000000 0.000000
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 11.331359 21.824929 26.519841 29.808767 21.483230 43.462437 13.786393 22.503620 0.044764 0.063635 0.016238 1.214385 1.205802
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.380483 36.264023 -0.828646 3.084831 0.706532 16.331332 1.109473 5.786170 0.760698 0.624305 0.319738 3.224116 3.841494
162 N13 digital_ok 0.00% 0.00% 0.00% 1.07% 11.76% 14.44% 0.937441 0.412043 -0.690863 0.029992 2.033697 0.222797 0.820625 -0.087035 0.770100 0.750102 0.335021 1.912754 1.647961
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 3.74% 0.746452 -0.247193 -0.668201 0.351970 -0.341454 1.875518 0.142539 1.912664 0.775686 0.747850 0.334187 1.727942 1.586059
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.931895 -0.508530 -0.827063 1.120987 0.709837 0.705793 1.451688 4.299540 0.770350 0.746554 0.331450 3.897546 3.227928
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.597742 1.600200 6.483443 -0.681804 3.370845 3.998068 2.805357 0.495442 0.777391 0.749547 0.334243 3.930244 3.378422
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.896916 4.023044 1.249351 1.385797 4.332642 10.574818 5.439839 20.397056 0.732822 0.723535 0.304175 4.956540 4.181693
167 N15 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
168 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 260.810769 259.845248 inf inf 13787.732752 13787.704735 14631.146631 14634.690907 nan nan nan 0.000000 0.000000
169 N15 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
170 N15 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
171 N16 not_connected 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
173 N16 not_connected 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
176 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.219035 0.597027 1.215826 1.971871 0.838204 2.719312 1.110223 14.293929 0.722744 0.711191 0.361915 2.652084 2.473749
177 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.458340 -0.391986 -0.115827 2.064346 -0.046167 1.179984 0.650918 10.960125 0.736808 0.719199 0.363112 0.000000 0.000000
178 N12 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.365999 -0.393067 17.077342 6.350400 7.644349 1.652488 3.728080 7.673426 0.657167 0.710959 0.371814 0.000000 0.000000
179 N12 digital_ok 100.00% 100.00% 88.61% 0.00% 100.00% 0.00% 11.195010 22.076135 27.144598 31.606907 21.632919 43.502241 12.068863 19.916689 0.035531 0.140694 0.059251 0.892451 0.907900
180 N13 RF_maintenance 100.00% 0.00% 76.80% 0.00% 100.00% 0.00% 0.377893 18.219426 0.304240 28.932192 0.809093 38.281984 0.291187 18.388783 0.763111 0.372306 0.464554 12.043645 2.635432
181 N13 digital_ok 100.00% 99.36% 88.08% 0.00% 100.00% 0.00% 10.979559 50.758409 27.109566 6.833385 21.524150 40.109085 13.623584 25.710256 0.073152 0.271927 0.117202 1.225342 1.620915
182 N13 RF_maintenance 100.00% 0.00% 89.15% 0.00% 100.00% 0.00% 2.695667 20.859634 22.665870 29.213458 7.785392 43.471954 3.896592 21.296412 0.770536 0.125578 0.539865 3.858117 1.360062
183 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -1.586274 -1.327852 0.703229 -0.499507 -0.827660 -1.455977 -0.392203 1.796157 0.765183 0.737857 0.342798 1.672838 1.491563
184 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% -0.007907 -0.597402 -0.770084 0.417919 -0.560446 -0.354997 0.377037 -0.181783 0.767815 0.736125 0.338365 1.637955 1.512241
185 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 0.707487 -0.483002 0.615190 0.245064 -0.022125 -0.917904 0.146453 -0.627466 0.774753 0.742710 0.336807 1.513888 1.468278
186 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 2.234033 1.663284 -0.117293 -0.686013 2.976801 3.411751 3.104067 0.068003 0.767340 0.744229 0.337376 1.501441 1.441639
187 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 11.76% 0.00% 0.056003 0.057342 0.716017 -0.758324 0.326689 0.698248 2.683066 2.550073 0.754613 0.738423 0.338904 1.900895 1.533786
189 N15 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
190 N15 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
191 N15 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
192 N16 not_connected 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
193 N16 not_connected 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
200 N18 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
201 N18 RF_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
202 N18 RF_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
203 N18 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
219 N18 RF_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
220 N18 RF_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
221 N18 RF_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
222 N18 RF_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
237 N18 RF_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
238 N18 RF_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
239 N18 RF_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
320 N03 dish_maintenance 100.00% 0.00% 90.23% 0.00% 100.00% 0.00% 0.394143 22.309221 4.106863 18.218397 -0.482522 43.405665 2.661685 22.003773 0.755737 0.104277 0.494825 0.000000 0.000000
321 N02 not_connected 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
322 N05 digital_maintenance 100.00% 0.00% 0.00% 1.07% 100.00% 0.00% 1.254910 7.173809 15.897550 20.885384 6.667936 23.943632 5.821819 14.749469 0.666667 0.644597 0.368981 0.000000 0.000000
323 N02 not_connected 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
324 N04 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.762977 6.298536 19.097110 19.491465 6.896904 20.139218 3.064305 14.169034 0.682120 0.652037 0.349258 0.000000 0.000000
329 N12 dish_maintenance 100.00% 6.98% 0.00% 0.00% 100.00% 0.00% 3.521872 3.074482 0.595359 12.314401 8.632711 12.515539 7.799323 13.115077 0.602861 0.655592 0.365786 0.000000 0.000000
333 N12 dish_maintenance 100.00% 10.20% 0.00% 0.00% 100.00% 0.00% 4.030140 3.569396 0.749361 10.433029 8.325549 12.257412 5.708977 11.160351 0.592879 0.638115 0.362729 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, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 78, 84, 85, 86, 87, 92, 93, 94, 101, 102, 103, 104, 109, 110, 111, 112, 120, 121, 122, 123, 127, 128, 129, 130, 135, 136, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 173, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 200, 201, 202, 203, 219, 220, 221, 222, 237, 238, 239, 320, 321, 322, 323, 324, 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_2459851.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.dev9+gdffdef6
3.1.5.dev83+g5d33d87
In [ ]: