示例#1
0
文件: 64Equiv.py 项目: nkern/capo
data1, data2 = n.ma.array(data1), n.ma.array(data2)
data = n.multiply(n.conjugate(data1), data2) * norm
#data is shaped [timesample, channel]
P = n.ma.array([])
for ind in n.arange(len(taulist)):
    P = n.append(P, n.mean(data.T[ind]))
print P
#print len(taulist), len(P)
#kz = taulist*2*n.pi/Y
kz = cosmo_units.eta2kparr(taulist * 1.E-9,
                           z)  #This function needs tau in Hz^-1

#print "shapes of arrays:", data1.shape, data2.shape
#Bootstrap resampling
B = 10
bootmean, booterr = boot_simple.bootstrap(B, data)

#plotting
fig = p.figure()
ax = fig.add_subplot(311)
#plotp.P_v_Eta(ax,kz,P)
ax.set_xlabel('kz')
ax.set_ylabel(r'$P(k) mK^{2} (h^{-1} Mpc)^{3}$')
p.plot(kz, P, 'bo')
ax.set_yscale('log')
ax = fig.add_subplot(312)
ax.errorbar(kz, bootmean, yerr=booterr, fmt='ok', ecolor='gray', alpha=0.5)
#ax.set_ylim([0,0.5])
ax.set_yscale('log')
ax.set_xlabel('kz')
ax.set_ylabel(r'$P(k) mK^{2} (h^{-1} Mpc)^{3}$')
#print "data shapes", data1.shape, data2.shape
print "Average over %d time points" % len(data1)
data1, data2 = n.array(data1), n.array(data2)
data = n.multiply(n.conjugate(data1), data2)*norm
#data is shaped [timesample, channel]
P=[]
for ind in n.arange(len(taulist)): P.append(n.mean(data.T[ind]))
#print len(taulist), len(P)
#kz = taulist*2*n.pi/Y
kz = cosmo_units.eta2kparr(taulist*1.E-9,z)     #This function needs tau in Hz^-1


#print "shapes of arrays:", data1.shape, data2.shape
#Bootstrap resampling
B = 100
bootmean, booterr = boot_simple.bootstrap(B, data)


#plotting
fig = p.figure()
ax = fig.add_subplot(311)
#plotp.P_v_Eta(ax,kz,P)
ax.set_xlabel('kz')
ax.set_ylabel(r'$P(k) K^{2} (h^{-1} Mpc)^{3}$')
p.plot(kz,P,'bo')
ax = fig.add_subplot(312)
ax.errorbar(kz, bootmean, yerr=booterr, fmt='ok', ecolor='gray', alpha=0.5)
#ax.set_ylim([0,0.5])
#ax.set_yscale('log')
ax.set_xlabel('kz')
ax.set_ylabel(r'$P(k) K^{2} (h^{-1} Mpc)^{3}$')