Esempio n. 1
0
import numpy as np
import matplotlib.pyplot as plt

# 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, '-')
Esempio n. 2
0
# =======================================================================
# Example code: how to compute the three-point correlation function model
# =======================================================================

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$")
Esempio n. 3
0
# ==========================================================================
# Example code: how to compute the theoretical size function of cosmic voids
# ==========================================================================

# to ensure compatibility in Python versions 2.x and 3.x
from __future__ import print_function

# import the CosmoBolognaLib #
import CosmoBolognaLib as cbl
import numpy as np

# set the CosmoBolognaLib and the current directories
cbl.SetDirs("../../../", "./")

# define a cosmological model, using default parameters #
cosm = cbl.Cosmology()

# Minimum and maximum of effective void radii
R_min = 1.
R_max = 30.

# number of radii at which the size function is computed
n_val = 10

# list of effective void radii with logarithmic binning
RR = np.logspace(np.log10(R_min), np.log10(R_max), n_val, endpoint=True)

# redshift of the sample
zz = 0.

# effective bias of the mass tracers
##########################################################
# Coordinates type selection

if param.findBool('comovingCoordinates'):
    coordinates = cbl.CoordinateType__comoving_
else:
    coordinates = cbl.CoordinateType__observed_

##########################################################
# define a cosmological model, using parameters from file #

cosm = cbl.Cosmology(param.findDouble('OmM'), param.findDouble('Omb'),
                     param.findDouble('Omn'), param.findDouble('massless'),
                     param.findInt('massive'), param.findDouble('OmL'),
                     param.findDouble('Omr'), param.findDouble('hh'),
                     param.findDouble('As'), param.findDouble('pivot'),
                     param.findDouble('ns'), param.findDouble('w0'),
                     param.findDouble('wa'), param.findDouble('fNL'),
                     param.findInt('type_NG'), param.findDouble('tau'),
                     param.findString('model'), param.findBool('unit'))

# set sigma_8 value from file
cosm.set_sigma8(param.findDouble('sigma8'))

##########################################################
# load the input void catalogue

cast = []
clmn = []
attrNames = [
    'X_coord', 'Y_coord', 'Z_coord', 'Radius', 'centralDensity',
Esempio n. 5
0
import numpy as np

print "I'm importing matplotlib..."
import matplotlib.pyplot as plt

### import the CosmoBolognaLib ###

import CosmoBolognaLib as cbl

# set the CosmoBolognaLib and the current directories

cbl.SetDirs("../../../", "./")

### create an object of class Cosmology ###

cosmo = cbl.Cosmology()

### define k and r for the computation of dark matter power spectrum and  two point correlation correlation function ###

kk = np.logspace(-3, 0, 100)
rr = np.linspace(1., 100, 50)

### Compute the power spectrum using CAMB  ###

PkCAMB = np.asarray(
    [cosmo.Pk(kk[i], "CAMB", False, 0.2) for i in range(len(kk))])

### Compute the two point correlation function using CAMB ###

xiCAMB = [
    cosmo.xi_DM(rr[i], "CAMB", 0.2, "test", False) for i in range(len(rr))