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 = "2459827"
data_path = "/mnt/sn1/2459827"
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-4-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/2459827/zen.2459827.25321.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/2459827/zen.2459827.?????.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/2459827/zen.2459827.?????.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 2459827
Date 9-4-2022
LST Range 18.427 -- 4.448 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 1862
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 N09, N18
Nodes Not Correlating N02, N04, N12
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 74 / 147 (50.3%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 113 / 147 (76.9%)
Redcal Done? ✅
Redcal Flagged Antennas 2 / 147 (1.4%)
Never Flagged Antennas 18 / 147 (12.2%)
A Priori Good Antennas Flagged 77 / 95 total a priori good antennas:
3, 5, 7, 9, 10, 15, 17, 19, 20, 21, 30, 31,
37, 40, 41, 42, 46, 53, 54, 55, 56, 68, 69,
71, 72, 73, 81, 83, 84, 86, 88, 91, 93, 94,
98, 99, 101, 103, 105, 106, 107, 108, 111,
116, 117, 118, 121, 122, 123, 128, 140, 141,
142, 144, 156, 157, 158, 160, 161, 164, 165,
167, 169, 170, 176, 177, 178, 179, 181, 183,
184, 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_2459827.csv

Build DataFrame¶

In [20]:
# build dataframe
to_show = {'Ant': [f'<a href="{ant_to_report_url(ant)}" target="_blank">{ant}</a>' for ant in ants],
           'Node': [f'N{nodes[ant]:02}' for ant in ants], 
           'A Priori Status': [a_priori_statuses[ant] for ant in ants]}
           #'Worst Metric': worst_metrics, 'Worst Modified Z-Score': worst_zs}
df = pd.DataFrame(to_show)

# create bar chart columns for flagging percentages:
bar_cols = {}
if use_auto_metrics:
    bar_cols['Auto Metrics Flags'] = [float(ant in auto_ex_ants) for ant in ants]
if use_ant_metrics:
    if np.sum(list(a_priori_flag_frac.values())) > 0:  # only include this col if there are any a priori flags
        bar_cols['A Priori Flag Fraction in Ant Metrics'] = [a_priori_flag_frac[ant] for ant in ants]
    for ap in antpols:
        bar_cols[f'Dead Fraction in Ant Metrics ({ap})'] = [dead_ant_frac[ap][ant] for ant in ants]
    bar_cols['Crossed Fraction in Ant Metrics'] = [crossed_ant_frac[ant] for ant in ants]
if use_redcal:
    bar_cols['Flag Fraction Before Redcal'] = [redcal_prior_flag_frac[ant] for ant in ants]
    bar_cols['Flagged By Redcal chi^2 Fraction'] = [redcal_flagged_frac[ant] for ant in ants]  
for col in bar_cols:
    df[col] = bar_cols[col]

# add auto_metrics
if use_auto_metrics:
    for label, modz in all_modzs.items():
        df[label] = modz
z_score_cols = [col for col in df.columns if 'Modified Z-Score' in col]        
        
# add ant_metrics
ant_metrics_cols = {}
if use_ant_metrics:
    for ap in antpols:
        ant_metrics_cols[f'Average Dead Ant Metric ({ap})'] = [average_dead_metrics[ap][ant] for ant in ants]
    ant_metrics_cols['Average Crossed Ant Metric'] = [average_crossed_metrics[ant] for ant in ants]
    for col in ant_metrics_cols:
        df[col] = ant_metrics_cols[col]   

# add redcal chisq
redcal_cols = []
if use_redcal:
    for ap in antpols:
        col_title = f'Median chi^2 Per Antenna ({ap})'
        df[col_title] = [cspa[ant, ap] for ant in ants]
        redcal_cols.append(col_title)

# sort by node number and then by antenna number within nodes
df.sort_values(['Node', 'Ant'], ascending=True)

# style dataframe
table = df.style.hide_index()\
          .applymap(lambda val: f'background-color: {status_colors[val]}' if val in status_colors else '', subset=['A Priori Status']) \
          .background_gradient(cmap='viridis', vmax=mean_round_modz_cut * 3, vmin=0, axis=None, subset=z_score_cols) \
          .background_gradient(cmap='bwr_r', vmin=dead_cut-.25, vmax=dead_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .background_gradient(cmap='bwr_r', vmin=crossed_cut-.25, vmax=crossed_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .background_gradient(cmap='plasma', vmax=4, vmin=1, axis=None, subset=redcal_cols) \
          .applymap(lambda val: 'font-weight: bold' if val < dead_cut else '', subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val < crossed_cut else '', subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .applymap(lambda val: 'color: red' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .bar(subset=list(bar_cols.keys()), vmin=0, vmax=1) \
          .format({col: '{:,.4f}'.format for col in z_score_cols}) \
          .format({col: '{:,.4f}'.format for col in ant_metrics_cols}) \
          .format({col: '{:,.2%}'.format for col in bar_cols}) \
          .applymap(lambda val: 'font-weight: bold', subset=['Ant']) \
          .set_table_styles([dict(selector="th",props=[('max-width', f'70pt')])])

Table 2: RTP Per-Antenna Metrics Summary Table¶

This admittedly very busy table incorporates summary information about all antennas in the array. Its columns depend on what information is available when the notebook is run (i.e. whether auto_metrics, ant_metrics, and/or redcal is done). These can be divided into 5 sections:

Basic Antenna Info: antenna number, node, and its a priori status.

Flag Fractions: Fraction of the night that an antenna was flagged for various reasons. Note that auto_metrics flags antennas for the whole night, so it'll be 0% or 100%.

auto_metrics Details: If auto_metrics is included, this section shows the modified Z-score signifying how much of an outlier each antenna and polarization is in each of four categories: bandpass shape, overall power, temporal variability, and temporal discontinuities. Bold red text indicates that this is a reason for flagging the antenna. It is reproduced from the auto_metrics_inspect.ipynb nightly notebook, so check that out for more details on the precise metrics.

ant_metrics Details: If ant_metrics is included, this section shows the average correlation-based metrics for antennas over the whole night. Low "dead ant" metrics (nominally below 0.4) indicate antennas not correlating with the rest of the array. Negative "crossed ant" metrics indicate antennas that show stronger correlations in their cross-pols than their same-pols, indicating that the two polarizations are probably swapped. Bold text indicates that the average is below the threshold for flagging.

redcal chi^2 Details: If redcal is included, this shows the median chi^2 per antenna. This would be 1 in an ideal array. Antennas are thrown out when they they are outliers in their median chi^2, usually greater than 4-sigma outliers in modified Z-score.

In [21]:
HTML(table.render())
Out[21]:
Ant Node A Priori Status Auto Metrics Flags Dead Fraction in Ant Metrics (Jee) Dead Fraction in Ant Metrics (Jnn) Crossed Fraction in Ant Metrics Flag Fraction Before Redcal Flagged By Redcal chi^2 Fraction ee Shape Modified Z-Score nn Shape Modified Z-Score ee Power Modified Z-Score nn Power Modified Z-Score ee Temporal Variability Modified Z-Score nn Temporal Variability Modified Z-Score ee Temporal Discontinuties Modified Z-Score nn Temporal Discontinuties Modified Z-Score Average Dead Ant Metric (Jee) Average Dead Ant Metric (Jnn) Average Crossed Ant Metric Median chi^2 Per Antenna (Jee) Median chi^2 Per Antenna (Jnn)
3 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.000718 -0.634646 0.148403 -0.816729 0.967669 -0.491830 -0.247534 0.414223 0.736096 0.637754 0.438775 10.544967 7.645199
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.222731 6.140671 -0.363628 1.972120 -0.441583 -0.159753 5.373364 0.361201 0.753355 0.626693 0.447759 17.004295 9.502904
5 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.062133 0.487576 -0.438627 5.760210 0.759406 0.884043 3.674172 -0.739299 0.751276 0.639596 0.446039 10.708792 6.460767
7 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.113635 -1.147840 0.875096 0.822608 -0.005495 4.066729 1.265590 7.194386 0.069156 0.064335 0.009758 1.257870 1.256182
8 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 7.858452 7.756523 26.675612 27.388679 15.765824 17.885616 0.257587 -2.210737 0.089671 0.082176 0.010480 1.228993 1.228914
9 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.397713 -1.620250 0.044772 0.272894 0.180022 -0.003568 -0.915267 -1.148985 0.078111 0.061572 0.007314 1.275039 1.272274
10 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.882477 -1.051993 -0.396077 0.915916 1.250097 0.802326 0.775506 -0.384740 0.090075 0.071169 0.013107 1.242944 1.244005
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.463823 0.883879 1.839110 0.470323 -0.941232 -0.679230 -0.049496 7.132524 0.754105 0.644455 0.436936 11.499681 11.551291
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -1.524303 -1.005866 -0.708323 -0.022723 0.036715 0.115181 1.346026 0.354552 0.759543 0.648179 0.438819 0.779297 0.639744
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.484856 0.800123 0.806562 0.702544 0.816874 -0.394358 11.619983 7.250409 0.748037 0.640752 0.441986 11.289432 11.231505
18 N01 RF_maintenance 100.00% 0.00% 77.34% 0.00% 100.00% 0.00% 14.462115 19.809800 3.930931 1.942675 13.197068 4.610684 43.295764 30.264893 0.699238 0.387128 0.502883 6.048054 2.824674
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.566110 1.365986 0.959151 10.693143 26.196793 106.165151 1.151242 0.688447 0.045983 0.058760 0.006434 1.249905 1.246317
20 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.981285 3.548561 0.042977 0.762442 -0.285154 -0.088618 1.519032 -0.723237 0.062480 0.055579 0.004683 1.239157 1.241735
21 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.617758 -0.669937 1.584992 0.900803 22.967074 24.752913 3.445947 2.023401 0.079053 0.064488 0.010065 1.102957 1.101310
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 23.422638 25.944644 35.551540 36.812062 24.645816 26.118563 1.862758 0.982565 0.037698 0.041239 0.002338 1.279685 1.282330
28 N01 RF_maintenance 100.00% 49.95% 100.00% 0.00% 100.00% 0.00% 23.245928 46.594031 0.795715 3.178252 12.193221 13.611011 4.874171 20.993983 0.382377 0.159213 0.248274 6.782112 2.016351
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.739991 -0.925814 0.696019 -0.347990 -0.946302 -0.630504 -0.249709 0.353146 0.755885 0.646166 0.437864 1.181462 1.007180
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.767485 -0.034909 0.231554 -0.549992 2.808195 0.592458 9.903250 -0.569960 0.751252 0.645871 0.441318 8.217051 10.045244
31 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.394918 -1.061621 -0.458191 0.285186 1.880078 3.440095 0.565698 0.170842 0.083527 0.087012 0.018433 1.240258 1.238618
32 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 44.409247 18.752342 3.107224 2.127258 9.959728 18.971340 42.695678 141.560125 0.097801 0.085851 0.010062 1.355255 1.355418
33 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.473730 16.434176 -0.247819 0.239853 30.754036 27.562967 113.971115 111.336200 0.054189 0.096352 0.030409 1.336757 1.322387
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 15.831478 11.871588 0.406583 -0.001201 1.431135 0.709282 1.347805 0.462460 0.767305 0.665077 0.410402 11.436197 7.618471
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.472561 1.852696 -0.042946 0.649100 5.738380 -0.143484 -0.432270 8.503397 0.770903 0.675104 0.408751 14.500966 12.072840
38 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.168769 0.332276 -0.357227 -0.798324 1.257173 1.545288 3.375329 0.215773 0.772829 0.676577 0.419252 1.289280 1.099029
40 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.558700 -0.271716 -0.256293 -0.544537 -0.294171 -0.920806 -0.825490 0.537754 0.079978 0.087753 0.015687 1.214938 1.214030
41 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.178627 -0.899175 3.784125 1.396925 1.402806 -1.041017 -0.786007 0.014909 0.041559 0.074955 0.006620 1.238029 1.235928
42 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.044125 3.501847 2.498898 1.044535 -0.758104 -0.370292 -0.471635 -0.587906 0.090264 0.102629 0.017821 1.253100 1.247706
45 N05 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.106978 1.284020 -0.642899 -0.248805 -0.122389 0.255664 -0.513082 3.022283 0.746929 0.629845 0.453923 1.104317 0.985382
46 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.914365 0.398593 0.233326 -0.782904 -0.778107 -0.777720 -0.211314 4.571148 0.741701 0.632267 0.461065 5.554254 5.356632
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 19.287521 3.772414 0.464741 3.728344 2.098206 0.989557 10.140715 1.310938 0.744369 0.676940 0.371535 13.402084 11.023455
51 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.987450 3.515104 -0.694734 -0.569426 0.211722 0.913428 -0.818865 3.070317 0.771472 0.688832 0.394364 1.586087 1.384575
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 12.401689 10.976249 2.199552 0.249250 5.241054 0.371830 0.294880 -0.639949 0.776845 0.691410 0.394533 14.603412 12.336965
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.920973 3.561489 -0.617399 0.265246 -0.543264 -0.092325 1.294163 4.469761 0.776547 0.690324 0.408056 13.891815 10.726306
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.465320 26.744552 1.336424 1.512398 0.645341 3.833578 0.127570 0.623499 0.094650 0.103375 0.019112 1.202207 1.199721
55 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 2.591775 3.671415 -0.545279 1.633052 4.909692 -0.710820 6.685251 0.629137 0.064822 0.067252 0.006334 1.227293 1.225536
56 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.674846 0.974863 1.889147 1.707322 0.452108 1.547255 -0.128665 13.201299 0.058448 0.058247 0.004553 1.237341 1.233474
57 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 48.334575 -0.274425 10.582060 3.432361 11.447484 -0.001403 2.443265 1.534613 0.111864 0.076845 0.024186 1.168364 1.169557
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.773040 0.998446 0.752244 0.933862 1.138058 0.341263 0.221993 0.391873 0.762548 0.681155 0.409811 1.744443 1.451002
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 2.171244 2.380105 -0.683454 1.267503 -0.115912 2.089667 -0.708239 0.844789 0.771831 0.695823 0.390141 1.576940 1.300739
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.587126 -0.720380 0.084381 0.859122 1.014635 0.255948 -0.238186 -0.226739 0.774484 0.702727 0.379860 1.457793 1.285112
68 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.724386 1.406564 0.202729 10.466520 0.388498 3.554953 0.328102 -0.299157 0.774348 0.692798 0.378102 8.922033 9.508836
69 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.346447 -0.983178 -0.096426 0.076454 1.555559 0.827002 -0.620004 -0.670635 0.103269 0.103929 0.024645 1.231489 1.227850
70 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 11.764318 -1.454700 0.611002 -0.968971 2.609994 2.265415 -0.281667 -0.118386 0.072976 0.072102 0.008527 1.235505 1.235236
71 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.393564 -0.212024 -0.818932 0.152182 0.003568 0.039676 -0.653146 -0.711716 0.087233 0.083409 0.013332 1.202621 1.202971
72 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 5.653505 -0.401279 -0.421397 1.954498 1.284032 0.441090 6.968338 3.673110 0.084670 0.077875 0.013044 1.237231 1.232689
73 N05 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 22.139982 0.336987 34.735896 5.214357 24.525605 1.635140 0.204597 -0.107667 0.035218 0.661062 0.342576 1.209018 4.822102
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.342416 1.291717 -0.704063 5.347754 0.584832 1.747652 2.696634 -0.248434 0.738863 0.672566 0.414653 8.868701 8.184833
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.680130 0.822632 2.830661 -0.289711 -0.398164 0.394527 4.085214 9.260892 0.755720 0.684850 0.401743 10.225162 7.907942
83 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.254420 1.513665 2.925876 5.914086 -0.784412 -0.181068 -0.669230 -0.709139 0.769889 0.706998 0.389028 11.014514 9.833194
84 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 14.380185 15.600494 2.043653 1.431114 -1.007270 0.722977 -0.688205 -1.332677 0.779164 0.709090 0.378917 14.017173 13.947425
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.025917 0.153769 -0.594153 -0.742403 -1.020248 -0.970354 -1.015512 -1.311352 0.759815 0.694743 0.394134 1.562885 1.408643
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.195592 9.487898 -0.187455 0.753293 6.562410 1.975624 0.222313 -0.288522 0.762343 0.665986 0.400642 11.905541 9.074951
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 22.113121 16.407422 3.624668 1.617132 20.055806 0.325369 71.380303 -0.278347 0.717518 0.699342 0.385210 8.248442 9.607054
88 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
90 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
91 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
92 N10 RF_maintenance 100.00% 99.46% 100.00% 0.00% 100.00% 0.00% 64.893106 77.477298 4.217055 5.803617 15.340198 18.838449 1.299146 9.223042 0.276052 0.211509 0.105282 3.444992 3.023475
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.057656 0.072820 4.471351 0.955482 1.000049 -0.732839 0.033890 -1.114495 0.673146 0.585593 0.412485 7.342098 6.333634
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.185920 -1.835654 -0.457376 -0.462858 -0.093478 1.377368 5.398538 3.911519 0.673992 0.571213 0.421779 6.974581 5.184767
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.382738 14.408278 2.027328 1.416582 10.379716 12.184975 7.004963 3.969357 0.733261 0.641952 0.414980 12.544955 9.961005
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.251361 0.197573 4.192478 -0.100143 2.321927 1.751949 0.542454 -0.500910 0.751140 0.674031 0.411734 9.076694 9.005933
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.129955 -0.536617 1.447222 -0.026004 1.215068 -0.974340 -0.198376 -1.088540 0.763535 0.687765 0.404520 1.649059 1.201445
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 13.969980 15.099167 3.952539 0.233967 -0.657373 -1.047423 5.067712 3.023787 0.779669 0.708689 0.389832 10.754012 10.268939
102 N08 RF_maintenance 100.00% 0.00% 8.06% 0.00% 100.00% 0.00% 25.972982 26.887601 5.136967 3.733902 319.613543 342.559502 4338.347206 4320.349803 0.713591 0.507668 0.453908 0.000000 0.000000
103 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.756204 13.436346 0.238214 -0.042304 1.442536 1.095629 0.787702 -0.163028 0.775977 0.704383 0.386112 7.769822 6.238170
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 10.699247 103.720383 1.277045 14.795990 3.796209 0.003753 2.106250 0.000920 0.772589 0.697399 0.405258 6.319400 5.530707
105 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
106 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
107 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
109 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.558301 0.118593 0.396370 0.832868 -0.299683 -0.558419 0.274565 1.240673 0.696821 0.605054 0.417766 1.567591 1.422756
110 N10 RF_maintenance 100.00% 3.22% 6.98% 0.00% 100.00% 0.00% 47.387118 46.311408 3.245171 2.333231 5.657968 12.180788 6.537118 54.446141 0.583495 0.506041 0.248961 7.250030 6.757581
111 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.422119 1.544226 -0.141853 1.736546 0.168861 0.713130 7.464070 5.351041 0.681521 0.589541 0.409982 8.847605 9.864512
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.262457 -0.403197 -0.472126 1.451862 -0.535376 -0.537901 -0.506288 -1.372603 0.668445 0.581895 0.424072 1.808752 1.612762
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 3.21% -0.297871 2.485989 -0.370305 -0.567617 2.442489 1.890873 3.945124 0.676144 0.722409 0.644105 0.436140 1.355464 1.063433
117 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.261838 1.046594 7.002217 7.079434 1.434016 0.396057 0.945010 -0.726477 0.747077 0.669725 0.429774 12.024668 11.162623
118 N07 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 2.440443 29.505855 2.769368 31.025237 -0.031438 26.692914 -0.193162 -0.948185 0.755405 0.048431 0.410680 8.400148 1.270718
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.322245 1.804561 11.907420 0.997137 2.428912 -0.592202 -1.034999 -1.019859 0.774525 0.683368 0.411667 9.325054 6.653085
120 N08 RF_maintenance 100.00% 37.06% 100.00% 0.00% 100.00% 0.00% 24.290310 42.425774 1.387650 41.852670 13.094137 26.133332 -0.102420 3.375433 0.427954 0.044694 0.262094 3.728970 1.186754
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.146723 9.416513 -0.186917 1.106946 9.670350 1.544571 22.152891 14.799078 0.785114 0.711644 0.390080 8.626030 5.638154
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 12.894335 11.174520 1.425591 1.887365 0.698904 -0.974596 -0.561465 -0.954810 0.785256 0.711327 0.394025 5.287544 4.597474
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 11.249750 14.810446 0.426659 0.619937 -0.942958 0.266302 0.146576 -0.019614 0.783051 0.713441 0.398138 10.354725 7.009901
125 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.351242 -0.250753 -0.024074 -0.539725 -0.080819 0.342605 -0.140884 -0.084790 0.697200 0.619222 0.414926 1.495813 1.307058
128 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.428078 6.219833 -0.069471 2.508083 -0.123736 1.727286 -0.363877 -0.445807 0.695076 0.606299 0.407982 8.938381 11.329961
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.519008 -1.095707 -0.676989 -0.778969 -0.911896 0.068767 -0.668001 -0.898284 0.688510 0.602759 0.410186 1.899369 1.542517
130 N10 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.290609 0.295112 0.216748 1.378731 0.346168 -0.326827 0.107092 1.603226 0.669571 0.585369 0.412088 1.789369 1.525762
135 N12 digital_maintenance 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.589469 0.156941 -0.833998 -0.746646 -0.339981 -0.099854 1.398413 1.459807 0.080352 0.090998 0.014427 1.316968 1.316333
136 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.664023 15.857815 -0.719259 0.835821 0.649340 1.093470 1.068631 3.411155 0.077610 0.092060 0.013031 1.224320 1.225424
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 11.690163 2.892330 30.930034 16.148202 20.356436 2.160348 -2.708302 -1.612549 0.731085 0.662843 0.435639 5.792979 5.130745
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.993870 1.893618 26.254453 -0.343813 24.829431 -0.207815 -0.188174 -0.476424 0.758499 0.670586 0.427645 6.973083 4.987131
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 20.928971 25.231115 34.565394 36.867929 24.582369 26.042044 -0.139313 -0.300666 0.038661 0.042630 0.002173 1.141990 1.135269
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.541244 4.151928 0.453567 9.712322 1.014735 2.017006 7.435981 15.233342 0.769454 0.666711 0.394764 6.907913 4.303553
142 N13 digital_ok 100.00% 27.39% 100.00% 0.00% 100.00% 0.00% 39.487431 30.928520 2.029461 37.098140 13.470020 26.036777 1.514940 0.513113 0.447142 0.041972 0.213567 2.166178 0.887705
143 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.229226 -0.642359 1.261196 1.428152 -0.030140 -1.181060 -0.527700 -0.490320 0.769465 0.710289 0.398529 0.000000 0.000000
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.929214 -1.024642 2.119470 1.774670 -0.361039 33.508906 3.467563 10.753035 0.772690 0.694304 0.413931 0.000000 0.000000
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 23.787587 26.357786 35.830248 37.477815 24.717795 26.295294 1.205963 2.058728 0.032788 0.032882 -0.000537 0.000000 0.000000
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 26.083415 29.573531 35.678397 38.340870 24.792955 26.249910 1.731747 1.819729 0.045865 0.046577 0.000648 1.214590 1.214839
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 21.956040 21.497152 34.712234 36.544962 24.494588 26.035078 1.522957 1.342058 0.035443 0.038044 0.000879 1.205887 1.327700
156 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.055308 17.391039 2.065325 0.867784 -0.463670 30.361414 1.939803 46.925211 0.053920 0.078894 0.003690 23.097632 21.962288
157 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.477891 -1.091793 0.164828 3.855760 -0.515744 -0.910168 -0.014909 -0.455488 0.067493 0.062722 0.006430 30.244071 53.323990
158 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 22.465660 -1.548885 35.553667 0.243342 24.833922 0.018842 -0.009547 1.325577 0.031702 0.066113 0.059267 0.000000 0.000000
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 22.502059 24.394398 35.323948 36.944466 24.703474 26.175823 1.247677 1.664350 0.039307 0.043184 0.003349 0.000000 0.000000
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.454356 51.434703 0.315470 3.716702 -0.586916 5.639604 1.696920 0.751064 0.768015 0.572071 0.392642 0.000000 0.000000
162 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.961056 0.706622 0.179675 -0.700673 1.083692 -0.362222 0.473461 1.476312 0.774430 0.691860 0.403770 0.000000 0.000000
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.586790 -0.025917 0.022723 -0.846513 -1.204998 -0.092183 0.672837 2.061765 0.774874 0.700857 0.402987 0.000000 0.000000
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.530206 -0.629968 -0.736417 0.425404 -0.499359 19.994449 0.719159 2.416603 0.772286 0.697511 0.406181 0.000000 0.000000
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.426076 0.865748 7.762938 -0.776678 0.789025 -0.957344 2.265240 0.045280 0.776861 0.699235 0.410175 0.000000 0.000000
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 47.426892 39.752973 2.670510 2.085057 7.564730 6.335812 19.605778 39.679778 0.642743 0.566139 0.234824 5.484655 4.077335
167 N15 digital_ok 100.00% 8.06% 0.00% 0.00% 100.00% 0.00% 51.593268 22.482244 23.234680 27.247702 20.835633 19.292382 97.109792 38.891812 0.554147 0.548389 0.244300 3.749418 3.790128
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.962697 11.517303 26.899563 30.472390 15.925495 20.637384 -1.626222 -2.740895 0.757493 0.662945 0.428829 8.727166 6.042214
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 11.327277 9.943659 29.995046 28.672496 18.681960 18.882120 -1.643079 5.068762 0.748760 0.650470 0.437797 9.790375 6.347387
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 11.150799 7.777593 30.418514 27.180439 19.215497 17.158518 -1.115014 -1.960741 0.733168 0.656263 0.448541 8.261321 6.132683
176 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.505548 -0.297552 -0.364924 1.094200 -0.718478 0.252076 -0.064967 1.591698 0.056861 0.072796 0.004925 15.351949 41.057445
177 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.459977 2.369761 1.162331 6.372483 -0.351035 53.593902 5.467158 10.392233 0.068062 0.069041 0.007061 0.000000 0.000000
178 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.217148 -0.773972 0.996036 -0.671993 -1.225546 1.373525 1.435145 0.110061 0.073425 0.062421 0.010352 0.000000 0.000000
179 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.104599 1.163918 -0.792024 0.067664 2.194970 -0.781281 0.681099 -1.478662 0.064023 0.064269 0.012006 -0.000000 -0.000000
180 N13 RF_maintenance 100.00% 0.00% 87.11% 0.00% 100.00% 0.00% 0.668533 21.783497 0.775231 35.333569 -0.408415 21.485000 1.048863 0.929200 0.764062 0.313171 0.548714 0.000000 0.000000
181 N13 digital_ok 100.00% 100.00% 96.78% 0.00% 100.00% 0.00% 24.410956 69.687964 35.985371 11.048916 24.731103 23.762066 1.090610 6.247627 0.043020 0.252487 0.098598 0.000000 0.000000
182 N13 RF_maintenance 100.00% 0.00% 22.02% 0.00% 100.00% 0.00% 8.050530 7.483698 26.739471 17.042145 14.881995 118.801985 -1.551207 1.147623 0.765555 0.596163 0.444906 0.000000 0.000000
183 N13 digital_ok 100.00% 0.00% 6.44% 0.00% 100.00% 0.00% -1.538437 -1.573049 0.059626 2.320213 -0.969709 64.847440 1.002440 9.291013 0.767738 0.638295 0.430075 0.000000 0.000000
184 N14 digital_ok 100.00% 2.15% 0.00% 0.00% 100.00% 0.00% 0.658878 0.108232 2.038865 0.607006 44.329740 -0.232618 6.968506 -1.186698 0.748495 0.691134 0.414489 0.000000 0.000000
185 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.080354 0.023914 0.009468 1.188891 23.694440 -0.659221 4.866161 4.612245 0.776526 0.690913 0.408140 0.000000 0.000000
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.222909 -0.339161 3.394996 2.186086 2.105270 -0.642476 6.835474 0.964746 0.764296 0.686223 0.408846 0.000000 0.000000
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.511196 1.635680 0.215445 1.292029 -0.530180 -0.561925 6.194864 2.330439 0.760775 0.690518 0.412261 8.224500 6.913602
189 N15 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 3.74% 3.166218 3.592974 0.789109 -0.356675 0.115650 3.219561 1.794390 1.087516 0.746105 0.667447 0.436460 2.056275 1.635583
190 N15 digital_ok 100.00% 15.04% 100.00% 0.00% 100.00% 0.00% 75.854462 29.977024 5.235608 37.468333 15.326430 26.315620 109.386530 1.865611 0.531707 0.042708 0.318080 3.864798 1.380583
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.497937 0.775996 -0.524141 -0.820426 -0.349338 -0.759702 14.408894 5.326910 0.739564 0.653136 0.465256 6.985612 5.713924
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% 24.109468 24.126203 19.062513 3.636091 10.579364 7.673400 15.590797 22.230215 0.748484 0.608317 0.436055 0.000000 0.000000
206 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 23.269016 22.945236 3.880272 11.369344 5.144116 10.232401 18.603296 25.624266 0.703812 0.637438 0.426226 0.000000 0.000000
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 24.099514 23.495499 21.196436 17.073571 11.578956 9.740239 6.151541 5.733948 0.729628 0.640624 0.414836 7.486677 5.597722
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% 46.333401 46.334013 inf inf 2209.076715 2580.561582 5232.968612 7197.188838 nan nan nan 0.000000 0.000000
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 23.145621 22.741825 10.131740 14.868535 2.585416 49.178132 0.151839 1.117565 0.729155 0.625264 0.434524 0.000000 0.000000
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 28.291701 27.196138 33.442183 32.379539 24.011079 23.822610 -3.520582 -3.919995 0.703310 0.601952 0.423953 0.000000 0.000000
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% 46.023261 45.991754 inf inf 3068.091353 3268.481292 8735.725257 8761.637481 nan nan nan 0.000000 0.000000
320 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 31.316608 28.967962 22.707354 23.382106 24.340498 25.886976 3.425152 1.456541 0.051089 0.047689 0.002679 0.000000 0.000000
321 N02 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 3.251820 1.779228 17.626571 15.594064 11.350366 9.003641 20.537194 19.632912 0.099266 0.085558 0.041678 0.000000 0.000000
323 N02 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 34.027488 4.054573 2.919661 21.035701 15.010700 11.055765 65.475314 4.259229 0.083451 0.087481 0.035042 0.000000 0.000000
324 N04 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 6.759723 4.229177 23.102905 14.772001 12.080389 6.713344 1.019937 0.103642 0.103365 0.086993 0.044855 0.000000 0.000000
329 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 9.654673 0.897616 -0.153575 15.109379 56.204768 6.562718 6.551299 0.792854 0.086660 0.086846 0.031287 0.000000 0.000000
333 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 7.852665 1.875901 -0.051541 13.030285 8.231309 39.621093 -0.148397 7.029477 0.085005 0.085448 0.033941 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, 17, 18, 19, 20, 21, 27, 28, 30, 31, 32, 33, 36, 37, 40, 41, 42, 46, 50, 52, 53, 54, 55, 56, 57, 68, 69, 70, 71, 72, 73, 81, 82, 83, 84, 86, 87, 88, 90, 91, 92, 93, 94, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 110, 111, 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 128, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 150, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 203, 205, 206, 207, 220, 221, 222, 223, 224, 241, 242, 243, 320, 321, 323, 324, 329, 333]

unflagged_ants: [16, 29, 38, 45, 51, 65, 66, 67, 85, 100, 109, 112, 127, 129, 130]

golden_ants: [16, 29, 38, 45, 51, 65, 66, 67, 85, 100, 109, 112, 127, 129, 130]
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_2459827.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 [ ]: