示例#1
0
def GetAutoSpectrum(cosmo,
                    z,
                    dndz,
                    bins,
                    b=1,
                    alpha=1.,
                    lmax=1000,
                    sigma_zph=0.,
                    compute_at_z0=False):
    DNDZ = dNdzInterpolation(z,
                             dndz,
                             bins=bins,
                             sigma_zph=sigma_zph,
                             z_min=0,
                             z_max=1)
    limb = Limber(cosmo, lmin=0, lmax=lmax, compute_at_z0=compute_at_z0)
    gals = GalsTomo(cosmo, DNDZ, b=b, alpha=alpha)
    return limb.GetCl(gals)
示例#2
0
def GetCrossSpectrum(cosmo,
                     z,
                     dndz,
                     bins,
                     b=1,
                     alpha=1.,
                     lmax=1000,
                     sigma_zph=0.,
                     i=0):
    DNDZ = dNdzInterpolation(z,
                             dndz,
                             bins=bins,
                             sigma_zph=sigma_zph,
                             z_min=0,
                             z_max=1)
    # DNDZ = dNdzInterpolation(z, dndz, nbins=1, z_min=z[0], z_max=z[-1], sigma_zph=sigma_zph)
    limb = Limber(cosmo, lmin=0, lmax=lmax)
    gals = GalsTomo(cosmo, DNDZ, b=b, alpha=alpha)
    return limb.GetCl(gals, k2=LensCMB(cosmo), i=i)
ds_std = np.std(ds, 0)

# Plot D_G vs redshift
bmax = 5
_z_ = np.linspace(0.,1.4)
plt.figure(figsize=(9,6))
# for i in xrange(len(ds[:100])):
# 	plt.plot(z_, ds[i], color='lightgrey', alpha=0.1)
plt.fill_between(z_, np.asarray(cosmo_nl.D_z_norm(z_))+2*ds_std, np.asarray(cosmo_nl.D_z_norm(z_))-2*ds_std, color='#BEBBBB', alpha=0.3)
plt.fill_between(z_, np.asarray(cosmo_nl.D_z_norm(z_))+ds_std, np.asarray(cosmo_nl.D_z_norm(z_))-ds_std, color='#BEBBBB', alpha=0.5)
plt.plot(_z_, np.asarray(cosmo_nl.D_z_norm(_z_)), label=r'$\Lambda$CDM',color='#152614')
plt.plot(z_, dw, '-.', label=r'$w_0=%.2f$'%w)#, color='#E40066')
plt.plot(z_, dgamma0, '--', label=r'$\gamma_0=%.2f$'%gamma0)#, color='#03CEA4')
plt.plot(z_, dgammaa, ':', label=r'$\gamma_a=%.2f$'%gammaa)#, color='#EAC435')
for i,zbin in enumerate(zbins):
	DNDZ = dNdzInterpolation(z, nz, bins=[zbin[0],zbin[1]], sigma_zph=0.015, z_min=0, z_max=1)
	zmed = DNDZ.z_med_bin(0)
	plt.errorbar(zmed, dgs_data[zbin][bmax], yerr=dgs_err[zbin][bmax], fmt='o', color='#083D77', label='2MPZ', ms=6)
plt.errorbar(des_z, des_DG, yerr=des_DG_errs, label='DES (Giannantonio+16)', color='#8C2F39', fmt='s', ms=6, alpha=0.7)#, alpha=0.8)
# plt.plot(z_, np.asarray(cosmo_nl.D_z_norm(z_))+ds_std, 'k--')
# plt.plot(z_, np.asarray(cosmo_nl.D_z_norm(z_))-ds_std, 'k--')
plt.xlim([0,1.4])
plt.ylim([0,1.5])
plt.legend(loc='upper right', ncol=2)
plt.ylabel(r'$D_G$')#, size=15)
plt.xlabel(r'$z$')#, size=15)
plt.tight_layout()
plt.savefig('plots/D_G_vs_z_dl'+str(delta_ell)+'_lmin_'+str(lmin)+'_lmax'+str(lmax)+'_KS_min_'+str(K_S_min)+'_KS_max_'+str(K_S_max)+'_nside256_weighted_PlanckChains.pdf')

