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 = "2459843"
data_path = "/mnt/sn1/2459843"
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-20-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/2459843/zen.2459843.34026.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 1832 ant_metrics files matching glob /mnt/sn1/2459843/zen.2459843.?????.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 184 ant_metrics files matching glob /mnt/sn1/2459843/zen.2459843.?????.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 2459843
Date 9-20-2022
LST Range 21.573 -- 7.433 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ❌
Number of Files 1832
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
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 143 / 158 (90.5%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 132 / 158 (83.5%)
Redcal Done? ✅
Redcal Flagged Antennas 12 / 158 (7.6%)
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_2459843.csv

Build DataFrame¶

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

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

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

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

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

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

Table 2: RTP Per-Antenna Metrics Summary Table¶

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

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

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

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

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

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

In [21]:
HTML(table.render())
Out[21]:
Ant Node A Priori Status Auto Metrics Flags Dead Fraction in Ant Metrics (Jee) Dead Fraction in Ant Metrics (Jnn) Crossed Fraction in Ant Metrics Flag Fraction Before Redcal Flagged By Redcal chi^2 Fraction ee Shape Modified Z-Score nn Shape Modified Z-Score ee Power Modified Z-Score nn Power Modified Z-Score ee Temporal Variability Modified Z-Score nn Temporal Variability Modified Z-Score ee Temporal Discontinuties Modified Z-Score nn Temporal Discontinuties Modified Z-Score Average Dead Ant Metric (Jee) Average Dead Ant Metric (Jnn) Average Crossed Ant Metric Median chi^2 Per Antenna (Jee) Median chi^2 Per Antenna (Jnn)
3 N01 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 7.514284 -1.445634 -0.887548 1.213504 -0.490393 0.670711 -0.247603 1.917094 0.733100 0.739997 0.390400 3.642357 3.483257
4 N01 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 1.077178 5.598751 0.056941 1.079135 0.079752 0.708208 1.666439 -0.469219 0.750355 0.738384 0.390111 5.585910 4.215135
5 N01 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 1.09% 0.216308 1.035193 -0.213272 1.969606 -0.229467 0.340736 -0.129615 -1.283207 0.749557 0.748067 0.386866 1.879931 1.544073
7 N02 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% -0.117275 -1.306462 -1.149996 -0.892427 0.071676 0.011803 0.481651 14.646545 0.743769 0.742329 0.393791 4.262610 4.020635
8 N02 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.094052 5.505901 16.218429 16.980363 69.397126 74.572512 0.012037 -2.028936 0.748996 0.734625 0.400030 4.695228 4.074001
9 N02 digital_ok 0.00% 0.66% 0.66% 0.00% 15.76% 0.00% -0.490712 -1.453507 -0.405526 -0.672143 -0.015057 0.015057 -0.693945 0.468725 0.739489 0.736603 0.402565 1.489327 1.371113
10 N02 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
15 N01 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 0.825532 0.917353 1.106333 0.484750 1.120630 0.092416 3.967481 4.487072 0.747992 0.751033 0.381788 4.628280 4.121959
16 N01 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 0.00% -0.890046 -0.001971 -1.024649 -1.191913 -0.819698 -0.373506 2.977496 0.111499 0.756953 0.754337 0.380852 1.933493 1.625236
17 N01 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 1.63% -0.397063 0.971484 -0.045846 -0.127249 0.352633 -0.466855 0.415639 -0.556164 0.750420 0.752445 0.373866 1.961045 1.681482
18 N01 RF_maintenance 100.00% 0.66% 14.85% 0.00% 100.00% 0.00% 20.388488 28.232469 -0.393530 0.565737 11.633242 20.859352 67.387261 43.296523 0.706095 0.533229 0.428881 3.307784 1.898641
19 N02 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
20 N02 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
21 N02 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 1.662447 -0.795610 4.726825 0.461861 5.468565 0.031460 -0.114844 3.868416 0.722455 0.738646 0.402803 4.118781 3.820100
22 N06 not_connected 100.00% 7.21% 0.66% 0.00% 100.00% 0.00% 53.827177 9.148215 4.943364 15.156686 11.606506 3.297745 5.270577 3.384078 0.550961 0.702798 0.327414 0.000000 0.000000
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 17.540563 18.774093 19.300034 20.280510 64.466762 71.101993 2.947827 2.102283 0.033788 0.040128 0.003882 1.240236 1.238062
28 N01 RF_maintenance 100.00% 38.86% 92.90% 0.00% 100.00% 0.00% 26.200746 53.751217 1.203030 1.859777 7.573921 35.392439 3.627772 33.785425 0.439773 0.210389 0.267190 5.355609 2.077416
29 N01 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 0.00% -1.907807 -0.817807 -0.676839 1.348406 -1.115627 -0.507277 -0.805076 1.034000 0.756802 0.760181 0.371643 1.915467 1.722328
30 N01 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% -0.251126 -1.289823 3.378764 -0.793178 9.510200 -0.051219 2.842146 -0.294379 0.743810 0.760838 0.376290 3.555006 3.453905
31 N02 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 0.00% 0.628417 -0.427689 -0.819281 0.736158 3.572230 3.446004 0.548422 0.477919 0.765614 0.757648 0.388962 1.594764 1.550017
32 N02 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 47.407932 4.508289 2.163426 5.195471 4.025041 8.072116 27.645746 123.954101 0.650571 0.746364 0.349795 4.132497 3.980561
33 N02 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 1.316934 28.722638 1.859513 1.483575 6.332690 19.960179 21.742261 59.911646 0.741697 0.584224 0.468529 3.772808 2.139473
34 N06 not_connected 100.00% 100.00% 0.66% 0.00% 100.00% 0.00% 20.020080 6.360883 6.017662 15.026662 64.263762 4.610992 0.189582 -2.710582 0.042592 0.738921 0.577505 0.000000 0.000000
35 N06 not_connected 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 3.680015 4.186813 0.417580 15.149002 20.001279 5.526512 1.083987 -2.656929 0.674511 0.733499 0.430021 5.057419 3.518508
36 N03 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 11.555207 10.682209 2.535306 -0.719919 1.616988 2.423553 -0.235827 0.723602 0.747131 0.752359 0.395041 4.762892 3.942423
37 N03 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% -0.253618 1.658188 -0.312856 1.206859 1.360756 0.954451 -0.626105 12.508689 0.753122 0.759652 0.388194 4.857968 4.017999
38 N03 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 0.606379 0.621394 -0.850330 0.165027 2.371109 3.827660 5.178083 2.350239 0.756925 0.763457 0.385874 3.755380 3.570210
40 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.323275 0.743061 -1.044883 -0.788588 74.381578 80.594530 -0.552465 -0.455606 0.755015 0.764170 0.382778 4.032753 4.189799
41 N04 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 1.63% 0.001971 -0.266430 2.928052 -0.061620 1.192890 0.090384 -1.072669 -0.364438 0.759633 0.757204 0.370979 1.667232 1.585739
42 N04 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 10.33% 0.024789 3.678843 1.132447 0.108275 -0.032715 -0.143365 -1.082316 -1.096265 0.767654 0.756924 0.383548 1.904659 1.762678
44 N05 digital_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 3.362164 2.557196 10.358821 9.517660 3.958690 4.027538 14.297383 9.130444 0.755809 0.764696 0.367075 4.109246 3.922218
45 N05 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% -0.925969 0.778592 -0.904342 -1.155141 0.388619 0.113210 -0.507676 17.027346 0.756786 0.760637 0.380770 4.588113 3.786458
46 N05 digital_ok 100.00% 0.66% 100.00% 0.00% 100.00% 0.00% -1.563119 19.135496 -0.149899 20.259934 0.087452 71.034518 0.203346 0.814512 0.755294 0.039376 0.595851 4.436371 1.288283
47 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.374157 4.716411 15.815780 14.570690 66.429853 80.465860 -2.044887 0.842556 0.747442 0.753501 0.395120 5.092102 5.252259
48 N06 not_connected 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 8.571797 9.063615 18.894662 18.882324 9.044108 13.570397 -3.467713 -3.625519 0.723407 0.730359 0.403250 3.199406 2.977271
49 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.773003 9.091434 16.427144 18.911178 67.639825 74.469418 -2.834937 -3.640016 0.727519 0.726000 0.405925 8.768411 5.341877
50 N03 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 3.203867 30.329712 -0.115490 0.868893 3.362871 7.758900 13.504852 90.385798 0.743364 0.693742 0.363728 6.989629 4.916726
51 N03 digital_ok 100.00% 100.00% 0.66% 0.00% 100.00% 0.00% 37.249866 4.123398 25.112691 -0.800046 335.236379 2.259519 1099.834408 11.942767 0.042674 0.760764 0.503174 1.210448 3.948356
52 N03 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 9.546064 10.165408 1.891305 -0.757352 23.625247 1.929301 83.450993 4.862747 0.754166 0.766149 0.377052 4.611769 4.215529
53 N03 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 2.478732 3.882097 -0.435240 -0.201959 1.267728 1.229135 2.716732 5.270628 0.759211 0.768241 0.380600 3.915411 3.654843
54 N04 digital_ok 100.00% 100.00% 0.66% 0.00% 100.00% 0.00% 17.085871 -0.975150 19.115369 -1.175527 64.463905 0.196363 0.231233 1.592351 0.052059 0.762484 0.621223 1.696072 4.048418
55 N04 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 4.213594 4.709007 0.267848 -0.344216 3.614181 -0.411944 0.386832 -0.588137 0.749095 0.755775 0.366951 4.380011 4.047868
56 N04 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 0.022562 1.949208 -0.116435 0.840491 -0.445224 0.907885 -0.401653 9.168430 0.757863 0.768988 0.370980 6.741222 4.721992
57 N04 RF_maintenance 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 55.185849 0.520442 5.401220 1.614225 9.199928 0.522061 2.345635 1.137458 0.596555 0.770224 0.372479 6.199082 4.235744
58 N05 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 16.366531 19.254533 18.917034 20.471857 64.610921 71.087180 1.442209 0.911971 0.045717 0.040983 0.004943 1.257227 1.254190
59 N05 digital_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 1.270081 19.158184 10.781159 -0.029407 3.770363 1.333786 4.581501 24.254117 0.763533 0.733553 0.371511 4.834336 3.320700
61 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 2.529349 3.089329 11.040154 12.503875 74.334021 74.449396 2.465296 7.199451 0.754580 0.753831 0.385570 5.966480 4.796899
62 N06 not_connected 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 8.412020 9.765314 18.058582 18.870159 4.608402 9.914160 -3.090676 -3.757773 0.738489 0.738602 0.391940 3.142983 2.947175
63 N06 not_connected 100.00% 1.20% 100.00% 0.00% 100.00% 0.00% 6.384008 20.074056 17.654620 6.909023 4.000899 70.936411 -2.958791 1.227950 0.696090 0.055244 0.621756 3.429500 1.158012
64 N06 not_connected 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.668228 8.349445 16.432380 18.014517 68.432464 74.462024 -2.692527 -3.442105 0.697667 0.707757 0.413661 3.824204 3.612527
65 N03 digital_ok 0.00% 0.66% 0.66% 0.00% 16.30% 0.54% 1.798346 1.299077 1.941395 0.334179 1.180271 1.322938 -0.717562 0.059013 0.740109 0.750603 0.392925 1.736824 1.668273
66 N03 digital_ok 0.00% 0.66% 0.66% 0.00% 16.30% 0.00% 0.665943 3.121541 0.526941 0.843845 1.445980 1.433840 -0.438823 2.541452 0.748979 0.757566 0.381966 1.832510 1.674130
67 N03 digital_ok 0.00% 0.66% 0.66% 0.00% 16.30% 0.00% -0.100865 -0.594242 -0.262415 0.585798 1.512394 0.888943 0.570018 2.282285 0.749095 0.760041 0.373552 1.724048 1.627364
68 N03 digital_ok 100.00% 0.66% 100.00% 0.00% 100.00% 0.00% 5.469558 44.830321 1.609231 28.789323 0.685699 68.962224 1.931203 8.088528 0.743744 0.031039 0.469727 3.562063 1.216694
69 N04 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 32.07% 0.058614 -0.777224 -0.534463 -0.814024 0.838233 0.831187 -0.449550 0.375456 0.750504 0.763713 0.376005 1.628635 1.495282
70 N04 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.895978 -0.252056 0.098134 -0.977040 73.978875 81.109984 0.964184 0.685384 0.773271 0.772074 0.378294 15.184850 11.835276
71 N04 digital_ok 0.00% 0.66% 0.66% 0.00% 15.22% 84.24% -0.074039 -0.361707 -1.195611 -0.659554 -0.535225 -0.952227 -0.440991 0.278577 0.753522 0.766499 0.380822 14.401003 14.115862
72 N04 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.565153 0.180660 -0.673490 0.372974 70.876600 81.654332 12.431728 0.329012 0.755033 0.769115 0.375226 4.580657 3.636482
73 N05 digital_ok 100.00% 100.00% 0.66% 0.00% 100.00% 0.00% 16.007778 2.248079 18.782401 -1.061603 64.594094 0.184444 0.603028 0.995822 0.035641 0.748451 0.540353 1.233459 3.438533
75 N05 digital_maintenance 100.00% 0.66% 100.00% 0.00% 100.00% 0.00% 11.174636 20.374579 7.631271 20.791966 11.980539 71.001240 12.007850 3.092790 0.717695 0.054362 0.575828 2.600041 1.234678
77 N06 not_connected 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 13.188014 15.997729 18.084359 16.637240 5.429292 9.566976 5.666674 2.454352 0.621276 0.614905 0.208763 0.000000 0.000000
78 N06 not_connected 100.00% 1.75% 0.66% 0.00% 100.00% 0.00% 22.571245 7.598276 16.576853 17.367270 5.032624 7.420442 -0.884770 -2.947332 0.600394 0.719590 0.370888 3.279019 3.606941
81 N07 digital_ok 0.00% 0.66% 0.66% 0.00% 16.30% 2.17% 0.664979 0.683038 0.848861 2.090341 0.188733 0.312344 1.857390 1.252111 0.725815 0.738715 0.393830 1.831410 1.715685
82 N07 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 5.349921 0.583769 0.918936 0.127652 6.868680 4.047646 4.176175 -0.384613 0.715243 0.740097 0.389218 4.225535 3.739949
83 N07 digital_ok 0.00% 0.66% 0.66% 0.00% 16.30% 0.00% 0.890671 0.976080 1.378174 2.637013 -0.810607 -1.175658 -0.863822 -0.668294 0.744417 0.754262 0.373218 1.754726 1.667221
84 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
85 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
86 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
87 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
88 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
89 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
90 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
91 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
92 N10 RF_maintenance 100.00% 75.98% 82.53% 0.00% 100.00% 0.00% 67.160498 81.682942 2.733079 4.426994 7.730684 11.422078 0.481950 7.050945 0.371563 0.327089 0.132416 2.746215 2.208029
93 N10 digital_ok 100.00% 8.84% 0.66% 0.00% 100.00% 0.00% 11.408784 0.455039 16.449688 -1.078724 47.134420 -0.606504 0.180666 -0.875078 0.549111 0.753159 0.438739 2.460802 4.847519
94 N10 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% -1.211817 -1.978948 -0.251460 -1.111313 0.100692 1.046387 7.245663 2.041501 0.750822 0.749135 0.391065 5.733802 5.227246
98 N07 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% -0.353480 15.241641 -0.323788 1.988528 4.838051 9.178963 0.309670 2.066807 0.712073 0.706385 0.383632 4.170076 3.349867
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.711831 0.668789 2.136244 -0.701023 72.137358 86.356554 0.075187 0.421140 0.738324 0.740354 0.383885 5.542685 3.625636
100 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 0.458306 -0.731070 0.785591 -0.896692 69.876477 79.699814 -0.481398 -0.121770 0.748100 0.748238 0.380262 4.646492 3.577114
101 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
102 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 5.016419 8.993928 6.845704 6.145914 179.640669 214.014008 5614.802218 5621.393971 nan nan nan 0.000000 0.000000
103 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
104 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
105 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
106 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
107 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
108 N09 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
109 N10 digital_ok 100.00% 0.66% 100.00% 0.00% 100.00% 0.00% 0.536557 18.832104 -0.791405 19.877993 -1.081288 71.065342 0.411311 0.205787 0.762069 0.039745 0.511533 6.084143 1.406781
110 N10 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 45.557218 54.968374 1.245715 1.195107 6.510872 6.872867 3.403751 26.294848 0.670126 0.641223 0.226413 3.881386 3.990967
111 N10 digital_ok 100.00% 0.66% 98.36% 0.00% 100.00% 0.00% 0.103957 18.493032 -0.470075 20.088157 -0.336084 70.933122 -0.016750 0.386530 0.753215 0.101978 0.531363 4.875477 1.493235
112 N10 digital_ok 0.00% 0.66% 0.66% 0.00% 15.76% 2.72% 0.743081 -0.182115 1.986269 0.045846 2.526158 0.692098 0.748966 -1.075600 0.732707 0.744223 0.401905 1.070826 0.975224
116 N07 digital_ok 100.00% 1.20% 1.20% 95.52% 100.00% 0.00% 3.149446 1.750045 6.596773 5.394468 3.997293 15.235633 -0.449842 -0.241749 0.373026 0.332030 -0.257740 2.907472 2.827243
117 N07 digital_ok 100.00% 100.00% 99.45% 0.00% 100.00% 0.00% 18.171695 20.273842 15.322210 16.687280 64.382277 70.800352 0.037918 -0.096480 0.028693 0.092809 0.051130 1.256043 1.277511
118 N07 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 18.162340 19.061673 15.291719 16.929888 64.415081 71.069794 -0.369252 -0.414930 0.030063 0.036329 0.005589 1.171048 1.170968
119 N07 RF_maintenance 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 2.069342 0.755563 5.959774 -1.125059 0.557490 1.671065 0.271429 -0.495957 0.750814 0.741382 0.380723 4.279615 3.070601
120 N08 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
121 N08 digital_ok 100.00% 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
122 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
123 N08 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
124 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
125 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
126 N09 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan 0.000000 0.000000
127 N10 digital_ok 0.00% 0.66% 0.66% 0.00% 17.93% 0.54% -1.170152 -0.643506 -0.616989 -0.093278 -0.656884 0.460049 -0.546594 2.236301 0.759486 0.754683 0.384331 1.039673 1.006711
128 N10 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% -0.867030 6.955169 -0.328242 1.334085 -0.286887 1.041420 -0.258577 -0.312819 0.758895 0.749934 0.380837 4.925799 5.025558
129 N10 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
130 N10 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
135 N12 digital_maintenance 0.00% 1.20% 0.66% 0.00% 100.00% 0.00% -0.970414 0.571934 -0.479900 2.909079 -0.347972 2.658965 0.672608 0.395658 0.708960 0.714780 0.401464 3.431947 2.981005
136 N12 digital_maintenance 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 1.852069 14.624777 -1.091660 -0.442653 -0.167163 0.908416 3.572371 5.006900 0.714820 0.708179 0.386320 3.351015 2.678784
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 3.655824 0.493288 10.839151 2.661671 67.039958 74.558200 -1.120768 1.256177 0.740662 0.743054 0.397353 3.225960 2.569926
138 N07 RF_maintenance 0.00% 1.20% 0.66% 0.00% 100.00% 0.00% 0.817217 0.239082 -0.870835 1.895760 -1.186089 1.416564 1.034579 -0.676374 0.738843 0.737479 0.398668 3.305617 2.469378
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 16.908012 19.409155 18.673933 20.368408 64.527812 71.032170 0.149501 0.525965 0.037543 0.038084 0.002323 0.000000 0.000000
141 N13 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 3.583530 5.342074 1.734576 5.393391 1.905014 6.950482 3.556892 35.274483 0.726970 0.716452 0.379138 0.000000 0.000000
142 N13 digital_ok 100.00% 78.17% 100.00% 0.00% 100.00% 0.00% 50.359676 19.709549 1.345217 20.593118 8.868189 70.917807 3.750626 1.754111 0.357395 0.038065 0.228901 0.000000 0.000000
143 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 6.496034 8.454740 17.072934 18.878555 66.907006 73.468120 -1.559616 -3.438789 0.754714 0.750948 0.390936 0.000000 0.000000
144 N14 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% -0.274239 -0.880846 0.839911 -0.553704 -0.301040 0.127165 5.296003 5.069868 0.750597 0.752015 0.391908 0.000000 0.000000
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 18.409762 20.303096 19.421440 20.735284 64.435477 71.027872 1.810740 3.783885 0.035858 0.027999 0.005200 0.000000 0.000000
147 N15 digital_ok 100.00% 0.66% 0.66% 0.00% 100.00% 0.00% 18.317617 2.247321 12.672229 12.002989 6.947274 4.971680 3.832247 -1.895435 0.713959 0.756506 0.377878 6.539698 5.367101
148 N15 RF_maintenance 100.00% 100.00% 0.00% 0.00% 100.00% 0.00% 17.327451 1.013655 19.011593 2.425844 64.492526 77.549248 0.745992 -0.328534 0.041387 0.761860 0.554690 1.382529 4.687863
149 N15 RF_maintenance 100.00% 0.66% 100.00% 0.00% 100.00% 0.00% 4.208333 19.528209 13.971097 20.432847 9.355148 71.033119 -0.906205 1.354324 0.748926 0.040546 0.571446 6.396029 1.362557
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 18.888832 20.100858 18.047712 19.929449 64.390789 70.990295 2.005752 2.683322 0.050088 0.052725 0.002688 1.333868 1.331214
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 17.685948 17.657114 18.763507 20.180546 64.483991 71.217553 2.564441 2.842374 0.038237 0.027819 0.003731 1.365752 1.345356
156 N12 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 0.012846 -0.132195 0.387154 -0.568784 -0.399992 -0.295882 2.370356 10.775453 0.714573 0.716686 0.393026 4.486483 4.059275
157 N12 digital_ok 0.00% 1.20% 0.66% 0.00% 15.76% 0.00% -1.253431 -0.942751 -0.643670 0.274191 -0.434787 -0.646015 -0.059013 -0.234030 0.722864 0.731151 0.401343 1.525892 1.331941
158 N12 digital_ok 100.00% 100.00% 0.66% 0.00% 100.00% 0.00% 17.134018 -1.216998 19.210039 -0.045480 64.525695 0.161615 0.275924 2.287578 0.038301 0.738494 0.481063 1.310638 4.856865
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 100.00% 0.00% 19.182981 21.211696 19.140796 20.442377 64.312300 70.847405 2.142056 3.582372 0.041449 0.043767 0.004162 1.275682 1.273061
161 N13 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 0.211239 48.373963 -1.042684 2.905020 -1.065983 3.692106 1.486002 1.458147 0.736373 0.633514 0.369955 4.550561 4.537585
162 N13 digital_ok 0.00% 1.20% 0.66% 0.00% 15.22% 0.54% 1.955678 0.931465 -0.261083 0.360889 -0.147765 -0.128965 2.987432 0.732197 0.744998 0.752642 0.395901 1.760450 1.572630
163 N14 digital_ok 0.00% 1.20% 0.66% 0.00% 15.22% 0.00% -0.099326 -0.083000 -0.104487 -1.180743 -0.425228 -0.717205 0.165685 1.074758 0.744424 0.750403 0.396056 1.758557 1.640010
164 N14 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% -0.599452 -1.165370 -0.653538 4.468012 -1.315144 5.178516 -0.419662 1.933986 0.747223 0.739664 0.395900 4.954533 3.685399
165 N14 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% -1.175942 0.829038 3.705747 -0.634554 1.315104 -0.757543 5.556044 0.000101 0.754373 0.750909 0.395656 5.269661 4.547470
166 N14 RF_maintenance 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 53.655329 48.278874 1.118307 0.926551 2.341965 3.353019 19.284733 19.233012 0.623902 0.630053 0.207869 3.827898 3.593036
167 N15 digital_ok 100.00% 0.00% 0.55% 0.00% 100.00% 0.00% 30.619776 27.113496 14.682241 16.352855 58.934205 73.733951 24.369890 23.820653 0.622979 0.606932 0.177286 3.631362 2.877020
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 7.472590 9.007274 16.823468 18.652212 67.036191 74.103397 -2.567654 -3.361314 0.754359 0.738807 0.407480 0.000000 0.000000
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 9.622701 7.369313 18.833360 18.326445 67.770824 74.166905 -2.707273 -2.528936 0.743954 0.727832 0.410781 5.194377 3.638494
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 100.00% 0.00% 8.342278 5.415960 18.847458 17.338930 67.321802 74.702590 -1.761927 -2.530290 0.733324 0.739417 0.419269 3.351275 2.737235
176 N12 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% -0.147985 -0.147978 -0.662569 7.155118 -0.715549 9.468118 -0.087289 1.314207 0.703590 0.690468 0.411923 4.474779 3.750483
177 N12 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 0.977400 2.479626 -0.639119 3.109752 -0.725731 13.436561 0.761038 7.892308 0.716107 0.702761 0.410314 5.424600 4.076216
178 N12 digital_ok 0.00% 1.20% 0.66% 0.00% 15.22% 0.54% 1.403005 -0.806068 1.165752 -0.130318 0.854004 -0.469321 -0.306749 -0.469875 0.715088 0.726606 0.414059 1.671617 1.432965
179 N12 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 0.961015 -0.434916 -1.170971 -1.207273 2.555120 -0.992306 6.734754 -0.519134 0.725139 0.731328 0.416220 4.407438 4.167485
180 N13 RF_maintenance 100.00% 1.20% 71.62% 0.00% 100.00% 0.00% 1.512337 16.907226 0.258464 19.747980 -0.470597 62.524908 -0.719830 1.821682 0.738053 0.387867 0.516256 12.064062 2.760082
181 N13 digital_ok 100.00% 100.00% 91.27% 0.00% 100.00% 0.00% 18.689465 74.431790 19.553065 5.562075 64.417138 12.611812 1.885600 6.738339 0.047398 0.260812 0.152739 1.245310 1.793793
182 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 100.00% 0.00% 6.396738 19.941698 16.479589 20.305090 69.240909 71.007687 -2.747641 2.601149 0.746046 0.054595 0.586445 5.437756 1.514515
183 N13 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% -2.023155 -1.138835 -0.600830 0.350546 -0.403051 0.341672 0.488146 7.047187 0.738400 0.735148 0.402322 4.583887 3.724865
184 N14 digital_ok 0.00% 1.20% 0.66% 0.00% 15.22% 0.00% -1.078625 -1.317854 -0.569131 1.195869 -0.893498 0.336879 -0.384383 -0.960001 0.742914 0.735992 0.400673 1.715503 1.679793
185 N14 digital_ok 0.00% 1.20% 0.66% 0.00% 15.22% 0.00% 0.403223 0.138672 0.650716 1.106558 -0.489396 0.531143 -0.714726 0.297312 0.750338 0.740136 0.397503 1.591305 1.526328
186 N14 digital_ok 0.00% 1.20% 0.66% 0.00% 15.22% 0.00% -0.413876 0.254232 1.859826 -0.340183 2.808544 -0.864685 2.136067 -0.824547 0.739849 0.745674 0.400961 1.594538 1.488141
187 N14 digital_ok 100.00% 1.20% 0.66% 0.00% 100.00% 0.00% 0.463158 -0.328545 -0.562279 -0.766029 0.151600 -0.851485 6.161788 2.400497 0.741692 0.744863 0.395913 4.619231 3.378136
189 N15 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
190 N15 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
191 N15 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
320 N03 dish_maintenance 100.00% 0.66% 100.00% 0.00% 100.00% 0.00% 8.750690 21.615303 18.734659 12.125550 5.260620 70.777975 -0.972761 2.972083 0.739708 0.064497 0.516492 0.000000 0.000000
321 N02 not_connected 100.00% 0.55% 0.55% 0.00% 100.00% 0.00% 2.674724 2.422770 10.031245 10.231028 65.820747 72.730582 2.552809 1.247759 0.643633 0.628989 0.442796 0.000000 0.000000
322 N05 digital_maintenance 100.00% 1.20% 1.20% 0.00% 100.00% 0.00% 8.192526 9.844353 18.077033 19.713353 4.549552 11.260944 -2.864730 -3.763338 0.624368 0.593480 0.428237 0.000000 0.000000
323 N02 not_connected 100.00% 56.33% 1.20% 0.00% 100.00% 0.00% 44.101044 3.831363 1.803450 14.262565 15.668744 4.779880 1.756736 -1.224753 0.410514 0.605441 0.391144 0.000000 0.000000
324 N04 not_connected 100.00% 1.20% 1.20% 0.00% 100.00% 0.00% 2.976597 5.099466 12.776776 14.142828 0.982176 4.524149 2.836725 -0.040095 0.628046 0.625456 0.428944 0.000000 0.000000
325 N09 dish_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
329 N12 dish_maintenance 100.00% 6.11% 0.66% 0.00% 100.00% 0.00% 6.144188 -1.061524 0.763616 8.954448 26.813420 1.723581 3.104727 -0.726173 0.591634 0.661900 0.439277 0.000000 0.000000
333 N12 dish_maintenance 100.00% 14.85% 1.20% 0.00% 100.00% 0.00% 9.934918 0.996860 -0.576926 7.719663 29.808056 3.498198 0.280083 0.532915 0.535485 0.643238 0.439051 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, 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_2459843.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.dev9+g5da028f
3.1.5.dev78+gda49a16
In [ ]: