Python API

Cosmology Module

class EffectiveHalos.Cosmology.Cosmology(redshift, name='', verb=False, npoints=100000, **params)[source]

Class to hold the basic cosmology and CLASS attributes. This can be initialized by a set of cosmological parameters or a pre-defined cosmology.

Loaded cosmological models:

  • Planck18: Bestfit cosmology from Planck 2018, using the baseline TT,TE,EE+lowE+lensing likelihood.
  • Quijote: Fiducial cosmology from the Quijote simulations of Francisco Villaescusa-Navarro et al.
  • Abacus: Fiducial cosmology from the Abacus simulations of Lehman Garrison et al.
Parameters:
  • redshift (float) – Desired redshift \(z\)
  • name (str) – Load cosmology from a list of predetermined cosmologies (see above).
  • params (kwargs) – Any other CLASS parameters. (Note that sigma8 does not seem to be supported by CLASS in Python 3).
Keyword Arguments:
 
  • verb (bool) – If true output useful messages througout run-time, default: False.
  • npoints (int) – Number of points to use in the interpolators for sigma^2, default: 100000
compute_linear_power(kh, kh_min=0.0, with_neutrinos=False)[source]

Compute the linear power spectrum from CLASS for a vector of input k.

If set, we remove any modes below some minimum k.

Parameters:

kh (float, np.ndarray) – Wavenumber or vector of wavenumbers (in h/Mpc units) to compute linear power with.

Keyword Arguments:
 
  • kh_min (float) – Value of k (in h/Mpc units) below which to set \(P(k) = 0\), default: 0.
  • with_neutrinos (bool) – If True, return the full matter power spectrum, else return the CDM+baryon power spectrum (which is generally used in the halo model). Default: False.
Returns:

Linear power spectrum in \((h^{-1}\mathrm{Mpc})^3\) units

Return type:

np.ndarray

dlns_dlogM_int(logM_h)[source]

Return the value of \(d\ln\sigma/d\log M\) using the prebuilt interpolators, which are constructed if not present.

Parameters:logM (np.ndarray) – Input \(\log_{10}(M/h^{-1}M_\mathrm{sun})\)
Returns:\(d\ln\sigma/d\log M\)
Return type:np.ndarray
sigma_logM_int(logM_h)[source]

Return the value of \(\sigma(M,z)\) using the prebuilt interpolators, which are constructed if not present.

Parameters:logM (np.ndarray) – Input \(\log_{10}(M/h^{-1}M_\mathrm{sun})\)
Returns:\(\sigma(M,z)\)
Return type:np.ndarray

Mass Function Module

class EffectiveHalos.MassFunction.MassFunction(cosmology, mass_function_name='Bhattacharya', verb=False, **mass_params)[source]

Class to hold a mass function for halos and associated bias.

Implemented Mass Functions:

  • Sheth-Tormen: Sheth & Tormen 1999 analytic mass function. This assumes virialized halos, and uses the critical density from Nakamura & Suto 1997.
  • Tinker: Tinker et al. 2010, eq. 8. This assume a spherical overdensity, the value of which can be specified.
  • Crocce: Crocce et al. 2009, eq. 22. Calibrated from Friends-of-Friends halos with linking length 0.2
  • Bhattacharya: Bhattacharya et al. 2010, eq. 12. Calibrated from Friends-of-Friends halos with linking length 0.2

Implemented Bias Functions:

  • Sheth-Tormen Sheth-Tormen 2001, eq. 8 Associated to the ‘Sheth-Tormen’ mass function.
  • Tinker: Tinker et al. 2010, eq. 15. Associated to the ‘Tinker’ mass function.
  • Crocce: Peak-background split derivation from the ‘Crocce’ mass function of eq. 22, Crocce et al. 2009.
  • Bhattacharya: Bhattacharya et al. 2010, eq. 18. Associated to the ‘Bhattacharya’ mass function.
Parameters:
  • cosmology (Cosmology) – Class instance containing relevant cosmological information
  • mass_function_name (str) – Mass function to use (see above), default: ‘Crocce’
  • mass_param (kwargs) – Any additional parameters to pass to the class. These include: - tinker_overdensity: (Only for the Tinker mass function): spherical overdensity defining halos, default: 200
Keyword Arguments:
 

verb (bool) – If true output useful messages througout run-time, default: False.

linear_halo_bias(m_h)[source]

Compute the linear halo bias, from the peak background split.

Associated bias functions are available for each mass function, and more can be user-defined. See the class description for details of the loaded parametrizations.

Parameters:m_h (np.ndarray) – Array of masses in \(h^{-1}M_\mathrm{sun}\) units.
Returns:Linear Eulerian halo bias (dimensionless)
Return type:np.ndarray
mass_function(m_h)[source]

Return the mass function, equal to the number density of halos per unit logarithmic mass interval. This assumes the existence of a universal mass function, with

\[dn/d\log_{10}M = f(\sigma(M))\frac{\bar{\rho}_M}{M} \frac{d\ln\sigma(M)}{d\log_{10}(M)}\]

where \(f\) is the universal mass function, \(\bar{\rho}_M\) is the mean matter density at redshift zero and \(\sigma^2(M)\) is the overdensity variance on spheres with a radius given by the Lagrangian radius for mass \(M\).

For details of the available mass function parametrizations, see the class description.

Note

For efficiency, we return the mass function \(\frac{dn}{d\log_{10}(M)}\) rather than the standard form \(\frac{dn}{dM}\).

Parameters:m_h (np.ndarray) – Array of masses in \(h^{-1}M_\mathrm{sun}\) units.
Returns:Mass function, \(dn/d\log_{10}(M/h^{-1}M_\mathrm{sun})\) in \(h^3\mathrm{Mpc}^{-3}\) units
Return type:np.ndarray
second_order_bias(m_h)[source]

Compute the second order Eulerian bias, defined as \(\frac{4}{21}b_1^L + \frac{1}{2}b_2^L\) where \(b_1^L\) and \(b_2^L\) are the Lagrangian bias parameters.

Associated bias functions are available for each mass function, and more can be user-defined. See the class description for details of the loaded parametrizations.

Args: - m_h: Mass in \(h^{-1}M_\mathrm{sun}\) units.

Returns:Quadratic Eulerian halo bias (dimensionless)
Return type:np.ndarray

Halo Physics Module

class EffectiveHalos.HaloPhysics.HaloPhysics(cosmology, mass_function, concentration_name='Duffy', profile_name='NFW', min_logM_h=6, max_logM_h=17, npoints=100000, halo_overdensity=200, verb=False)[source]

Class to hold halo model quantities and relevant integrals.

Implemented Concentration Functions:

  • Duffy: Duffy et al. (2008) for virial-density haloes (second section in Table 1)

Implemented Halo Profiles:

  • NFW: Navarro, Frenk & White (1997) universal halo profile.
Parameters:
  • cosmology (Cosmology) – Instance of the Cosmology class containing relevant cosmology and functions.
  • mass_function (MassFunction) – Instance of the MassFunction class, containing the mass function and bias
  • concentration_name (str) – Concentration parametrization to use (see above), default: ‘Duffy’
  • profile_name (str) – Halo profile parametrization to use (see above), default: ‘NFW’
  • hyperparams (kwargs) – Any additional parameters to pass to the class (see below).
Keyword Arguments:
 
  • min_logM_h (float) – Minimum halo mass in \(\log_{10}(M/h^{-1}M_\mathrm{sun})\), default: 6
  • max_logM_h (float) – Maximum halo mass in \(\log_{10}(M/h^{-1}M_\mathrm{sun})\), default: 17
  • npoints (int) – Number of sampling points in mass for \(\sigma(M)\) interpolation and mass integrals, default: 1e5
  • halo_overdensity (float) – Characteristic halo overdensity in units of background matter density. Can be a fixed value or ‘virial’, whereupon the virial collapse overdensity relation of Bryan & Norman 1998 to construct this. Default: 200.
  • verb (bool) – If true output useful messages througout run-time, default: False.
halo_concentration(m_h)[source]

Compute the halo concentration \(c = r_\mathrm{virial} / r_\mathrm{scale}\).

For details of the available concentration parametrizations, see the class description.

Parameters:m_h (np.ndarray) – Mass in \(h^{-1}M_\mathrm{sun}\) units.
Returns:Array of concentration parameters.
Return type:np.ndarray
halo_profile(m_h, kh, norm_only=False)[source]

Compute the halo profile function in Fourier space; \(\rho(k|m) = \frac{m}{\bar{\rho}_M}u(k|m)\) where \(\bar{\rho}_M\) is the background matter density and \(u(k|m)\) is the halo profile.

We assume halos have a virial collapse overdensity here, based on the parametrization of Bryan & Norman 1998.

For details of the available profile parametrizations, see the class description.

Parameters:
  • m_h (np.ndarray) – Mass in \(h^{-1}M_\mathrm{sun}\) units.
  • kh (np.ndarray) – Wavenumber in h/Mpc units.
  • norm_only (bool) – Boolean, if set, just return the normalization factor \(m/\bar{\rho}_M\), default: False
Returns:

Halo profile \(\rho(k|m)\) or \(m/\bar{\rho}_M\), if the norm_only parameter is set.

Return type:

np.ndarray

Mass Integrals Module

class EffectiveHalos.MassIntegrals.MassIntegrals(cosmology, mass_function, halo_physics, kh_vector, min_logM_h=6.001, max_logM_h=16.999, npoints=10000, verb=False, m_low=-1)[source]

Class to compute and store the various mass integrals of the form

\[I_p^{q_1,q_2}(k_1,...k_p) = \int n(m)b^{(q_1)}(m)b^{(q_2)}\frac{m^p}{\rho_M^p}u(k_1|m)..u(k_p|m)dm\]

which are needed to compute the power spectrum model. Here \(b^{(q)}\) is the q-th order bias (with \(b^{0}=1\)), \(u(k|m)\) is the normalized halo profile and \(n(m)\) is the mass function.

All integrals are performed via Simpson’s rule over a specified mass range, and are simply returned if they are already computed.

For the \(I_1^{1,0} = I_1^1\) integral, the integral must be corrected to ensure that we recover the bias consistency relation \(I_1^1 \rightarrow 1\) as \(k \rightarrow 0\).

This requires an infinite mass range, so we instead approximate;

\[I_1^1(k)_{\mathrm{corrected}} = I_1^1(k) + ( 1 - I_1^1(0) ) \frac{u(k|m_min)}{u(k|0)}\]

for normalized halo profile \(u(k|m)\).

Note that this can also be used to compute \({}_iJ_p^{q_1,q_2}\) and \({}_iK_p^{q_1,q_2}[f]\) type integrals required for the exclusion counts covariance.

Parameters:
  • cosmology (Cosmology) – Instance of the Cosmology class containing relevant cosmology and functions.
  • mass_function (MassFunction) – Instance of the MassFunction class, containing the mass function and bias.
  • halo_physics (HaloPhysics) – Instance of the HaloPhysics class, containing the halo profiles and concentrations.
  • kh_vector (np.ndarray) – Array (or float) of wavenumbers in \(h\mathrm{Mpc}^{-1}\) units from which to compute mass integrals.
Keyword Arguments:
 
  • min_logM_h (float) – Minimum mass in \(\log_{10}(M/h^{-1}M_\mathrm{sun})\) units, default: 6.001.
  • max_logM_h (float) – Maximum mass in \(\log_{10}(M/h^{-1}M_\mathrm{sun})\) units, default: 16.999.
  • npoints (int) – Number of logarithmically spaced mass grid points, default: 10000.
  • verb (bool) – If true output useful messages througout run-time, default: False.
compute_I_00()[source]

Compute the I_0^0 integral, if not already computed.

Returns:Value of \(I_0^0\)
Return type:float
compute_I_01()[source]

Compute the I_0^1 integral, if not already computed.

Returns:Value of \(I_0^1\)
Return type:float
compute_I_02()[source]

Compute the I_0^2 integral, if not already computed.

Returns:Value of \(I_0^2\)
Return type:float
compute_I_10(apply_correction=False)[source]

Compute the I_1^0 integral, if not already computed. Also apply the correction noted in the class header if required.

When computing \({}_i J_1^1\) type integrals (over a finite mass bin), the correction should not be applied.

Keyword Arguments:
 apply_correction (bool) – Whether to apply the correction in the class header to ensure the bias consistency relation is upheld.
Returns:Array of \(I_1^0\) values for each k.
Return type:float
compute_I_11(apply_correction=True)[source]

Compute the \(I_1^1(k)\) integral, if not already computed. Also apply the correction noted in the class header if required.

When computing \({}_i J_1^1\) type integrals (over a finite mass bin), the correction should not be applied.

Keyword Arguments:
 apply_correction (bool) – Whether to apply the correction in the class header to ensure the bias consistency relation is upheld.
Returns:Array of \(I_1^1\) values for each k.
Return type:np.ndarray
compute_I_111()[source]

Compute the \(I_1^{1,1}(k)\) integral, if not already computed.

Returns:Array of \(I_1^{1,1}\) values for each k.
Return type:np.ndarray
compute_I_12(apply_correction=True)[source]

Compute the \(I_1^2(k)\) integral, if not already computed. Also apply the correction noted in the class header if required.

When computing \({}_i J_1^2\) type integrals (over a finite mass bin), the correction should not be applied.

Keyword Arguments:
 apply_correction (bool) – Whether to apply the correction in the class header to ensure the bias consistency relation is upheld.
Returns:Array of \(I_1^2\) values for each k.
Return type:np.ndarray
compute_I_20()[source]

Compute the \(I_2^0(k,k)\) integral, if not already computed. Note that we assume both k-vectors are the same here.

Returns:Array of \(I_2^0\) values for each k.
Return type:np.ndarray
compute_I_21()[source]

Compute the \(I_2^1(k,k)\) integral, if not already computed. Note that we assume both k-vectors are the same here.

Returns:Array of \(I_2^1\) values for each k.
Return type:np.ndarray
compute_K_PTheta_11(alpha, PTheta_interpolator)[source]

Compute the \(K_2^1[P st \Theta](k)\) integral, if not already computed. \(\Theta\) is the Fourier transform of the exclusion window function which is convolved with the power spectrum.

Parameters:
  • alpha (float) – Dimensionless ratio of exclusion to Lagrangian halo radius
  • PTheta_interpolator (interp1d) – Interpolator for the non-linear \(S(R_\mathrm{ex})\) function
Returns:

Array of \(K_1^1[Pst \Theta](k)\) values for each k.

Return type:

np.ndarray

compute_K_S_01(alpha, S_L_interpolator)[source]

Compute the \(K_0^1[S](k)\) integral, if not already computed. \(S\) is the integral of the 2PCF windowed by the halo exclusion function of radius \(R_\mathrm{ex}\).

Parameters:
  • alpha (float) – Dimensionless ratio of exclusion to Lagrangian halo radius
  • S_L_interpolator (interp1d) – Interpolator for the linear \(S(R_\mathrm{ex})\) function
Returns:

Array of \(K_0^1[S](k)\) values for each k.

Return type:

np.ndarray

compute_K_S_21(alpha, S_NL_interpolator)[source]

Compute the \(K_2^1[S](k)\) integral, if not already computed. \(S\) is the integral of the 2PCF windowed by the halo exclusion function of radius \(R_\mathrm{ex}\). Note this function uses the non-linear form.

Parameters:
  • alpha (float) – Dimensionless ratio of exclusion to Lagrangian halo radius
  • S_NL_interpolator (interp1d) – Interpolator for the non-linear \(S(R_\mathrm{ex})\) function
Returns:

Array of \(K_2^1[S](k)\) values for each k.

Return type:

np.ndarray

compute_K_Theta_01(alpha)[source]

Compute the \(K_0^1[\Theta](k)\) integral, if not already computed. \(Theta\) is the Fourier transform of the exclusion window function.

Parameters:alpha (float) – Dimensionless ratio of exclusion to Lagrangian halo radius
Returns:Array of \(K_0^1[\Theta](k)\) values for each k.
Return type:np.ndarray
compute_K_Theta_10(alpha)[source]

Compute the \(K_1^0[\Theta](k)\) integral, if not already computed. \(Theta\) is the Fourier transform of the exclusion window function.

Parameters:alpha (float) – Dimensionless ratio of exclusion to Lagrangian halo radius
Returns:Array of \(K_1^0[\Theta](k)\) values for each k.
Return type:np.ndarray
compute_K_V_11(alpha)[source]

Compute the \(K_1^1[V](k)\) integral, if not already computed. :mathrm:`V` is the volume of the exclusion window function.

Parameters:alpha (float) – Dimensionless ratio of exclusion to Lagrangian halo radius
Returns:Array of \(K_1^1[V](k)\) values for each k.
Return type:np.ndarray
compute_K_V_20(alpha)[source]

Compute the \(K_2^0[V](k)\) integral, if not already computed. :mathrm:`V` is the volume of the exclusion window function.

Parameters:alpha (float) – Dimensionless ratio of exclusion to Lagrangian halo radius
Returns:Array of \(K_2^0[V](k)\) values for each k.
Return type:np.ndarray

Halo Model Module

class EffectiveHalos.HaloModel.HaloModel(cosmology, mass_function, halo_physics, kh_vector, kh_min=0, verb=False)[source]

Class to compute the non-linear power spectrum from the halo model of Philcox et al. 2020.

The model power is defined as

\[P_\mathrm{model} = I_1^1(k)^2 P_\mathrm{NL}(k) W^2(kR) + I_2^0(k,k)\]

where \(I_p^q\) are mass function integrals defined in the MassIntegrals class, \(P_\mathrm{NL}\) is the 1-loop non-linear power spectrum from Effective Field Theory and \(W(kR)\) is a smoothing window on scale R.

Parameters:
  • cosmology (Cosmology) – Instance of the Cosmology class containing relevant cosmology and functions.
  • mass_function (MassFunction) – Instance of the MassFunction class, containing the mass function and bias.
  • halo_physics (HaloPhysics) – Instance of the HaloPhysics class, containing the halo profiles and concentrations.
  • kh_vector (np.ndarray) – Vector of wavenumbers (in \(h/\mathrm{Mpc}\) units), for which power spectrum will be computed.
Keyword Arguments:
 
  • kh_min – Minimum k vector in the simulation (or survey) region in \(h/\mathrm{Mpc}\) units. Modes below kh_min are set to zero, default: 0.
  • verb (bool) – If true, output useful messages througout run-time, default: False.
compute_one_loop_only_power()[source]

Compute the one-loop SPT power from the linear power spectrum in the Cosmology class. This returns the one-loop power evaluated at the wavenumber vector specfied in the class initialization. When first called, this computes an interpolator function, which is used in this and subsequent calls.

Returns:Vector of 1-loop power \(P_\mathrm{1-loop}(k)\) for the input k-vector.
Return type:np.ndarray
compute_resummed_linear_power()[source]

Compute the IR-resummed linear power spectrum, using the linear power spectrum in the Cosmology class.

The output power is defined by

\[P_\mathrm{lin, IR}(k) = P_\mathrm{lin, nw}(k) + P_\mathrm{lin, w}(k)e^{-k^2\Sigma^2}\]

where ‘nw’ and ‘w’ refer to the no-wiggle and wiggle parts of the linear power spectrum and \(\Sigma^2\) is the BAO damping scale (computed in the _prepare_IR_resummation function)

If already computed, the IR resummed linear power is simply returned.

Returns:Vector of IR-resummed linear power \(P_\mathrm{lin,IR}(k)\) for the input k-vector.
Return type:np.ndarray
compute_resummed_one_loop_power()[source]

Compute the IR-resummed linear-plus-one-loop power spectrum, using the linear power spectrum in the Cosmology class.

The output power is defined by

\[P_\mathrm{lin+1, IR}(k) = P_\mathrm{lin, nw}(k) + P_\mathrm{1-loop, nw}(k) + e^{-k^2\Sigma^2} [ P_\mathrm{lin, w}(k) (1 + k^2\Sigma^2) + P_\mathrm{1-loop,w}(k) ]\]

where ‘nw’ and ‘w’ refer to the no-wiggle and wiggle parts of the linear / 1-loop power spectrum and \(Sigma^2\) is the BAO damping scale (computed in the _prepare_IR_resummation function)

Returns:Vector of IR-resummed linear-plus-one-loop power \(P_\mathrm{lin+1,IR}(k)\) for the input k-vector.
Return type:np.ndarray
halo_model(cs2, R, pt_type='EFT', pade_resum=True, smooth_density=True, IR_resum=True, include_neutrinos=True, return_terms=False)[source]

Compute the non-linear halo-model power spectrum to one-loop order, with IR corrections and counterterms. Whilst we recommend including all non-linear effects, these can be optionally removed with the Boolean parameters.

This is similar to the ‘non_linear_power()’ function, but includes the halo mass integrals, and is the complete model of the matter power spectrum at one-loop-order in our approximations. Note that the function requires two free parameters; the smoothing scale R and the effective squared sound-speed \(c_s^2\), which cannot be predicted from theory. (Note that \(c_s^2<0\) is permissible).

For massive neutrino cosmologies, we assume that the matter power spectrum is given by a mass-fraction-weighted sum of the halo model CDM+baryon power spectrum, linear neutrino spectrum and linear neutrino cross CDM+baryon spectrum. This is a good approximation in practice (i.e. including halo-model effects only for the CDM+baryon component.) The function can return either the halo-model CDM+baryon power spectrum (suitable for comparison to CDM+baryon power spectra) or the combined CDM+baryon+neutrino power spectrum (suitable for comparison to matter spectra) using the ‘include_neutrinos’ flag. When ‘include_neutrinos’ is specified the model has three components; the weighted two-halo CDM+baryon part, the weighted one-halo CDM+baryon part and the weighted linear neutrino and cross spectra. The sum of all three and the first two individually are returned by the ‘return_terms’ command.

For further details, see the class description.

Parameters:
  • cs2 (float) – Squared-speed-of-sound counterterm \(c_s^2\) in \((h^{-1}\mathrm{Mpc})^2\) units. (Unused if pt_type is not “EFT”)
  • R (float) – Smoothing scale in \(h^{-1}Mpc\). This is a free parameter of the model. (Unused if smooth_density = False)
Keyword Arguments:
 
  • pt_type (str) – Which flavor of perturbation theory to adopt. Options ‘EFT’ (linear + 1-loop + counterterm), ‘SPT’ (linear + 1-loop), ‘Linear’, default: ‘EFT’
  • pade_resum (bool) – If True, use a Pade resummation of the counterterm \(k^2/(1+k^2) P_\mathrm{lin}\) rather than \(k^2 P_\mathrm{lin}(k)\), default: True
  • smooth_density (bool) – If True, smooth the density field on scale R, i.e. multiply power by W(kR)^2, default: True
  • IR_resum (bool) – If True, perform IR resummation on the density field to resum non-perturbative long-wavelength modes, default: True
  • include_neutrinos (bool) – If True, return the full power spectrum of CDM+baryons+neutrinos (with the approximations given above). If False, return only the CDM+baryon power spectrum. This has no effect in cosmologies without massive neutrinos, default: True.
  • return_terms (bool) – If True, return the one- and two-halo CDM+baryon halo-model terms in addition to the combined power spectrum model, default: False
Returns:

Non-linear halo model power spectrum \(P_\mathrm{halo}\) evaluated at the input k-vector. np.ndarray: One-halo power spectrum term (if return_terms is true) np.ndarray: Two-halo power spectrum term (if return_terms is true)

Return type:

np.ndarray

non_linear_power(cs2, R, pt_type='EFT', pade_resum=True, smooth_density=True, IR_resum=True, include_neutrinos=True)[source]

Compute the non-linear power spectrum to one-loop order, with IR corrections and counterterms. Whilst we recommend including all non-linear effects, these can be optionally removed with the Boolean parameters. Setting (pt_type=’Linear’, pade_resum=False, smooth_density=False, IR_resum = False) recovers the standard halo model prediction.

Including all relevant effects, this is defined as

\[P_\mathrm{NL}(k, R, c_s^2) = [P_\mathrm{lin}(k) + P_\mathrm{1-loop}(k) + P_\mathrm{counterterm}(k;c_s^2)] W(kR)\]

where

\[P_\mathrm{counterterm}(k;c_s^2) = - c_s^2 \frac{k^2 }{(1 + k^2)} P_\mathrm{lin}(k)\]

is the counterterm, and IR resummation is applied to all spectra.

This computes the relevant loop integrals if they haven’t already been computed. The function returns \(P_\mathrm{NL}\) given smoothing scale R and effective squared sound-speed \(c_s^2\).