plt.show()
示例#4
0
clkg_slash_nl = GetCrossSpectrum(cosmo_nl, z, nz, [zmin,zmax], b=bias, alpha=1., lmax=500, sigma_zph=0.015, compute_at_z0=True)
clgg_slash_nl = GetAutoSpectrum(cosmo_nl,  z, nz, [zmin,zmax], b=bias, alpha=1., lmax=500, sigma_zph=0.015, compute_at_z0=True)
clkg_slash_binned_nl = binner.bin_spectra(clkg_slash_nl)
clgg_slash_binned_nl = binner.bin_spectra(clgg_slash_nl)


# D_G errors from sims
dgs_err = [np.std(GetAllDg(clkg_sims['sims'],clgg_sims['sims'],clkg_slash_binned,clgg_slash_binned, err_kg=np.std(clkg_sims[zbin]['sims'], axis=(0)), err_gg=np.std(clgg_sims[zbin]['sims'], axis=(0)),lbmax=i)) for i in xrange(2,clkg_slash_binned.size+1)]
dgs_err_nl = [np.std(GetAllDg(clkg_sims['sims'],clgg_sims['sims'],clkg_slash_binned_nl,clgg_slash_binned_nl, err_kg=np.std(clkg_sims[zbin]['sims'], axis=(0)), err_gg=np.std(clgg_sims[zbin]['sims'], axis=(0)),lbmax=i)) for i in xrange(2,clkg_slash_binned.size+1)]

# D_G Data 
dgs_data = [GetDg(clkg,clgg,clkg_slash_binned,clgg_slash_binned,err_kg=err_clkg, err_gg=err_clgg, lbmax=i) for i in xrange(2,clgg.size+1)]
dgs_data_nl = [GetDg(clkg,clgg,clkg_slash_binned_nl,clgg_slash_binned_nl, err_kg=err_clkg, err_gg=err_clgg,lbmax=i) for i in xrange(2,clgg.size+1)]


DNDZ = dNdzInterpolation(z, nz, bins=[zmin,zmax], sigma_zph=0.015, z_min=0, z_max=1)
zmed = DNDZ.z_med_bin(0)

fig, ax = plt.subplots(figsize=(5,5))
ax.set_title(r'2MPZ - $%.2f < z < %.2f$'%(zmin,zmax))
# plt.fill_between(lb[1:], [cosmo.D_z_norm(zmed) for i in xrange(len(lb[1:]))]+np.asarray(dgs_err[zbin]), [cosmo.D_z_norm(zmed) for i in xrange(len(lb[1:]))]-np.asarray(dgs_err[zbin]),alpha=0.6, color='lightgrey', label=r'$1\sigma$ from sims')
ax.axhline(cosmo.D_z_norm(zmed), ls='--', color='k')#, label=r'$D_G(z_{\rm med}=%.3f)$'%zmed)
ax.errorbar([1,2], [dgs_data[lbmax],dgs_data_nl[lbmax]], yerr=[dgs_err[lbmax],dgs_err_nl[lbmax]], fmt='o')#, label='2MPZ Data')
ax.legend()
labels = ['Linear', 'Non-linear']#[str(ks) for ks in K_S_mins]
# ax.set_xticklabels(labels)
plt.xticks([1,2], labels)
ax.set_ylim(0.75,1.5)
ax.set_xlim(0.,3)
# ax.set_xlabel(r'Minimum $K_S$')#, size=15)
ax.set_ylabel(r'$D_G$')#, size=15)
示例#5
0
# _, _, _  = hist(twompz.ZSPEC[twompz.ZSPEC>0.],'knuth', normed=1, histtype='step', label=r'Full-$z_{\rm s}$')
# _, _, _  = hist(twompz.ZPHOTO[twompz.ZSPEC>0.],'knuth', normed=1, histtype='step', label=r'Cross-$z_{\rm s}$')
z_spec = 0.5 * (z_spec[1:]+z_spec[:-1])
plt.close()

nz_overlap, z_overlap, _ = hist(twompz.ZPHOTO[twompz.ZSPEC>0.],'knuth', normed=1, histtype='step', label=r'overlap photo')
# _, _, _  = hist(twompz.ZSPEC[twompz.ZSPEC>0.],'knuth', normed=1, histtype='step', label=r'Full-$z_{\rm s}$')
# _, _, _  = hist(twompz.ZPHOTO[twompz.ZSPEC>0.],'knuth', normed=1, histtype='step', label=r'Cross-$z_{\rm s}$')
z_overlap = 0.5 * (z_overlap[1:]+z_overlap[:-1])
plt.close()

# CMB lens kernel
lcmb = LensCMB(Cosmo())

# Plot dN/dz
DNDZ = dNdzInterpolation(z, nz, bins=[0.,0.24], sigma_zph=0.015, z_min=0, z_max=1)
DNDZ_spec = dNdzInterpolation(z_spec, nz_spec, bins=[0.,0.24], sigma_zph=0.015, z_min=0, z_max=1)
# DNDZ_overlap = dNdzInterpolation(z_overlap, nz_overlap, bins=[0.,0.24], sigma_zph=0.015, z_min=0, z_max=1)
plt.plot(z, DNDZ.raw_dndz_bin(z,0), label=r'2MPZ $z \le 0.24$', color='#083D77')
nz_spec, z_spec, _ = hist(twompz.ZSPEC[twompz.ZSPEC>0.],'knuth', normed=1, histtype='step', label=r'Spec-z', color='#8C2F39')
# plt.plot(z, DNDZ_spec.raw_dndz_bin(z,0), label=r'2MPZ $z \le 0.24$ spec')
# plt.plot(z, DNDZ_overlap.raw_dndz_bin(z,0), label=r'2MPZ $z \le 0.24$ overlap')
# plt.plot(z, DNDZ.raw_dndz_bin(z,0)/np.max(DNDZ.raw_dndz_bin(z,0)), label='Fiducial')
# for i,zbin in enumerate(zbins):
#    DNDZ = dNdzInterpolation(z, nz, bins=[zbin[0],zbin[1]], sigma_zph=0.015, z_min=0, z_max=1)
#    # plt.plot(z, DNDZ.raw_dndz_bin(z,0)/np.max(DNDZ.raw_dndz_bin(z,0)), label='Bin-%d' %(i+1))
#    plt.plot(z, DNDZ.raw_dndz_bin(z,0), label='Bin-%d' %(i+1))
   # plt.plot(z, DNDZ.raw_dndz_bin(z,0), label=r'$%.2f < z < %.2f$' %(zbin[0],zbin[1]))
plt.plot(z[z>0], 30*lcmb.W_z(z[z>0]), ls='--', label=r'$W^{\kappa}$', color='#F6AE2D')
# plt.axvline(0.08, ls='--', color='grey')
plt.xlabel(r'$z$')
示例#6
0
    ax.set_xscale('linear')
    # ax.set_ylim([1e-5, 1e-3])
    # ax.set_ylim([1e-5, 8e-4])
    ax.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))

    fig.tight_layout(rect=[0, 0.03, 1, 0.95])
    # plt.savefig('plots/2MPZ_Planck_clkg_dl'+str(args.delta_ell)+'_lmin_'+str(args.lmin)+'_lmax'+str(args.lmax)+'_KS_min_'+str(args.K_S_min)+'_KS_max_'+str(args.K_S_max)+'_nside'+str(args.nside)+'_zmin_'+str(args.zmin)+'_zmax'+str(args.zmax)+'_split.pdf', bbox_inches='tight')
    # plt.show()
    # plt.close()

    embed()

z = np.linspace(0, 1)
DNDZ_1 = dNdzInterpolation(z1,
                           nz1,
                           bins=[0., 0.24],
                           sigma_zph=0.0,
                           z_min=0,
                           z_max=1)
DNDZ_2 = dNdzInterpolation(z2,
                           nz2,
                           bins=[0., 0.24],
                           sigma_zph=0.0,
                           z_min=0,
                           z_max=1)
DNDZ_3 = dNdzInterpolation(z2,
                           nz2,
                           bins=[0., 0.24],
                           sigma_zph=0.07,
                           z_min=0,
                           z_max=1)
DNDZ_4 = dNdzInterpolation(z1,