Exemplo n.º 1
0
def save_gains(s,f,pol,filename=None,ubls=None,ex_ants=None):
    """
    s: solutions
    f: frequencies
    pol: polarization
    filename: if a specific file was used (instead of many), change output name
    ubls: unique baselines used to solve for s'
    ex_ants: antennae excluded to solve for s'
    """
    s2 = {}
    delays = []
    for k,i in s.iteritems():
        s2[str(k)] = omni.get_phase(f,i)
        try:
            delays.append([k,i[0],i[1]])
        except(TypeError,IndexError):
            delays.append([k,i])
    s2['delays'] = np.array(delays)
    if not ubls is None: s2['ubls']=ubls
    if not ex_ants is None: s2['ex_ants']=ex_ants
    if not filename is None:
        outname='%s.fc.npz'%filename
    else:
        outname='fcgains.%s.npz'%pol
    print 'Saving fcgains to %s'%outname
    n.savez(outname,**s2)
Exemplo n.º 2
0
def save_gains(s, f, pol):
    s2 = {}
    for k, i in s.iteritems():
        s2[str(k)] = omni.get_phase(f, i)
    #s2['pol'] = pol #XXX not saving pol in npz file
    print 'Saving fcgains.%s.npz' % pol
    n.savez('fcgains.%s.npz' % pol, **s2)
Exemplo n.º 3
0
def save_gains(s,f,pol):
    s2 = {}
    for k,i in s.iteritems():
        s2[str(k)] = omni.get_phase(f,i)
    #s2['pol'] = pol #XXX not saving pol in npz file
    print 'Saving fcgains.%s.npz'%pol
    n.savez('fcgains.%s.npz'%pol,**s2)
Exemplo n.º 4
0
def save_gains(s,f,name='fcgains',verbose=False):
    s2 = {}
    for k,i in s.iteritems():
        try:
            len(i)
            s2[str(k)] = omni.get_phase(f,i,offset=True)
            s2['d'+str(k)] = i[0]
            if verbose:
                print 'ant=%d dly=%f , off=%f '%(k,i[0],i[1])
        except(TypeError):
            s2[str(k)] = omni.get_phase(f,i)
            s2['d'+str(k)] = i
            if verbose:
                print 'ant=%d dly=%f  '%(k,i)
    cmd = sys.argv
    s2['cmd'] = ' '.join(cmd)
    np.savez('%s.npz'%name,**s2)
Exemplo n.º 5
0
def save_gains(s,f,name='fcgains',verbose=False):
    s2 = {}
    for k,i in s.iteritems():
        if len(i)>1:
            s2[str(k)] = omni.get_phase(f,i,offset=True)
            s2['d'+str(k)] = i[0]
            if verbose:
                print 'ant=%d dly=%f , off=%f '%(k,i[0],i[1])
        else:    
            s2[str(k)] = omni.get_phase(f,i)
            s2['d'+str(k)] = i
            if verbose:
                print 'ant=%d dly=%f  '%(k,i)
    import sys
    cmd = sys.argv
    s2['cmd'] = ' '.join(cmd)
    n.savez('%s.npz'%name,**s2)
Exemplo n.º 6
0
def save_gains(s,f,name='fcgains'):
    s2 = {}
    for k,i in s.iteritems():
        s2[str(k)] = omni.get_phase(f,i)
    for k,i in s.iteritems():
        s2['d'+str(k)] = i
    import sys
    cmd = sys.argv
    s2['cmd'] = ' '.join(cmd)
    n.savez('%s.npz'%name,**s2)
Exemplo n.º 7
0
def save_gains(s,f,pol,filename=None,ubls=None,ex_ants=None):
    """
    s: solutions
    f: frequencies
    pol: polarization
    filename: if a specific file was used (instead of many), change output name
    ubls: unique baselines used to solve for s'
    ex_ants: antennae excluded to solve for s'
    """
    s2 = {}
    for k,i in s.iteritems():
        s2[str(k)] = omni.get_phase(f,i)
        s2[str(k)+'d'] = i
    if not ubls is None: s2['ubls']=ubls
    if not ex_ants is None: s2['ex_ants']=ex_ants
    if not filename is None:
        if not opts.outpath is None:
            outname='%s/%s.fc.npz'%(opts.outpath,filename.split('/')[-1])
        else:
            outname='%s.fc.npz'%filename
    else:
        outname='fcgains.%s.npz'%pol
    print 'Saving fcgains to %s'%outname
    n.savez(outname,**s2)
