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 = "2459823"
data_path = "/mnt/sn1/2459823"
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-31-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/2459823/zen.2459823.25320.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 850 ant_metrics files matching glob /mnt/sn1/2459823/zen.2459823.?????.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 9 ant_metrics files matching glob /mnt/sn1/2459823/zen.2459823.?????.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 2459823
Date 8-31-2022
LST Range 18.164 -- 2.163 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 852
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 77 / 147 (52.4%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 106 / 147 (72.1%)
Redcal Done? ✅
Redcal Flagged Antennas 1 / 147 (0.7%)
Never Flagged Antennas 19 / 147 (12.9%)
A Priori Good Antennas Flagged 77 / 95 total a priori good antennas:
5, 7, 9, 10, 19, 20, 21, 29, 30, 31, 37, 38,
40, 41, 42, 45, 46, 53, 54, 55, 56, 66, 67,
69, 71, 72, 73, 81, 83, 84, 88, 91, 93, 94,
98, 99, 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, 186, 187, 189, 190, 191
A Priori Bad Antennas Not Flagged 1 / 52 total a priori bad antennas:
4
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_2459823.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% 1.028098 -0.886778 -0.614288 -0.868830 -0.272488 -1.225077 -0.753297 -0.665162 0.743528 0.595001 0.496868 2.247465 2.454165
4 N01 RF_maintenance 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.307505 3.257683 -0.521105 1.630455 -0.547578 -0.817576 0.269298 -0.191831 0.756360 0.589502 0.502013 15.265260 15.810155
5 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.050456 0.495541 -0.605939 4.241223 -0.551837 2.236282 -0.242704 -1.663781 0.756470 0.597681 0.507279 8.228280 8.908313
7 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.219268 -1.044600 0.950737 0.787282 0.007621 0.347846 -0.308359 6.011210 0.051071 0.066937 0.009332 1.249366 1.248400
8 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 15.731094 16.075401 18.458689 18.942022 23.963424 25.608523 14.551610 12.636771 0.088093 0.077852 0.012538 1.230065 1.223340
9 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.236776 -0.826435 -0.047485 -0.127144 0.453349 0.789229 0.550656 2.292016 0.072319 0.059669 0.009367 0.885633 0.890110
10 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.199248 -1.079663 -0.561886 0.515014 -0.704675 0.625826 1.470253 0.845615 0.076801 0.062900 0.013796 0.982258 0.970710
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.619863 1.351172 -0.743170 -0.647324 -0.480694 -0.128103 1.522333 1.215017 0.755334 0.600013 0.498805 2.645347 3.036308
16 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.027864 -0.994688 -0.312208 -0.792135 0.056907 -0.827901 3.600494 0.686723 0.760472 0.602895 0.498026 2.448673 2.551248
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.011050 1.011335 0.837314 0.995851 1.000728 2.908148 3.466225 2.833596 0.751460 0.598814 0.503284 2.434786 3.312349
18 N01 RF_maintenance 100.00% 0.00% 68.24% 0.00% 100.00% 0.00% 3.916172 3.218134 3.017163 0.059536 3.105287 6.898303 25.251734 103.994909 0.712697 0.360145 0.546136 7.414097 3.810002
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.868080 8.704884 -0.910580 13.088749 0.195031 12.019292 1.901549 4.562713 0.054431 0.066945 0.008399 1.245676 1.243031
20 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.457072 0.801631 -0.459845 -0.317510 0.163359 1.046486 -0.148766 -0.594253 0.067483 0.058912 0.007207 1.115213 1.112574
21 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.164947 -0.551671 1.268578 1.550341 0.079503 2.011359 3.528965 -0.663222 0.075090 0.065312 0.011912 0.000000 0.000000
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 24.674448 25.090014 47.289348 48.093592 34.417077 35.846334 31.159017 29.780164 0.037373 0.040752 0.002718 1.294258 1.306838
28 N01 RF_maintenance 100.00% 43.53% 100.00% 0.00% 100.00% 0.00% 14.719953 17.083429 5.590782 6.759681 31.755610 37.682714 24.315739 103.816295 0.379915 0.153569 0.238969 23.376009 5.418071
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 11.11% -0.867705 -0.326409 0.456486 -0.327406 -0.181231 -1.447386 -0.382522 2.986091 0.760346 0.605700 0.500166 3.896885 3.923334
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.094147 -0.357138 0.173846 -0.827760 0.255894 -0.021975 13.556504 0.381534 0.753298 0.605684 0.502434 6.818279 6.920826
31 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.493016 -0.538982 -0.755584 -0.769096 0.623416 0.333823 5.486428 9.256052 0.074863 0.087864 0.018460 1.229206 1.230723
32 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 5.614933 34.502261 4.472487 3.036750 2.965655 6.329502 2.684937 25.283167 0.078717 0.091462 0.015365 1.187893 1.198302
33 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.571088 4.962658 0.736730 -0.269548 1.782601 0.179344 -0.165174 1.955274 0.771921 0.630256 0.462150 6.353631 5.422087
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.105633 1.046897 -0.788229 -0.411650 -0.881893 -0.568030 -0.053923 21.387341 0.774251 0.641223 0.460110 50.472128 24.740967
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.809851 0.235825 -0.747559 -0.803592 0.595494 -0.850315 15.113180 3.026386 0.776185 0.642794 0.471206 4.659817 3.748822
40 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.067552 0.121812 0.192441 -0.177182 1.805723 0.163904 0.341806 -0.330182 0.089719 0.097073 0.022558 1.210466 1.211290
41 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.037098 -1.465375 2.011222 1.181955 0.894975 -0.767755 -1.388988 -0.185917 0.041175 0.085311 0.011666 1.205092 1.191448
42 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.953798 0.011050 2.093095 1.082141 -0.218083 1.439711 -1.429974 -0.034195 0.092440 0.108540 0.023512 1.207239 1.222951
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.332779 0.191154 -0.780729 0.652576 -0.923591 -0.533018 0.586265 9.160366 0.739792 0.582683 0.511945 3.443867 3.416652
46 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.078677 -0.858797 0.082972 -0.542656 -0.305754 -0.600263 -0.115259 14.841478 0.731806 0.581295 0.521899 3.143487 3.045796
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.065242 19.837810 -0.263304 1.458389 0.153787 6.709533 6.331548 21.591339 0.768669 0.576327 0.427185 9.524199 10.744450
51 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.586236 1.161557 -0.608498 -0.195303 0.089422 1.211805 -0.201392 2.243395 0.778701 0.662472 0.439020 2.130212 2.051685
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.450111 5.767260 0.122859 0.068141 2.015915 -0.895345 0.771404 4.048611 0.782612 0.663542 0.440898 52.452986 35.555434
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.648223 1.608764 -0.469414 0.110027 -0.442356 -0.335190 5.215615 12.776737 0.782302 0.664297 0.455365 30.211795 14.042985
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.168314 6.588890 1.941136 3.457562 0.094130 3.290488 2.220261 1.683441 0.095527 0.105533 0.021991 1.132707 1.129892
55 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 3.644528 0.331745 0.935400 1.269704 1.047472 -0.906996 17.276892 0.558736 0.067813 0.067201 0.007454 1.196664 1.196224
56 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.734172 0.968297 1.517145 1.882071 0.499509 1.768923 1.050352 45.771353 0.062616 0.059495 0.005277 1.157726 1.166768
57 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 26.749726 -0.917430 15.967771 2.461596 13.280491 2.190056 20.948857 7.199814 0.114398 0.084258 0.025054 0.856762 0.856478
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.322386 0.468146 -0.014150 1.325904 0.006220 -0.818015 -0.110821 1.701625 0.770664 0.658588 0.456600 1.145444 1.149831
66 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.569572 -0.191054 -0.559088 0.204140 1.210198 0.117794 0.691408 5.543695 0.779677 0.675790 0.436450 10.286593 12.268885
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.359207 -0.001174 -0.838419 0.177522 1.051559 1.159175 3.172144 9.664574 0.784245 0.683098 0.422024 6.633334 8.374283
68 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.486251 1.711329 1.121924 2.410308 0.868924 1.896999 -0.843725 1.057194 0.784018 0.679152 0.424370 1.989428 2.039854
69 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.068947 -0.683295 0.403604 0.574588 -0.711853 0.658869 -0.285360 -0.307389 0.104659 0.108638 0.029249 1.234352 1.234605
70 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 7.203718 -1.398972 1.485308 -0.452326 0.479001 -0.939514 -0.679824 1.893036 0.080453 0.075607 0.009758 1.182393 1.195141
71 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.211216 -0.310490 -0.087638 -0.426247 -0.638842 -0.260488 1.932679 8.126819 0.088907 0.088872 0.015283 1.189927 1.194340
72 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.125065 -0.657474 -0.697792 1.883983 -0.343370 1.756559 1.868401 -1.509048 0.088951 0.074259 0.011898 1.125285 1.125856
73 N05 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 25.179339 0.478329 46.463214 2.124980 34.197772 0.255078 25.600294 0.139449 0.033230 0.618532 0.276241 -0.000000 -0.000000
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.359388 2.555322 -0.271483 3.438580 1.025106 5.515841 2.108575 0.114578 0.746291 0.646613 0.457844 69.611679 33.388479
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.524845 0.001722 1.844314 2.480797 -0.076600 0.519363 1.531980 0.746816 0.755263 0.658960 0.446776 63.227405 33.892769
83 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.001027 2.884907 2.433861 4.687827 1.513172 3.831000 -0.653437 -1.345082 0.779024 0.689892 0.433771 147.893082 62.287714
84 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 7.231308 8.839119 0.659478 0.981154 0.123828 -0.535560 -0.388015 0.350581 0.786624 0.692459 0.420767 202.509415 110.692068
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.283099 0.530801 0.912609 1.779007 -0.494278 -0.405466 0.070111 -0.001491 0.771254 0.676686 0.435254 1.812637 1.808984
86 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 2.384351 2.354315 1.876108 -0.484614 2.791269 1.076924 0.200362 1.156542 0.777000 0.649288 0.446848 2.066423 1.956057
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.918211 10.385934 7.149053 1.335014 6.515622 -0.228776 -1.247014 0.409423 0.786014 0.674296 0.463573 7.865166 7.569830
88 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 20.448274 17.031510 21.909186 19.903685 29.505127 27.050636 18.641626 13.740034 0.745587 0.651252 0.483823 4.149059 4.643277
90 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.521258 -0.107476 0.392039 3.744525 -0.416640 -0.313386 1.024805 6.746483 0.754881 0.612490 0.502614 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% 100.00% 100.00% 0.00% 100.00% 0.00% 35.913613 50.726114 7.925789 10.408295 32.343100 39.224624 24.509696 39.757632 0.085773 0.082756 0.010532 0.000000 0.000000
93 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.975470 -0.419479 2.775158 0.801997 1.456204 -0.634084 0.778937 -1.558880 0.071138 0.082276 0.011280 0.000000 0.000000
94 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.967149 -1.697189 -0.696849 -1.002644 -0.765968 6.328372 7.235540 13.993654 0.074515 0.089570 0.013246 0.000000 0.000000
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.721086 1.848214 1.381465 3.193632 2.267821 -0.094527 20.047806 4.246186 0.741002 0.624294 0.477751 66.875538 42.995406
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.771717 0.788965 3.578719 1.142731 2.775243 0.167341 -1.152922 -0.737041 0.758068 0.652637 0.462811 228.941711 151.466232
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.820325 -0.544118 -0.197036 0.067587 -0.065820 -0.768452 -0.734296 0.726150 0.769670 0.668102 0.454170 0.434218 0.400088
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.002589 8.647694 3.607372 0.169965 2.982933 -1.399017 2.454022 -0.399985 0.786442 0.689792 0.433551 155.144146 103.034607
102 N08 RF_maintenance 100.00% 0.00% 10.59% 0.00% 100.00% 0.00% 1.632754 8.471618 14.031290 32.642808 6.692932 13.955530 6.836866 9.101172 0.719136 0.478805 0.481579 48.812566 26.598913
103 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.079120 8.291959 -0.277211 0.232309 -0.242623 0.504386 -0.031557 -0.557655 0.787350 0.689963 0.432971 34.635834 23.544683
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 5.468717 68.845466 -0.047758 13.890574 0.689014 5.733384 1.126189 3.043864 0.787001 0.676243 0.456750 5.432226 4.443025
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% 0.00% 0.00% 0.00% 100.00% 0.00% 17.829353 13.265911 19.722397 18.242573 25.432436 23.738259 12.927414 11.676428 0.764712 0.637844 0.487568 2.458708 2.090916
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% 100.00% 100.00% 0.00% 100.00% 0.00% -0.990560 0.565278 0.793331 0.752447 -0.700674 1.854382 -0.495024 1.274363 0.084682 0.079379 0.020791 0.000000 0.000000
110 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 37.172853 21.260132 3.618400 2.725596 2.767622 7.587693 0.193587 3.446821 0.094995 0.086875 0.009570 0.000000 0.000000
111 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.308320 1.582711 -0.343413 0.599805 0.885647 1.684812 -0.023896 -0.205977 0.057220 0.061251 0.006230 0.000000 0.000000
112 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.707099 -0.568193 -0.893045 0.626505 -0.395276 -0.758145 -0.592885 -1.372948 0.062591 0.071824 0.009494 0.000000 0.000000
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.031126 1.988051 -0.414086 -0.640072 -0.296171 -1.060637 2.208299 -0.591139 0.726081 0.610259 0.492311 1.825183 1.486039
117 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.293578 2.307048 5.183036 5.516737 4.995661 5.092739 -1.095148 -1.536233 0.752620 0.641696 0.484415 166.986820 171.706242
118 N07 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 2.541613 27.536644 2.933803 42.490663 1.606483 36.032293 -0.468575 25.210659 0.766288 0.048671 0.377115 54.166641 1.333457
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.357035 0.937717 9.217208 0.484319 10.356860 0.401718 -0.106000 -0.892412 0.781952 0.660396 0.460997 42.684808 26.160059
120 N08 RF_maintenance 100.00% 35.29% 100.00% 0.00% 100.00% 0.00% 17.848101 33.306177 6.818738 53.203895 32.265394 36.650243 26.645274 38.594585 0.436628 0.040546 0.244092 5.833716 1.284018
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.647958 5.142471 -0.458133 0.472254 0.907905 1.341867 56.775674 49.468164 0.793007 0.691177 0.434353 3.540516 3.266989
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.134794 7.107214 1.633201 1.127315 1.184904 -0.022693 1.219938 1.421897 0.794021 0.688240 0.437243 8.950929 3.816369
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 5.861247 8.551935 -0.077167 0.198783 -0.534924 -1.205590 -0.133621 -0.470597 0.790837 0.685567 0.442930 18.337541 11.158559
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% 100.00% 100.00% 0.00% 100.00% 0.00% 0.205242 -0.081809 0.196367 -0.238519 1.332340 0.157754 0.572935 0.380172 0.094218 0.082980 0.028497 0.000000 0.000000
128 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.134370 1.112929 -0.631083 1.052794 1.554595 -0.506494 0.669227 -1.170823 0.084279 0.071764 0.018720 0.000000 0.000000
129 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.099722 -1.031437 -0.677003 -0.729735 -0.360239 0.003740 -0.679755 -0.087274 0.050788 0.064676 0.006225 0.000000 0.000000
130 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.612726 -0.153366 0.948787 1.999135 0.486698 1.537879 0.750002 8.870196 0.071064 0.071929 0.011340 0.000000 0.000000
135 N12 digital_maintenance 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.505161 0.136650 -0.819738 -0.795755 -0.856199 -1.314302 -0.027468 -0.254507 0.080029 0.082957 0.017983 1.295809 1.293197
136 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 3.491461 13.598112 0.115597 1.298589 2.253763 1.144681 4.449578 4.015504 0.079079 0.086610 0.017879 1.348030 1.339413
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 19.256452 15.228876 20.833688 18.238692 27.638700 24.750522 14.786747 11.335449 0.739622 0.621858 0.491167 3.780346 3.995202
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 16.368590 0.792545 19.036542 -0.352842 24.468788 -0.786779 11.562021 -0.259351 0.763891 0.640067 0.479585 3.126501 3.177069
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 23.265495 23.078012 46.285535 48.131411 34.331221 36.044470 24.975171 26.792219 0.038390 0.041917 0.001225 1.178492 1.165979
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.950741 5.757542 -0.013587 10.936203 0.303055 2.427144 0.889568 18.654453 0.781504 0.634724 0.453357 8.082341 3.948999
142 N13 digital_ok 100.00% 34.12% 100.00% 0.00% 100.00% 0.00% 21.604792 28.222044 6.587560 48.396396 37.127597 36.133838 26.995375 30.120324 0.444047 0.041098 0.193240 0.000000 0.000000
143 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.276781 -1.082827 1.421349 1.067012 0.415518 -0.003740 0.229084 -1.728416 0.781475 0.682112 0.445327 0.000000 0.000000
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.464063 0.478611 2.116515 3.531603 0.612442 3.053780 -0.072801 27.338390 0.782054 0.662660 0.460241 0.000000 0.000000
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 24.855238 24.998723 47.569887 48.813595 34.491916 35.959935 29.561307 33.568126 0.031979 0.032602 -0.000649 0.000000 0.000000
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 24.820965 25.285743 47.505866 49.711772 34.527857 36.056200 30.332159 32.822204 0.041864 0.041525 0.000640 0.000000 0.000000
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 24.170496 23.948184 46.267877 47.786683 34.300356 35.729230 33.580352 34.317987 0.034549 0.033130 0.001055 1.361382 1.287465
156 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.541414 1.639187 1.585672 0.120993 0.684026 -0.442509 1.236058 10.564194 0.048398 0.053692 0.004281 95.051216 39.260636
157 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.665687 -0.222077 -0.489104 3.349845 0.133980 0.648113 0.724049 -1.694407 0.066618 0.055905 0.006323 511.742416 95.254002
158 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.097482 -0.601732 -0.848384 -0.869630 -0.102488 -0.435006 -0.478248 1.335237 0.082315 0.067266 0.011984 0.875719 0.888579
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 23.435476 22.959861 47.074828 48.240564 34.474761 36.057551 29.155232 34.085500 0.038760 0.041949 0.004271 1.182568 1.197078
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.130860 43.349897 -0.075021 4.220495 0.334774 7.168843 0.040306 2.964432 0.774901 0.548346 0.443819 5.850605 11.186245
162 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.574622 1.053068 -0.636383 -0.671978 0.803208 -0.279457 0.508544 0.033739 0.777170 0.657522 0.456393 3.078306 3.205754
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.504561 -0.105032 0.014762 -0.412099 -0.282217 1.130897 -0.089241 1.512185 0.779634 0.669792 0.448235 2.647421 2.889904
164 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.751086 -1.413271 -0.547635 -0.630496 -0.415645 -0.690112 -0.071578 0.720728 0.777168 0.669668 0.453091 2.913442 2.958160
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.406650 1.521926 7.032059 -0.680219 6.567471 -0.648024 -0.547075 0.042533 0.776644 0.666209 0.455715 58.284873 46.307863
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.995590 0.856294 1.764239 2.398829 1.893604 1.380459 30.986309 3.074956 0.743338 0.644212 0.454430 0.000000 0.000000
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 20.958396 20.652667 15.205119 19.109062 26.948613 30.173406 37.409301 21.875303 0.610891 0.506072 0.347848 0.000000 0.000000
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 15.723854 18.471720 18.655558 20.926496 23.903072 28.592853 11.841304 15.887068 0.740315 0.611045 0.497803 0.000000 0.000000
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 18.556653 17.424104 20.513580 19.756664 26.962562 27.126795 14.120724 14.073687 0.727659 0.595142 0.507920 0.000000 0.000000
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 18.819777 15.931121 20.764973 19.070924 27.342136 25.008653 14.459468 11.972770 0.712545 0.601503 0.518908 0.000000 0.000000
176 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.283350 -0.017149 -0.313364 0.999755 0.159393 0.517547 -0.258183 3.981721 0.052800 0.064827 0.007711 219.337532 100.126732
177 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.526438 2.341019 1.146881 2.746202 0.525643 2.309272 23.283651 3.640629 0.069960 0.062481 0.006413 668.552567 163.545555
178 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.398640 -1.693145 0.677235 -0.961398 -0.289124 -1.085879 0.199169 -0.944758 0.073136 0.060009 0.009533 648.765076 252.588753
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 2.002835 -0.135416 -0.340247 -0.024544 0.750044 -0.033247 9.849564 0.163716 0.065149 0.070651 0.017116 0.877384 0.882741
180 N13 RF_maintenance 100.00% 0.00% 92.94% 0.00% 100.00% 0.00% 0.825330 16.538335 0.292635 43.911897 1.929401 24.079039 0.445894 21.951941 0.765812 0.281878 0.582256 317.222939 41.389027
181 N13 digital_ok 100.00% 100.00% 98.82% 0.00% 100.00% 0.00% 25.316024 47.979873 47.743096 4.743025 34.538390 38.948675 29.078752 29.202734 0.042419 0.257845 0.097761 1.201097 3.073280
182 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 15.421866 26.135180 18.755413 47.253742 24.220842 33.503137 10.591726 30.632902 0.769001 0.131592 0.483439 53.462581 5.233170
183 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -1.221236 -1.128744 0.279870 -0.735390 -0.245109 -1.729318 0.001491 3.940904 0.771445 0.645840 0.468353 2.910879 2.986532
184 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.480756 0.165569 0.014150 0.387050 1.070376 0.467803 1.214390 -0.352369 0.771990 0.655702 0.448797 2.635870 2.880892
185 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.287174 0.169959 1.046617 0.880321 -0.461142 1.249323 1.170286 -0.308928 0.777514 0.657279 0.454154 2.656774 2.766368
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.724811 0.048417 4.386796 2.660285 2.756809 0.195171 5.564810 0.952722 0.758960 0.649237 0.453747 5.240813 6.424942
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.051655 0.625112 0.437129 0.912772 0.482460 -0.894384 15.354463 2.553835 0.755918 0.656257 0.461339 0.000000 0.000000
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.116796 5.014118 0.277618 0.969141 -0.175741 1.410753 2.502187 5.448068 0.730728 0.618440 0.499110 0.000000 0.000000
190 N15 digital_ok 100.00% 18.82% 100.00% 0.00% 100.00% 0.00% 29.313380 27.076991 2.332616 48.790199 21.763454 36.047252 65.020554 32.204252 0.588687 0.038947 0.325138 0.000000 0.000000
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.634427 0.470688 -0.777612 -0.577138 0.500662 0.184662 3.467338 11.875316 0.722428 0.599584 0.526759 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% 21.373103 19.848597 12.378287 1.085038 17.145476 2.315489 5.016642 22.385516 0.753199 0.561205 0.493609 12.193864 8.184271
206 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 16.868102 18.657007 3.727173 9.171156 7.771865 11.408617 1.822391 3.740808 0.718312 0.598026 0.473825 4.106594 4.200779
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 23.356454 20.746128 14.568550 11.853466 21.205165 16.404572 8.197825 4.923311 0.728687 0.600188 0.468402 0.000000 0.000000
220 N18 RF_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
221 N18 RF_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
222 N18 RF_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 18.190594 17.510864 7.877900 5.921908 10.536313 8.302082 1.644926 41.910143 0.736219 0.566754 0.493185 12.712826 7.889633
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 30.309040 29.741259 21.832031 21.589928 30.915896 31.615699 17.362579 18.028482 0.705213 0.554456 0.473857 8.906316 6.358276
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% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
320 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 28.629851 27.346143 34.489121 34.723886 34.752680 35.801407 37.835549 33.392610 0.047575 0.044616 0.002842 0.000000 0.000000
321 N02 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
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% 13.679164 8.043625 16.360953 10.678824 21.953628 15.023006 8.714393 3.237700 0.104226 0.080693 0.047721 0.000000 0.000000
329 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 3.229559 7.229390 5.593716 10.823108 7.252207 14.976074 10.743010 3.098321 0.088657 0.077006 0.038620 0.000000 0.000000
333 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 2.299714 6.652733 0.637278 10.282890 4.232627 12.232111 2.671227 1.172054 0.087086 0.078298 0.040759 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, 18, 19, 20, 21, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 40, 41, 42, 45, 46, 50, 52, 53, 54, 55, 56, 57, 66, 67, 69, 70, 71, 72, 73, 81, 82, 83, 84, 87, 88, 90, 91, 92, 93, 94, 98, 99, 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, 143, 144, 145, 150, 155, 156, 157, 158, 160, 161, 165, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 181, 182, 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, 15, 16, 17, 51, 65, 68, 85, 86, 100, 116, 162, 163, 164, 183, 184, 185]

golden_ants: [3, 15, 16, 17, 51, 65, 68, 85, 86, 100, 116, 162, 163, 164, 183, 184, 185]
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_2459823.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.dev47+ga570afb
3.1.4.dev14+g122e1cb
In [ ]: