1) I have a little issue about the number of [math] that generates CAMB 1.3.5.
Indeed, if I apply the following code snippet :
Code: Select all
kmin = 1e-4 # Mpc
kmax = 1 # Mpc
npoints = 1000 # Number of elements in the Pk array
lmax = 2500 # Maximum multipole calculated for the CLs
"""
Create a CAMB results object, and use it to calculate the power spectrum
"""
# Start a CAMB parameters object
pars = camb.CAMBparams()
# Specify the parameters
pars.set_cosmology(H0=cosmo['h']*100, ombh2=cosmo['omega_b'], omch2=cosmo['omega_cdm'], tau=cosmo['tau_reio'])
pars.InitPower.set_params(As=cosmo['A_s'], ns=cosmo['n_s'])
pars.set_matter_power(redshifts=[0.], kmax=2.0)
pars.set_for_lmax(lmax - 50) # CAMB calculates 50 more than 2500 that I ask it to (to fix)
Code: Select all
pars.set_for_lmax(lmax)
Code: Select all
print('pars.get_for_lmax = ', pars.max_l)
2600
2) But if I want to angular power spectrum with classt wrapper of CLASS, I do :
Code: Select all
# Get the Cls for Class
cls = LambdaCDM.lensed_cl(lmax)
ell = cls['ell'][2:]
Code: Select all
len(ell)=2499
len(clTT_camb) = 2499
Code: Select all
pars.set_for_lmax(lmax)
Code: Select all
# Get the Cls for CAMB
powers = results.get_cmb_power_spectra(pars, CMB_unit='muK')
totCL=powers['total']
clTT_camb = totCL[2:,0]
# %%
"""
Plot them
"""
# %%
# plot C_l^TT
plt.figure()
plt.xscale('log');plt.yscale('linear');plt.xlim(2,2500)
plt.xlabel(r'$\ell$')
plt.ylabel(r'$[\ell(\ell+1)/2\pi] C_\ell^\mathrm{TT}$')
plt.plot(ell,clTT_class, 'r-', label = 'CLASS')
plt.plot(ell,clTT_camb,'k--', label = 'CAMB')
If anyone could make suggestions or explanations ...
Regards