# import the CosmoBolognaLib # import CosmoBolognaLib as cbl from CosmoBolognaLib import DoubleVector as dv # set the CosmoBolognaLib and the current directories cbl.SetDirs("../../", "./") # set the cosmological model, with default parameters cosmology = cbl.Cosmology() # compute the dark matter power spectrum kk = np.logspace(-4, 2, 200) Pk = [cosmology.Pk(kk[i], "CAMB", False, 0) for i in range(len(kk))] # get correlation function from fftlog: dir is the transformation # direction, mu is the order of the Bessel function (see the # documentation for other options) dir = 1 mu = 0 rr = np.linspace(1., 200, 100) xi = np.array(cbl.transform_FFTlog(dv(rr), dir, dv(kk), dv(Pk), mu)) # plot results plt.plot(rr, xi * rr * rr) plt.xlabel(r"$s$ $[$Mpc$h^{-1}]$") plt.ylabel(r"$\xi(s)\cdot s^2$ $[$Mpc$^2h^{-2}]$") plt.plot(rr, xi * rr * rr, '-') plt.show(block=False)
import numpy as np import matplotlib.pyplot as plt import CosmoBolognaLib as cbl from CosmoBolognaLib import DoubleVector as dv import os # set the CosmoBolognaLib and the current directories cbl.SetDirs("../../../", "./") ''' Define the cosmology ''' cosmo = cbl.Cosmology(cbl.CosmologicalModel__Planck15_) ''' Compute Pk ''' redshift = 1 kk = np.logspace(-4, 2, 200) Pk_DM = np.array([cosmo.Pk(_kk, "CAMB", False, redshift) for _kk in kk]) ''' Parameters for 3pt signal ''' rr = dv(np.linspace(1., 300, 200)) theta = np.linspace(0, np.pi, 100) r1, r2 = 20, 40 ''' Slepian model ''' zeta_DM_s = np.array(cosmo.zeta_DM(r1, r2, theta, "Slepian", kk, Pk_DM)) q_DM_s = np.array(cosmo.Q_DM(r1, r2, theta, "Slepian", kk, Pk_DM)) ''' Barriga-Gatzagnaga model ''' zeta_DM_bg = np.array( cosmo.zeta_DM(r1, r2, theta, "BarrigaGatzanaga", kk, Pk_DM)) q_DM_bg = np.array(cosmo.Q_DM(r1, r2, theta, "BarrigaGatzanaga", kk, Pk_DM)) '''Plot the results''' plt.xlabel(r"$\theta/\pi$") plt.ylabel(r"$\zeta(r1, r2, \theta)$") plt.plot(theta / np.pi, zeta_DM_s, '-k', label=r"Slepian et al 2016") plt.plot(theta / np.pi, zeta_DM_bg, '--r', label=r"Barriga-Gaztanaga 2002") plt.legend(loc="best")