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 = "2459844"
data_path = "/mnt/sn1/2459844"
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-21-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/2459844/zen.2459844.25298.sum.auto_metrics.h5.

Load Ant Metrics¶

In [7]:
use_ant_metrics = False

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

# if they exist, load as many of them as possible
if len(ant_metrics_files) > 0:
    print(f'Found {len(ant_metrics_files)} ant_metrics files matching glob {glob_str}')
    ant_metrics_apriori_exants = {}
    ant_metrics_xants_dict = {}
    ant_metrics_dead_ants_dict = {}
    ant_metrics_crossed_ants_dict = {}
    ant_metrics_dead_metrics = {}
    ant_metrics_crossed_metrics = {}
    dead_cuts = {}
    crossed_cuts = {}
    for amf in ant_metrics_files:
        with h5py.File(amf, "r") as infile: # use h5py directly since it's much faster than load_metric_file
            # get out results for this file
            dead_cuts[amf] = infile['Metrics']['dead_ant_cut'][()]
            crossed_cuts[amf] = infile['Metrics']['cross_pol_cut'][()]
            xants = infile['Metrics']['xants'][:]
            dead_ants = infile['Metrics']['dead_ants'][:]
            crossed_ants = infile['Metrics']['crossed_ants'][:]        
            try:
                # look for ex_ants in history
                ex_ants_string = infile['Header']['history'][()].decode()
                ex_ants_string = ex_ants_string.split('--apriori_xants')[1]
                ex_ants_string = ex_ants_string.split('--')[0].strip()
            except:
                ex_ants_string = ''
                    
            # This only works for the new correlation-matrix-based ant_metrics
            if 'corr' in infile['Metrics']['final_metrics'] and 'corrXPol' in infile['Metrics']['final_metrics']:
                ant_metrics_dead_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corr'][ant][()]
                                                 for ant in infile['Metrics']['final_metrics']['corr']}
                ant_metrics_crossed_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corrXPol'][ant][()]
                                                    for ant in infile['Metrics']['final_metrics']['corrXPol']}                       
            else:
                raise(KeywordError)
        
        # organize results by file
        ant_metrics_xants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in xants]
        ant_metrics_dead_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in dead_ants]
        ant_metrics_crossed_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in crossed_ants]
        ant_metrics_apriori_exants[amf] = [int(ant) for ant in ex_ants_string.split()]
    
    dead_cut = np.median(list(dead_cuts.values()))
    crossed_cut = np.median(list(crossed_cuts.values()))
        
    use_ant_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping ant_metrics.')
