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/2460200" APRIORI_STATUSES = dish_maintenance,dish_ok,RF_maintenance,RF_ok,digital_ok,digital_maintenance,calibration_maintenance,calibration_triage,calibration_ok JULIANDATE = 2460200 Date = 9-12-2023
# 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)
2534 sum files found between JDs 2460200.26372 and 2460200.92844 2534 diff files found between JDs 2460200.26372 and 2460200.92844 85 sum auto files found between JDs 2460200.76819 and 2460200.79613 85 diff auto files found between JDs 2460200.76819 and 2460200.79613 This day contains 196 antennas of the given status category.
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In [3], line 18 16 uvd.read(HHautos[::10], skip_bad_files=True, antenna_nums = use_ants) 17 lsts = uvd.lst_array ---> 18 uvdx.select(antenna_nums=use_ants) 19 uvdy.select(antenna_nums=use_ants) File ~/mambaforge/envs/RTP/lib/python3.10/site-packages/pyuvdata/uvdata/uvdata.py:8607, in UVData.select(self, antenna_nums, antenna_names, ant_str, bls, frequencies, freq_chans, times, time_range, lsts, lst_range, polarizations, blt_inds, phase_center_ids, catalog_names, inplace, keep_all_metadata, run_check, check_extra, run_check_acceptability, strict_uvw_antpos_check) 8599 uv_obj = self.copy() 8601 # Figure out which index positions we want to hold on to. 8602 ( 8603 blt_inds, 8604 freq_inds, 8605 pol_inds, 8606 history_update_string, -> 8607 ) = uv_obj._select_preprocess( 8608 antenna_nums, 8609 antenna_names, 8610 ant_str, 8611 bls, 8612 frequencies, 8613 freq_chans, 8614 times, 8615 time_range, 8616 lsts, 8617 lst_range, 8618 polarizations, 8619 blt_inds, 8620 phase_center_ids, 8621 catalog_names, 8622 ) 8624 # Call the low-level selection method. 8625 uv_obj._select_by_index( 8626 blt_inds, freq_inds, pol_inds, history_update_string, keep_all_metadata 8627 ) File ~/mambaforge/envs/RTP/lib/python3.10/site-packages/pyuvdata/uvdata/uvdata.py:7935, in UVData._select_preprocess(self, antenna_nums, antenna_names, ant_str, bls, frequencies, freq_chans, times, time_range, lsts, lst_range, polarizations, blt_inds, phase_center_ids, catalog_names) 7930 ant_check = np.logical_or( 7931 np.isin(antenna_nums, self.ant_1_array), 7932 np.isin(antenna_nums, self.ant_2_array), 7933 ) 7934 if not np.all(ant_check): -> 7935 raise ValueError( 7936 f"Antenna number {antenna_nums[~ant_check]} is not present in the " 7937 "ant_1_array or ant_2_array" 7938 ) 7939 ant_blt_inds = np.where( 7940 np.logical_and( 7941 np.isin(self.ant_1_array, antenna_nums), 7942 np.isin(self.ant_2_array, antenna_nums), 7943 ) 7944 )[0] 7945 else: ValueError: Antenna number [130 138 75 322 137 99 98 82 129 119 203 33 100 116 118 219 81 117 83] is not present in the ant_1_array or ant_2_array
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)
Shows the LSTs (in hours) and JDs for which data is collected. Green represents data, red means no data.
utils.plot_lst_coverage(uvd)
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)
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)