Useful functions
- colibri.useful_functions.extrapolate(x, y, xmin, xmax, order)[source]
This function extrapolates a given function (y) defined in some points (x) to some other points external to the extension of x itself. The extrapolation is a power-law of an order which must be specified in input The points x must be linearly spaced, xmin and xmax must be smaller and greater than x.min() and x.max() respectively.
- Parameters:
- Returns:
x_ext (array) – Extended/extrapolated abscissa.
y_ext (array) – Extended/extrapolated ordinate.
- colibri.useful_functions.extrapolate_log(x, y, xmin, xmax)[source]
This function extrapolates a given function (y) defined in some points (x) to some other points external to the extension of x itself. The extrapolation is a power-law of an order which must be specified in input The points x must be log-spaced, xmin and xmax must be smaller and greater than x.min() and x.max() respectively.
- Parameters:
- Returns:
x_ext (array) – Extended/extrapolated abscissa.
y_ext (array) – Extended/extrapolated ordinate.
- colibri.useful_functions.neutrino_masses(M_nu, hierarchy='normal')[source]
Value of neutrino masses according to particle physics and the Solar Neutrino Experiment. Taken from Pylians codes by Francisco Villaescusa-Navarro.
- Parameters:
M_nu (float) – Value of the sum of neutrino masses (in \(eV\)).
hierarchy (string, default = ‘normal’) –
Set the neutrino hierarchy.
’normal’, ‘Normal’, ‘NH’, ‘N’, ‘n’ for normal hierarchy.
’inverted’, ‘Inverted’, ‘IH’, ‘I’, ‘i’ for inverted hierarchy.
’degenerate’, ‘Degenerate’, ‘DH’, ‘deg’, ‘D’, ‘d’ for degenerate hierarchy.
- Returns:
m1, m2, m3
- Return type:
values of the three neutrino masses \(\mathrm{eV}\).
- colibri.useful_functions.phase_space_distribution(momentum, mass, temperature, multiplicity, chemical_potential, sign='+')[source]
Returns either the Fermi-Dirac or the Bose-Einstein distribution.
- Parameters:
- Returns:
array in \(\mathrm{eV}^{-3} s^{-3}\)
- colibri.useful_functions.TopHat_window(x)[source]
Top-hat window function in Fourier space.
- Parameters:
x (array) – Abscissa
- Returns:
array
- colibri.useful_functions.Gaussian_window(x)[source]
Gaussian window function.
- Parameters:
x (array) – Abscissa.
- Returns:
array.
- colibri.useful_functions.Sharp_k_window(x, step=0.01)[source]
Sharp window function in Fourier space.
- Parameters:
x (array) – Abscissa.
step (float, default = 1e-2) – Transition width from 0 to 1.
- Returns:
array.
- colibri.useful_functions.Smooth_k_window(x, beta)[source]
Smooth window function in Fourier space.
- Parameters:
x (array) – Abscissa.
beta (float, default = 1e-2) – Transition width from 0 to 1.
- Returns:
array.
- colibri.useful_functions.smooth(y, box_pts)[source]
This routine smooths an array of a certain range of points.
- Parameters:
y (array) – Array to smooth.
box_pts (int) – Number of points over which to smooth.
- Returns:
array
- colibri.useful_functions.Nyquist_frequency(boxsize, grid)[source]
This routine returns the Nyquist frequency of a cosmological box where the density field is computed with a grid of a certain size.
- colibri.useful_functions.fundamental_frequency(boxsize)[source]
This routine returns the fundamental frequency of a cosmological box where the density field is computed with a grid of a certain size.
- Parameters:
boxsize (float) – Size of the cubic box in \(\mathrm{Mpc}/h\).
- Returns:
float
- colibri.useful_functions.sky_fraction(area)[source]
Returns the sky fraction given the survey size in square degrees.
- Parameters:
area (float) – Survey area in square degrees.
- Returns:
float
- colibri.useful_functions.feedback_suppression(k, z, log_Mc, eta_b, z_c)[source]
Suppression of the matter power spectrum according to the Baryon Correction Model (Schneider et al., 2015).
Warning
This function also exists in the class
colibri.cosmology.cosmo().- Parameters:
k (array) – Scales in units of \(h/\mathrm{Mpc}\).
z (array) – Redshifts.
log_Mc (float>12.1) – Feedback mass: all halos below the mass of 10.**log_Mc are stripped of their gas.
eta_b (float) – Ratio between the thermal velocity of the gas and the escape velocity from the halo.
z_c (float) – Scale redshift of feedback.
- Returns:
2D array of shape
(len(z), len(k))
- colibri.useful_functions.WDM_suppression(k, z, M_wdm, Omega_cdm, h, nonlinear=False)[source]
Suppression of the matter power spectrum due to (thermal) warm dark matter. In the linear case, the formula by https://arxiv.org/pdf/astro-ph/0501562.pdf is followed; otherwise the formula by https://arxiv.org/pdf/1107.4094.pdf is used. The linear formula is an approximation strictly valid only at \(k < 5-10 \ h/\mathrm{Mpc}\). The nonlinear formula has an accuracy of 2% level at \(z < 3\) and for masses larger than 0.5 keV.
Warning
This function also exists in the class
colibri.cosmology.cosmo(), whereOmega_cdmandhare set to the values fixed at initialization of the class.Warning
This function returns the total suppression in power. To obtain the suppression in the transfer function, take the square root of the output.
- Parameters:
k (array) – Scales in units of \(h/\mathrm{Mpc}\).
z (array) – Redshifts.
M_wdm (float) – Mass of the warm dark matter particle in keV.
Omega_cdm (float) – Total matter density parameter today
h (float) – Hubble constant in units of 100 km/s/Mpc
nonlinear (boolean, default = False) – Whether to return non-linear transfer function.
- Returns:
2D array of shape
(len(z), len(k))
- colibri.useful_functions.decaying_dark_matter_suppression(k, z, tau, f_ddm, Omega_b, Omega_m, h)[source]
Suppression of the matter power spectrum due to decaying dark matter (DDM), according to Hubert et al., 2021. It predicts the correct shape at up to \(k>10 h/\mathrm{Mpc}\) and \(z<2.35\).
Warning
This function returns the total suppression in power. To obtain the suppression in the transfer function, take the square root of the output.
- Parameters:
k (array) – Scales in units of \(h/\mathrm{Mpc}\).
z (array) – Redshifts.
tau (float) – Half-life time of the particle in Gyr
f_ddm (float between 0 and 1) – fraction of DDM.
- Returns:
2D array of shape
(len(z), len(k))
- colibri.useful_functions.fR_correction(k, z, f_R0, nonlinear=True)[source]
Enhancement of the matter power spectrum due to f(R) gravity. The formula used is from Winther et al. (2019)
Warning
This function returns the total suppression in power. To obtain the suppression in the transfer function, take the square root of the output.
- Parameters:
k (array) – Scales in units of \(h/\mathrm{Mpc}\).
z (array) – Redshifts.
f_R0 (float) – modified gravity amplitude
nonlinear (boolean, default = True) – whether to return the linear or nonlinear enhancement
- Returns:
2D array of shape
(len(z), len(k))
- colibri.useful_functions.compute_sigma_8(k, pk)[source]
This routine computes \(sigma_8\).
- Parameters:
k (array, default = []) – Scales in units of \(h/\mathrm{Mpc}\).
pk (array, default = []) – Power spectrum in units of \((\mathrm{Mpc}/h)^3\).
- Returns:
float
- colibri.useful_functions.WDM_temperature_vs_cmb(omega_wdm, m_wdm)[source]
This routine computes the temperature of thermal WDM in units of photon temperature given its mass and its density parameter.
- colibri.useful_functions.WDM_temperature(Omega_wdm, m_wdm, h=0.67, T_cmb=2.7255)[source]
This routine computes the temperature of thermal WDM given its mass and its density parameter.
- Parameters:
- Returns:
float, in kelvin.
- colibri.useful_functions.omega_wdm_from_mass_and_temperature(m_wdm, T_wdm_wrt_cmb)[source]
This routine computes the reduced density parameter of WDM given its mass and its temperature.
- colibri.useful_functions.Omega_wdm_from_mass_and_temperature(m_wdm, T_wdm, h=0.67, T_cmb=2.7255)[source]
This routine computes the reduced density parameter of WDM given its mass and its temperature.
- colibri.useful_functions.remove_bao(k_in, pk_in, k_low=0.028, k_high=0.45)[source]
This routine removes the BAOs from the input power spectrum and returns the no-wiggle power spectrum in \((\mathrm{Mpc}/h)^3\). Originally written by Mario Ballardini (you can find it in the montepython repository . )
- Parameters:
- Returns:
array, power spectrum without BAO.
- colibri.useful_functions.AP_factors(z, cosmo, cosmo_fid, massive_nu_approx=True)[source]
Compute the Alcock-Paczynski parallel and perpendicular factors.
- Parameters:
z (float) – redshift.
cosmo (
colibri.cosmology.cosmo()object) – current cosmology for which parameters will be computedcosmo_fid (
colibri.cosmology.cosmo()object) – fiducial cosmology for which probes are measuredmassive_nu_approx (boolean, default = True) – whether to assume neutrinos behave as pure matter at all redshifts
- Returns:
2 floats, \(q_\parallel\) and \(q_\perp\)
- colibri.useful_functions.AP_polar_coordinates_fourier_space(z, k_fid, mu_fid, cosmo, cosmo_fid, massive_nu_approx=True)[source]
Compute the Alcock-Paczynski corrected polar coordinates in Fourier space.
- Parameters:
z (float) – redshift.
k_fid (array) – scales in \(h/\mathrm{Mpc}\)
mu_fid (array) – cosines of angle w.r.t. line of sight.
cosmo (
colibri.cosmology.cosmo()object) – current cosmology for which parameters will be computedcosmo_fid (
colibri.cosmology.cosmo()object) – fiducial cosmology for which probes are measuredmassive_nu_approx (boolean, default = True) – whether to assume neutrinos behave as pure matter at all redshifts
- Returns:
two 2D arrays of shape
(len(s_fid), len(mu_fid))containing scales and angles in the new cosmology
- colibri.useful_functions.AP_polar_coordinates_configuration_space(z, s_fid, mu_fid, cosmo, cosmo_fid, massive_nu_approx=True)[source]
Compute the Alcock-Paczynski corrected polar coordinates in configuration space.
- Parameters:
z (float) – redshift.
s_fid (array) – scales in \(\mathrm{Mpc}/h\)
mu_fid (array) – cosines of angle w.r.t. line of sight.
cosmo (
colibri.cosmology.cosmo()object) – current cosmology for which parameters will be computedcosmo_fid (
colibri.cosmology.cosmo()object) – fiducial cosmology for which probes are measuredmassive_nu_approx (boolean, default = True) – whether to assume neutrinos behave as pure matter at all redshifts
- Returns:
two 2D arrays of shape
(len(s_fid), len(mu_fid))containing scales and angles in the new cosmology
- colibri.useful_functions.AP_cartesian_coordinates_fourier_space(z, k_par_fid, k_perp_fid, cosmo, cosmo_fid, massive_nu_approx=True)[source]
Compute the Alcock-Paczynski corrected Cartesian coordinates in Fourier space.
- Parameters:
z (float) – redshift.
k_par_fid (array) – parallel component of the separation wavevector in \(h/\mathrm{Mpc}\)
k_perp_fid (array) – perpendicular component of the separation wavevector in \(h/\mathrm{Mpc}\)
cosmo (
colibri.cosmology.cosmo()object) – current cosmology for which parameters will be computedcosmo_fid (
colibri.cosmology.cosmo()object) – fiducial cosmology for which probes are measuredmassive_nu_approx (boolean, default = True) – whether to assume neutrinos behave as pure matter at all redshifts
- Returns:
two 1D arrays containing scales in the new cosmology
- colibri.useful_functions.AP_cartesian_coordinates_configuration_space(z, s_par_fid, s_perp_fid, cosmo, cosmo_fid, massive_nu_approx=True)[source]
Compute the Alcock-Paczynski corrected Cartesian coordinates in configuration space.
- Parameters:
z (float) – redshift.
s_par_fid (array) – parallel component of the separation vector in \(\mathrm{Mpc}/h\)
s_perp_fid (array) – perpendicular component of the separation vector in \(\mathrm{Mpc}/h\)
cosmo (
colibri.cosmology.cosmo()object) – current cosmology for which parameters will be computedcosmo_fid (
colibri.cosmology.cosmo()object) – fiducial cosmology for which probes are measuredmassive_nu_approx (boolean, default = True) – whether to assume neutrinos behave as pure matter at all redshifts
- Returns:
two 1D arrays of shape containing scales in the new cosmology