Ejemplo n.º 1
0
def pair_fin(clos_app,dt, aa, src, freq,fbmamp,multweight=True,noiseweight=True,ovlpweight=True,cutoff=9000.*0.005*0.005,puv=False):
    final = []
    cnt, N = 0,len(clos_app)
    bm_intpl = export_beam.beam_interpol(freq,fbmamp,'cubic')
    if ovlpweight: #rbm2interp: FT of sq of beam
        fbm2 = n.multiply(fbmamp,fbmamp)   #element wise square for power beam
        rbm2 = n.fft.fft2(fbm2); rbm2 = n.fft.fftshift(rbm2)
        freqlm = n.fft.fftfreq(len(freq),d=(freq[1]-freq[0])); freqlm = n.fft.fftshift(freqlm)
        print "###small imaginary components are error, nothing to worry about"
        rbm2interp = interpolate.interp2d(freqlm, freqlm, rbm2, kind='cubic')
    for key in clos_app:
        cnt = cnt+1
        if (cnt/1000)*1000 == cnt:
            print 'Calculating baseline pair %d out of %d:' % (cnt,N)
        bl1,bl2 = key[0],key[1]
        t1,t2 = clos_app[key][1],clos_app[key][2]
        correlation,(uvw1,uvw2) = get_corr(aa, src, bm_intpl, t1,t2, bl1, bl2)
        if correlation == 0: continue
        if ovlpweight: ovlp = get_ovlp(aa,t1,t2,rbm2interp)
        else: ovlp = 1.
        weight = get_weight(aa,bl1,bl2,uvw1,multweight,noiseweight,ovlp)
        #while correlation > cutoff:
        if puv: final.append((weight*correlation,correlation,(bl1,t1,uvw1),(bl2,t2,uvw2)))
        else: final.append((weight*correlation,correlation,(bl1,t1),(bl2,t2)))
        #t1,t2 = t1+dt,t2+dt
        try: correlation,(uvw1,uvw2)  = get_corr(aa, src,bm_intpl, t1,t2, bl1, bl2)
        except(TypeError): correlation  = 0.
        else:
            if ovlpweight: ovlp = get_ovlp(aa,t1,t2,rbm2interp)
            else: ovlp = 1.
            weight = get_weight(aa,bl1,bl2,uvw1,multweight,noiseweight,ovlp)

    quick_sort.quick_sort(final,0,len(final)-1)
    return final
Ejemplo n.º 2
0
#peak.append(fbmamp[mid,mid])
fig = p.figure()
ax1 = fig.add_subplot(121)
im1 = ax1.imshow(bmp, interpolation='nearest', extent=rax)
ax1.set_xlabel('l')
ax1.set_ylabel('m')
cbar1 = p.colorbar(im1,fraction=0.046, pad=0.04)
ax2 = fig.add_subplot(122)
ax2.set_xlabel('u')
ax2.set_ylabel('v')
im2 = plt.imshow(fbmamp[f_range[:,None],f_range], interpolation='nearest', extent=freqax)
cbar2 = p.colorbar(im2,fraction=0.046, pad=0.04)

fig2 = p.figure()
u_range = n.linspace(-3,3,100)
f = export_beam.beam_interpol(freq,fbmamp)
z = export_beam.get_overlap(f, u_range,u_range)
#z = z/n.amax(n.abs(z))
U,V = n.meshgrid(u_range,u_range)
#z = abs(z)
ax3 = fig2.add_subplot(121,projection='3d')
ax3.set_xlabel('u')
ax3.set_ylabel('v')
surf = ax3.plot_surface(U,V,z,cmap=cm.coolwarm)
#p.colorbar(surf, shrink=0.5, aspect=5)


ax4 = fig2.add_subplot(122)
ax4.set_xlabel('u')
ax4.set_ylabel('FT')
for v in [0.,1.]:
Ejemplo n.º 3
0
    except(a.phs.PointingError):                                #test if below horizon
        print 'remove',t, len(T_iter), len(T_files)
        T_files.remove(t)
print T_files
#times_coarse = n.arange(T_files[0],T_files[-1]+dt_file, dt)
#times_fine = n.arange(T_files[0],T_files[-1]+dt_file, dt_fine)
times_coarse = n.arange(T_files[0],T_files[-1], dt)
times_fine = n.arange(T_files[0],T_files[-1], dt_fine)

nants = len(aa)
bmp_list  = export_beam.beam_real(aa[0], ntop, shape0, 'x')

for ni in range(len(list_freq)):
    bmp = bmp_list[ni]
    freq, fbmamp = export_beam.beam_fourier(bmp, sp, 400)
    bm_intpl = export_beam.beam_interpol(freq,fbmamp,'cubic')
    print 'Time to initialize:', sys_time.clock(), 'seconds'
    print 'fbmampshape, midval', fbmamp.shape, fbmamp[200][200]

    d = select_pair.pair_coarse(aa, src,times_coarse,dist,False, 0.1, True)  #coarsely determine crossings
    print 'Time after coarse selection:', sys_time.clock(), 'seconds'
    #pairs_sorted = select_pair.pair_sort(d,freq,fbmamp)        #sort crossings
    #clos_app = select_pair.get_closest(pairs_sorted)           #determine closest approach points
    clos_app = select_pair.alter_clos(d,bm_intpl)            #determine closest approach points
    print 'Found closest approach points after:', sys_time.clock(), 'seconds'
    pairs_final = select_pair.pair_fin(clos_app,dt_fine,aa,src,freq,fbmamp,multweight=True,noiseweight=True,ovlpweight=True,puv=True)
    print 'Total time:', sys_time.clock(), 'seconds'

    #write result to file and screen
    Oname = './P'+str(n.around(list_freq[ni],decimals=3))+'.out'
    Cname = './P'+str(n.around(list_freq[ni],decimals=3))+'.cue'
Ejemplo n.º 4
0
ax1 = fig.add_subplot(121)
im1 = ax1.imshow(bmp, interpolation='nearest', extent=rax)
ax1.set_xlabel('l')
ax1.set_ylabel('m')
cbar1 = p.colorbar(im1, fraction=0.046, pad=0.04)
ax2 = fig.add_subplot(122)
ax2.set_xlabel('u')
ax2.set_ylabel('v')
im2 = plt.imshow(fbmamp[f_range[:, None], f_range],
                 interpolation='nearest',
                 extent=freqax)
cbar2 = p.colorbar(im2, fraction=0.046, pad=0.04)

fig2 = p.figure()
u_range = n.linspace(-3, 3, 100)
f = export_beam.beam_interpol(freq, fbmamp)
z = export_beam.get_overlap(f, u_range, u_range)
#z = z/n.amax(n.abs(z))
U, V = n.meshgrid(u_range, u_range)
#z = abs(z)
ax3 = fig2.add_subplot(111, projection='3d')
ax3.set_xlabel('u')
ax3.set_ylabel('v')
surf = ax3.plot_surface(U, V, z, cmap=cm.coolwarm)
#p.colorbar(surf, shrink=0.5, aspect=5)

#ax4 = fig2.add_subplot(122)
#ax4.set_xlabel('u')
#ax4.set_ylabel('FT')
#for v in [0.,1.]:
#    z = export_beam.get_overlap(f,u_range,v)