For massive neutrino cosmologies, we assume that the matter power spectrum is given by a mass-fraction-weighted sum of the non-linear CDM+baryon power spectrum, linear neutrino spectrum and linear neutrino cross CDM+baryon spectrum. This is a good approximation for the halo model spectra (i.e. including non-linear effects only for the CDM+baryon component.) The function can return either the non-linear CDM+baryon power spectrum or the combined CDM+baryon+neutrino power spectrum using the ‘include_neutrinos’ flag.

Parameters:
  • cs2 (float) – Squared-speed-of-sound counterterm \(c_s^2\) in \((h^{-1}\mathrm{Mpc})^2\) units. (Unused if pt_type is not “EFT”)
  • R (float) – Smoothing scale in \(h^{-1}Mpc\). This is a free parameter of the model. (Unused if smooth_density = False)
Keyword Arguments:
 
  • pt_type (str) – Which flavor of perturbation theory to adopt. Options ‘EFT’ (linear + 1-loop + counterterm), ‘SPT’ (linear + 1-loop), ‘Linear’, default: ‘EFT’
  • pade_resum (bool) – If True, use a Pade resummation of the counterterm \(k^2/(1+k^2) P_\mathrm{lin}\) rather than \(k^2 P_\mathrm{lin}(k)\), default: True
  • smooth_density (bool) – If True, smooth the density field on scale R, i.e. multiply power by W(kR)^2, default: True
  • IR_resum (bool) – If True, perform IR resummation on the density field to resum non-perturbative long-wavelength modes, default: True
  • include_neutrinos (bool) – If True, return the full power spectrum of CDM+baryons+neutrinos (with the approximations given above). If False, return only the CDM+baryon power spectrum. This has no effect in cosmologies without massive neutrinos, default: True.
Returns:

Non-linear power spectrum \(P_\mathrm{NL}\) evaluated at the input k-vector.

Return type:

np.ndarray

Counts Covariance Module

class EffectiveHalos.CountsCovariance.CountsCovariance(cosmology, mass_function, halo_physics, kh_vector, mass_bins, volume, kh_min=0, pt_type='EFT', pade_resum=True, smooth_density=True, IR_resum=True, npoints=1000, verb=False)[source]

Class to compute the covariance of cluster counts and the non-linear power spectrum using the halo model of Philcox et al. 2020. We provide routines for both the \(N_i\)-\(N_j\) and \(N_i\)-\(P(k)\) covariance where \(N_i\) is the halo count in a mass bin defined by [\(m_{\mathrm{low},i}\), \(m_{\mathrm{high},i}\)]

In the Effective Halo Model, the covariance between \(X\) and \(Y\) is defined as

\[\mathrm{cov}(X,Y) = \mathrm{cov}_\mathrm{intrinsic}(X,Y) + \mathrm{cov}_\mathrm{exclusion}(X,Y) + \mathrm{cov}_\mathrm{super-sample}(X,Y).\]

The full expressions for the cluster auto-covariance and cross-covariance with the power spectrum are lengthy but can be found in Philcox et al. (2020). These depend on mass function integrals, \(I_p^q\), \({}_iJ_p^q\) and \({}_iK_p^q[f]\) which are computed in the MassIntegrals class for mass bin i, \(P_{NL}\) is the 1-loop non-linear power spectrum from Effective Field Theory and \(W(kR)\) is a smoothing window on scale R.

Parameters:
  • cosmology (Cosmology) – Class containing relevant cosmology and functions.
  • mass_function (MassFunction) – Class containing the mass function and bias.
  • halo_physics (HaloPhysics) – Class containing the halo profiles and concentrations.
  • kh_vector (np.ndarray) – Vector of wavenumbers (in \(h/\mathrm{Mpc}\) units), for which power spectra will be computed.
  • mass_bins (np.ndarray) – Array of mass bin edges, in \(h^{-1}M_\mathrm{sun}\) units. Must have length N_bins + 1.
  • volume – Volume of the survey in \((h^{-1}\mathrm{Mpc})^3\).
