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 = "2459822"
data_path = "/mnt/sn1/2459822"
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: 8-30-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/2459822/zen.2459822.25304.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 372 ant_metrics files matching glob /mnt/sn1/2459822/zen.2459822.?????.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 38 ant_metrics files matching glob /mnt/sn1/2459822/zen.2459822.?????.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 2459822
Date 8-30-2022
LST Range 18.094 -- 20.094 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 372
Total Number of Antennas 147
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
RF_maintenance: 32
RF_ok: 11
digital_maintenance: 3
digital_ok: 95
not_connected: 3
Commanded Signal Source None
Antennas in Commanded State 0 / 147 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 15
Nodes Registering 0s N18
Nodes Not Correlating N02, N04, N10, N12
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 75 / 147 (51.0%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 105 / 147 (71.4%)
Redcal Done? ✅
Redcal Flagged Antennas 1 / 147 (0.7%)
Never Flagged Antennas 21 / 147 (14.3%)
A Priori Good Antennas Flagged 74 / 95 total a priori good antennas:
5, 7, 9, 10, 15, 19, 20, 21, 30, 31, 40, 41,
42, 51, 54, 55, 56, 68, 69, 71, 72, 73, 81,
83, 84, 86, 88, 91, 93, 94, 98, 100, 101, 103,
105, 106, 107, 108, 109, 111, 112, 117, 118,
121, 122, 123, 127, 128, 129, 130, 140, 141,
142, 144, 156, 157, 158, 160, 161, 165, 167,
169, 170, 176, 177, 178, 179, 181, 185, 186,
187, 189, 190, 191
A Priori Bad Antennas Not Flagged 0 / 52 total a priori bad antennas:
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_2459822.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% 0.00% 0.00% 2.740368 -0.884883 -0.690691 -0.577828 1.706936 1.331262 3.539642 3.375140 0.776742 0.559952 0.541284 1.818021 1.531939
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.685107 4.589902 -0.821319 1.924864 -0.851639 -0.496895 2.686573 -0.351011 0.790280 0.559128 0.540577 4.641249 4.459183
5 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.094686 0.537346 -0.759013 4.644489 -0.888348 1.874974 1.691586 -0.601154 0.794307 0.568256 0.545524 5.116554 4.622372
7 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.284207 -1.412943 0.688733 0.107489 -0.268921 0.358208 -0.677828 0.682278 0.076165 0.075010 0.015102 1.225029 1.217156
8 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 13.788493 14.424676 20.315212 20.779574 21.840470 21.829972 -0.140742 0.178231 0.096818 0.089932 0.015100 1.136877 1.136928
9 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.392697 -0.147220 0.587905 -0.539438 6.263271 6.182956 4.309513 3.147102 0.068905 0.055747 0.006716 1.196612 1.193585
10 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.359093 -0.883888 -0.783986 0.220872 -1.003378 1.028444 0.299527 -0.730583 0.070381 0.070358 0.009428 1.283442 1.279007
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.325873 1.426272 1.868166 1.285922 4.363138 3.879691 8.613853 4.754666 0.799793 0.572172 0.534722 4.583715 4.880186
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.161230 -0.760581 -0.493300 -0.486329 -0.975565 -1.072507 3.242218 2.107408 0.801966 0.581563 0.533025 1.874493 1.540542
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.083759 0.552005 0.730915 0.789203 0.325951 0.023437 2.990175 2.551375 0.800927 0.576264 0.546490 1.958907 1.552764
18 N01 RF_maintenance 100.00% 0.00% 81.18% 0.00% 100.00% 0.00% 5.889825 8.184575 3.083503 -0.084120 3.946958 5.209558 14.499218 17.283978 0.768828 0.348835 0.594402 4.379020 2.341813
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.519999 7.187688 -0.838042 14.027157 3.615855 14.225717 3.507960 3.803382 0.048368 0.078472 0.008263 1.209665 1.199960
20 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.519455 0.646254 -0.283350 -0.328655 -0.160043 0.793015 -0.558865 -0.929940 0.060746 0.056285 0.005500 1.250537 1.248835
21 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.383876 -0.384121 1.033474 1.907408 -0.682520 0.926858 -0.095827 -0.677903 0.068882 0.066515 0.008251 1.272384 1.273256
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 25.567127 26.643823 43.328030 44.257446 30.886411 29.495082 1.628701 0.828723 0.039645 0.043517 0.002288 1.226936 1.227375
28 N01 RF_maintenance 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 16.516410 26.687773 1.818838 3.625804 26.798528 29.159129 3.535647 14.027200 0.449884 0.202805 0.299259 10.699155 2.894699
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -1.177077 -0.017193 0.400968 -0.130594 -1.079847 -0.722094 -0.322610 -0.566018 0.807323 0.586976 0.540344 2.016715 1.639668
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.879364 0.172485 0.098233 -0.442135 -0.478864 0.333374 4.556629 -0.719967 0.801402 0.581665 0.544596 4.493485 4.386979
31 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.059623 -0.745309 -0.887356 0.557771 0.227452 0.867948 0.698734 0.467445 0.079957 0.086078 0.015565 1.204562 1.203597
32 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 47.445175 9.417852 3.531708 1.718797 6.528212 14.033363 36.953200 149.813000 0.092686 0.087211 0.012807 1.205605 1.200640
33 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 46.559323 46.141493 inf inf 3894.459793 3894.106748 5147.013472 5146.487106 nan nan nan 0.000000 0.000000
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.703575 7.614487 0.353594 -0.142058 1.535267 -0.069257 -0.587927 -0.685150 0.791797 0.581209 0.513904 5.460983 4.691915
37 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.573105 1.118846 0.837192 0.729519 -0.925838 -1.008403 -0.197259 3.481286 0.802851 0.597341 0.510193 2.031126 1.626320
38 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.264367 -0.182592 -0.524840 -0.929635 -0.666462 -0.085250 1.640274 -0.080973 0.804039 0.608675 0.512071 1.956836 1.604652
40 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.048630 0.156524 0.270221 0.005662 1.487320 0.433718 -0.610309 -1.089531 0.095122 0.100886 0.022295 1.166033 1.164159
41 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.020205 -0.776545 2.939874 1.464651 3.069860 -1.132125 -0.760032 -0.314366 0.073179 0.088607 0.016297 1.184971 1.182510
42 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.800563 0.302593 2.205488 1.317262 0.113018 -0.463016 -0.194571 -0.900240 0.110514 0.107152 0.024930 1.191274 1.192155
45 N05 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.137527 0.471937 -0.523516 0.292656 -0.705607 -0.632628 -0.475323 0.556394 0.790187 0.557979 0.555798 1.515803 1.285624
46 N05 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.940806 -0.900503 0.429026 -0.734618 -0.887032 -0.740958 -0.523008 0.265657 0.787606 0.541299 0.570070 1.477637 1.290423
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.300483 27.239193 -0.897130 1.489416 -0.284254 6.138645 4.209085 10.346533 0.798297 0.515402 0.487033 4.931185 5.610839
51 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.558099 2.270638 -0.778862 -0.554454 1.305058 -0.942390 -0.284045 4.049469 0.806178 0.622254 0.492933 5.067919 4.846087
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.319739 7.560948 1.050507 0.138901 1.581811 -1.037183 0.712223 -0.647768 0.813876 0.628491 0.492773 5.456208 5.543786
53 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.805352 1.920953 -0.660248 0.155250 -1.067511 -1.061840 1.043453 1.939725 0.812316 0.638407 0.498991 1.958439 1.750861
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.914717 8.403356 1.392426 3.117768 -0.513406 5.749390 0.976564 7.216219 0.088927 0.094843 0.018165 1.199499 1.192283
55 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 4.570805 0.801800 -0.513871 0.972569 2.592200 -1.037868 5.578910 -0.621351 0.079201 0.067269 0.006505 1.164903 1.166528
56 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.354407 0.690551 1.351000 1.257669 1.040687 -0.479923 0.035956 8.937317 0.062976 0.071138 0.006922 1.175181 1.174852
57 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 32.628819 -1.093990 14.026791 2.521759 11.282870 1.495692 3.690788 1.645296 0.123409 0.100696 0.023526 1.176799 1.177095
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.923386 0.603692 0.771584 1.394641 -0.544073 -0.048728 -0.513923 -0.498171 0.802570 0.598500 0.514218 2.008400 1.680546
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.996567 0.552257 -0.837092 0.703444 -0.120824 2.659143 0.157757 0.682587 0.807020 0.628678 0.484409 1.871528 1.522775
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.810798 -0.452839 -0.493532 0.491633 2.507078 1.419276 0.352538 2.288804 0.814663 0.646463 0.476932 2.073503 1.759036
68 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.637138 0.898933 0.425462 3.304682 1.375359 4.000856 0.501032 0.814695 0.814228 0.652818 0.477732 6.475642 7.760546
69 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.543591 -0.682302 -0.298436 -0.005662 -0.459596 1.031031 -0.142957 -0.965075 0.100749 0.113532 0.027201 1.189636 1.187931
70 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 8.841712 -1.063345 0.474672 -1.021649 -0.656194 -1.243257 0.627963 -0.218445 0.089212 0.082952 0.009114 1.177698 1.177539
71 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.505317 -0.471364 -0.787439 -0.437131 0.419871 -0.532417 -0.385653 -0.630788 0.080672 0.083784 0.008953 1.174760 1.176978
72 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 3.573627 -0.841520 -0.621610 1.482194 1.386167 -0.341102 6.634668 4.188646 0.114714 0.101610 0.020170 1.154528 1.151649
73 N05 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 24.452221 0.281384 42.578167 2.451166 30.794583 0.993050 0.687979 -0.861425 0.032929 0.606993 0.257533 1.205376 3.293573
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.970423 3.151389 -0.159520 3.956960 0.318805 3.388112 1.447914 -0.335059 0.791538 0.584132 0.497712 5.209807 4.916065
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.113422 0.081588 3.213660 2.907046 0.393637 -0.301969 17.273789 5.298724 0.804015 0.610768 0.506382 7.025698 5.050796
83 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.883061 2.438365 2.298280 4.713053 0.868873 1.980782 -0.585487 -0.882791 0.809480 0.643804 0.479459 5.325270 5.058635
84 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 10.504014 11.856045 0.864122 1.138214 -0.241103 -0.080198 -0.563475 -0.982278 0.816581 0.654227 0.472600 4.916173 5.105727
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.577993 0.548634 -0.872719 -0.332280 -1.346205 -1.536986 -0.466625 -1.110454 0.816861 0.658393 0.496783 2.010686 1.512946
86 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 7.89% 1.878874 3.917192 -0.399122 -0.491651 0.350601 1.428900 -0.209532 -0.942052 0.811739 0.632638 0.498126 2.284802 1.632631
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 36.953223 12.662479 2.440386 1.527720 13.618307 0.881056 15.510699 -0.407926 0.722872 0.656908 0.413569 5.546224 4.673397
88 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 18.603648 15.232664 24.302949 21.539624 27.128348 21.686040 0.702102 0.209367 0.776040 0.626675 0.508950 3.219941 3.128166
90 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.021352 0.120365 0.323283 4.066120 -0.694889 -0.614255 -0.012014 0.316390 0.811380 0.609073 0.524856 4.736874 3.300668
91 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 16.069208 16.998810 22.114816 22.752240 24.051159 23.968056 -0.264074 0.446877 0.780641 0.569645 0.538266 4.614238 3.379602
92 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 45.616581 61.826116 5.334336 7.019734 28.449720 34.011172 0.749934 3.303780 0.096401 0.090249 0.012246 0.000000 0.000000
93 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.573453 0.532475 4.059735 0.584369 4.069221 -0.879414 0.079832 -0.684840 0.081611 0.091361 0.014212 0.000000 0.000000
94 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.947257 -1.554103 -0.290975 0.106237 -0.137241 1.557493 4.916300 2.098078 0.080129 0.095518 0.016231 0.000000 0.000000
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.468511 5.831967 0.783605 3.158203 0.321509 -0.364252 3.863716 -0.085432 0.790726 0.560826 0.525654 5.435048 5.836832
99 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.866828 0.517642 3.451926 -0.255747 1.350173 -0.834869 -0.703420 0.597393 0.798791 0.593932 0.515125 2.046353 1.633659
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% 0.00% 0.00% 0.00% 100.00% 0.00% 9.567781 10.987811 3.413858 0.090584 0.832004 -1.025325 2.629229 2.133303 0.814113 0.641410 0.494745 5.507380 4.668896
102 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.948624 12.605552 16.612033 30.774484 59.691132 151.588393 84.019952 202.596213 0.775577 0.511224 0.530808 5.220735 3.115356
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% 0.00% 0.00% 0.00% 100.00% 0.00% 3.712164 7.276575 8.820378 13.162964 6.486244 10.493096 -0.716106 -0.623006 0.824532 0.662346 0.499985 4.630051 3.759704
106 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.616581 15.886505 6.485772 21.789377 0.964834 22.122136 0.457046 0.005663 0.809849 0.631629 0.506716 3.805714 3.109539
107 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 16.253002 11.927030 21.095087 19.152617 22.422755 19.316358 0.851357 0.607342 0.807731 0.619920 0.495074 3.662304 2.973848
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.238544 4.983391 13.077987 0.419879 0.394274 -1.196191 0.475963 -0.604885 0.788811 0.617406 0.509919 3.807409 3.103822
109 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.415237 1.154458 0.333437 0.803908 -0.515048 -0.051364 4.132036 0.501268 0.082640 0.087727 0.015955 0.000000 0.000000
110 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 46.602376 20.586506 3.515580 0.884239 2.499541 11.805776 6.335611 41.834650 0.085133 0.069459 0.007830 0.000000 0.000000
111 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.227441 1.166884 -0.264870 0.994414 -0.026350 1.664755 0.685792 4.218245 0.064098 0.058179 0.005515 0.000000 0.000000
112 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.435493 0.047363 -0.786527 1.064943 0.214928 -0.204375 0.188030 -0.723731 0.069561 0.078144 0.013008 0.000000 0.000000
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.156753 2.271631 0.115025 -0.745070 -0.491010 -1.235569 0.920384 -1.015944 0.783269 0.558601 0.535326 2.041743 1.531185
117 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.840545 1.786963 5.677866 5.745628 4.272387 3.085362 -0.919780 -1.012424 0.793169 0.576062 0.531454 5.848053 5.642379
118 N07 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 2.686601 29.773009 2.296176 38.562312 -0.447120 29.723044 0.106859 -0.103968 0.803312 0.050275 0.412173 4.809486 1.273519
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% 0.00% 0.00% 0.00% 100.00% 0.00% 3.263409 6.736206 -0.532762 0.896097 -0.482849 0.734781 9.584038 5.944538 0.816608 0.653212 0.491660 4.223599 3.463624
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.859128 9.164591 1.217182 1.237439 -0.366396 0.074455 0.253659 0.777471 0.824169 0.659521 0.488126 6.194340 4.868198
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.523819 11.176847 -0.108959 0.248041 -0.871964 -1.100572 0.338930 0.662148 0.828078 0.666741 0.488943 7.164878 5.326635
125 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.328486 12.739236 11.811631 15.832969 9.456835 14.126167 -0.778033 -0.637899 0.824575 0.644541 0.497652 5.601978 4.025309
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 25.700442 3.268495 6.385784 6.794351 10.192293 4.793460 3.782579 -0.900118 0.710165 0.636191 0.389214 3.708507 3.257059
127 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.268611 0.322060 0.073263 -0.222422 0.082957 0.430985 -0.373287 -0.831647 0.095356 0.094156 0.024185 0.000000 0.000000
128 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.030554 2.233248 -0.155249 1.617265 0.749095 1.538213 0.671154 0.016499 0.083534 0.072255 0.014250 0.000000 0.000000
129 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.122944 -0.666679 -0.829629 -0.800829 0.337930 0.298699 -0.398176 -0.862934 0.055214 0.064668 0.007044 0.000000 0.000000
130 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.011612 0.192413 0.637086 1.734206 1.045194 -0.364482 -0.335003 0.950909 0.087463 0.077589 0.015307 0.000000 0.000000
135 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.096550 0.439456 -0.934749 -0.891535 -0.358732 -0.946555 2.799916 4.535869 0.095944 0.091113 0.026201 1.275869 1.278106
136 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 2.812003 12.845377 -0.339645 0.791994 2.952003 1.326112 0.951614 2.887273 0.091487 0.089287 0.023073 1.251889 1.247104
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 17.681755 13.972495 23.238947 20.146229 26.018190 18.959964 -0.279821 -0.394298 0.764898 0.546966 0.539162 3.687310 3.108239
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% 23.534190 24.814004 42.357081 44.308469 30.818561 29.527975 0.521775 0.190929 0.039178 0.042251 0.001927 1.118128 1.113902
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.127647 3.606226 0.385708 9.691430 0.875133 3.567888 3.572939 34.649618 0.818351 0.623876 0.507011 8.961033 6.811908
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 26.406267 30.592361 3.236734 44.529283 24.573683 29.531329 1.360510 0.587900 0.515756 0.043542 0.230718 17.511482 1.411585
143 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.122048 -1.281522 1.181881 1.118058 0.288319 -0.797625 0.790964 -0.016499 0.822468 0.663041 0.481141 1.054050 0.819413
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.209145 -0.462368 1.213202 0.663629 -0.560988 1.192412 3.077215 5.913821 0.824076 0.654262 0.491853 9.726073 7.677324
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 25.910411 26.400676 43.597711 44.878161 30.912088 29.573381 1.211334 1.433994 0.033702 0.034280 -0.000646 1.301422 1.320840
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 27.357952 29.113814 43.454197 45.755632 30.891378 29.539243 1.581160 1.264974 0.045125 0.046055 0.000681 0.000000 0.000000
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 25.289755 25.857331 42.455554 43.914117 30.794210 29.420539 1.415336 1.095268 0.035723 0.036207 0.000237 1.272979 1.267945
156 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.115596 1.582600 1.419967 -0.094285 -0.261056 -0.541950 5.310340 2.557242 0.065486 0.064997 0.008866 1.279868 1.282884
157 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.568871 0.033941 0.028105 3.229347 0.473909 0.002923 0.825862 0.717066 0.066029 0.061632 0.005544 0.905956 0.914355
158 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.314439 -1.224648 -0.426085 -0.383167 0.205642 0.349690 0.468424 -0.172805 0.072166 0.058403 0.005984 0.847640 0.852542
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 24.533778 24.735888 43.108786 44.392296 30.923641 29.592753 1.261705 1.303411 0.040327 0.042747 0.003839 1.187225 1.194239
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.443754 48.503298 -0.251031 3.697681 -0.210308 3.491791 0.844100 0.359348 0.807705 0.533420 0.469268 4.635795 7.219739
162 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.812159 0.688610 -0.398362 -0.879058 1.563692 0.403291 0.926490 2.824168 0.813734 0.628637 0.505807 2.256369 1.949037
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.363027 -0.119315 0.168969 -0.899812 -0.654998 -0.151487 0.640295 -0.023948 0.815646 0.646154 0.492013 2.147480 1.705858
164 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.990601 -1.283345 -0.725418 -0.753682 0.684958 0.749105 1.438153 0.788568 0.817903 0.646420 0.497973 2.080178 1.912494
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.975745 1.671056 6.566717 -0.799720 2.870501 -1.243203 0.720350 -0.170941 0.813683 0.641230 0.490595 5.222906 6.436415
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 16.140299 25.815336 0.496458 1.969943 15.775012 5.396251 121.295732 24.334034 0.748108 0.538043 0.379091 0.000000 0.000000
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 37.050258 18.184126 15.796180 20.487084 27.040196 24.734654 58.675336 11.649535 0.646416 0.516589 0.317821 0.000000 0.000000
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 14.478196 17.231591 20.664758 23.083194 22.237704 24.312224 -0.611948 0.118157 0.777544 0.560703 0.517013 0.000000 0.000000
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 16.959956 16.158182 22.694879 21.784487 24.973400 23.077993 -0.251870 0.117565 0.767960 0.536782 0.535057 0.000000 0.000000
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 17.142712 14.344994 22.909067 20.854588 25.216518 21.150668 0.158114 -0.013606 0.758638 0.531095 0.540604 0.000000 0.000000
176 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.152784 -0.788094 -0.494150 0.637869 0.049549 -0.002923 -0.042345 -0.036795 0.052584 0.068551 0.010692 1.236582 1.237240
177 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 2.117376 1.626636 0.911036 2.778353 -0.368420 1.299445 0.830467 1.930488 0.065955 0.062105 0.006231 1.206533 1.202696
178 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.856879 -1.552102 1.084094 -0.500180 -0.485410 -0.332747 0.130164 -0.777212 0.068003 0.056034 0.005218 1.212774 1.212286
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.344974 0.823320 -0.940155 0.121739 4.012698 -0.962325 4.379445 -0.744692 0.065335 0.070210 0.012923 1.186536 1.189353
180 N13 RF_maintenance 100.00% 0.00% 78.49% 0.00% 100.00% 0.00% 0.941260 18.995992 0.579025 40.950142 -0.159650 21.752081 0.445364 0.299743 0.803339 0.337325 0.610056 15.619641 3.902542
181 N13 digital_ok 100.00% 100.00% 91.94% 0.00% 100.00% 0.00% 26.268310 46.629622 43.747996 6.490886 30.935693 41.910773 1.123709 6.942986 0.045474 0.329093 0.131009 1.181540 3.313841
182 N13 RF_maintenance 100.00% 0.00% 94.62% 0.00% 100.00% 0.00% 13.963081 27.434809 20.554135 43.474758 21.769330 27.984314 -0.644091 0.967505 0.791398 0.171709 0.552146 5.352238 1.854803
183 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -1.244827 -0.546189 0.230198 -0.936262 -1.137358 -1.545698 0.396058 1.996917 0.808666 0.619097 0.513787 1.955139 1.688442
184 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.331109 0.011612 -0.290589 0.835753 -0.055145 0.301803 0.247542 0.129258 0.811851 0.631545 0.501755 2.160582 1.696510
185 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.893616 0.253119 1.192622 1.193590 -0.559096 -0.262099 1.295101 4.339682 0.812381 0.629340 0.502248 4.313038 3.920356
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.579159 0.617293 3.651231 2.482255 2.518337 1.565668 5.263761 2.526106 0.801685 0.618922 0.495709 3.798236 3.383260
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.989075 1.076690 0.349241 0.841475 -0.008652 -0.991489 7.876410 0.684035 0.801391 0.619869 0.495670 0.000000 0.000000
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.674463 4.272980 0.727934 0.375975 6.383257 5.994941 4.652701 4.154288 0.786258 0.574025 0.528077 0.000000 0.000000
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 33.510730 29.472632 2.131387 44.896870 9.692739 29.611515 63.453638 1.325346 0.699054 0.044367 0.391690 0.000000 0.000000
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.389913 0.340741 -0.805315 -0.577195 -0.073187 -0.493236 9.383397 3.364209 0.775914 0.536769 0.561273 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
205 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 22.750156 21.492228 13.554893 0.856164 15.118304 6.057583 6.987464 8.400039 0.787762 0.553295 0.522168 5.086177 3.317121
206 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 19.664737 20.332316 1.245252 9.325556 5.019251 9.230195 8.871910 6.924499 0.766964 0.568469 0.510327 3.067055 2.684325
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 24.522487 22.064921 16.172459 13.162970 18.604357 13.762510 2.999254 2.291288 0.764209 0.559114 0.504291 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% 42.441276 42.272729 inf inf 2816.406655 3323.502310 3132.475266 4312.541430 nan nan nan 0.000000 0.000000
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 20.220042 19.438131 7.916030 5.977450 7.487719 4.304763 0.058736 2.913902 0.774234 0.543864 0.529414 4.310445 3.027539
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 30.544625 30.325371 24.517020 24.089162 28.604662 26.714691 -0.674297 -0.827856 0.727807 0.502604 0.508991 2.745647 2.364894
241 N19 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
242 N19 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
243 N19 RF_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 42.270303 42.069562 inf inf 3894.591245 3894.222900 5114.303393 5112.708796 nan nan nan 0.000000 0.000000
320 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 31.461591 29.478167 30.744058 31.081040 30.769652 29.399065 2.290995 1.088015 0.053639 0.050240 0.003429 0.000000 0.000000
321 N02 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 42.574037 42.371013 inf inf 3894.529461 3894.148523 5149.357315 5148.737724 nan nan nan 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% 100.00% 100.00% 0.00% 100.00% 0.00% 12.125107 7.123065 17.739461 11.447926 18.553022 10.856704 0.628087 0.293613 0.114072 0.075442 0.049470 0.000000 0.000000
329 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 6.107736 5.856118 4.068322 11.833602 7.527418 11.189347 0.738870 -1.285942 0.095054 0.069644 0.039054 0.000000 0.000000
333 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 4.793476 5.700573 0.156849 10.859564 3.023169 8.612248 0.189417 -0.780880 0.094017 0.070407 0.041046 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: [4, 5, 7, 8, 9, 10, 15, 18, 19, 20, 21, 27, 28, 30, 31, 32, 33, 36, 40, 41, 42, 50, 51, 52, 54, 55, 56, 57, 68, 69, 70, 71, 72, 73, 81, 82, 83, 84, 86, 87, 88, 90, 91, 92, 93, 94, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130, 135, 136, 137, 138, 140, 141, 142, 144, 145, 150, 155, 156, 157, 158, 160, 161, 165, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 181, 182, 185, 186, 187, 189, 190, 191, 203, 205, 206, 207, 220, 221, 222, 223, 224, 241, 242, 243, 320, 321, 323, 324, 329, 333]

unflagged_ants: [3, 16, 17, 29, 37, 38, 45, 46, 53, 65, 66, 67, 85, 99, 116, 143, 162, 163, 164, 183, 184]

golden_ants: [3, 16, 17, 29, 37, 38, 45, 46, 53, 65, 66, 67, 85, 99, 116, 143, 162, 163, 164, 183, 184]
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_2459822.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.3.dev44+g7d4aa18
3.1.4.dev9+gea58d1b
In [ ]: