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.

In [1]:
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 os
import h5py
from copy import deepcopy
from IPython.display import display, HTML
from hera_notebook_templates.utils import status_colors

%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_'
# 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
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']
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}"')
JD = "2459741"
data_path = "/mnt/sn1/2459741"
ant_metrics_ext = ".ant_metrics.hdf5"
redcal_ext = ".known_good.omni.calfits"
nb_outdir = "/home/obs/src/H5C_Notebooks/_rtp_summary_"
In [4]:
from astropy.time import Time
utc = Time(JD, format='jd').datetime
print(f'Date: {utc.month}-{utc.day}-{utc.year}')
Date: 6-10-2022
In [5]:
# Per-season options
def ant_to_report_url(ant):
    return f'https://htmlpreview.github.io/?https://github.com/HERA-Team/H5C_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/2459741/zen.2459741.25313.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/2459741/zen.2459741.?????.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/2459741/zen.2459741.?????.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
hd = io.HERAData(sorted(glob.glob(os.path.join(data_path, 'zen.*.sum.uvh5')))[0])
unused_ants = [ant for ant in hd.antpos if ant not in ants]    

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}

Build DataFrame¶

In [14]:
# build dataframe
to_show = {'Ant': [f'<a href="{ant_to_report_url(ant)}" target="_blank">{ant}</a>' for ant in ants],
           'Node': [nodes[ant] 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 1: 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 [15]:
HTML(table.render())
Out[15]:
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
0 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% 50.157071 45.844133 60.040943 56.821716 54105.480332 51482.209662 21477.953226 20233.983656 nan nan nan
1 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
2 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
3 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
4 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
5 1 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
7 2 digital_ok 100.00% 100.00% 100.00% 0.00% 5.838953 5.543721 3.848354 3.794960 5.412616 23.362650 4.305766 33.453736 0.075447 0.074811 0.011592
8 2 RF_maintenance 100.00% 0.00% 0.00% 0.00% 50.613007 50.935234 57.342401 60.257228 98.540930 90.080209 47.813820 37.446653 0.655636 0.614813 0.483083
9 2 digital_ok 0.00% 100.00% 100.00% 0.00% -0.463501 -0.544953 -0.816381 -0.651561 -1.112658 -1.625908 -0.190118 -0.413725 0.066514 0.074306 0.009198
10 2 digital_ok 100.00% 100.00% 100.00% 0.00% 0.316851 5.083621 -0.667280 3.216476 14.166374 20.792315 37.552437 40.824030 0.032475 0.038982 0.001921
11 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
12 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
13 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
14 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
15 1 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
16 1 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
17 1 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
18 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
19 2 digital_ok 100.00% 100.00% 100.00% 0.00% 4.875705 6.256809 1.482289 5.368769 4.048309 31.839115 19.174858 4.636922 0.034874 0.038979 0.002518
20 2 digital_ok 0.00% 100.00% 100.00% 0.00% 2.333507 1.486254 3.131218 2.313388 1.122168 -0.020222 1.910688 -1.488216 0.034538 0.039444 0.002157
21 2 digital_ok 100.00% 100.00% 100.00% 0.00% 0.374944 0.074012 -0.696832 -0.662595 2.619376 2.284473 3.318410 14.317295 0.031573 0.031959 0.000960
23 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
24 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
25 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
26 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
27 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
28 1 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
29 1 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
30 1 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
31 2 digital_ok 100.00% 100.00% 100.00% 0.00% 9.259503 -0.067374 3.759476 1.122528 11.626577 9.550677 5.292228 2.508968 0.028799 0.029205 0.000408
32 2 RF_maintenance 100.00% 100.00% 100.00% 0.00% 1.378419 0.876825 2.334874 1.541844 1167.259779 1406.358999 475.244565 565.510766 0.028786 0.029239 0.000572
33 2 RF_maintenance 100.00% 100.00% 100.00% 0.00% -0.919696 13.529366 -0.880587 25.273221 81.872135 84.598258 32.824722 44.036415 0.062236 0.043331 0.005409
36 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
37 3 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
38 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
39 0 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
40 4 digital_ok 100.00% 0.00% 0.00% 0.00% 52.342524 52.180172 46.837988 48.955201 97.043167 74.904004 18.400954 17.871775 0.705100 0.668650 0.467118
41 4 digital_ok 0.00% 100.00% 100.00% 0.00% -0.925821 0.415383 -0.778929 -0.596005 -0.175214 -2.998692 0.056463 -0.655629 0.037735 0.034497 0.001361
42 4 digital_ok 0.00% 100.00% 100.00% 0.00% 2.137027 2.853945 0.132427 -0.118050 0.720119 3.273585 -0.056594 -0.960515 0.056687 0.064889 0.006253
45 5 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.198577 31.258896 -0.446851 11.633352 314.295675 808.020830 128.394069 329.485608 0.028918 0.031942 0.002074
46 5 digital_ok 100.00% 100.00% 100.00% 0.00% 3.909691 4.817751 8.047859 7.174790 35.048381 32.608120 52.238522 51.035711 0.028599 0.027721 0.001434
50 3 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
51 3 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
52 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
53 3 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
54 4 digital_ok 0.00% 100.00% 100.00% 0.00% 0.005561 0.077282 -0.697420 0.465841 0.176445 0.628863 0.693352 3.529523 0.056155 0.068284 0.002791
55 4 digital_ok 100.00% 100.00% 100.00% 0.00% -0.938260 1.922036 -0.171962 -0.319985 0.020647 5.670172 0.743392 6.197277 0.034626 0.051661 0.002531
56 4 digital_ok 0.00% 100.00% 100.00% 0.00% 1.607046 2.346759 0.202401 2.077160 2.706072 1.309198 1.852233 0.853872 0.039569 0.041228 0.002588
57 4 digital_ok 100.00% 100.00% 100.00% 0.00% 7.118239 5.571751 1.212282 6.140383 14.265250 5.019840 0.491401 0.735769 0.040205 0.038267 0.004545
65 3 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
66 3 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
67 3 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
68 3 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
69 4 digital_ok 100.00% 100.00% 100.00% 0.00% 1.336311 2.091372 1.603856 0.607901 3.668777 24.080601 2.000658 2.703096 0.038970 0.041695 0.004729
70 4 RF_maintenance 100.00% 0.00% 0.00% 0.00% 61.253376 54.689055 36.128948 34.543453 131.869057 110.116135 38.547722 50.618294 0.735231 0.706653 0.448476
71 4 digital_ok 100.00% 100.00% 100.00% 0.00% 5.112964 8.157496 7.112463 10.232537 4.492425 1.933223 5.709867 1.932998 0.036473 0.043508 0.005764
72 4 digital_ok 100.00% 0.00% 0.00% 0.00% 47.714932 53.141587 47.496827 52.184309 95.180542 62.974690 19.778221 12.109532 0.712099 0.699936 0.426128
73 5 RF_maintenance 100.00% 100.00% 100.00% 0.00% 2.514627 11.371368 4.373987 1.480622 23.478576 8.287189 22.179671 13.159233 0.028795 0.030542 0.001091
81 7 digital_ok 100.00% 100.00% 100.00% 0.00% 6.599382 1.952441 2.538515 3.729742 -1.888546 -0.389860 0.295310 1.200175 0.064296 0.053849 0.008275
82 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% 9.902920 8.442200 1.928400 1.162649 3.908758 6.369537 12.500411 11.610276 0.076448 0.077317 0.006594
83 7 digital_ok 100.00% 100.00% 100.00% 0.00% 32.956981 31.696265 6.772358 6.739609 13.362610 32.183687 6.264234 4.754761 0.082705 0.085936 0.007413
84 8 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
85 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
86 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
87 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
88 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
89 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
90 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
91 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
92 10 digital_ok 100.00% 100.00% 100.00% 0.00% 75.349908 72.497430 102.983147 73.270553 657.347849 427.863464 1933.347995 1182.078647 0.017560 0.016677 0.000757
93 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 62.338084 80.067438 79.822438 91.015863 604.693518 737.553088 1255.310128 1873.992497 0.016548 0.016331 0.000427
94 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 60.804466 67.849638 71.425574 75.104547 413.610155 435.822006 1156.039816 1274.986797 0.016533 0.016343 0.000261
98 7 digital_maintenance 100.00% 100.00% 100.00% 0.00% 33.697911 32.192990 5.781508 5.764781 3.784528 1.454361 6.525749 4.757359 0.076630 0.102975 0.030989
99 7 digital_ok 100.00% 0.00% 0.00% 0.00% 55.892539 55.447452 44.331214 45.892892 109.669224 96.369711 25.858725 21.953819 0.662044 0.639647 0.475868
100 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% 33.657050 31.548466 5.924100 7.721475 3.801044 3.503943 7.786537 8.181902 0.058114 0.076223 0.019615
101 8 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
102 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
103 8 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
104 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
105 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
106 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
107 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
108 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
109 10 digital_ok 100.00% 100.00% 100.00% 0.00% 65.923976 81.050474 81.447549 78.435469 629.879909 425.446326 1273.490878 1258.223383 0.017993 0.016566 0.001332
110 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 56.560616 70.419105 57.298283 83.579099 215.995965 454.728638 605.588063 1081.711477 0.017751 0.016335 0.001441
111 10 digital_ok 100.00% 100.00% 100.00% 0.00% 62.682593 68.271561 72.228370 63.427930 208.122596 306.216962 663.456901 861.675811 0.016997 0.016563 0.000437
112 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 62.820810 75.555445 77.649334 61.448831 510.242302 330.327057 1386.567877 851.725922 0.017850 0.016995 0.000637
116 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% 31.468441 29.867480 6.693457 6.874316 2.312611 1.403967 4.456453 4.853195 0.099226 0.101698 0.005209
119 7 RF_maintenance 100.00% 100.00% 100.00% 0.00% 33.214196 2.441309 6.137524 2.060872 1.672916 -0.660912 4.707774 0.383121 0.093663 0.081949 0.021758
120 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
121 8 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
122 8 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
123 8 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
124 9 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
125 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
126 9 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
127 10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 60.560218 92.899191 70.466959 77.537533 430.939136 451.210385 1081.763245 1124.058382 0.016804 0.016484 0.000494
128 10 digital_ok 100.00% 100.00% 100.00% 0.00% 65.317179 79.310168 80.851332 91.098608 676.131345 533.584058 1315.329210 1407.292782 0.016472 0.016188 0.000371
129 10 digital_ok 100.00% 100.00% 100.00% 0.00% 73.427111 65.288645 84.973500 59.873262 455.476092 274.499693 1085.850115 793.579064 0.017914 0.017264 0.000457
130 10 digital_maintenance 100.00% 100.00% 100.00% 0.00% 99.315968 82.322324 169.033259 91.693968 2039.501451 530.856570 4568.018280 1569.879013 0.016016 0.016340 0.000830
135 12 digital_ok 0.00% 100.00% 100.00% 0.00% -0.652859 -0.550252 -0.469071 -0.831872 -0.314653 -0.067904 1.256344 0.771355 0.034631 0.033261 0.003415
136 12 RF_maintenance 100.00% 100.00% 100.00% 0.00% -0.683756 -0.540211 0.957349 0.804127 4.798903 0.110916 2.002773 1.834405 0.035393 0.036978 0.000995
138 7 digital_ok 100.00% 100.00% 100.00% 0.00% 8.535862 5.861856 1.443879 0.930582 0.168483 0.315137 1.012917 0.567149 0.093398 0.068440 0.002008
140 13 digital_ok 100.00% 100.00% 100.00% 0.00% 6.644568 7.367058 13.672075 13.662540 28.764642 23.217071 42.132499 40.684086 0.043831 0.054343 0.003831
141 13 digital_ok 100.00% 100.00% 100.00% 0.00% 1.652016 20.548295 0.898710 9.733703 3.634706 -0.058187 2.370822 4.542222 0.040640 0.051988 0.002666
142 13 digital_ok 100.00% 100.00% 100.00% 0.00% 5.588417 29.375644 3.107399 12.753037 -2.105193 -0.582470 2.655199 2.616101 0.045611 0.041817 0.002635
143 14 digital_ok 100.00% 0.00% 0.00% 0.00% 49.753619 53.004338 50.041955 51.039119 73.413141 69.633887 13.867191 14.564991 0.686948 0.670577 0.456839
144 14 digital_ok 100.00% 100.00% 100.00% 0.00% 12.071871 15.369164 4.318027 6.408662 -0.444249 -0.707937 3.366959 4.621341 0.033097 0.034235 0.001189
145 14 digital_ok 100.00% 100.00% 100.00% 0.00% 8.334283 -0.942097 3.678231 -0.673832 -0.644130 -0.245369 2.948286 2.233228 0.032341 0.032969 0.000971
150 15 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
155 12 RF_maintenance 100.00% 100.00% 100.00% 0.00% 35.393616 35.407002 11.662486 12.289020 0.644905 1.758516 6.118075 7.250459 0.034331 0.038853 0.000698
156 12 RF_maintenance 0.00% 100.00% 100.00% 0.00% -0.696122 -0.923886 0.118050 0.146785 -2.087588 -0.348309 -0.472457 1.206610 0.032881 0.037770 0.001744
157 12 RF_maintenance 100.00% 100.00% 100.00% 0.00% 3.259687 1.875783 4.592813 -0.395567 -0.639558 1.332395 2.482098 -0.057153 0.036264 0.039662 0.001910
158 12 RF_maintenance 0.00% 100.00% 100.00% 0.00% 3.542999 1.407624 1.214161 1.923599 0.424419 0.188040 -0.293192 3.167578 0.037532 0.034961 0.003128
160 13 digital_ok 100.00% 100.00% 100.00% 0.00% 3.796788 2.503447 3.568989 1.284343 6.509571 1.017043 0.809829 9.119094 0.044653 0.051644 0.004307
161 13 digital_ok 0.00% 100.00% 100.00% 0.00% 0.502005 -0.112356 -0.351773 -0.357925 0.288116 -1.146610 0.464599 -0.020925 0.053453 0.036864 0.000683
162 13 digital_ok 0.00% 100.00% 100.00% 0.00% -1.373662 -0.508092 -0.326401 -0.838990 -1.505112 0.522148 0.225686 0.020925 0.084393 0.036971 0.014649
163 14 digital_ok 100.00% 100.00% 100.00% 0.00% 1.715066 -0.624014 0.524168 -0.726590 3.436934 5.676393 5.857395 8.548622 0.039775 0.042198 0.006378
164 14 digital_ok 100.00% 100.00% 100.00% 0.00% 1.083597 2.370829 0.617433 0.298234 2.799334 8.834918 1.355607 1.074938 0.044046 0.061984 0.012240
165 14 digital_ok 0.00% 100.00% 100.00% 0.00% -1.386162 -0.257743 0.820246 1.493852 0.348938 -0.247394 -0.475398 -0.769921 0.032352 0.035994 0.000854
166 14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 6.905745 10.123281 2.009820 3.236105 -0.042375 -1.902664 0.829775 0.320053 0.032995 0.036024 0.003377
167 15 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
168 15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 50.363457 50.375908 58.284551 63.234267 42.768170 20.600095 2.392186 2.477981 0.706230 0.678931 0.418615
169 15 digital_ok 100.00% 0.00% 0.00% 0.00% 50.390926 49.820173 61.350610 61.554417 27.396214 24.166654 -0.330512 3.561712 0.692822 0.676599 0.409692
170 15 digital_ok 100.00% 0.00% 0.00% 0.00% 49.903270 49.747414 61.693552 60.090713 28.248428 33.207849 0.079520 7.610808 0.680652 0.683578 0.419544
176 12 digital_ok 0.00% 100.00% 100.00% 0.00% 2.574765 0.017608 3.009313 -0.143092 -1.914572 -1.589515 -0.931078 -1.522127 0.037307 0.034795 0.002899
177 12 digital_ok 100.00% 100.00% 100.00% 0.00% 1.129135 5.248994 0.085050 5.058036 -0.147617 17.893115 1.456751 7.080277 0.040018 0.039818 0.002694
178 12 digital_ok 100.00% 100.00% 100.00% 0.00% 4.053926 6.885148 6.728045 11.889936 34.646011 37.685452 68.890674 77.096493 0.040621 0.041523 0.001513
179 12 digital_ok 100.00% 100.00% 100.00% 0.00% 2.923474 1.367393 1.883259 -0.519355 32.905626 -3.330156 9.331883 -0.221412 0.039855 0.036595 0.003515
180 13 RF_maintenance 100.00% 100.00% 100.00% 0.00% 1.063384 31.211457 -0.036866 13.217923 7.085164 0.573171 21.804234 3.798143 0.042119 0.046414 0.002931
181 13 digital_ok 100.00% 100.00% 100.00% 0.00% 15.226441 4.360642 6.515161 2.515978 -1.852567 -2.161302 1.234950 2.587395 0.036643 0.027803 0.003960
182 13 RF_maintenance 100.00% 0.00% 8.60% 0.00% 45.794403 49.024704 57.114418 6.723858 45.325080 147.003500 3.802329 152.797250 0.640730 0.508023 0.459549
183 13 digital_ok 100.00% 100.00% 100.00% 0.00% 1.465522 1.393173 0.160722 0.677006 -2.250958 -1.087873 0.526656 7.876964 0.033325 0.033439 0.001839
184 14 digital_ok 100.00% 100.00% 100.00% 0.00% 1.717808 2.229896 3.253482 3.518770 45.358302 48.705713 73.072276 72.868282 0.032319 0.032441 0.001131
185 14 digital_ok 100.00% 100.00% 100.00% 0.00% 7.115683 7.442392 16.605614 19.479888 17.081553 12.646502 21.533039 18.607563 0.041593 0.040998 0.004764
186 14 digital_ok 100.00% 100.00% 100.00% 0.00% 1.669220 2.237898 -0.371497 -0.087449 6.228308 -1.668131 5.195632 1.879677 0.036339 0.038938 0.005530
187 14 digital_ok 100.00% 100.00% 100.00% 0.00% 0.442187 2.296801 0.024809 2.422568 0.286057 2.057163 3.640184 5.998170 0.035546 0.034275 0.000714
189 15 digital_ok 100.00% 100.00% 100.00% 0.00% 1.552607 1.738061 -0.368243 0.145585 10.647854 6.439429 20.937306 7.922528 0.031882 0.033324 0.001760
190 15 digital_ok 0.00% 100.00% 100.00% 0.00% -0.028557 -0.005561 -0.425860 1.384187 0.020222 0.819420 -0.096952 0.224774 0.031065 0.033610 0.001739
191 15 digital_ok 100.00% 100.00% 100.00% 0.00% 2.048566 6.664337 0.783164 4.140557 2.072331 1.092856 1.390691 15.227962 0.031270 0.031529 0.001414
220 18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
221 18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
222 18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
320 3 dish_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
321 2 not_connected 100.00% 0.00% 3.23% 0.00% 50.921051 52.372864 56.330176 58.254490 54.775597 42.103149 7.075528 5.055436 0.550551 0.529387 0.427561
323 2 not_connected 100.00% 100.00% 100.00% 0.00% 13.998939 3.222339 15.475598 27.653819 3.132792 6.695107 4.948862 2.213191 0.070066 0.049838 0.014349
324 4 not_connected 100.00% 100.00% 100.00% 0.00% 8.393946 8.515883 34.678591 36.588874 2.619056 -0.265726 -0.315569 -0.430291 0.039094 0.034954 0.000936
325 9 dish_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
329 12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 19.750369 3.858006 14.314808 24.708403 0.060882 7.164488 3.461043 6.676482 0.031829 0.030830 0.001358
333 12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 30.284291 0.986233 11.390981 20.188726 4.146619 17.483114 5.637264 14.711596 0.038710 0.041385 0.002034
In [16]:
# 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] > .1 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
ex_ants: [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 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, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 135, 136, 138, 140, 141, 142, 143, 144, 145, 150, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 220, 221, 222, 320, 321, 323, 324, 325, 329, 333]
In [17]:
# write to csv
outpath = os.path.join(nb_outdir, f'rtp_summary_table_{JD}.csv')
print(f'Now saving Table 1 to a csv at {outpath}')
df.to_csv(outpath)
Now saving Table 1 to a csv at /home/obs/src/H5C_Notebooks/_rtp_summary_/rtp_summary_table_2459741.csv
In [18]:
# 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 [19]:
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 [20]:
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 [21]:
from hera_qm import __version__
print(__version__)
from hera_cal import __version__
print(__version__)
2.0.2
3.1.1.dev2+g1b5039f
In [ ]: