def ant_trange(vis): ''' Figure out nominal times for tracking of old EOVSA antennas, and return time range in CASA format ''' import eovsa_array as ea from astropy.time import Time from taskinit import ms # Get timerange from the visibility file # msinfo = dict.fromkeys(['vis', 'scans', 'fieldids', 'btimes', 'btimestr', 'inttimes', 'ras', 'decs', 'observatory']) ms.open(vis) # metadata = ms.metadata() scans = ms.getscansummary() sk = np.sort(scans.keys()) vistrange = np.array([scans[sk[0]]['0']['BeginTime'],scans[sk[-1]]['0']['EndTime']]) # Get the Sun transit time, based on the date in the vis file name (must have UDByyyymmdd in the name) aa = ea.eovsa_array() date = vis.split('UDB')[-1][:8] slashdate = date[:4] + '/' + date[4:6] + '/' + date[6:8] aa.date = slashdate sun = aa.cat['Sun'] mjd_transit = Time(aa.next_transit(sun).datetime(), format='datetime').mjd # Construct timerange limits based on +/- 3h55m from transit time (when all dishes are nominally tracking) # and clip the visibility range not to exceed those limits mjdrange = np.clip(vistrange, mjd_transit - 0.1632, mjd_transit + 0.1632) trange = Time(mjdrange[0], format='mjd').iso[:19] + '~' + Time(mjdrange[1], format='mjd').iso[:19] trange = trange.replace('-', '/').replace(' ', '/') return trange
def amphz(out): bl2ord = ri.p.bl_list() uv = copy.copy(out['uvw'][:,:,:2]) time = Time(out['time'],format='jd') # Get some of the other information we need for this source srclist = ec.load_VLAcals() cat = aipy.amp.SrcCatalog(srclist) aa = ea.eovsa_array() cat.compute(aa) aa.cat = cat src = aa.cat[out['source']] src.name = out['source'] ha = np.zeros(len(time),'double') for i in range(1,len(time)): ha[i] = el.eovsa_ha(src,time[i]) # Select only baselines with Ant 14, and eliminate XY and YX polarizations, and the first time data = out['x'][bl2ord[:13,13],:2,:,1:] phz = np.angle(data) a0 = abs(np.sum(data,3)) # Time averaged amplitude damp = np.std(abs(data),3) p0 = np.angle(np.sum(data,3)) # Time averaged angle nbl,npol,nf,nt = data.shape pdif = np.zeros(data.shape,'float') for i in range(nt): pdif[:,:,:,i] = phz[:,:,:,i] - p0 pdif[np.where(pdif > np.pi)] -= 2*np.pi pdif[np.where(pdif < -np.pi)] += 2*np.pi dphase = np.std(pdif,3) outdict = {'amp':a0,'damp':damp,'phase':p0,'dphase':dphase,'time':time,'ha':np.mean(ha),'dec':src.dec, 'fghz':out['fghz'],'source':src,'uv':uv} return outdict
def bl_phz(bn,be,fghz,times): ''' Initial test routine to play with baseline corrections. This routine takes a baseline error in N direction, bn, and baseline error in E direction, be, as well as a list of frequencies and times corresponding to an actual observation, and returns the phase error associated with the baseline error. The phase errors are relative to the phases at the first time, for easy comparison with "calibrated" phases in actual data. Usage: dphz = bl_phz(bn,be,fghz,times) ''' nf = len(fghz) nt = len(times) aa = ea.eovsa_array() src = aipy.amp.RadioSpecial('Sun') dphz = np.zeros((nf,nt),'float') for i,t in enumerate(times): aa.set_jultime(t.jd) src.compute(aa) ha = el.eovsa_ha(src,t) dec = src.dec bx = -bn * np.sin(aa.lat) by = be bz = bn*np.cos(aa.lat) dphz[:,i] = 2*np.pi*(bx*np.cos(dec)*np.cos(ha) - by*np.cos(dec)*np.sin(ha) + bz*np.sin(dec))*fghz/0.3 # Normal phases to first time blah2 = copy.copy(dphz) for i in range(nt): blah2[:,i] = blah2[:,i]-dphz[:,0] dphz = blah2 # Ensure the phases are between -pi and pi dphz = dphz % (2*np.pi) dphz[where(dphz > np.pi)] -= 2*np.pi return dphz
def ant_trange(vis): ''' Figure out nominal times for tracking of old EOVSA antennas, and return time range in CASA format ''' import eovsa_array as ea from astropy.time import Time # Get the Sun transit time, based on the date in the vis file name (must have UDByyyymmdd in the name) aa = ea.eovsa_array() date = vis.split('UDB')[-1][:8] slashdate = date[:4] + '/' + date[4:6] + '/' + date[6:8] aa.date = slashdate sun = aa.cat['Sun'] mjd_transit = Time(aa.next_transit(sun).datetime(), format='datetime').mjd # Construct timerange based on +/- 3h55m from transit time (when all dishes are nominally tracking) trange = Time(mjd_transit - 0.1632, format='mjd').iso[:19] + '~' + Time(mjd_transit + 0.1632, format='mjd').iso[:19] trange = trange.replace('-', '/').replace(' ', '/') return trange
def amphz(out): bl2ord = ri.p.bl_list() uv = copy.copy(out['uvw'][:, :, :2]) time = Time(out['time'], format='jd') # Get some of the other information we need for this source srclist = ec.load_VLAcals() cat = aipy.amp.SrcCatalog(srclist) aa = ea.eovsa_array() cat.compute(aa) aa.cat = cat src = aa.cat[out['source']] src.name = out['source'] ha = np.zeros(len(time), 'double') for i in range(1, len(time)): ha[i] = el.eovsa_ha(src, time[i]) # Select only baselines with Ant 14, and eliminate XY and YX polarizations, and the first time data = out['x'][bl2ord[:13, 13], :2, :, 1:] phz = np.angle(data) a0 = abs(np.sum(data, 3)) # Time averaged amplitude damp = np.std(abs(data), 3) p0 = np.angle(np.sum(data, 3)) # Time averaged angle nbl, npol, nf, nt = data.shape pdif = np.zeros(data.shape, 'float') for i in range(nt): pdif[:, :, :, i] = phz[:, :, :, i] - p0 pdif[np.where(pdif > np.pi)] -= 2 * np.pi pdif[np.where(pdif < -np.pi)] += 2 * np.pi dphase = np.std(pdif, 3) outdict = { 'amp': a0, 'damp': damp, 'phase': p0, 'dphase': dphase, 'time': time, 'ha': np.mean(ha), 'dec': src.dec, 'fghz': out['fghz'], 'source': src, 'uv': uv } return outdict
def bl_phz(bn, be, fghz, times): ''' Initial test routine to play with baseline corrections. This routine takes a baseline error in N direction, bn, and baseline error in E direction, be, as well as a list of frequencies and times corresponding to an actual observation, and returns the phase error associated with the baseline error. The phase errors are relative to the phases at the first time, for easy comparison with "calibrated" phases in actual data. Usage: dphz = bl_phz(bn,be,fghz,times) ''' nf = len(fghz) nt = len(times) aa = ea.eovsa_array() src = aipy.amp.RadioSpecial('Sun') dphz = np.zeros((nf, nt), 'float') for i, t in enumerate(times): aa.set_jultime(t.jd) src.compute(aa) ha = el.eovsa_ha(src, t) dec = src.dec bx = -bn * np.sin(aa.lat) by = be bz = bn * np.cos(aa.lat) dphz[:, i] = 2 * np.pi * (bx * np.cos(dec) * np.cos(ha) - by * np.cos(dec) * np.sin(ha) + bz * np.sin(dec)) * fghz / 0.3 # Normal phases to first time blah2 = copy.copy(dphz) for i in range(nt): blah2[:, i] = blah2[:, i] - dphz[:, 0] dphz = blah2 # Ensure the phases are between -pi and pi dphz = dphz % (2 * np.pi) dphz[where(dphz > np.pi)] -= 2 * np.pi return dphz
def src2dict(out): import aipy import eovsa_array import eovsa_cat import eovsa_lst import copy bl2ord = ri.p.bl_list() uv = copy.copy(out['uvw'][:,:,:2]) time = Time(out['time'],format='jd') # Get some of the other information we need for this source srclist = eovsa_cat.load_VLAcals() cat = aipy.amp.SrcCatalog(srclist) aa = eovsa_array.eovsa_array() cat.compute(aa) aa.cat = cat src = aa.cat[out['source']] src.name = out['source'] ha = np.zeros(len(time),'double') for i in range(len(time)): ha[i] = eovsa_lst.eovsa_ha(src,time[i]) phase = np.angle(out['x'][bl2ord[:,13]]) outdict = {'phase':phase,'time':time,'ha':ha,'dec':src.dec,'fghz':out['fghz'],'source':src,'uv':uv} return outdict