Found 372 ant_metrics files matching glob /mnt/sn1/2459844/zen.2459844.?????.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.')
No files found matching glob /mnt/sn1/2459844/zen.2459844.?????.sum.known_good.omni.calfits. Skipping redcal chisq.

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 2459844
Date 9-21-2022
LST Range 19.538 -- 21.538 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 372
Total Number of Antennas 158
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
dish_ok: 1
RF_maintenance: 34
digital_maintenance: 8
digital_ok: 97
not_connected: 15
Commanded Signal Source None
Antennas in Commanded State 0 / 158 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 14
Nodes Registering 0s N08, N09
Nodes Not Correlating N01, N03, N05, N07, N10, N12
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 146 / 158 (92.4%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 123 / 158 (77.8%)
Redcal Done? ❌
Never Flagged Antennas 0 / 158 (0.0%)
A Priori Good Antennas Flagged 97 / 97 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, 46, 51, 53,
54, 55, 56, 65, 66, 67, 68, 69, 71, 72, 73,
81, 83, 84, 85, 86, 88, 91, 93, 94, 98, 99,
100, 101, 103, 105, 106, 107, 108, 109, 111,
112, 116, 117, 118, 121, 122, 123, 124, 127,
128, 129, 130, 140, 141, 142, 143, 144, 147,
156, 157, 158, 160, 161, 162, 163, 164, 165,
167, 169, 170, 176, 177, 178, 179, 181, 183,
184, 185, 186, 187, 189, 190, 191
A Priori Bad Antennas Not Flagged 0 / 61 total a priori bad antennas:
In [19]:
# write to csv
outpath = os.path.join(nb_outdir, f'array_health_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.replace({'\u2705': 'Y'}, regex=True).replace({'\u274C': 'N'}, regex=True).replace({'<br>': ' '}, regex=True).to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/array_health_table_2459844.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 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
3 N01 digital_ok 0.00% 100.00% 100.00% 0.00% 0.561198 -0.561607 -0.700940 0.647574 0.035712 -0.050098 1.029362 0.453983 0.027816 0.024869 0.001693
4 N01 RF_maintenance 0.00% 100.00% 100.00% 0.00% -1.092549 -0.309853 0.803180 0.333952 2.056763 1.284604 1.428426 -0.269307 0.024646 0.024457 0.000524
5 N01 digital_ok 0.00% 100.00% 100.00% 0.00% -0.593366 3.655802 -0.303927 2.100264 -0.097749 -0.016020 -0.331458 -1.880589 0.024798 0.024919 0.000551
7 N02 digital_ok 0.00% 100.00% 100.00% 0.00% -0.655124 1.825787 -0.984828 0.915915 0.675981 1.183987 0.341985 3.370621 0.102504 0.106728 0.020912
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 40.168285 43.917645 170.111146 177.146314 89.153515 75.529633 11.148676 27.793170 0.880020 0.568418 0.614835
9 N02 digital_ok 0.00% 100.00% 100.00% 0.00% -0.499290 0.651266 0.021252 0.066194 0.121365 -0.374436 0.479956 0.111246 0.078040 0.045280 0.037544
10 N02 digital_ok 0.00% 100.00% 100.00% 0.00% -0.745060 1.043563 1.252949 -0.573878 0.611681 2.810546 0.671851 -0.602478 0.024604 0.024829 0.000454
15 N01 digital_ok 0.00% 100.00% 100.00% 0.00% 0.585267 -0.542661 3.465166 2.646444 -0.682622 0.900033 -1.015636 -0.494023 0.027719 0.025298 0.001463
16 N01 digital_ok 0.00% 100.00% 100.00% 0.00% -0.904709 -0.480445 -0.917291 0.124699 1.184724 -0.397176 0.050286 -0.617501 0.024531 0.024132 0.000418
17 N01 digital_ok 0.00% 100.00% 100.00% 0.00% 0.185405 -0.439996 -0.089542 1.279923 1.661586 -0.015244 -0.552838 0.000174 0.024514 0.024168 0.000340
18 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 6.050841 23.824174 18.078668 48.431849 119.480757 35.111629 221.214154 24.406184 0.028828 0.030557 0.001105
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% -0.056869 0.065902 0.135737 0.899306 5.145459 11.135287 34.188847 7.540081 0.029100 0.027283 0.001309
20 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 12.892425 1.177848 15.810596 0.564083 9.801767 -0.216844 8.707358 -0.197230 0.025719 0.025000 0.000936
21 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 0.794122 1.796346 0.516918 1.065587 1.184604 0.291240 1.717053 2.034959 0.026873 0.024304 0.001561
22 N06 not_connected 100.00% 100.00% 100.00% 0.00% 7.013451 2.850241 60.230871 60.919491 3.860912 8.397641 -0.156580 0.432707 0.030272 0.028598 0.001492
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 14.141155 16.278850 6.579364 6.701280 2.851572 3.036631 12.691107 8.547926 0.024432 0.040194 0.003068
28 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% -0.001004 42.172743 0.694648 70.820603 0.048898 12.089623 1.179074 15.156064 0.025398 0.028478 0.002384
29 N01 digital_ok 0.00% 100.00% 100.00% 0.00% -0.142008 -0.171291 2.183905 2.915808 1.160371 -0.378829 -0.000174 -1.276890 0.027980 0.025135 0.001746
30 N01 digital_ok 100.00% 100.00% 100.00% 0.00% 1.621403 -0.197070 -0.630744 -0.322080 1.471871 1.706926 11.944439 2.839781 0.024838 0.024664 0.000448
31 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 38.926628 2.804989 32.077806 0.701011 6.771450 8.450858 13.315939 6.144606 0.021176 0.024641 0.002529
32 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 10.360278 9.696247 3.195813 2.665840 0.942529 0.084265 -0.869858 0.049044 0.024889 0.024738 0.000308
33 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% -0.069550 24.783816 -0.981497 32.408073 1681.909845 836.370089 1101.760289 562.691177 0.043031 0.036286 0.006567
34 N06 not_connected 100.00% 100.00% 100.00% 0.00% 10.471518 3.143226 51.369139 55.946271 0.349979 4.944669 2.372725 1.034953 0.028249 0.028573 0.000935
35 N06 not_connected 100.00% 100.00% 100.00% 0.00% 7.835868 4.028087 55.525076 55.668650 0.968416 0.431693 3.388481 -2.053945 0.028130 0.028380 0.000635
36 N03 RF_maintenance 100.00% 100.00% 100.00% 0.00% 29.015706 21.062125 23.818029 18.048132 3.003095 2.863274 9.324786 8.611221 0.022665 0.022551 0.000371
37 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 32.212855 27.963924 24.126302 19.996515 2.849163 2.802785 12.537040 18.761344 0.022053 0.021987 0.000454
38 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 33.598483 26.827054 26.313814 21.052163 6.395518 13.537154 16.880338 13.344823 0.021680 0.021790 0.000291
40 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 46.063211 47.757239 97.153723 99.871762 256.469980 243.707979 50.582623 67.831940 0.882454 0.583052 0.599311
41 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 4.891416 4.566896 2.885837 0.330272 2.226674 -0.736344 -0.449048 0.209587 0.029653 0.027488 0.001539
42 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 5.916293 1.557649 0.304466 2.279350 1.780745 0.435954 0.262541 1.450229 0.038594 0.058366 0.020803
44 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 3.764925 0.492366 5.156471 3.661905 0.276942 0.101182 0.410799 -0.632997 0.025498 0.025038 0.000629
45 N05 digital_ok 100.00% 100.00% 100.00% 0.00% -0.438611 0.846819 0.964423 1.242493 1.832837 4.649721 1.243927 18.352355 0.025847 0.024704 0.001027
46 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 2.309659 15.443402 0.568554 6.913147 1.018883 4.913375 -0.654799 13.450994 0.024675 0.023824 0.000912
47 N06 not_connected 100.00% 0.00% 0.00% 0.00% 41.350296 44.155135 130.595854 133.108958 227.980728 212.049791 27.580018 33.910209 0.881985 0.632329 0.572071
48 N06 not_connected 100.00% 100.00% 100.00% 0.00% 30.002485 31.338418 77.490359 77.675570 9.441747 10.310696 26.926853 30.985971 0.032879 0.031201 0.001056
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 42.030247 45.087766 136.347790 163.477569 176.201975 94.682492 20.760260 5.296889 0.876096 0.623526 0.570479
50 N03 RF_maintenance 100.00% 100.00% 100.00% 0.00% 32.650218 24.536740 21.387075 22.062935 2.855781 0.914833 8.839999 9.664335 0.022673 0.021885 0.000539
51 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 12.286074 25.978506 36.644175 19.376715 296.648337 115.131321 241.756403 90.324854 0.021467 0.022065 0.000217
52 N03 RF_maintenance 100.00% 100.00% 100.00% 0.00% 22.225167 15.986336 20.234231 16.670714 177.126098 105.426069 132.362854 79.531240 0.025481 0.022955 0.001137
53 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 29.744195 22.342269 21.174433 21.514016 4.962909 5.934105 7.880453 19.433955 0.026617 0.024351 0.000825
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 13.915515 0.504969 5.904540 0.152813 0.808160 0.454357 6.230232 1.493963 0.051671 0.073954 0.023397
55 N04 digital_ok 0.00% 100.00% 100.00% 0.00% -0.743149 -0.154859 0.458716 0.231418 2.016976 -0.138594 1.054761 0.584729 0.026719 0.024490 0.001463
56 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 3.209913 5.933817 -0.073667 0.338230 0.303298 0.429747 0.367708 0.703593 0.029772 0.027534 0.001423
57 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 3.557460 0.911637 -0.309295 1.803977 3.311608 -0.217249 6.789452 -1.177304 0.029274 0.026300 0.002182
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 14.879169 15.452362 5.864911 8.517685 3.079212 2.442691 12.694035 11.455551 0.025287 0.023846 0.000931
59 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 4.262356 1.219994 6.765837 1.487968 1.107066 1.292099 -0.687745 0.549580 0.028757 0.025861 0.002141
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 35.789226 41.020599 113.843368 122.949932 283.090025 202.410135 103.821198 108.766232 0.867734 0.623018 0.581724
62 N06 not_connected 100.00% 100.00% 100.00% 0.00% 0.994023 5.030416 65.370515 70.654899 1.031227 1.460836 1.125008 -0.549334 0.031130 0.033410 0.003308
63 N06 not_connected 100.00% 100.00% 100.00% 0.00% 0.967006 14.768290 61.312182 51.697147 4.956800 5.188699 1.916851 7.512628 0.042997 0.053123 0.010801
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 40.043577 46.582712 134.947653 155.560479 189.232269 134.719197 56.862574 9.727327 0.865229 0.600541 0.584595
65 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 31.193234 21.359866 23.746052 19.770097 4.419338 9.105425 9.911426 13.528697 0.023707 0.022118 0.001121
66 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 32.436641 23.227586 22.521189 21.918292 8.401513 5.221339 9.165380 15.188162 0.022077 0.021611 0.000416
67 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 24.964772 22.244021 18.400105 14.474333 2.584343 5.203992 7.132424 12.808491 0.022385 0.022526 0.000341
68 N03 digital_ok 100.00% 100.00% 100.00% 0.00% 33.503617 11.608340 23.850192 44.742875 3.345283 9.178670 11.064367 44.206295 0.025379 0.020163 0.002513
69 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 1.547988 1.382030 0.865875 0.428474 0.281899 8.334031 0.756664 1.611655 0.031822 0.027621 0.003676
70 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 60.469304 50.467234 97.760971 103.394563 310.875066 227.092493 48.965997 63.044520 0.889212 0.613969 0.577864
71 N04 digital_ok 0.00% 100.00% 100.00% 0.00% -0.930827 2.202295 -0.729193 -0.499534 0.363286 -0.206158 -0.414141 -0.888864 0.025410 0.027377 0.001165
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 38.424467 51.275607 93.156976 110.863856 262.041704 225.625252 58.750752 54.561811 0.882463 0.629975 0.573365
73 N05 digital_ok 100.00% 100.00% 100.00% 0.00% 15.567953 0.846542 4.957166 -0.218120 3.618700 1.052709 12.533094 1.597940 0.023892 0.024332 0.000522
75 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 4.951943 14.825428 4.103232 9.204592 8.546905 4.031350 12.883975 13.973882 0.030163 0.026639 0.001825
77 N06 not_connected 100.00% 100.00% 100.00% 0.00% 5.379697 2.628111 64.017585 70.303799 323.101396 322.764064 222.771750 215.206696 0.029238 0.029686 0.000544
78 N06 not_connected 100.00% 100.00% 100.00% 0.00% 1.934561 0.251785 66.212188 64.427461 2.694056 2.966033 1.401476 2.287592 0.044321 0.057343 0.017561
81 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 0.999399 3.577437 13.289326 10.687950 1.234274 0.907421 -1.458954 2.050684 0.030058 0.026412 0.002767
82 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.039065 4.588427 17.730284 12.316321 3.255252 0.019616 0.463619 1.491986 0.026737 0.026472 0.000883
83 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 2.677287 0.615085 15.694559 13.506567 3.100808 2.967580 -0.686867 -0.874124 0.026378 0.026495 0.000698
84 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
85 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
86 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
87 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
88 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
89 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
90 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
91 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
92 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 11.277542 8.472958 4.785506 5.129191 7.784178 11.616295 2.596406 8.303403 0.027736 0.025451 0.001548
93 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 5.985727 -0.689512 1.819477 0.835388 3.551836 0.784094 4.971758 1.206518 0.024469 0.024194 0.000543
94 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 0.993116 -0.300735 0.677697 -0.683030 11.840318 13.007496 8.795177 6.399509 0.024359 0.024217 0.000467
98 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
99 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
100 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
101 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
102 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 32.806248 40.733506 61.712707 81.291161 5340.746735 5944.806845 22803.772664 22827.263524 nan nan nan
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
104 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
105 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
106 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
107 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
109 N10 digital_ok 100.00% 100.00% 100.00% 0.00% 0.330661 15.460425 -0.880105 5.020512 0.384747 1.866733 0.675409 5.007849 0.027728 0.023904 0.001748
110 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 42.328072 33.172084 10.683393 16.395670 6.403336 8.114447 3.732210 5.490823 0.023418 0.022370 0.000541
111 N10 digital_ok 100.00% 100.00% 100.00% 0.00% -0.366030 15.715672 -0.887261 5.853281 -0.527467 2.390699 -0.022862 7.372948 0.024502 0.023439 0.000648
112 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 2.843283 1.919106 -0.258435 -0.503361 -0.210366 -0.060938 -1.051228 -1.153083 0.027248 0.024616 0.001553
116 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
117 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
118 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
119 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
120 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
121 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
122 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
123 N08 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
124 N09 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
125 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
127 N10 digital_ok 0.00% 100.00% 100.00% 0.00% 0.453641 1.112768 -0.750032 -0.614165 -0.220645 2.694474 -1.006237 0.141540 0.024946 0.024253 0.000599
128 N10 digital_ok 0.00% 100.00% 100.00% 0.00% -0.912364 3.398109 -0.191246 1.144540 -0.320985 2.262651 -0.708642 -1.206729 0.024385 0.024613 0.000462
129 N10 digital_ok 0.00% 100.00% 100.00% 0.00% -0.530073 2.003781 -1.088461 0.151649 -0.673000 -0.629454 0.443225 -0.088754 0.027773 0.024887 0.001453
130 N10 digital_ok 0.00% 100.00% 100.00% 0.00% -0.808445 -0.146581 -0.764418 -0.539488 2.419076 1.387538 -0.230305 0.568011 0.024958 0.024235 0.000834
135 N12 digital_maintenance 0.00% 100.00% 100.00% 0.00% 0.089286 -0.589371 -0.021252 0.756137 0.015244 -0.550210 0.755617 0.239145 0.026545 0.024587 0.001313
136 N12 digital_maintenance 0.00% 100.00% 100.00% 0.00% 0.969195 0.091423 1.616548 1.355571 0.843759 -0.662092 0.107376 -0.707983 0.025248 0.024873 0.000510
137 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
138 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 14.183170 14.631803 3.845415 7.099261 2.557155 3.047855 5.395587 7.898878 0.029107 0.026309 0.001132
141 N13 digital_ok 100.00% 100.00% 100.00% 0.00% -1.023092 10.123497 -0.084877 4.023408 0.433450 21.774068 1.022486 58.797060 0.028875 0.026374 0.001933
142 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 9.606230 15.699816 3.027963 8.189843 12.400998 2.089120 5.643759 7.370955 0.028305 0.024873 0.001971
143 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 39.878527 44.455229 173.440142 184.137548 80.924217 55.282209 -4.303115 26.250430 0.875842 0.547419 0.640660
144 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 0.276579 2.230198 -0.849082 -0.426676 1.392997 1.202148 3.421803 6.459591 0.027124 0.025009 0.001168
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 12.943248 14.745030 7.173619 8.772988 2.387549 5.226332 9.297327 15.299309 0.024228 0.023460 0.000624
147 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 9.662685 5.490455 2.558251 0.659101 0.041995 -0.625004 0.146205 0.153514 0.029955 0.028174 0.001455
148 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 45.294535 51.675780 126.894996 118.764174 222.534772 207.207194 25.310002 44.873049 0.887099 0.600447 0.596935
149 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 6.014736 14.216732 3.036200 8.309683 2.794969 2.789157 0.659363 9.850346 0.026033 0.023637 0.001111
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 12.452788 15.230877 6.436020 8.098123 2.067004 2.705341 10.510509 12.054114 0.026278 0.023361 0.001598
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 14.106821 17.224562 4.143383 6.175180 2.857118 5.322076 10.569666 15.400917 0.024733 0.023673 0.000798
156 N12 digital_ok 0.00% 100.00% 100.00% 0.00% -0.353088 2.486859 -1.043422 -0.421753 0.770827 -0.809604 -0.529514 0.576241 0.028775 0.026874 0.001326
157 N12 digital_ok 0.00% 100.00% 100.00% 0.00% -0.814963 0.258099 -0.356884 2.634329 -0.366966 1.024190 -0.553822 -2.057472 0.027875 0.026024 0.001339
158 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 13.395034 0.274224 7.229740 2.042297 0.842803 1.091081 5.093554 3.795202 0.024159 0.024034 0.000446
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 12.091185 13.915568 5.853268 7.409404 4.277949 6.007770 10.114761 15.335812 0.032801 0.030472 0.002901
161 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 1.810289 11.837282 -0.249454 4.589678 0.076472 0.054460 1.388243 2.457379 0.058163 0.031107 0.016673
162 N13 digital_ok 0.00% 100.00% 100.00% 0.00% -0.604650 3.776941 -0.966663 -0.164267 1.109673 2.103996 -0.059204 0.301059 0.108136 0.036418 0.021348
163 N14 digital_ok 0.00% 100.00% 100.00% 0.00% 0.851178 1.491841 -0.646425 -0.605713 -0.487480 0.616752 0.548918 2.548471 0.028574 0.026440 0.001119
164 N14 digital_ok 0.00% 100.00% 100.00% 0.00% -0.911341 -0.229740 -1.021811 0.458432 -0.301855 2.997633 0.352529 2.987513 0.090067 0.121192 0.020307
165 N14 digital_ok 100.00% 100.00% 100.00% 0.00% 7.955316 3.790918 6.739246 0.649286 0.970567 0.576838 -0.541204 1.034746 0.027245 0.024962 0.001318
166 N14 RF_maintenance 0.00% 100.00% 100.00% 0.00% 1.537942 -0.029899 1.756249 2.826198 1.156695 -0.483864 -1.304825 -1.828624 0.025072 0.024898 0.000399
167 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 10.687615 9.935456 4.716454 6.924323 2.937605 5.262129 1.067596 -0.926189 0.025047 0.025217 0.000515
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 45.701652 49.382215 103.187101 125.968376 252.626488 202.087433 44.501072 36.570746 0.887400 0.601882 0.605135
169 N15 digital_ok 0.00% 100.00% 100.00% 0.00% 3.832261 0.164771 0.270692 0.814053 -0.709829 0.035259 0.388291 -1.103711 0.025966 0.025807 0.000789
170 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 13.144275 -0.331965 3.576459 -0.736394 4.293886 -0.536278 0.818267 0.264508 0.025287 0.025220 0.000648
176 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 0.413933 0.799427 -0.880951 1.257057 -0.585882 -1.368157 -0.822268 -1.167015 0.028409 0.025811 0.001453
177 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 0.514835 2.043929 -0.076413 -0.443927 -0.932666 3.251463 -0.918216 1.038077 0.026348 0.024890 0.001036
178 N12 digital_ok 0.00% 100.00% 100.00% 0.00% -0.861788 0.042040 -0.804331 0.120201 -0.927009 -1.072567 -0.207766 -0.795119 0.024776 0.024628 0.000463
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 1.698743 2.806105 -0.055747 3.158749 14.882429 0.717759 3.015217 1.576994 0.028504 0.026480 0.001235
180 N13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 3.146371 13.803471 -0.149260 9.155432 1.112976 3.338336 0.067935 10.028663 0.028033 0.045530 0.002163
181 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 12.595070 19.310930 7.749107 10.616789 3.276257 12.813566 9.555749 10.542098 0.036897 0.026923 0.008125
182 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 41.298317 14.889959 171.537879 6.655057 91.163273 4.623611 -2.445624 12.817141 0.878053 0.036567 0.440687
183 N13 digital_ok 0.00% 100.00% 100.00% 0.00% -1.016177 -0.232392 -1.122062 -0.695566 -0.961724 0.614488 -1.177429 2.217401 0.028774 0.026727 0.001106
184 N14 digital_ok 0.00% 100.00% 100.00% 0.00% -0.953217 -0.477631 0.643951 0.516115 2.083557 -0.056970 1.110164 0.677131 0.024632 0.024212 0.000540
185 N14 digital_ok 0.00% 100.00% 100.00% 0.00% 0.965217 -0.693858 -0.592447 -0.614068 -0.697116 -0.430245 -0.490779 -0.112899 0.028640 0.026642 0.001007
186 N14 digital_ok 100.00% 100.00% 100.00% 0.00% -0.374161 2.153433 0.951198 -0.476495 1.194395 -0.059491 4.878157 2.018490 0.027897 0.025149 0.001658
187 N14 digital_ok 0.00% 100.00% 100.00% 0.00% 0.029899 -0.239057 -0.505419 -1.024760 1.664224 -0.209815 2.220132 0.196434 0.024796 0.024530 0.000439
189 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 3.216871 1.908770 2.375983 -0.459974 32.875180 0.343954 76.384245 7.124932 0.028067 0.024697 0.001805
190 N15 digital_ok 100.00% 100.00% 100.00% 0.00% 10.219037 15.557088 3.649125 8.937379 0.954469 4.849678 0.013930 12.567522 0.025106 0.023299 0.001181
191 N15 digital_ok 0.00% 100.00% 100.00% 0.00% 0.717160 -0.546781 0.913927 0.653416 2.402665 -0.185513 1.680620 1.210376 0.024359 0.024276 0.000553
320 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% 18.602305 13.975083 39.331096 28.048562 7.907506 6.809487 11.952320 11.717500 0.030527 0.028673 0.001150
321 N02 not_connected 100.00% 0.00% 0.00% 0.00% 42.822766 47.696390 144.696703 150.763278 170.160669 144.207910 29.876305 28.551546 0.867091 0.498542 0.671891
322 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 1.536840 16.732100 62.883360 70.795788 -0.109267 1.690105 0.138288 -0.728517 0.031095 0.029367 0.001309
323 N02 not_connected 100.00% 100.00% 100.00% 0.00% 4.843926 10.821873 54.676768 67.518523 1.881461 4.156990 2.372131 0.451596 0.048737 0.042227 0.013176
324 N04 not_connected 100.00% 100.00% 100.00% 0.00% 8.303264 10.001129 63.923558 67.187863 6.682012 -0.758717 -1.180384 0.388218 0.029593 0.028673 0.000943
325 N09 dish_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
329 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 7.977899 0.767338 55.208514 56.184359 -0.305193 0.303931 -0.561444 -0.494044 0.029913 0.028857 0.001259
333 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 7.050764 1.021327 56.002381 56.233835 1.176334 3.409620 2.433739 -1.507103 0.029118 0.028685 0.000794
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [3, 4, 5, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 77, 78, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 147, 148, 149, 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, 320, 321, 322, 323, 324, 325, 329, 333]

unflagged_ants: []

golden_ants: []
In [23]:
# write to csv
outpath = os.path.join(nb_outdir, f'rtp_summary_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/rtp_summary_table_2459844.csv
In [24]:
# Load antenna positions
data_list = sorted(glob.glob(os.path.join(data_path, f'zen.{JD}.?????.sum.uvh5')))
hd = io.HERAData(data_list[len(data_list) // 2])

# Figure out where to draw the nodes
node_centers = {}
for node in sorted(set(list(nodes.values()))):
    if np.isfinite(node):
        this_node_ants = [ant for ant in ants + unused_ants if nodes[ant] == node]
        if len(this_node_ants) == 1:
            # put the node label just to the west of the lone antenna 
            node_centers[node] = hd.antpos[ant][node] + np.array([-14.6 / 2, 0, 0])
        else:
            # put the node label between the two antennas closest to the node center
            node_centers[node] = np.mean([hd.antpos[ant] for ant in this_node_ants], axis=0)
            closest_two_pos = sorted([hd.antpos[ant] for ant in this_node_ants], 
                                     key=lambda pos: np.linalg.norm(pos - node_centers[node]))[0:2]
            node_centers[node] = np.mean(closest_two_pos, axis=0)
In [25]:
def Plot_Array(ants, unused_ants, outriggers):
    plt.figure(figsize=(16,16))
    
    plt.scatter(np.array([hd.antpos[ant][0] for ant in hd.data_ants if ant in ants]), 
                np.array([hd.antpos[ant][1] for ant in hd.data_ants if ant in ants]), c='w', s=0)

    # connect every antenna to their node
    for ant in ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', zorder=0)

    rc_color = '#0000ff'
    antm_color = '#ffa500'
    autom_color = '#ff1493'

    # Plot 
    unflagged_ants = []
    for i, ant in enumerate(ants):
        ant_has_flag = False
        # plot large blue annuli for redcal flags
        if use_redcal:
            if redcal_flagged_frac[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=7 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=rc_color, alpha=redcal_flagged_frac[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot medium green annuli for ant_metrics flags
        if use_ant_metrics: 
            if ant_metrics_xants_frac_by_ant[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=antm_color, alpha=ant_metrics_xants_frac_by_ant[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot small red annuli for auto_metrics
        if use_auto_metrics:
            if ant in auto_ex_ants:
                ant_has_flag = True                
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, lw=0, color=autom_color)) 
        
        # plot black/white circles with black outlines for antennas
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4 * (2 - 1 * float(not outriggers)), fill=True, color=['w', 'k'][ant_has_flag], ec='k'))
        if not ant_has_flag:
            unflagged_ants.append(ant)

        # label antennas, using apriori statuses if available
        try:
            bgc = matplotlib.colors.to_rgb(status_colors[a_priori_statuses[ant]])
            c = 'black' if (bgc[0]*0.299 + bgc[1]*0.587 + bgc[2]*0.114) > 186 / 256 else 'white'
        except:
            c = 'k'
            bgc='white'
        plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color=c, backgroundcolor=bgc)

    # label nodes
    for node in sorted(set(list(nodes.values()))):
        if not np.isnan(node) and not np.all(np.isnan(node_centers[node])):
            plt.text(node_centers[node][0], node_centers[node][1], str(node), va='center', ha='center', bbox={'color': 'w', 'ec': 'k'})
    
    # build legend 
    legend_objs = []
    legend_labels = []
    
    # use circles for annuli 
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgecolor='k', markerfacecolor='w', markersize=13))
    legend_labels.append(f'{len(unflagged_ants)} / {len(ants)} Total {["Core", "Outrigger"][outriggers]} Antennas Never Flagged')
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='k', markersize=15))
    legend_labels.append(f'{len(ants) - len(unflagged_ants)} Antennas {["Core", "Outrigger"][outriggers]} Flagged for Any Reason')

    if use_auto_metrics:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=autom_color, markersize=15))
        legend_labels.append(f'{len([ant for ant in auto_ex_ants if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas Flagged by Auto Metrics')
    if use_ant_metrics: 
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=antm_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum([frac for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants]), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Ant Metrics\n(alpha indicates fraction of time)')        
    if use_redcal:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=rc_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum(list(redcal_flagged_frac.values())), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in redcal_flagged_frac.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Redcal\n(alpha indicates fraction of time)')

    # use rectangular patches for a priori statuses that appear in the array
    for aps in sorted(list(set(list(a_priori_statuses.values())))):
        if aps != 'Not Found':
            legend_objs.append(plt.Circle((0, 0), radius=7, fill=True, color=status_colors[aps]))
            legend_labels.append(f'A Priori Status:\n{aps} ({[status for ant, status in a_priori_statuses.items() if ant in ants].count(aps)} {["Core", "Outrigger"][outriggers]} Antennas)')

    # label nodes as a white box with black outline
    if len(node_centers) > 0:
        legend_objs.append(matplotlib.patches.Patch(facecolor='w', edgecolor='k'))
        legend_labels.append('Node Number')

    if len(unused_ants) > 0:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='grey', markersize=15, alpha=.2))
        legend_labels.append(f'Anntenna Not In Data')
        
    
    plt.legend(legend_objs, legend_labels, ncol=2, fontsize='large', framealpha=1)
    
    if outriggers:
        pass
    else:
        plt.xlim([-200, 150])
        plt.ylim([-150, 150])        
       
    # set axis equal and label everything
    plt.axis('equal')
    plt.tight_layout()
    plt.title(f'Summary of {["Core", "Outrigger"][outriggers]} Antenna Statuses and Metrics on {JD}', size=20)    
    plt.xlabel("Antenna East-West Position (meters)", size=12)
    plt.ylabel("Antenna North-South Position (meters)", size=12)
    plt.xticks(fontsize=12)
    plt.yticks(fontsize=12)
    xlim = plt.gca().get_xlim()
    ylim = plt.gca().get_ylim()    
        
    # plot unused antennas
    plt.autoscale(False)    
    for ant in unused_ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', alpha=.2, zorder=0)
        
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='w', ec=None, alpha=1, zorder=0))
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='grey', ec=None, alpha=.2, zorder=0))
        if hd.antpos[ant][0] < xlim[1] and hd.antpos[ant][0] > xlim[0]:
            if hd.antpos[ant][1] < ylim[1] and hd.antpos[ant][1] > ylim[0]:
                plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color='k', alpha=.2) 

Figure 1: Array Plot of Flags and A Priori Statuses¶

This plot shows all antennas, which nodes they are connected to, and their a priori statuses (as the highlight text of their antenna numbers). It may also show (depending on what is finished running):

  • Whether they were flagged by auto_metrics (red circle) for bandpass shape, overall power, temporal variability, or temporal discontinuities. This is done in a binary fashion for the whole night.
  • Whether they were flagged by ant_metrics (green circle) as either dead (on either polarization) or crossed, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.
  • Whether they were flagged by redcal (blue circle) for high chi^2, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.

Note that the last fraction does not include antennas that were flagged before going into redcal due to their a priori status, for example.

In [26]:
core_ants = [ant for ant in ants if ant < 320]
outrigger_ants = [ant for ant in ants if ant >= 320]
Plot_Array(ants=core_ants, unused_ants=unused_ants, outriggers=False)
if len(outrigger_ants) > 0:
    Plot_Array(ants=outrigger_ants, unused_ants=sorted(set(unused_ants + core_ants)), outriggers=True)

Metadata¶

In [27]:
from hera_qm import __version__
print(__version__)
from hera_cal import __version__
print(__version__)
2.0.4.dev8+g8ce4cac
3.1.5.dev74+gf9d2808
In [ ]: