Пример #1
0
def check_visible(src,aa,t=None,check27m=True,check2m=True):
    ''' Check whether a source is observable from the location of aa
        given the limits on az/el of the 2-m's and HA/dec of the 27-m's, at
        date/time dt. Returns True if visible, False otherwise.
        
        If no time is given, it checks for the current time.
        
        By default, returns True only if it is visible from both the 2-m's and the
        27-m's; use check27m=False or check2m=False to ignore either the 27-m's or
        the 2-m's, respectively.
    '''
    
    if t is None:
        t = util.Time.now()
    
    # get alt, az, ha, dec at given date/time    
    aa.set_jultime(t.jd)
    src.compute(aa)
    alt = rad2deg(src.alt)
    az  = rad2deg(src.az)
    ha  = rad2deg(eovsa_ha(src,t))
    dec = rad2deg(src.dec)
    
    if check27m and check2m:
        return check_27m_visible(ha,dec) and check_2m_visible(az,alt) and check_2meq_visible(ha,dec)
    elif check27m:
        return check_27m_visible(ha,dec)
    elif check2m:
        return check_2m_visible(az,alt) and check_2meq_visible(ha,dec)
    else:
        return True
Пример #2
0
def check_visible(src, aa, t=None, check27m=True, check2m=True):
    ''' Check whether a source is observable from the location of aa
        given the limits on az/el of the 2-m's and HA/dec of the 27-m's, at
        date/time dt. Returns True if visible, False otherwise.
        
        If no time is given, it checks for the current time.
        
        By default, returns True only if it is visible from both the 2-m's and the
        27-m's; use check27m=False or check2m=False to ignore either the 27-m's or
        the 2-m's, respectively.
    '''

    if t is None:
        t = util.Time.now()

    # get alt, az, ha, dec at given date/time
    aa.set_jultime(t.jd)
    src.compute(aa)
    alt = rad2deg(src.alt)
    az = rad2deg(src.az)
    ha = rad2deg(eovsa_ha(src, t))
    dec = rad2deg(src.dec)

    if check27m and check2m:
        return check_27m_visible(ha, dec) and check_2m_visible(az, alt)
    elif check27m:
        return check_27m_visible(ha, dec)
    elif check2m:
        return check_2m_visible(az, alt)
    else:
        return True
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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
Пример #6
0
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
Пример #7
0
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