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 = "2459824"
data_path = "/mnt/sn1/2459824"
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-1-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/2459824/zen.2459824.44553.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 998 ant_metrics files matching glob /mnt/sn1/2459824/zen.2459824.?????.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 100 ant_metrics files matching glob /mnt/sn1/2459824/zen.2459824.?????.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 2459824
Date 9-1-2022
LST Range 18.228 -- 4.250 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 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 114 / 147 (77.6%)
Redcal Done? ✅
Redcal Flagged Antennas 3 / 147 (2.0%)
Never Flagged Antennas 12 / 147 (8.2%)
A Priori Good Antennas Flagged 84 / 95 total a priori good antennas:
3, 5, 7, 9, 10, 15, 16, 17, 19, 20, 21, 29,
30, 31, 37, 38, 40, 41, 42, 45, 53, 54, 55,
56, 69, 71, 72, 73, 83, 84, 86, 88, 91, 93,
94, 99, 100, 101, 103, 105, 106, 107, 108,
109, 111, 112, 117, 118, 121, 122, 123, 127,
128, 129, 130, 140, 141, 142, 143, 144, 156,
157, 158, 160, 161, 162, 163, 164, 165, 167,
169, 170, 176, 177, 178, 179, 181, 183, 184,
185, 186, 189, 190, 191
A Priori Bad Antennas Not Flagged 1 / 52 total a priori bad antennas:
90
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_2459824.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% 100.00% 100.00% 0.00% 100.00% 0.00% 190.771639 190.692969 inf inf 2234.238096 2236.246761 4906.128936 4886.630179 nan nan nan 0.000000 0.000000
4 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 198.146054 195.231812 inf inf 3160.985192 3232.919946 5948.164156 6352.920521 nan nan nan 0.000000 0.000000
5 N01 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 328.583378 329.089655 inf inf 5467.034264 5432.682885 8163.889653 8090.803549 nan nan nan 0.000000 0.000000
7 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.217356 -0.833285 0.036548 -0.475561 8.440015 8.343996 10.873896 29.845771 0.050773 0.056231 0.005519 24.677699 19.834121
8 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 6.417581 4.377690 23.206568 23.808236 10.678485 14.645146 13.661605 9.839828 0.080328 0.078199 0.009265 40.683834 37.135650
9 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.313578 -0.541585 -0.249392 -0.255378 11.703866 11.362590 20.766665 21.377315 0.081443 0.063972 0.008370 0.965512 0.966638
10 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.765149 -0.431301 -0.767454 0.229355 7.922095 7.810270 14.674376 13.410154 0.099541 0.071162 0.014031 0.996788 0.993954
15 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.045235 0.373610 1.306875 0.341704 7.881001 7.860668 14.628566 15.077526 0.701596 0.686660 0.408798 2.724829 2.699503
16 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.362613 0.621176 0.085369 -0.942937 4.767340 5.140215 6.539801 7.427482 0.701217 0.677402 0.414491 7.738011 9.775218
17 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.496070 0.695578 0.451616 0.609063 6.699531 7.588786 13.178538 17.476809 0.686213 0.667333 0.416255 5.722717 6.524751
18 N01 RF_maintenance 100.00% 0.00% 60.12% 0.00% 100.00% 0.00% 14.673664 20.273272 3.665142 2.850624 4.772955 6.529556 20.610743 41.222890 0.647060 0.435924 0.468123 4.325821 2.523432
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.670900 -0.278602 -0.453716 3.152370 10.528729 12.278389 12.171162 20.819367 0.058966 0.068801 0.007984 0.941179 0.938844
20 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.527682 4.838057 -0.089554 0.174981 5.839747 5.793864 9.158945 7.762931 0.069121 0.064212 0.006461 0.931541 0.932108
21 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.297066 -0.496997 0.819027 1.039130 9.760219 8.992423 11.009766 10.526136 0.091832 0.067740 0.010351 1.432976 1.425351
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 15.856355 19.879022 25.399366 26.286249 12.232212 20.017448 11.705316 10.428715 0.035668 0.039706 0.002374 1.132204 1.128737
28 N01 RF_maintenance 100.00% 70.14% 100.00% 0.00% 100.00% 0.00% 20.846355 42.869545 0.730211 3.127496 12.942781 19.741691 13.806538 32.390805 0.359969 0.159369 0.223712 1.811839 1.297568
29 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.586379 -1.056569 -0.192184 -0.399327 2.939382 2.915744 8.162274 9.383372 0.696352 0.680617 0.402258 6.088248 9.884213
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.124021 -0.253156 -0.446498 -0.721351 5.467165 3.413469 11.399778 8.624690 0.687119 0.678214 0.408237 4.446352 6.275191
31 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.871407 -0.589957 -0.102758 -0.743718 8.719161 9.695631 13.685350 13.446366 0.087667 0.085582 0.015282 1.301131 1.293221
32 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 24.458371 17.931443 2.316899 1.788111 27.583863 28.314938 36.000489 66.819590 0.093498 0.091632 0.011303 1.182401 1.198020
33 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.137791 20.973890 -0.592486 0.136329 54.701229 47.003557 194.542899 186.894231 0.063998 0.099098 0.030156 1.632441 1.642507
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 14.618815 11.252529 -0.022509 -0.236434 1.589202 2.565256 3.284808 2.395897 0.738246 0.729124 0.360016 12.697384 8.100683
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.129832 0.833752 -0.941438 -0.914670 -0.427810 -0.315375 -0.048540 14.189390 0.743090 0.738179 0.361719 7.662772 5.559644
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.017268 0.452779 -0.495476 -0.602130 1.735420 -0.659548 8.192355 2.225654 0.744195 0.734813 0.373379 5.743864 5.020216
40 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.041342 -0.966281 -0.647425 -0.524825 -0.480360 -0.860652 -0.318949 -0.779334 0.084242 0.091055 0.014212 1.210912 1.209472
41 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.453469 -0.902870 1.550860 0.927406 0.227102 -1.001109 -0.374339 -0.898712 0.055640 0.083313 0.004217 1.174092 1.166765
42 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.366805 3.904774 0.868805 0.372363 -1.032085 0.507261 -0.346585 -0.796806 0.091264 0.115932 0.016280 1.191546 1.190896
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.222986 1.945741 -0.972014 0.083162 -0.299619 1.379447 0.254403 5.843735 0.680518 0.665837 0.412186 7.535720 9.409277
46 N05 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -1.147826 -0.021683 0.350038 -0.829884 -0.357787 -0.324386 -0.154327 1.250523 0.668564 0.672400 0.424055 -0.007247 -0.007905
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.347750 4.891785 -0.598204 2.498217 1.154541 2.477097 0.756681 -0.224969 0.727260 0.738082 0.345358 8.785080 7.696672
51 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.578706 2.272366 -0.212601 0.282034 0.317181 0.619651 0.117799 2.763499 0.741756 0.749245 0.345301 1.729065 1.836192
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 11.371693 9.818135 1.153257 0.284989 0.568116 -0.934492 0.747127 0.704082 0.751099 0.753517 0.342908 8.601732 7.327025
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.177114 3.154052 -0.619977 0.513486 -0.644795 -0.506446 3.728093 9.288236 0.746951 0.747900 0.356175 5.565241 5.123060
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.568712 28.965965 1.229012 0.985292 0.224002 2.603130 1.311546 0.107834 0.107325 0.116486 0.020167 1.216093 1.215526
55 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 2.563886 4.134846 0.730822 0.733432 4.928707 -0.235789 2.135677 -0.381617 0.064862 0.076412 0.006305 1.225752 1.224122
56 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.869699 1.204107 1.154677 1.702371 -0.687134 0.219546 -0.248409 3.145436 0.057159 0.056622 0.004432 1.171170 1.170438
57 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 45.120606 -0.403499 7.246983 2.457348 3.950301 -0.026168 5.337314 5.164208 0.108731 0.080712 0.031583 1.160059 1.167462
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.506881 0.520192 0.039779 0.432235 0.730148 1.877708 -0.493325 -0.013008 0.728416 0.747455 0.363242 1.978673 1.967137
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 1.163962 1.503208 0.676358 1.062148 0.844831 -0.135968 -0.347990 1.101498 0.738653 0.757211 0.343937 2.188693 2.265444
67 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.108646 -0.146253 -0.039779 0.914075 -0.586538 -0.700599 0.860299 1.735311 0.740059 0.756638 0.325362 1.958685 2.071839
68 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 2.393584 1.411057 -0.389631 3.378787 -0.053450 0.926914 0.069960 0.740074 0.746379 0.760096 0.317922 1.912970 1.974894
69 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.614831 -1.236384 -0.177431 0.211432 0.337583 1.959750 -0.056989 0.818988 0.109385 0.115040 0.027601 1.223879 1.217808
70 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 9.340714 -1.812851 0.779806 -0.986517 2.317545 -0.906943 0.230268 0.860818 0.076703 0.077134 0.009622 1.200873 1.199740
71 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.033956 0.100230 -0.574889 -0.416084 1.196172 -1.226309 -0.385505 -0.189098 0.097964 0.101654 0.018361 1.254416 1.256060
72 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 3.986092 -0.055399 -0.678177 1.496756 0.955029 -0.152017 1.222230 -0.837659 0.079560 0.074433 0.012248 1.170652 1.165635
73 N05 digital_ok 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 14.487537 1.596627 24.703633 2.257002 10.648017 -0.290968 1.400649 -0.094360 0.034412 0.709003 0.299169 1.241069 9.654327
81 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.075586 0.855161 -0.988985 3.802246 -0.441363 1.265718 -0.095900 -0.811205 0.698002 0.738221 0.375801 1.839648 1.950303
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.460545 -0.195360 0.988073 -0.121399 -0.597979 -1.052103 -0.411956 -0.700752 0.717908 0.746008 0.359579 8.554843 6.476259
83 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.135685 0.368298 1.764234 4.634787 -1.206101 -0.359316 -0.477453 -0.402487 0.739094 0.768624 0.352128 6.357315 5.325988
84 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 12.150956 12.882267 -0.030395 0.826070 -0.828183 -0.426194 -0.347431 -0.608988 0.748195 0.771450 0.330763 7.244478 7.262122
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.539610 -0.044645 -0.814135 -0.916405 -0.439192 -0.757162 -0.640125 -0.949430 0.730030 0.754410 0.349140 1.582838 1.710827
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.028950 10.609331 1.666438 0.573479 5.022240 1.113413 0.494943 0.416342 0.736758 0.730508 0.342414 5.438773 6.002575
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.133899 13.612987 6.397015 1.222776 3.514956 -0.565833 0.060978 -0.723300 0.745462 0.762740 0.349966 4.026365 4.586212
88 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 10.563956 6.538348 28.872081 25.097113 8.366104 10.135981 -2.108126 -2.942687 0.711739 0.749267 0.373095 5.655639 11.345876
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.253930 0.201517 -0.125201 2.153933 -0.296569 -0.645641 -0.042729 1.265796 0.711309 0.713782 0.391483 4.724532 4.296546
91 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 7.499175 6.647799 25.652550 26.490105 5.646064 12.453171 -1.729390 -2.470291 0.701476 0.715744 0.407174 5.788145 4.859859
92 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 57.047413 64.340494 3.364548 4.086293 12.384339 21.367713 3.213760 8.900284 0.081819 0.077874 0.009762 0.000000 0.000000
93 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.101204 1.264823 2.321363 -0.184329 1.272098 -1.057768 2.027073 -0.836079 0.067675 0.083306 0.008101 0.000000 0.000000
94 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.245006 -1.463384 -0.720938 -0.957327 2.041318 3.593913 5.105871 5.165810 0.070488 0.088783 0.007855 0.000000 0.000000
98 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.574170 1.307619 1.685557 1.408176 1.477048 1.479493 0.570196 0.820760 0.682528 0.709344 0.382484 1.910684 2.021508
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.205613 -0.086647 2.661610 1.098049 -0.889575 0.101017 0.958622 -0.261167 0.709968 0.737537 0.368594 7.877744 8.038869
100 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 5.00% -0.856047 -0.831399 -0.346531 -0.091297 0.306879 -0.661847 -0.375625 -0.920605 0.723571 0.748926 0.367728 2.075972 2.158160
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 12.433684 13.130834 2.699223 -0.123382 0.284424 -1.349612 6.616684 -0.576226 0.752517 0.773225 0.346357 7.509508 6.543715
102 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 22.252034 21.789416 5.447863 4.796233 492.165915 498.361869 6181.902879 6159.156960 0.651708 0.563502 0.380326 0.000000 0.000000
103 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 4.690234 10.467508 -0.423694 -0.176931 0.282535 0.099111 -0.232641 -0.480782 0.749677 0.768070 0.332326 7.816902 6.311602
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.796311 88.846359 0.552747 12.251320 0.264125 -0.335267 0.290082 -0.501315 0.746008 0.763335 0.349963 3.812157 3.769545
105 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 1.252928 0.880794 10.149998 15.602254 0.362732 1.571501 0.040092 -1.373050 0.745775 0.771750 0.352451 -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% 7.071543 4.160053 24.844281 22.502919 5.800971 9.029484 -0.919714 0.415618 0.726527 0.741725 0.375752 4.191174 4.025189
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.391930 4.427735 7.277254 0.987640 2.867156 -1.030596 -0.124775 -0.143256 0.662877 0.730116 0.409242 0.000000 0.000000
109 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.735342 0.103254 -0.215338 1.084964 -0.732753 -0.452963 -0.286730 -0.539648 0.087990 0.081819 0.019256 0.000000 0.000000
110 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 34.505409 47.810739 1.922752 2.070559 6.171401 8.026950 3.584520 3.068530 0.094212 0.097441 0.009225 0.000000 0.000000
111 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.073568 0.876835 -0.434680 0.672624 -0.571894 1.460933 0.106372 0.369555 0.055657 0.063944 0.003625 0.000000 0.000000
112 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.421671 -0.193962 -0.302487 -0.176963 1.003177 0.615896 2.014010 1.590037 0.065626 0.074420 0.007339 0.000000 0.000000
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% -0.746869 1.259163 -0.848032 -0.906943 0.121811 0.955061 1.118737 -0.749911 0.659612 0.699707 0.396212 1.678581 1.782603
117 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.122216 0.945873 4.880797 5.094955 -0.798067 -1.270677 -0.357337 -0.866763 0.695717 0.730711 0.391995 7.805289 7.031568
118 N07 digital_ok 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 1.184588 22.073296 2.158959 21.811973 -0.552542 19.548152 0.177300 -0.025019 0.712760 0.048067 0.317985 5.430461 1.321672
119 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.088656 1.385369 9.127893 0.539115 -0.699330 0.188493 -0.656738 -0.725154 0.741512 0.743499 0.368704 7.325472 6.188384
120 N08 RF_maintenance 100.00% 37.07% 100.00% 0.00% 100.00% 0.00% 22.792697 32.366856 1.311841 30.574881 8.809551 19.012207 0.526462 6.212847 0.422473 0.042837 0.228752 3.832803 1.211509
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.966887 7.364780 -0.498087 0.771512 0.053043 1.438966 45.231047 22.468948 0.759643 0.774489 0.335308 4.465737 3.743687
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 11.136881 8.491442 0.917719 0.666068 -0.215977 -0.939857 0.021046 -0.285394 0.761251 0.775689 0.328857 3.466231 3.404772
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.478737 11.386128 -0.041314 -0.035031 -1.131267 -0.276430 -0.165815 -0.592952 0.760357 0.779747 0.331768 -0.000000 -0.000000
125 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
127 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.362152 -0.593227 0.845350 0.173064 0.527219 0.517500 0.658851 0.690130 0.099477 0.093788 0.025490 0.000000 0.000000
128 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% -1.638501 6.959856 -0.275246 0.950295 1.136044 1.811327 2.446311 2.480912 0.089068 0.081143 0.017942 0.000000 0.000000
129 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.021683 -1.256220 0.527464 0.625220 -0.844271 -0.287046 -0.116678 -0.332362 0.053146 0.065835 0.005133 0.000000 0.000000
130 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.235108 -0.266295 0.054000 1.155547 0.864486 1.063386 1.471099 5.023185 0.071405 0.066041 0.008530 0.000000 0.000000
135 N12 digital_maintenance 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.438987 -0.474249 -1.029780 -0.902210 0.140384 -0.085869 1.455356 -0.117540 0.080543 0.087880 0.012653 1.196184 1.210900
136 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.852806 13.588863 -0.649648 -0.044020 0.167552 2.216055 1.840824 2.527340 0.075675 0.094719 0.010110 1.211673 1.207688
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.854069 4.770393 26.972228 22.278677 7.505943 4.339083 -2.282638 -2.049028 0.690025 0.720521 0.397431 4.542329 4.567891
138 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.374105 0.527486 24.783336 -0.741925 6.553615 -0.586944 -1.856817 -0.584333 0.724699 0.731612 0.388474 5.698628 5.001158
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 13.497918 18.216952 24.555772 26.370357 10.667677 19.073009 0.922918 0.882121 0.038654 0.041559 0.001144 0.867534 0.869005
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.485012 7.576156 -0.836574 8.103380 0.684652 4.460638 1.219551 30.124668 0.737223 0.720923 0.328615 0.000000 0.000000
142 N13 digital_ok 100.00% 36.07% 100.00% 0.00% 100.00% 0.00% 35.894237 23.392589 1.625610 26.586605 11.072148 19.024303 1.471240 2.081262 0.439175 0.041176 0.179876 0.000000 0.000000
143 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 91.00% 8.00% 1.023329 -1.192953 1.805892 -0.238090 2.006341 0.946278 2.987605 2.249181 0.741976 0.770434 0.344008 0.000000 0.000000
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.958164 -0.779289 1.374050 -0.299839 4.157505 2.264009 6.364085 5.643137 0.743589 0.762438 0.348293 0.000000 0.000000
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 15.999920 19.494547 25.670322 26.915124 14.132546 21.613482 7.748650 8.739996 0.033035 0.033565 -0.000367 0.000000 0.000000
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 17.280899 21.412093 25.574030 27.684360 14.063217 21.581009 15.058273 15.388011 0.043995 0.044074 0.001402 0.000000 0.000000
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 14.218793 15.299322 24.654161 26.098103 10.672335 19.341977 3.234986 3.668929 0.037492 0.039497 0.000829 1.242325 1.291609
156 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.144105 0.244328 0.853202 0.154709 0.814004 9.378045 3.017654 15.239454 0.049225 0.063163 0.003073 18.631819 30.937458
157 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.652374 -0.601464 -0.060862 2.492016 -1.080289 -0.529912 0.431487 -0.592200 0.065734 0.062284 0.007146 19.874954 38.869146
158 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.196741 -1.134691 -0.713084 -0.902117 0.488017 -1.226252 -0.242312 1.434749 0.083819 0.071669 0.012319 1.014963 1.019638
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 14.845589 18.038665 25.193809 26.447634 10.771754 19.253869 2.765169 3.757095 0.038697 0.040473 0.002855 1.373032 1.364727
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.259982 38.781677 -0.551153 2.852730 -1.020749 5.048968 0.400006 0.032477 0.731925 0.634469 0.330594 7.180972 7.556650
162 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.00% 9.00% 1.419671 0.593834 -0.904872 -0.721116 0.689843 0.053450 1.618093 2.008702 0.742072 0.750616 0.348794 0.000000 0.000000
163 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.596406 -0.473334 0.152126 -0.531261 0.826571 2.250334 4.494332 6.968808 0.745112 0.756757 0.354165 5.684988 6.577228
164 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -1.737120 -1.204536 -0.753270 -0.289831 5.374617 5.647878 19.343149 10.423201 0.742042 0.757301 0.351914 4.589130 6.203419
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.043961 0.613807 6.429786 -0.927844 2.440200 1.632129 3.429190 3.090661 0.746341 0.754630 0.364058 3.390329 4.722295
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 16.985294 6.077601 1.032854 1.377538 4.250592 15.493780 5.755553 6.765107 0.684956 0.728762 0.337949 0.000000 0.000000
167 N15 digital_ok 100.00% 15.03% 0.00% 0.00% 100.00% 0.00% 52.512585 21.700953 19.730310 24.288382 15.509459 19.989232 15.627162 13.862703 0.495160 0.571962 0.173192 0.000000 0.000000
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.071890 7.978173 22.939239 26.854522 8.355245 16.257871 5.144247 3.912728 0.704410 0.721771 0.393607 0.000000 0.000000
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.001423 6.035744 26.322825 25.080895 11.570551 16.042175 7.589872 7.718288 0.685395 0.703831 0.408430 0.000000 0.000000
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.149097 4.172147 26.640928 23.507634 11.759228 14.076100 8.446335 8.404508 0.660258 0.707971 0.430101 0.000000 0.000000
176 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.125205 -0.063646 -0.906707 0.095574 -0.980206 1.064147 -0.191677 0.087345 0.066858 0.072559 0.007140 7.701315 22.045517
177 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.980080 1.593767 0.568245 1.387652 -0.211978 2.719225 0.267999 4.443763 0.073322 0.070377 0.008209 11.799264 35.731364
178 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 100.00% 0.00% -0.858593 -0.696607 0.621518 -0.619795 -1.347368 -1.032753 0.013008 -0.613373 0.075909 0.066466 0.011011 1.009985 1.010842
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 0.485771 0.864506 -0.555155 0.348550 5.114376 -1.132097 8.157282 -0.598949 0.068406 0.069181 0.011661 0.955371 0.952720
180 N13 RF_maintenance 100.00% 0.00% 76.95% 0.00% 100.00% 0.00% 0.572202 16.571528 -0.444507 25.553688 0.048312 16.516003 0.109992 2.351872 0.727209 0.359166 0.497254 14.884317 3.350603
181 N13 digital_ok 100.00% 100.00% 90.98% 0.00% 100.00% 0.00% 16.568850 59.606338 25.764612 9.509838 10.795935 17.610964 2.627274 5.044602 0.040998 0.235408 0.084630 1.171116 1.822020
182 N13 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 5.784974 1.666256 23.274730 7.098508 4.125275 7.511980 -2.327407 36.311558 0.739455 0.734932 0.375960 8.326854 9.652617
183 N13 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
184 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.131042 -0.415589 0.747069 0.719033 4.702924 4.225747 6.845240 5.561031 0.737002 0.741632 0.355240 5.342497 6.160783
185 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.152675 -0.383861 5.389198 0.969771 18.705926 0.496632 13.189062 2.264257 0.730200 0.745868 0.358465 3.540722 4.254506
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.524157 -0.587090 3.644855 2.014161 4.087181 2.993496 9.102573 7.103085 0.727848 0.743938 0.363514 3.011078 3.901742
187 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 92.00% 0.00% 0.723528 1.216827 0.311757 0.052243 0.415574 -0.205876 3.436101 1.894368 0.716285 0.748934 0.369531 0.000000 0.000000
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.197612 2.966783 0.660662 0.280941 9.882396 10.998803 19.580320 18.474800 0.680130 0.719022 0.399187 0.000000 0.000000
190 N15 digital_ok 100.00% 16.03% 100.00% 0.00% 100.00% 0.00% 63.350169 22.752909 3.658320 26.990515 13.670164 23.334840 13.920609 9.366384 0.488935 0.040232 0.251791 0.000000 0.000000
191 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% -0.814336 0.341378 -0.333171 -0.635917 7.099353 5.785115 13.846885 15.632114 0.665023 0.703823 0.438789 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% 20.057372 20.931808 16.122075 3.193386 8.447507 9.896746 24.510504 33.063384 0.708685 0.658677 0.395867 0.000000 0.000000
206 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 19.549767 19.516348 4.797792 9.995817 9.612079 8.268569 25.455486 29.368401 0.658671 0.692281 0.378029 0.000000 0.000000
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 19.684153 19.970398 18.095388 13.995130 3.897410 5.987263 9.428513 9.331990 0.678943 0.697575 0.366023 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% 37.237653 37.401371 inf inf 3148.194831 3659.753427 7585.506304 10232.659096 nan nan nan 0.000000 0.000000
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 19.371260 19.422573 8.653841 5.349106 -0.651193 35.119398 -0.200898 15.962619 0.686623 0.659393 0.390947 0.000000 0.000000
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 23.113511 22.181181 29.661710 28.899860 9.767507 17.137599 -3.994357 -4.316920 0.665575 0.671429 0.377871 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% 38.680304 38.779115 inf inf 4373.263182 4463.904193 12469.328058 12468.554783 nan nan nan 0.000000 0.000000
320 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 21.417876 21.124375 14.912926 15.397580 10.651618 19.007215 5.897067 3.507422 0.047440 0.044998 0.002108 0.000000 0.000000
321 N02 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 1.961254 1.082142 14.602352 13.001965 10.001879 10.276851 31.376781 30.798655 0.096021 0.090351 0.037677 0.000000 0.000000
323 N02 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 34.010170 1.126683 3.019851 17.742162 7.045784 4.469834 6.260115 2.427191 0.073300 0.092013 0.033627 0.000000 0.000000
324 N04 not_connected 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 3.269938 2.361812 20.195645 12.220528 2.139997 1.921774 -1.272507 -0.401934 0.094608 0.093222 0.039216 0.000000 0.000000
329 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 8.403583 -1.473544 0.520585 12.399350 5.177096 1.749725 1.368991 -0.518537 0.081092 0.091681 0.035278 0.000000 0.000000
333 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 6.240755 0.350170 0.463809 11.391008 2.478656 1.369821 1.338762 -0.078329 0.079210 0.092750 0.032882 0.000000 0.000000
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 4, 5, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 40, 41, 42, 45, 50, 52, 53, 54, 55, 56, 57, 69, 70, 71, 72, 73, 82, 83, 84, 86, 87, 88, 90, 91, 92, 93, 94, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130, 135, 136, 137, 138, 140, 141, 142, 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: [46, 51, 65, 66, 67, 68, 81, 85, 98, 116]

golden_ants: [46, 51, 65, 66, 67, 68, 81, 85, 98, 116]
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_2459824.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 [ ]: