Bases: object
The background calculations are based on a Friedmann-Robertson-Walker model for which the evolution is governed by the Friedmann equation.
Calculates the Hubble parameter for a given scale factor by calling the expression from CosmologyCore_model.py.
a – scale factor [1]
Hubble parameter \(H(a) [km/s/Mpc]\).
Example:
cosmo.background.H(a)
Returns the photon-baryon fluid sound speed [1] from the Recombination module
a – scale factor [1]
cs: photon-baryon sound speed [1]
Example:
cosmo.background.cs(a)
Calculates the angular-diameter distance to a given scale factor.
a – scale factor [1]
Angular diameter distance, \(D_A(a)\), in \([Mpc]\).
Example:
cosmo.background.dist_ang_a(a)
Calculates the luminosity distance to a given scale factor.
a – scale factor [1]
Luminosity distance, \(D_L(a)\), in \([Mpc]\).
Example:
cosmo.background.dist_lum_a(a)
Calculates the radial comoving distance, also known as the comoving radius.
a – scale factor [1]
Radial comoving distance, \(\chi(a)\), in \([Mpc]\).
Example:
cosmo.background.dist_rad_a(a)
Calculates the transverse comoving distance, also known as comoving angular-diameter distance.
a – scale factor [1]
Transverse comoving distance, \(r(\chi)\), in \([Mpc]\).
Example:
cosmo.background.dist_trans_a(a)
Calculates the visibility function for a given scale factor.
a – scale factor [1]
visibility function [1/Mpc]
Example:
cosmo.background.g_a(a)
Calculates the sound horizon at drag epoch.
sound horizon [\(\mathrm{Mpc} / h\)]
Calculates the optical depth of the photon-baryon fluid, by integrating taudot from the Recombination module.
a – scale factor [1]
tau: optical depth [1]
Example:
cosmo.background.tau(a)
Bases: object
All of main functionalities of PyCosmo are managed by the main (Cosmo) class, which links to the other classes where the bulk of the calculations is performed.
Loads parameter file and additional user-defined parameters to initialize the Cosmo object
paramfile – path to parameter file
Prints the parameters of PyCosmo instance.
inc_derived – prints derived parameters [True or False]
inc_internal – prints internal parameterss (e.g. for lin_pert) [True or False]
Changes the configuration parameters of the PyCosmo instance. This will also recalculate the derived quantities.
kwargs – keyword arguments for the input parameters to change.
Warning
Always change parameters of an instance of PyCosmo using the set function. Do not change variables directly!
If no keywords are passed then a list of options is printed
Example:
cosmo.set(omega_m=0.23)
Bases: LinearPerturbationBase
Class created to manage fitting functions for the computation of the linear matter power spectrum \(P_{lin}(k)\). The fitting functions provide transfer functions that are then used to compute the power spectrum.
The different fitting functions can be selected using the set function:
cosmo.set(pk_type = option)where option can be one the following keywords:
BBKS
for BBKS as summarized by Peacock, 1997, MNRAS, 284, 885For developers: in order to compare the codes \(\textsf{PyCosmo}\) and \(\texttt{CCL}\) in terms of linear matter power spectrum computed with the BBKS fitting function, the user should choose a routine which is optimized for this purpose. This further option can be selected as:
cosmo.set(pk_type = 'BBKS_CCL')where
BBKS_CCL
follows the implementation in the CCL code .
Returns the linear growth factor by calling a function that integrates the growth differential equation. It returns a vector of len(a) if k is None or a number, or if diag_only is set to True. Otherwise it returns a matrix with dimension (len(k), len(a)).
a – scale factor [1]
k – wavenumber k, necessary for massive neutrino models [\(h Mpc^{-1}\)]
norm – normalisation scheme: norm = 0: D(a=1)=1 (default), norm = 1: D(a)=a in matter era
diag_only – if set to False, the growth factor is repeated and reshaped to match the shape of k
growth factor [1]
computes max redshift for which this model is applicable.
k – wavenumber k, introduced in the abstract base class since this might be needed for some models. [\(h Mpc^{-1}\)]
redshift
Computes the linear total matter power spectrum, \(P_{lin}(k)\), using a choice of fitting functions.
a – scale factor [1]
k – wavenumber \([Mpc]^{-1}\)
diag_only – if set to True: compute powerspectrum for pairs \(a_i, k_i\), else consider all combinations \(a_i, k_j\)
Linear matter power spectrum, \(P_{lin}(k)\), in \([Mpc]^3\).
Example:
cosmo.set(pk_type = option)
cosmo.lin_pert.powerspec_a_k(a,k)
where option
can be set to one of the fitting functions (EH
or
BBKS
).
Bases: object
This is the parent class of LinearPerturbationApprox and LinearPerturbationBoltzmann. It provides some abstract methods for growth factors, transfer functions and the linear power spectrum. It also calculates \(\sigma_8\) and \(\sigma_r\).
Computes sigma8, the rms density contrast fluctuation smoothed with a top hat of radius 8 \(h^{-1} Mpc\). This routine is also used for the normalization of the power spectrum, when pk_type=``sigma8`` is chosen.
a – scale factor [1]
sigma8 [1]
Bases: LinearPerturbationBase
This class represents the interface to the tables class, which builds tabulated data for the costly calculations. Using this tabulated data this class constructs interpolation functions which can be called instead of the full function in order to increase speed.
Returns an interpolated growth factor computed from a predefined grid with interpolation error smaller than tol which has been set with enrich_params.
Returns an interpolated linear matter power spectrum computed from a predefined grid with interpolation error smaller than tol which has been set with enrich_params. :param: a: scale factor [1] :param: k: wavenumber [Mpc^-1] :return: P(k, a): interpolated matter power spectrum P(k) [Mpc^3]
Bases: NonLinearPerturbationBase
The class computes the non-linear matter power spectrum, \(P_{nl}(k)\), with a choice of analytic fitting funtions.
Warning
NonLinearPerturbationHalofit not supported by the Boltzmann solver yet. Calling any function from this module while using the Boltzmann solver (pk_type = ‘boltz’) will return AttributeError: ‘NoneType’ object has no attribute ‘function’
Computes the non-linear wave number \(k_{nl}\) as a function of the scale factor a.
a – scale factor [1]
k_nl: non-linear wave number [\(\mathrm{Mpc}^{-1}\)]
computes max redshift for which this model is applicable.
k – wavenumber k, might be needed for some underlying linear perturbation models. [\(h Mpc^{-1}\)]
redshift
Returns the nonlinear matter power spectrum using a choice of fitting functions. Currently both the Halofit fitting function and its revision by Takahashi et al., 2012 are supported. Those can be selected using the set function:
cosmo.set(pk_nonlin_type = option)
where option can be one the following keywords:
halofit
(default) for
Smith et al., 2003, MNRAS, 341, 1311
rev_halofit
for revision by
Takahashi et al., 2012, ApJ, 761, 152
After selecting the fitting function, the non-linear matter power spectrum, \(P_{nl}(k)\), can be computed as follows:
cosmo.nonlin_pert.powerspec_a_k(a,k)
a – scale factor [1]
k – wavenumber \([Mpc^{-1}]\)
Nonlinear matter power spectrum, \(P_{nl}(k)\), in \([Mpc^3]\).
Bases: NonLinearPerturbationBase
The class incorporates the implementation of the \(\texttt{HMCode}\) as described in Mead et al. 2015 and Mead et al. 2016 .
Warning
NonLinearPerturbationMead not supported by the Boltzmann solver yet. Calling any function from this module while using the Boltzmann solver (pk_type = ‘boltz’) will return AttributeError: ‘NoneType’ object has no attribute ‘function’
Computes the Fourier Transform of a 3D spherical top-hat function.
x – dimensionless parameter (usually equal to \(kr\)) [1]
Fourier Transform of a 3D spherical top-hat function.
Analytical computation of the derivative of the Fourier Transform of a 3D spherical top-hat function.
x – dimensionless parameter (usually equal to \(kr\)) [1]
Derivative of the Fourier Transform of a 3D spherical top-hat function.
Concentration-mass function of Dark Matter Haloes. The implemented fitting function is from Bullock et al, 2001, as described in Eq. (14) of Mead et al, 2015.
a – scale factor a [1]
m_msun – halo mass in solar masses [Msun]
Concentration \(c(a, M)\) of a halo of mass \(m_{msun}\) at scale factor \(a\).
Computation of the linear collapse threshold, \(\delta_c\).
Following Mead et al., 2015,, \(\delta_c\) is treated as a fitting parameter (read its fitted value in Table 2 of the paper). The current implementation in \(\textsf{PyCosmo}\) follows the updated formula reported in Eq.(8) of Mead et al., 2016,, where the original prescription from 2015 is augmented by the fitting formula proposed in Eq. C28 of Nakamura & Suto, 1997.
a – scale factor [no dimensions]
Linear collapse threshold, \(\delta_c\).
Multiplicity function \(f(\nu)\) as it appears in the calculation of the Halo Mass Function. The available fitting functions are Press & Schechter, 1974, Sheth & Tormen, 1999 , Tinker et al., 2010, and Watson et al., 2013 .
nu – array of \(\nu\) values as in \(\nu = \delta_c / \sigma(M)\) (see eq. 17 in Mead et al., 2015)
Multiplicity function \(f(\nu)\) .
Example of setting the multiplicity function:
cosmo.set(multiplicity_fnct = option)
where option can be ‘PS’ for Press & Schechter (1974), ‘ST’ for Sheth & Tormen (1999), ‘Ti’ for Tinker et al., 2010 or ‘Wa’ for Watson et al., 2013.
Converts mass of a sphere in solar masses [Msun] to corresponding radius in [Mpc], assuming homogeneous density corresponding to the critical matter density of the universe (redshift z=0).
m_msun – mass of sphere in solar masses [Msun]
Radius of the sphere in [Mpc].
computes max redshift for which this model is applicable.
k – wavenumber k, might be needed for some underlying linear perturbation models. [\(h Mpc^{-1}\)]
redshift
Calculates the effective spectral index of the linear power spectrum at the collapse scale, according to the implementation in the HMCode.
a – scale factor [1]
Effective spectral index of the linear power spectrum, \(n_{eff}\), at the collapse scale.
Extracts the halo mass from Eq.(17) in Mead et al., 2015, \(\nu = \delta_c / \sigma\), by converting the \(\nu\)-array into a mass-array by backwards interpolation.
nu – \(\nu\)-array as in \(\nu = \delta_c / \sigma\) [1]
Mass in solar masses [Msun].
One-Halo term of the non-linear matter power spectrum as defined in Eq.(8) of Mead et al, 2015.
k – wavelength \([Mpc^{-1}]\)
a – scale factor [1]
nu_range – nu_range-array used for the integration (default set to full lookup table)
mode – integration scheme. The values 0, 1 and 2 refer to numpy integration, cython integration and cython with adaptive integration, respectively.
One-Halo power spectrum \(P_{1h}(k) \ [Mpc^{3}]\).
Two-Halo term of the non-linear matter power spectrum as defined in Eq.(10) of Mead et al, 2015.
k – wavelength \([Mpc^{-1}]\)
a – scale factor [1]
Two-Halo power spectrum \(P_{2h}(k) \ [Mpc^{3}]\).
Calculates the non-linear matter power spectrum, using the mead
model, as described in Mead et al., 2015 and Mead et al., 2016,
consisting of the superposition
of the pk_1h()
and pk_2h()
terms.
k – wavelength \([Mpc]^{-1}\)
a – scale factor [1]
nu_range – nu-array used for the integration [1]
m_min_msun – minimum halo mass for the integration range [Msun]
m_max_msun – maximum halo mass for the integration range [Msun]
Halo Model power spectrum, \(P_{nl}(k)\), in \([Mpc^{3}]\).
Example:
cosmo.set(pk_nonlin_type = 'mead')
cosmo.nonlin_pert.powerspec_a_k(a,k)
Prints the cosmological setup and the parameters used for the computation of the non-linear matter power spectrum with the Mead et al., 2015 model.
Example:
cosmo.set(pk_nonlin_type = 'mead')
cosmo.nonlin_pert.print_params()
Converts radius of a sphere in [Mpc] to corresponding mass in solar masses [Msun], assuming homogeneous density corresponding to the critical matter density of the universe (redshift z=0).
r_mpc – radius of sphere [Mpc]
Mass of sphere in solar masses [Msun].
Calculates the virial radius corresponding to a dark matter halo of mass m_msun in a flat cosmology. See Bryan & Norman, 1998 for more details.
mvir_msun – Halo mass in solar masses [Msun]
Virial radius in \([Mpc]\).
Calculates \(\sigma(M, a)\), the RMS of the density field at a given mass.
m_msun – mass in solar masses at which sigma is evaluated [Msun]
a – scale factor [1]
\(\sigma(M, a)\) as the RMS of the density field.
Compute \(\sigma_8\), the rms density contrast fluctuation, smoothed with a top hat of radius 8 \(h^{-1}\mathrm{Mpc}\) at scale factor a.
a – scale factor [1]
\(\sigma_8\) at the desired scale factor.
Computes \(\sigma^2_D(a)\) as defined in Eq. B5 of Mead et al, 2015
a – scale factor [1]
\(\sigma^2_D(a)\) at the desired scale factor.
Computes \(\sigma^2_V(a)\) as defined in Eq. (22) of Mead et al, 2015 .
a – scale factor [1]
\(\sigma^2_v(a)\) at the desired scale factor.
Bases: NonLinearPerturbationBase
This class represents the interface to the tables class, which builds tabulated data for the costly calculations. Using this tabulated data this class constructs interpolation functions which can be called instead of the full function in order to increase speed.
Returns an interpolated non-linear wave number computed from a predefined grid with interpolation error smaller than tol which has been set with enrich_params.
Returns an interpolated nonlinear matter power spectrum computed from a predefined grid with interpolation error smaller than tol which has been set with enrich_params. :param: a: scale factor [1] :param: k: wavenumber [Mpc^-1] :return: P(k, a): interpolated nonlinear matter power spectrum P(k) [Mpc^3]
Bases: NonLinearPerturbation_HaloModel
The class incorporates the implementation of the Halo Model for neutral hydrogen (HI) as described in Padmanabhan et al., 2017.
This can be set as:
cosmo.set(pk_nonlin_type='HI')
Warning
NonLinearPerturbation_HI not supported by the Boltzmann solver yet. Calling any function from this module while using the Boltzmann solver (pk_type = ‘boltz’) will return AttributeError: ‘NoneType’ object has no attribute ‘function’
Concentration-mass function of HI halos.
m_msun – Halo mass in solar masses \([M_{\odot}]\), scalar or 1d array
a – Scale factor a, scalar or 1d array
Concentration \(c_\text{HI}(M, a)\) of a halo mass \([M_{\odot}]\) at scale factor \(a\)
Calculates the mean HI brightness temperature \(T_\text{b}(a)\) in \([K]\) as a function of the scale factor.
a – Scale factor, scalar or 1d array
Mean HI brightness temperature, in \([K]\)
HI-halo mass relation: Calculates the amount of HI mass in a dark matter halo of mass \(M\).
m_msun – Halo mass in solar masses \([M_{\odot}]\), scalar or 1d array
a – Scale factor a, scalar or 1d array
HI mass in solar masses \([M_{\odot}]\)
One-halo term \(P_\text{HI,1h}(k, a)\) of the non-linear HI power spectrum as described in the Halo Model for HI.
k – Wavelength \([Mpc^{-1}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
One-Halo power spectrum \(P_\text{HI,1h}(k, a) \ [Mpc^{3}]\)
Example of setting the multiplicity function, linear halo bias, halo profile, and the assumed minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation:
cosmo.set(multiplicity_fnct=option_mf,
lin_halo_bias_type=option_b,
halo_profile=option_p,
min_halo_mass=1e8,
max_halo_mass=1e14)
where the possible option_mf are given in the documentation to \(f(\nu, a)\) and option_b in the documentation to the linear halo bias in the NonLinearPerturbation_HaloModel module. option_p is either True for a NFW-profile or False for assumed point sources. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Two-halo term \(P_\text{HI,2h}(k, a)\) of the non-linear power spectrum as described in the Halo Model for HI.
k – Wavelength \([Mpc^{-1}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
Two-Halo power spectrum \(P_\text{HI,2h}(k, a) \ [Mpc^{3}]\)
Example of setting the multiplicity function, linear halo bias, halo profile, and the assumed minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation:
cosmo.set(multiplicity_fnct=option_mf,
lin_halo_bias_type=option_b,
halo_profile=option_p,
min_halo_mass=1e8,
max_halo_mass=1e14)
where the possible option_mf are given in the documentation to \(f(\nu, a)\) and option_b in the documentation to the linear halo bias in the NonLinearPerturbation_HaloModel module. option_p is either True for a NFW-profile or False for assumed point sources. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Calculates the non-linear matter power spectrum using the Halo Model,
described e.g. in Mo et al. “Galaxy Formation and Evolution” (2010) chapter 7.6,
as the sum of the pk_1h()
and pk_2h()
terms.
k – Wavelength \([Mpc^{-1}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
Halo Model power spectrum, \(P_\text{nl}(k, a)\), in \([Mpc^{3}]\)
Example on how to use the Halo model, set the multiplicity function, linear halo bias, halo profile, and the minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation, and then calculate the power spectrum:
cosmo.set(pk_nonlin_type='HaloModel',
multiplicity_fnct=option_mf,
lin_halo_bias_type=option_b,
halo_profile=option_p,
min_halo_mass=1e8,
max_halo_mass=1e14)
pk = cosmo.nonlin_pert.powerspec_a_k(a,k)
where the possible option_mf are given in the documentation to \(f(\nu, a)\), option_b in the documentation to the linear halo bias and option_p is either True for a NFW-profile or False for assumed point sources. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Calculates the non-linear HI power spectrum using the Halo Model for HI,
as the sum of the pk_HI_1h()
and pk_HI_2h()
terms.
k – Wavelength \([Mpc^{-1}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
HI Halo Model power spectrum, \(P_\text{HI,nl}(k, a)\), in \([Mpc^{3}]\)
Example on how to use the HI Halo model, set the multiplicity function, linear halo bias, halo profile, and the minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation, and then calculate the power spectrum:
cosmo.set(pk_nonlin_type='HI',
multiplicity_fnct=option_mf,
lin_halo_bias_type=option_b,
halo_profile=option_p,
min_halo_mass=1e8,
max_halo_mass=1e14)
pk = cosmo.nonlin_pert.powerspec_a_k_HI(a,k)
where the possible option_mf are given in the documentation to \(f(\nu, a)\) and option_b in the documentation to the linear halo bias in the NonLinearPerturbation_HaloModel module. option_p is either True for a NFW-profile or False for assumed point sources. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Calculates the mean HI density as a function of the scale factor.
a – Scale factor, scalar or 1d array
Mean HI density, in \([M_{\odot} \ Mpc^{-3}]\)
Example of setting the multiplicity function and the assumed minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation:
cosmo.set(multiplicity_fnct=option,
min_halo_mass=1e8,
max_halo_mass=1e14)
where option can be ‘PS’ for Press & Schechter (1974), ‘ST’ for Sheth & Tormen (1999), ‘Ti’ for Tinker et al., 2010, or ‘Wa’ for Watson et al., 2013. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Bases: NonLinearPerturbationBase
The class incorporates the implementation of the Halo Model.
This can be set as:
cosmo.set(pk_nonlin_type='HaloModel')
Warning
NonLinearPerturbation_HaloModel not supported by the Boltzmann solver yet. Calling any function from this module while using the Boltzmann solver (pk_type=’boltz’) will return AttributeError: ‘NoneType’ object has no attribute ‘function’
Computes the Fourier Transform of a 3D spherical top-hat function.
x – Dimensionless parameter (usually equal to \(kr\)) [1]
Fourier Transform of a 3D spherical top-hat function
Concentration-mass function of dark matter haloes. The implemented fitting function is from Bullock et al., 2001.
m_msun – Halo mass in solar masses \([M_{\odot}]\), scalar or 1d array
a – Scale factor a, scalar or 1d array
Concentration \(c(M, a)\) of a halo mass \([M_{\odot}]\) at scale factor \(a\)
Computation of the cosmology dependent linear collapse threshold, \(\delta_c\). For the mass functions of Press & Schechter, 1974 , Sheth & Tormen, 1999 , and Watson et al., 2013 , we use the cosmology dependent expression from Nakamura & Suto, 1997 , or Mo & White, 2010 . For the mass function of Tinker et al., 2010 , we assume \(\delta_c=1.686\).
a – Scale factor, scalar or 1d array
Linear collapse threshold \(\delta_c\)
Calculates the mean overdensity of a virialised dark matter halo for different cosmologies. We use equation (6) of Bryan & Norman, 1998 modified by a \(1/\Omega_m\) term, because we work with respect to the matter density, rather than the critical density.
a – Scale factor, scalar or 1d array
Mean overdensity of a dark matter halo \(\Delta_{vir}\)
Calculates the logarithmic mass function \(\frac{dn}{dln M}\) as a function of the halo mass. The functional form depends on the selected multiplicity function \(f(\nu, a)\), see the corresponding documentation.
m_msun – Halo mass \([M_{\odot}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
dm – Accuracy for triangle approximation of derivative \([M_{\odot}]\), scalar
Logarithmic mass function \(\frac{dn}{d\ln M}\) \([Mpc^{-3}]\)
Calculates logarithmic mass function \(\frac{dn}{d\ln M}\) as a function of the peak height \(\nu=\delta_c / \sigma(M, a)\). The functional form depends on the selected multiplicity function \(f(\nu, a)\), see the corresponding documentation.
nu – Peak height \(\nu=\delta_c / \sigma(M, a)\), scalar or 1d array
a – Scale factor, scalar or 1d array
dm – Accuracy for triangle approximation of derivative \([M_{\odot}]\), scalar
Logarithmic mass function \(\frac{dn}{d\ln M}\) \([Mpc^{-3}]\)
Calculates logarithmic mass function \(\frac{dn}{d\log_{10} M}\) as a function of the halo mass. The functional form depends on the selected multiplicity function \(f(\nu, a)\), see the corresponding documentation.
m_msun – Halo mass \([M_{\odot}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
dm – Accuracy for triangle approximation of derivative \([M_{\odot}]\), scalar
Logarithmic mass function \(\frac{dn}{d\log_{10} M}\) \([Mpc^{-3}]\)
Calculates logarithmic mass function \(\frac{dn}{d\log_{10} M}\) as a function of the peak height \(\nu=\delta_c / \sigma(M, a)\). The functional form depends on the selected multiplicity function \(f(\nu, a)\), see the corresponding documentation.
nu – Peak height \(\nu=\delta_c / \sigma(M, a)\), scalar or 1d array
a – Scale factor, scalar or 1d array
dm – Accuracy for triangle approximation of derivative \([M_{\odot}]\), scalar
Logarithmic mass function \(\frac{dn}{d\log_{10} M}\) \([Mpc^{-3}]\)
Calculates mass function \(\frac{dn}{dM}\) as a function of the halo mass. The functional form depends on the selected multiplicity function \(f(\nu, a)\), see the corresponding documentation.
m_msun – Halo mass \([M_{\odot}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
dm – Accuracy for triangle approximation of derivative \([M_{\odot}]\), scalar
Mass function \(\frac{dn}{dM}\) \([M_{\odot}^{-1} Mpc^{-3}]\)
Calculates mass function \(\frac{dn}{dM}\) as a function of the peak height \(\nu=\delta_c / \sigma(M, a)\). The functional form depends on the selected multiplicity function \(f(\nu, a)\), see the corresponding documentation.
nu – Peak height \(\nu=\delta_c / \sigma(M, a)\), scalar or 1d array
a – Scale factor, scalar or 1d array
dm – Accuracy for triangle approximation of derivative \([M_{\odot}]\), scalar
Mass function \(\frac{dn}{dM}\) \([M_{\odot}^{-1} Mpc^{-3}]\)
Multiplicity function \(f(\nu, a)\) as it appears in the calculation of the Halo Mass Function. The available fitting functions are Press & Schechter (‘PS’), 1974, Sheth & Tormen (‘ST’), 1999 , Tinker et al. (‘Ti’), 2010 , and Watson et al. (‘Wa’), 2013 .
nu – Peak height \(\nu=\delta_c / \sigma(M, a)\), scalar or 1d array
a – Scale factor, a=1.0 for multiplicity function=’PS’, ‘ST’, and ‘Wa’, scalar or 1d array for ‘Ti’
Multiplicity function \(f(\nu, a)\)
Example of setting the multiplicity function:
cosmo.set(multiplicity_fnct=option)
where option can be ‘PS’ for Press & Schechter (1974), ‘ST’ for Sheth & Tormen (1999), ‘Ti’ for Tinker et al., 2010, or ‘Wa’ for Watson et al., 2013.
Calculates the linear halo bias for a given peak height \(\nu=\delta_c / \sigma(M, a)\). The available biases are Mo & White (‘MW’), 1996 , Sheth & Tormen (‘ST’), 1999 , Sheth, Mo & Tormen (‘SMT’), 2001 , and Tinker et al. (‘Ti’), 2010 .
nu – Peak height \(\nu=\delta_c / \sigma(M, a)\), scalar or 1d array
a – Scale factor, scalar or 1d array
Linear halo bias
Example of setting the linear halo bias:
cosmo.set(lin_halo_bias_type=option)
where option can be ‘MW’ for Mo & White (1996), ‘ST’ for Sheth & Tormen (1999), ‘SMT’ for Sheth, Mo & Tormen (2001), or ‘Ti’ for Tinker et al., 2010.
Calculates the peak height \(\nu(M, a)=\delta_c / \sigma(M, a)\) as a function of the halo mass and scale factor.
m_msun – Halo mass \([M_{\odot}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
Peak height
Converts mass of a sphere in solar masses \([M_{\odot}]\) to the corresponding radius in \([Mpc]\), assuming homogeneous density corresponding to the matter density of the universe at redshift \(z=0\).
m_msun – Mass of sphere in solar masses \([M_{\odot}]\), scalar or 1d array
Radius of the sphere in \([Mpc]\)
Computes max redshift for which this model is applicable.
k – Wavenumber k, might be needed for some underlying linear perturbation models. \([h Mpc^{-1}]\)
Redshift
Extracts the halo mass from Eq.(17) in Mead et al., 2015, \(\nu(M, a)=\delta_c / \sigma(M, a)\), by converting the \(\nu\)-array into a mass-array by backwards interpolation.
nu – Peak height \(\nu=\delta_c / \sigma(M, a)\), scalar or 1d array
a – Scale factor, scalar or 1d array
Mass in solar masses \([M_{\odot}]\)
One-Halo term \(P_\text{1h}(k, a)\) of the non-linear matter power spectrum as described in Eq. (7.191) of Mo et al. “Galaxy Formation and Evolution” (2010).
k – Wavelength \([Mpc^{-1}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
One-Halo power spectrum \(P_\text{1h}(k, a) \ [Mpc^{3}]\)
Example of setting the multiplicity function, linear halo bias, halo profile, and the assumed minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation:
cosmo.set(multiplicity_fnct=option_mf,
lin_halo_bias_type=option_b,s
halo_profile=option_p,
min_halo_mass=1e8, max_halo_mass=1e14)
where the possible option_mf are given in the documentation to \(f(\nu, a)\), option_b in the documentation to the linear halo bias and option_p is either True for a NFW-profile or False for assumed point sources. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Two-Halo term \(P_\text{2h}(k, a)\) of the non-linear matter power spectrum as described in Eq. (7.194) of Mo et al. “Galaxy Formation and Evolution” (2010).
k – Wavelength \([Mpc^{-1}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
Two-Halo power spectrum \(P_\text{2h}(k, a) \ [Mpc^{3}]\)
Example of setting the multiplicity function, linear halo bias, halo profile, and the assumed minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation:
cosmo.set(multiplicity_fnct=option_mf,
lin_halo_bias_type=option_b,
halo_profile=option_p,
min_halo_mass=1e8,
max_halo_mass=1e14)
where the possible option_mf are given in the documentation to \(f(\nu, a)\), option_b in the documentation to the linear halo bias and option_p is either True for a NFW-profile or False for assumed point sources. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Calculates the non-linear matter power spectrum using the Halo Model,
described e.g. in Mo et al. “Galaxy Formation and Evolution” (2010) chapter 7.6,
as the sum of the pk_1h()
and pk_2h()
terms.
k – Wavelength \([Mpc^{-1}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
Halo Model power spectrum, \(P_\text{nl}(k, a)\), in \([Mpc^{3}]\)
Example on how to use the Halo model, set the multiplicity function, linear halo bias, halo profile, and the minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation, and then calculate the power spectrum:
cosmo.set(pk_nonlin_type='HaloModel',
multiplicity_fnct=option_mf,
lin_halo_bias_type=option_b,
halo_profile=option_p,
min_halo_mass=1e8,
max_halo_mass=1e14)
pk = cosmo.nonlin_pert.powerspec_a_k(a,k)
where the possible option_mf are given in the documentation to \(f(\nu, a)\), option_b in the documentation to the linear halo bias and option_p is either True for a NFW-profile or False for assumed point sources. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Prints the cosmological setup and the parameters used for the computation of the non-linear matter power spectrum with the halo model.
Example:
cosmo.set(pk_nonlin_type='HaloModel')
cosmo.nonlin_pert.print_params()
Converts radius of a sphere in \([Mpc]\) to corresponding mass in solar masses \([M_{\odot}]\), assuming homogeneous density corresponding to the matter density of the universe at redshift \(z=0\).
r_mpc – Radius of sphere \([Mpc]\), scalar or 1d array
Mass of sphere in solar masses \([M_{\odot}]\)
Calculates the mean dark matter density as a function of the scale factor.
a – Scale factor, scalar or 1d array
Mean matter density, in \([M_{\odot} \ Mpc^{-3}]\)
Example of setting the multiplicity function and the assumed minimal and maximal halo masses in solar masses \([M_{\odot}]\) considered in the calculation:
cosmo.set(multiplicity_fnct=option,
min_halo_mass=1e8,
max_halo_mass=1e14)
where option can be ‘PS’ for Press & Schechter (1974), ‘ST’ for Sheth & Tormen (1999), ‘Ti’ for Tinker et al., 2010, or ‘Wa’ for Watson et al., 2013. Default values for the minimal and maximal halo masses are min_halo_mass=1 and max_halo_mass=1e+20.
Calculates the virial radius corresponding to a dark matter halo of a given mass for different cosmologies. See Bryan & Norman, 1998 for more details.
mvir_msun – Halo mass in solar masses \([M_{\odot}]\), scalar or 1d array
a – Scale factor, 1d array
Virial radius in \([Mpc]\)
Calculates \(\sigma(M, a)\), the RMS of the density field at a given mass.
m_msun – Mass in solar masses at which \(\sigma\) is evaluated \([M_{\odot}]\), scalar or 1d array
a – Scale factor, scalar or 1d array
\(\sigma(M, a)\) as the RMS of the density field
Computes \(\sigma_8\), the RMS density contrast fluctuation, smoothed with a top hat of radius 8 \(h^{-1}Mpc\) at scale factor \(a\).
a – Scale factor, scalar or 1d array
\(\sigma_8\) at the desired scale factor
Compute subhalo mass function as a function of subhalo masses and host halo mass.
Chapter 7.5 of Mo, van den Bosch and White (Equations 7.149 and 7.150) Left panel of Figure 2 from Jiang et al., 2017 informs the value for mean_subhalo_mass_fraction ~ 0.1
Default=0.1, informed by arxiv:1610.02399
beta ~ 0.1 - 0.5, always < 1 (according to Mo, van den Bosch and White)
gamma ~ 0.8 - 1.0 (according to Mo, van den Bosch and White)
subhalo_m_msun – Subhalo mass \([M_{\odot}]\), scalar or 1d array
mean_subhalo_mass_fraction – Mean mass fraction contained in subhalos, scalar
host_halo_mass_msun – Mass of the host halo for which this subhalo mass function is computed \([M_{\odot}]\), scalar
beta – Exponent, scalar
Subhalo mass function \(\frac{dn}{dM}\) \([M_{\odot}^{-1} Mpc^{-3}]\)
Calculates the virial velocity corresponding to a dark matter halo of a given mass as described in Barnes & Haehnelt, 2014 .
mvir_msun – Halo mass in solar masses \([M_{\odot}]\), scalar or 1d array
a – Scale factor, 1d array
Virial velocity in \([km/s]\)
Bases: object
The class is used to create an instance that is needed to calculate the observables,
containing information about experiments and surveys. In this way the
PyCosmo.Obs
class acts at the same level as the
PyCosmo.Cosmo
class and is initialised using a parameter file or a set of
parameters. As shown also in the Section Usage of the documentation, the following
example illustrates how to instantiate the PyCosmo.Obs
class to compute the
lensing power spectrum \(C_{\ell}^{\gamma \gamma}\):
# PyCosmo instance
cosmo = PyCosmo.Cosmo()
# Set the fitting functions for the power spectrum
cosmo.set(pk_type = 'EH')
cosmo.set(pk_nonlin_type = 'rev_halofit')
# Information about the observables
# Note: 'perturb': 'nonlinear' can be replaced with 'linear' by the user.
clparams = {'nz': ['smail', 'smail'],
'z0': 1.13,
'beta': 2.,
'alpha': 2.,
'probes': ['gamma', 'gamma'],
'perturb': 'nonlinear',
'normalised': False,
'bias': 1.,
'm': 0,
'z_grid': np.array([0.0001, 5., 1000])
}
# Obs instance
obs = PyCosmo.Obs()
# Cls computation
cls_haloEH = obs.cl(ells, cosmo, clparams)
where the function cl()
is documented below.
Warning
Obs not supported by the Boltzmann solver yet, since it uses the Projection class. Calling any function from this module while using the Boltzmann solver (pk_type = ‘boltz’) will return ValueError: you must set pk_nonlin_type to access projections
Returns th:e linear intrinsic alignment amplitude C1.
cosmo – instance of PyCosmo.Cosmo (specifies cosmological model)
Linear intrinsic alignment amplitude for current value of h
Returns the \(F\) function of the linear alignment model. This follows Eq. (8) of Hildebrandt et al., 2016. Here we set \(\eta = \beta = 0\), i.e., no redshift and luminosity dependence is considered.
a – array of scale factor values. \(a\)
cosmo – instance of PyCosmo.Cosmo
(specifies the cosmological
model)
obsparams – dictionary containing specifications for the observables
Value of \(F\) as a function of the scale factor \(a\).
Set up the redshift selection functions, i.e. each redshift selection function is either calculated from the default hard coded ones or the tabulated selection functions are read in and saved as attributes in self.n.
obsparams – dictionary containing specifications for observable
Set up the redshift selection functions, i.e. each redshift selection function is either calculated from the default hard coded ones or the tabulated selection functions are read in and saved as attributes in self.n.
obsparams – dictionary containing specifications for observable
Wrapper around all the other cl routines which determines from the obsparams dictionary for which cosmological probes the angular power spectrum has to be computed. The provided cosmological probes are galaxy/halo overdensity ‘deltag’, neutral hydrogen HI overdensity ‘HI’, cosmic shear ‘gamma’, and CMB lensing convergence ‘cmbkappa’.
This is especially useful when interfacing with CosmoHammer.
ells – array of angular multipoles \(\ell\)
cosmo – instance of PyCosmo.Cosmo
(specifies cosmological model)
obsparams – dictionary containing specifications for observable
Array of values of the angular power spectrum for the desired probes for \(\ell\)’s
Calculates the angular power spectrum for GI intrinsic alignments (IAs) using the NLA or LA model for the multipole array specified by the angular multipoles \(\ell\). The NLA implementation follows Hildebrandt et al., 2016.
ells – array of angular multipoles \(\ell\)
cosmo – instance of PyCosmo.Cosmo
(it specifies the cosmological model)
obsparams – dictionary containing specifications for the observables
Array of values of the angular power spectrum for GI IAs.
Calculates the angular power spectrum for II intrinsic alignments (IAs) using the NLA or LA model for the multipole array specified by \(\ell\). The NLA implementation follows Hildebrandt et al., 2016.
ells – array of angular multipoles \(\ell\)
cosmo – instance of PyCosmo.Cosmo
(it specifies the cosmological
model)
obsparams – dictionary containing specifications for the observables
Array of values of the angular power spectrum for II IAs.
Calculates the \(C_{\ell}\) for the desired probes, as specified by the “probes” parameter in obsparams.
ells – array of angular multipoles \(\ell\)
cosmo – instance of PyCosmo.Cosmo
(specifies cosmological model)
obsparams_list – list of dictionaries containing specifications for observables
Returns the generalised growth factor used in the ISW angular power spectrum integrand both for the analytic approximation and the numerical derivative.
a – scale factor
cosmo – instance of PyCosmo.Cosmo
(specifies cosmological model)
mode – numerical or analytic
The value of the generalised growth factor at redshift x
Returns the growth factor divided by the scale factor a.
cosmo – instance of PyCosmo.Cosmo
(specifies cosmological model)
a – scale factor a
Growth factor divided by scale factor
Returns the derivative of growth_suba by scale factor a.
cosmo – instance of PyCosmo.Cosmo
(specifies cosmological model)
a – scale factor a
Derivative of growth_suba w.r.t. z
Computes and normalises the redshift selection-function of a survey.
obsparams – dictionary containing specifications for the observables
nzmode – string tag in [smail
, cfhtlens
, custom
,
custom_array
, uniform
]
path2zdist – if \(n(z)\) comes from a file, then this is the path to
the file (nzmode = custom
)
if \(n(z)\) comes from an array, this is the array
(nzmode = custom_array
)
z – redshift grid
Corresponding normalised redshift selection-function, \(P(z)_{|norm}\).
Return the critical density of the Universe at a_0 = 1 (today).
cosmo – instance of PyCosmo.Cosmo (specifies cosmological model)
critical density today, [rhoc] = kg/Mpc^3
Sets the multiplicative calibration parameters as defined in the dictionary obsparams.
obsparams – dictionary containing specifications for the observables
Sets up the radial window functions for the surveys and the probes, i.e., computes the window functions appropriate for the galaxy overdensity, HI, \(\gamma\), CMB temperature and CMB \(- \kappa\) and saves them in the attribute self.window.
obsparams – dictionary containing specifications for observable
radial window function
Bases: object
This class has been written to handle operations involving building tabulated data. For some of the calculations this is often useful. These tables can then be accessed through interpolation routines rather than doing the full calculations repeatedly.
Bases: object
Core projection functions to be used by the Obs
class to predict
observables.
Warning
Projection not supported by the Boltzmann solver yet, since it requires nonlinear perturbations. Calling any function from this module while using the Boltzmann solver (pk_type = ‘boltz’) will return ValueError: you must set pk_nonlin_type to access projections
Computes the angular power spectrum of the auto- or cross-correlation between two LSS probes i.e. galaxy/halo overdensity, HI overdensity, cosmic shear or CMB lensing in the Limber Approximation.
ells – array of angular multipoles \(\ell\)
weight_function1 – radial weight function for first probe
weight_function2 – radial weight function for second probe
a_grid – integration grid in scale factor a
probes – list with name of probes
perturb – string tag denoting if we use linear or nonlinear power
spectrum. It can be either linear
or nonlinear
.
Angular power spectrum \(C_{\ell}\) at the multipoles \(\ell\).
Computes the angular power spectrum of the cross correlation between intrinsic galaxy ellipticities and tracers of the LSS.
ell – array of angular multipole \(\ell\)
weight_function1 – radial weight function for first probe -> this needs to be the weight function
weight_function2 – radial weight function for second probe -> this needs to be n(z)
F – IA bias function
a_grid – integration grid in scale factor a
IAmodel – string tag denoting if we use NLA or LA IA model. It can be
either NLA
or IA
.
Angular power spectrum \(C_{\ell}\) at the multipoles \(\ell\).
Returns the integrand for the angular power spectrum of intrinsic alignments (IAs) computed using the NLA or LA model.
a – array of scale factor values a
ells – array of angular multipoles \(\ell\)
weight_function1 – radial weight function for first probe -> this needs to be the weight function
weight_function2 – radial weight function for second probe -> this needs to be n(z)
F – IA bias function
IAmodel – string tag denoting if we use NLA or LA IA model. It can be
either NLA
or IA
.
Integrand at \(\\ell\) for the values of a.
Computes the angular power spectrum of the auto power spectrum of intrinsic galaxy ellipticities.
ell – array of angular multipole \(\ell\)
weight_function1 – redshift selection function for first probe
weight_function2 – redshift selection function for second probe
F – IA bias function
a_grid – integration grid in scale factor a
IAmodel – string tag denoting if we use NLA or LA IA model. It can be
either NLA
or IA
.
Angular power spectrum \(C_{\ell}\) at the multipoles \(\ell\).
Returns the integrand for the angular power spectrum of the auto correlation of intrinsic alignments (IAs) computed using the NLA or LA model.
a – array of scale factor values a
ells – array of angular multipoles \(\ell\)
weight_function1 – redshift selection function for first probe
weight_function2 – redshift selection function for second probe
F – IA bias function
IAmodel – string tag denoting if we use NLA or LA IA model. It can be
either NLA
or IA
.
Integrand at \(\ell\) for the values of a.
Computes the angular power spectrum of the cross correlation between the CMB temperature anisotropies and the galaxy overdensity/cosmic shear.
ell – array of angular multipole \(\ell\)
weight_function1 – radial weight function for first probe
weight_function2 – radial weight function for second probe
growth_ISW – growth function for ISW
a_grid – integration grid in scale factor a
linear – string tag denoting if we use linear or nonlinear power spectrum.
It can be either linear
or nonlinear
Angular power spectrum \(.C_{\ell}\) at the multipoles \(\ell\).
Returns the integrand needed to compute the angular power spectrum of the cross correlation between the CMB temperature anisotropies and the galaxy overdensity/cosmic shear/CMB lensing.
a – array of scale factor values a
ells – array of angular multipoles \(\ell\)
weight_function1 – radial weight function for first probe
weight_function2 – radial weight function for second probe
growth_ISW – growth function for ISW
perturb – string tag denoting if we use linear or nonlinear power
spectrum. It can be either linear
or nonlinear
.
Integrand at \(\ell\) for the values of a.
Returns the integrand needed to compute the angular power spectrum of the auto- or cross-correlation between two LSS probes in the Limber approximation.
a – array of scale factor values a
ells – array of angular multipoles \(\ell\)
weight_function1 – radial weight function for first probe
weight_function2 – radial weight function for second probe
probes – list with name of probes
perturb – string tag denoting if we use linear or nonlinear power
spectrum. It can be either linear
or nonlinear
.
Integrand at \(\ell\) for the values of a.
Bases: object
Class for calculation of tabulated cosmological quantities from PyCosmo.
Returns the derivative of the growth function w.r.t. a. :param a: scale factor :param mode: 5-point derivative or 2-point derivative :return growth_deriv: derivative of the growth factor w.r.t. a
Returns the growth factor divided by the scale factor a :param a: scale factor a :return growth_suba_temp: growth factor divided by scale factor
Returns the derivative of growth_suba by redshift z :param a: scale factor a :return growth_deriv: derivative of growth_suba w.r.t. z
Returns the interpolated growth factor from PyCosmo. :param a: array of scale factor values a :return growth_interp: interpolated growth factor at a
Returns the interpolated inverse of the growth factor from PyCosmo. :param g: array of growth factor values g :return inv_growth_interp: interpolated inverse growth factor at g
Returns the interpolated linear matter power spectrum from PyCosmo. :param a: array of scale factor values a :param k: array of wave vector k values :return pk_lin_interp: interpolated linear power spectrum at a and k
>>> len(k2)
106
>>> e1
7.999793047824832e-05
>>> e2
0.0004712228618850567
>>>
This is the PyCosmo package.
Bases: object
All of main functionalities of PyCosmo are managed by the main (Cosmo) class, which links to the other classes where the bulk of the calculations is performed.
Loads parameter file and additional user-defined parameters to initialize the Cosmo object
paramfile – path to parameter file
Prints the parameters of PyCosmo instance.
inc_derived – prints derived parameters [True or False]
inc_internal – prints internal parameterss (e.g. for lin_pert) [True or False]
Changes the configuration parameters of the PyCosmo instance. This will also recalculate the derived quantities.
kwargs – keyword arguments for the input parameters to change.
Warning
Always change parameters of an instance of PyCosmo using the set function. Do not change variables directly!
If no keywords are passed then a list of options is printed
Example:
cosmo.set(omega_m=0.23)