import os
os.environ['HDF5_USE_FILE_LOCKING'] = 'FALSE'
import h5py
import hdf5plugin
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
import matplotlib.patches as mpatches
import matplotlib.gridspec as gridspec
import numpy as np
from pyuvdata import UVCal, UVData
import sys
import glob
import uvtools as uvt
from astropy.time import Time
from astropy.coordinates import EarthLocation, AltAz, Angle
from astropy.coordinates import SkyCoord as sc
import pandas
import warnings
import copy
from hera_notebook_templates import utils
import hera_qm
from hera_mc import cm_hookup
import importlib
from scipy import stats
from IPython.display import display, HTML
#warnings.filterwarnings('ignore')
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
display(HTML("<style>.container { width:100% !important; }</style>"))
#get data location
data_path = os.environ['DATA_PATH']
print(f'DATA_PATH = "{data_path}"')
statuses = os.environ['APRIORI_STATUSES']
print(f'APRIORI_STATUSES = {statuses}')
JD = os.environ['JULIANDATE']
print(f'JULIANDATE = {JD}')
utc = Time(JD, format='jd').datetime
print(f'Date = {utc.month}-{utc.day}-{utc.year}')
DATA_PATH = "/mnt/sn1/data1/2460575" APRIORI_STATUSES = dish_maintenance,dish_ok,RF_maintenance,RF_ok,digital_ok,digital_maintenance,calibration_maintenance,calibration_triage,calibration_ok JULIANDATE = 2460575 Date = 9-21-2024
# Load in data
HHfiles, difffiles, HHautos, diffautos, uvdx, uvdy = utils.load_data(data_path,JD)
uvd = UVData()
unread = True
readInd=0
while unread and readInd<len(HHautos):
try:
uvd.read(HHautos[readInd])
unread = False
except:
readInd += 1
continue
use_ants = utils.get_use_ants(uvd,statuses,JD)
print(f'This day contains {len(use_ants)} antennas of the given status category.')
uvd.read(HHautos[::10], skip_bad_files=True, antenna_nums = use_ants)
lsts = uvd.lst_array
uvdx.select(antenna_nums=use_ants)
uvdy.select(antenna_nums=use_ants)
377 sum files found between JDs 2460575.60301 and 2460575.68712 377 diff files found between JDs 2460575.60301 and 2460575.68712 377 sum auto files found between JDs 2460575.60301 and 2460575.68712 377 diff auto files found between JDs 2460575.60301 and 2460575.68712
This day contains 252 antennas of the given status category.
Sky Coverage Map¶
Map of the sky (made using the Haslam 408MHz map). The RA/DEC range covered by this night of observation is shaded based on a 12 degree FWHM of the beam. Horizontal dashed lines represent the stripe that HERA can observe, while the shaded region is what was observed on this night. Vertical lines represent the beginning and ending LSTs of this observation. Selected sources are labelled, sources included are those in the GLEAM 4Jy catalog with a flux >10.9 Jy. Note that the map is clipped at the northern horizon.
sources = utils.gather_source_list()
utils.plot_sky_map(uvd,dec_pad=55,ra_pad=55,clip=False,sources=sources)
LST Coverage¶
Shows the LSTs (in hours) and JDs for which data is collected. Green represents data, red means no data.
utils.plot_lst_coverage(uvd)
Autocorrelations for a single file¶
This plot shows autocorrelations for one timestamp of each antenna that is active and each polarization. For each node, antennas are ordered by SNAP number, and within that by SNAP input number. The antenna number label color corresponds to the a priori status of that antenna.
### plot autos
utils.plot_autos(uvdx, uvdy)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[6], line 2 1 ### plot autos ----> 2 utils.plot_autos(uvdx, uvdy) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:515, in plot_autos(uvdx, uvdy) 514 def plot_autos(uvdx, uvdy): --> 515 nodes, antDict, inclNodes = generate_nodeDict(uvdx) 516 ants = uvdx.get_ants() 517 sorted_ants = sort_antennas(uvdx) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1741, in generate_nodeDict(uv) 1722 """ 1723 Generates dictionaries containing node and antenna information. 1724 (...) 1737 Nodes that have hooked up antennas. 1738 """ 1740 antnums = uv.get_ants() -> 1741 x = cm_hookup.get_hookup('default') 1742 nodes = {} 1743 antDict = {} File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT
Waterfalls of Autocorrelation Amplitudes for each Antenna and Each polarization¶
These plots show autocorrelation waterfalls of each antenna that is active and whose status qualifies for this notebook. For each node, antennas are ordered by SNAP number, and within that by SNAP input number. The antenna number label color corresponds to the a priori status of that antenna.
utils.plot_wfs(uvd, pol = 0)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[7], line 1 ----> 1 utils.plot_wfs(uvd, pol = 0) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:584, in plot_wfs(uvd, pol, mean_sub, save, jd, auto_scale, vmin, vmax) 582 def plot_wfs(uvd, pol, mean_sub=False, save=False, jd='',auto_scale=True,vmin=6.5,vmax=8): 583 amps = np.abs(uvd.data_array[:, :, pol].reshape(uvd.Ntimes, uvd.Nants_data, uvd.Nfreqs, 1)) --> 584 nodes, antDict, inclNodes = generate_nodeDict(uvd) 585 ants = uvd.get_ants() 586 sorted_ants = sort_antennas(uvd) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1741, in generate_nodeDict(uv) 1722 """ 1723 Generates dictionaries containing node and antenna information. 1724 (...) 1737 Nodes that have hooked up antennas. 1738 """ 1740 antnums = uv.get_ants() -> 1741 x = cm_hookup.get_hookup('default') 1742 nodes = {} 1743 antDict = {} File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT
utils.plot_wfs(uvd, pol = 1)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[8], line 1 ----> 1 utils.plot_wfs(uvd, pol = 1) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:584, in plot_wfs(uvd, pol, mean_sub, save, jd, auto_scale, vmin, vmax) 582 def plot_wfs(uvd, pol, mean_sub=False, save=False, jd='',auto_scale=True,vmin=6.5,vmax=8): 583 amps = np.abs(uvd.data_array[:, :, pol].reshape(uvd.Ntimes, uvd.Nants_data, uvd.Nfreqs, 1)) --> 584 nodes, antDict, inclNodes = generate_nodeDict(uvd) 585 ants = uvd.get_ants() 586 sorted_ants = sort_antennas(uvd) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1741, in generate_nodeDict(uv) 1722 """ 1723 Generates dictionaries containing node and antenna information. 1724 (...) 1737 Nodes that have hooked up antennas. 1738 """ 1740 antnums = uv.get_ants() -> 1741 x = cm_hookup.get_hookup('default') 1742 nodes = {} 1743 antDict = {} File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT
Correlation Metrics¶
The first plot shows the correlation metric (described below) for a set of baseline types, as calculated at several times throughout the night. It is expected that longer baselines (darker color) will exhibit lower values than the short baselines.
The matrices show the phase correlation between antennas. Using the even and odd visibilities, each pixel is calculated as (even/abs(even)) * (conj(odd)/abs(odd)), and then averaged across time and frequency. If the phases are noise-like, this value will average down to zero. If the antennas are well correlated, the phases should not be noise-like, and this value should average to 1. The lines denoting node boundaries are intended to help confirm that inter-node correlations are functioning - if they aren't, this plot will appear block-diagonal.
This metric has shown to be LST locked - when comparing to other nights, be sure to compare for the same LST. It is expected that some LSTs will look much better or worse than others.
Note: Within each node, the order of antennas is determined by snap, and within that by snap input number.
badAnts = []
badAnts = utils.plotNodeAveragedSummary(uvd,HHfiles,JD,use_ants,mat_pols=['xx','yy','xy','yx'])
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[9], line 2 1 badAnts = [] ----> 2 badAnts = utils.plotNodeAveragedSummary(uvd,HHfiles,JD,use_ants,mat_pols=['xx','yy','xy','yx']) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:811, in plotNodeAveragedSummary(uv, HHfiles, jd, use_ants, pols, mat_pols, baseline_groups, removeBadAnts, plotRatios, plotSummary) 807 if baseline_groups == []: 808 baseline_groups = [(14,0,'14m E-W'),(14,-11,'14m NW-SE'),(14,11,'14m SW-NE'),(29,0,'29m E-W'),(29,22,'29m SW-NE'), 809 (44,0,'44m E-W'),(58.5,0,'58m E-W'),(73,0,'73m E-W'),(87.6,0,'88m E-W'), 810 (102.3,0,'102m E-W')] --> 811 nodeMedians,lsts,badAnts=get_correlation_baseline_evolutions(uv,HHfiles,jd,use_ants,pols=pols,mat_pols=mat_pols, 812 bl_type=baseline_groups,removeBadAnts=removeBadAnts, 813 plotRatios=plotRatios) 814 pols = mat_pols 815 if plotSummary is False: File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1489, in get_correlation_baseline_evolutions(uv, HHfiles, jd, use_ants, badThresh, pols, bl_type, removeBadAnts, plotMatrix, mat_pols, plotRatios) 1487 else: 1488 plotTimes = np.arange(0,nTimes,1) -> 1489 nodeDict, antDict, inclNodes = generate_nodeDict(uv) 1490 JD = math.floor(uv.time_array[0]) 1491 bad_antennas = [] File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1741, in generate_nodeDict(uv) 1722 """ 1723 Generates dictionaries containing node and antenna information. 1724 (...) 1737 Nodes that have hooked up antennas. 1738 """ 1740 antnums = uv.get_ants() -> 1741 x = cm_hookup.get_hookup('default') 1742 nodes = {} 1743 antDict = {} File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT
Visibility amplitude spectra for a set of redundant baselines, labeled by inter vs. intranode baselines. The red and blue should exhibit the same bandpass shape - if the red are consistently different from the blue, this indicates an issue with internode correlations.
Note: antennas that were identified as bad by the correlation matrix have been removed from this plot.
utils.plotVisibilitySpectra(HHfiles[len(HHfiles)//2+1], JD, use_ants, badAnts=[])
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[10], line 1 ----> 1 utils.plotVisibilitySpectra(HHfiles[len(HHfiles)//2+1], JD, use_ants, badAnts=[]) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:872, in plotVisibilitySpectra(file, jd, use_ants, badAnts, pols) 870 uv = UVData() 871 uv.read_uvh5(file) --> 872 x = cm_hookup.get_hookup('default') 873 baseline_groups = get_baseline_groups(uv,use_ants="auto") 874 freqs = uv.freq_array/1000000 File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT
<Figure size 640x480 with 0 Axes>
Even and Odd File Checks¶
A waterfall showing the ratio between the even and odd visibilities. The purpose of this is to highlight xengine failures, which will cause this value to fall to zero or go to infinity. If things are working properly, this value should be stable at 1. The boundaries between different x-engines are shown by the vertical white lines.
if len(HHautos) == len(diffautos):
uvd_diff = UVData()
uvd_diff.read(diffautos[::10], skip_bad_files=True, antenna_nums=use_ants)
rat = utils.plotEvenOddWaterfalls(uvd,uvd_diff)
else:
uvd_diff = UVData()
use_diffs = [f for f in diffautos if '%s/zen.%s.%s.sum.autos.uvh5' % (data_path,f.split('.')[1],f.split('.')[2]) in HHautos[::10]]
uvd_diff.read(use_diffs, skip_bad_files=True, antenna_nums = use_ants)
uvd_sum = uvd.select(times=np.unique(uvd_diff.time_array),inplace=False)
rat = utils.plotEvenOddWaterfalls(uvd_sum,uvd_diff)
Crossed Antenna Check¶
These are differences between different panels of the correlation matrices shown above (see panel titles for specifics). Antennas showing as consistently blue are ones which are correlating stronger in the cross pols than in the auto pols, indicating that the antenna polarizations are likely crossed.
crossedAnts = utils.plotNodeAveragedSummary(uvd,HHfiles,JD,use_ants,mat_pols=['xx','yy','xy','yx'],plotRatios=True,
plotSummary=False)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[12], line 1 ----> 1 crossedAnts = utils.plotNodeAveragedSummary(uvd,HHfiles,JD,use_ants,mat_pols=['xx','yy','xy','yx'],plotRatios=True, 2 plotSummary=False) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:811, in plotNodeAveragedSummary(uv, HHfiles, jd, use_ants, pols, mat_pols, baseline_groups, removeBadAnts, plotRatios, plotSummary) 807 if baseline_groups == []: 808 baseline_groups = [(14,0,'14m E-W'),(14,-11,'14m NW-SE'),(14,11,'14m SW-NE'),(29,0,'29m E-W'),(29,22,'29m SW-NE'), 809 (44,0,'44m E-W'),(58.5,0,'58m E-W'),(73,0,'73m E-W'),(87.6,0,'88m E-W'), 810 (102.3,0,'102m E-W')] --> 811 nodeMedians,lsts,badAnts=get_correlation_baseline_evolutions(uv,HHfiles,jd,use_ants,pols=pols,mat_pols=mat_pols, 812 bl_type=baseline_groups,removeBadAnts=removeBadAnts, 813 plotRatios=plotRatios) 814 pols = mat_pols 815 if plotSummary is False: File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1489, in get_correlation_baseline_evolutions(uv, HHfiles, jd, use_ants, badThresh, pols, bl_type, removeBadAnts, plotMatrix, mat_pols, plotRatios) 1487 else: 1488 plotTimes = np.arange(0,nTimes,1) -> 1489 nodeDict, antDict, inclNodes = generate_nodeDict(uv) 1490 JD = math.floor(uv.time_array[0]) 1491 bad_antennas = [] File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1741, in generate_nodeDict(uv) 1722 """ 1723 Generates dictionaries containing node and antenna information. 1724 (...) 1737 Nodes that have hooked up antennas. 1738 """ 1740 antnums = uv.get_ants() -> 1741 x = cm_hookup.get_hookup('default') 1742 nodes = {} 1743 antDict = {} File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT
Antenna Positions¶
Antennas outlined in black here have been identified by the correlation matrix as bad antennas. Antennas with a colorful outline correspond to their status as identified by ant_metrics (see above plot). Faded antennas are those not meeting the apriori status requirement for this notebook run. Gold stars are node box locations.
uvd1 = UVData()
uvd1.read(HHfiles[readInd], skip_bad_files=True)
utils.plot_antenna_positions(uvd1, badAnts=badAnts,use_ants=use_ants)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[13], line 3 1 uvd1 = UVData() 2 uvd1.read(HHfiles[readInd], skip_bad_files=True) ----> 3 utils.plot_antenna_positions(uvd1, badAnts=badAnts,use_ants=use_ants) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:962, in plot_antenna_positions(uv, badAnts, flaggedAnts, use_ants, includeOutriggers) 945 """ 946 Plots the positions of all antennas that have data, colored by node. 947 (...) 958 hex antennas. 959 """ 961 plt.figure(figsize=(12,10)) --> 962 nodes, antDict, inclNodes = generate_nodeDict(uv) 963 N = len(inclNodes) 964 cmap = plt.get_cmap('tab20') File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1741, in generate_nodeDict(uv) 1722 """ 1723 Generates dictionaries containing node and antenna information. 1724 (...) 1737 Nodes that have hooked up antennas. 1738 """ 1740 antnums = uv.get_ants() -> 1741 x = cm_hookup.get_hookup('default') 1742 nodes = {} 1743 antDict = {} File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT
<Figure size 1200x1000 with 0 Axes>
Observer Inspection Plots¶
Antennas of status digital_OK or better that are flagged as bad by any of the above metrics are plotted here so observers can inspect their failures in more detail. Additionally, a 'good' template has been used to identify outliers. The upper line plots are averages over the whole observation, and the lower line plots are slices of a single time in the middle of the observation. These plots are recommended diagnostics for demoting antennas to lower statuses or reporting issues. If the plots below look OK, check other plots in notebook to hunt why the antenna was flagged. NOTE: The colorbar/power scales in these plots are NOT locked between antennas OR polarizations so that the detail will be visible on all plots. Be sure to check for reasonable power levels, as this may be the reason the antenna was flagged for inspection.
d, tempAnts = utils.flag_by_template(uvd,HHautos,JD,use_ants=use_ants,pols=['XX','YY'],plotMap=False)
No template for lst=4.0 - skipping
inspectAnts = utils.plot_inspect_ants(uvd,JD,badAnts=badAnts,use_ants=use_ants,
tempAnts=tempAnts,crossedAnts=crossedAnts)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[15], line 2 1 inspectAnts = utils.plot_inspect_ants(uvd,JD,badAnts=badAnts,use_ants=use_ants, ----> 2 tempAnts=tempAnts,crossedAnts=crossedAnts) NameError: name 'crossedAnts' is not defined
Mean-Subtracted Waterfalls¶
Here the mean value in each frequency bin has been subtracted out. This effectively subtracts out the bandpass shape, making time variations more visible.
utils.plot_wfs(uvd,0,mean_sub=True,jd=JD)
utils.plot_wfs(uvd,1,mean_sub=True,jd=JD)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[16], line 1 ----> 1 utils.plot_wfs(uvd,0,mean_sub=True,jd=JD) 2 utils.plot_wfs(uvd,1,mean_sub=True,jd=JD) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:584, in plot_wfs(uvd, pol, mean_sub, save, jd, auto_scale, vmin, vmax) 582 def plot_wfs(uvd, pol, mean_sub=False, save=False, jd='',auto_scale=True,vmin=6.5,vmax=8): 583 amps = np.abs(uvd.data_array[:, :, pol].reshape(uvd.Ntimes, uvd.Nants_data, uvd.Nfreqs, 1)) --> 584 nodes, antDict, inclNodes = generate_nodeDict(uvd) 585 ants = uvd.get_ants() 586 sorted_ants = sort_antennas(uvd) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_notebook_templates/utils.py:1741, in generate_nodeDict(uv) 1722 """ 1723 Generates dictionaries containing node and antenna information. 1724 (...) 1737 Nodes that have hooked up antennas. 1738 """ 1740 antnums = uv.get_ants() -> 1741 x = cm_hookup.get_hookup('default') 1742 nodes = {} 1743 antDict = {} File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:71, in get_hookup(hpn, pol, at_date, at_time, float_format, exact_match, hookup_type, testing) 69 with mc.MCSessionWrapper(session=None, testing=testing) as session: 70 hookup = Hookup(session) ---> 71 return hookup.get_hookup_from_db( 72 hpn=hpn, 73 pol=pol, 74 at_date=at_date, 75 at_time=at_time, 76 float_format=float_format, 77 exact_match=exact_match, 78 hookup_type=hookup_type, 79 ) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_hookup.py:160, in Hookup.get_hookup_from_db(self, hpn, pol, at_date, at_time, float_format, exact_match, hookup_type) 158 self.active = cm_active.ActiveData(self.session, at_date=at_date) 159 self.active.load_parts(at_date=None) --> 160 self.active.load_connections(at_date=None) 161 self.active.load_apriori(at_date=None) 162 hpn, exact_match = self._proc_hpnlist(hpn, exact_match) File ~/mambaforge/envs/RTP/lib/python3.12/site-packages/hera_mc/cm_active.py:214, in ActiveData.load_connections(self, at_date, at_time, float_format) 212 continue 213 else: --> 214 raise ValueError("Duplicate active port {}".format(chk)) 215 check_keys["down"].append(chk) 216 key = cm_utils.make_part_key(cnn.upstream_part, cnn.up_part_rev) ValueError: Duplicate active port FDV333:A:INPUT