Exemplo n.º 8
0
def save_gains(s,f,pol):
    s2 = {}
    for k,i in s.iteritems():
        s2[str(k)] = omni.get_phase(f,i)
    s2['pol'] = pol
    n.savez('fcgains.%s.npz'%pol,**s2)
Exemplo n.º 9
0
dataxx = {}
for (i,j) in data.keys():
    dataxx[(i,j)] = data[(i,j)]['xx']
fqs = n.linspace(.1,.2,1024)
dlys = n.fft.fftshift(n.fft.fftfreq(fqs.size, fqs[1]-fqs[0]))

#gets phase solutions per frequency.
fc = omni.FirstCal(dataxx,fqs,info)
sols = fc.run()
#import IPython; IPython.embed()
#save_gains(sols,fqs, opts.pol)
#save solutions
dataxx_c = {}
for (a1,a2) in info.bl_order():
    if (a1,a2) in dataxx.keys():
        dataxx_c[(a1,a2)] = dataxx[(a1,a2)]*omni.get_phase(fqs,sols[a1])*n.conj(omni.get_phase(fqs,sols[a2]))
    else:
        dataxx_c[(a1,a2)] = n.conj(dataxx[(a2,a1)]*omni.get_phase(fqs,sols[a2])*n.conj(omni.get_phase(fqs,sols[a1])))

#def waterfall(d, ax, mode='log', mx=None, drng=None, recenter=False, **kwargs):
#    if n.ma.isMaskedArray(d): d = d.filled(0)
#    if recenter: d = a.img.recenter(d, n.array(d.shape)/2)
#    d = arp.data_mode(d, mode=mode)
#    if mx is None: mx = d.max()
#    if drng is None: drng = mx - d.min()
#    mn = mx - drng
#    return ax.imshow(d, vmax=mx, vmin=mn, aspect='auto', interpolation='nearest', **kwargs)
#
#plotting data
redbls = []
for r in redstest: redbls += r
Exemplo n.º 10
0
#import IPython; IPython.embed()
#save solutions
fname = args[0]
save_gains(sols,fqs,name=fname)


if PLOT:
    #For plotting a subset of baselines
    infotest = omni.aa_to_info(aa, fcal=True, ubls=[(80,96)],ex_ants=[81])
    redstest = infotest.get_reds()
    #########  To look at solutions and it's application to data. If only lookgin for solutions stop here  ##############
    dataxx_c = {}
    print dataxx.keys()
    for (a1,a2) in info.bl_order():
        if (a1,a2) in dataxx.keys():
            dataxx_c[(a1,a2)] = dataxx[(a1,a2)]*omni.get_phase(fqs,sols[a1])*n.conj(omni.get_phase(fqs,sols[a2]))
            #if a1==43 or a2==43:
            #    dataxx_c[(a1,a2)]*=n.exp(-2j*n.pi*fqs*n.pi)
        else:
            dataxx_c[(a1,a2)] = dataxx[(a2,a1)]*omni.get_phase(fqs,sols[a2])*n.conj(omni.get_phase(fqs,sols[a1]))
            #if a1==43 or a2==43:
            #    dataxx_c[(a1,a2)]*=n.exp(-2j*n.pi*fqs*n.pi)
    #plotting data
    redbls = []
    for r in redstest: redbls += r
    redbls = n.array(redbls)
    #print redbls.shape
    #dm = divmod(len(redbls), n.round(n.sqrt(len(redbls))))
    #nr,nc = int(dm[0]),int(dm[0]+n.ceil(float(dm[1])/dm[0]))
    #fig,ax = p.subplots(nrows=nr,ncols=nc,figsize=(14,10))
    #for i,bl in enumerate(redbls):