Keyword Arguments:
 
  • kh_min – Minimum k vector in the simulation (or survey) region in \(h/\mathrm{Mpc}\) units. Modes below kh_min are set to zero, default 0.
  • pt_type (str) – Which flavor of perturbation theory to adopt. Options ‘EFT’ (linear + 1-loop + counterterm), ‘SPT’ (linear + 1-loop), ‘Linear’, default: ‘EFT’
  • pade_resum (bool) – If True, use a Pade resummation of the counterterm \(k^2/(1+k^2) P_\mathrm{lin}\) rather than \(k^2 P_\mathrm{lin}(k)\), default: True
  • smooth_density (bool) – If True, smooth the density field on scale R, i.e. multiply power by W(kR)^2, default: True
  • IR_resum (bool) – If True, perform IR resummation on the density field to resum non-perturbative long-wavelength modes, default: True
  • npoints (int) – Number of mass bins to use in numerical integration, default: 1000
  • verb (bool) – If true output useful messages througout run-time, default: False.
NN_covariance(cs2, R, alpha, sigma2_volume=-1, use_exclusion=True, use_SSC=True)[source]

Compute the full covariance matrix of cluster counts \(N_i, N_j\) as defined in the class description.

An important parameter is \(\sigma^2(V)\), the variance of the (linear) density field across the survey or simulation box region. If this is not specified, it will be computed from the volume of the survey, assuming spherical symmetry. Note that this is rarely a valid assumption in practice.

Furthermore, note that the \(c_s^2\) and \(R\) parameters have only a minor impact on the covariances here, whilst the \(lpha\) parameter is important, since it controls halo exclusion.

Using the parameters ‘use_exclusion’ and ‘use_SSC’ the user can choose which parts of the covariance should be returned.

Parameters:
  • cs2 (float) – Squared-speed-of-sound \(c_s^2\) counterterm in \((h^{-1}\mathrm{Mpc})^2\) units. This should be set by fitting the power spectrum model. (Unused if pt_type is not “EFT”)
  • R (float) – Smoothing scale in :math:h^{-1}`mathrm{Mpc}`. This should be set by fitting the power spectrum model. (Unused if smooth_density = False)
  • alpha (float) – Dimensionless ratio of the halo exclusion radius to the halo Lagrangian radius. (Unused if use_exclusion = False)
Keyword Arguments:
 
  • sigma2_volume (float) – The variance of the linear density field across the survey. This will be computed from the survey volume, assuming isotropy, if not provided. (Unused if use_SSC = False)
  • use_excluson (bool) – Whether to include the halo exclusion terms, default: True
  • use_SSC (bool) – Whether to include the super-sample covariance (SSC) terms, default: True
Returns:

Two-dimensional array of \(\mathrm{cov}(N_i,N_j)\) with shape (N_bins, N_bins) for N_bins mass bins.

Return type:

np.ndarray

NP_covariance(cs2, R, alpha, sigma2_volume=-1, use_exclusion=True, use_SSC=True)[source]

Compute the full covariance matrix of cluster counts and the matter power spectrum \(N_i, P(k)\) as defined in the class description.

An important parameter is \(\sigma^2(V)\), the variance of the (linear) density field across the survey or simulation box region. If this is not specified, it will be computed from the volume of the survey, assuming spherical symmetry. Note that this is rarely a valid assumption in practice.

Using the parameters ‘use_exclusion’ and ‘use_SSC’ the user can choose which parts of the covariance should be returned.

Parameters:
  • cs2 (float) – Squared-speed-of-sound \(c_s^2\) counterterm in \((h^{-1}\mathrm{Mpc})^2\) units. This should be set by fitting the power spectrum model. (Unused if pt_type is not “EFT”)
  • R (float) – Smoothing scale in :math:h^{-1}`mathrm{Mpc}`. This should be set by fitting the power spectrum model. (Unused if smooth_density = False)
  • alpha (float) – Dimensionless ratio of the halo exclusion radius to the halo Lagrangian radius. (Unused if use_exclusion = False)
Keyword Arguments:
 
  • sigma2_volume (float) – The variance of the linear density field across the survey. This will be computed from the survey volume, assuming isotropy, if not provided. (Unused if use_SSC = False)
  • use_excluson (bool) – Whether to include the halo exclusion terms, default: True
  • use_SSC (bool) – Whether to include the super-sample covariance (SSC) terms, default: True
Returns:

Two-dimensional array of \(\mathrm{cov}(N_i,P(k))\) with shape (N_bins, N_k) for N_bins mass bins and N_k power spectrum bins.

Return type:

np.ndarray