Cosmology Functions

Some important functions for power spectrum and likelihood calculation

cosmofuncs.bar_fed(k, z, a_bary=0.0)[source]

Fitting formula for baryon feedback following equation 10 and Table 2 from J. Harnois-Deraps et al. 2014 (arXiv.1407.4301)

Param

k (np.ndarray): the wavevector

Param

z (np.ndarray): the redshift

Param

A_bary (float): the free amplitude for baryon feedback (Default: 0.0)

Returns

b^2(k,z): bias squared

cosmofuncs.cosmo_params(d: dict) → dict[source]

Given a dictionary for all the parameters, this function returns a dictionary only for the inputs to the emulator

Param

d (dict) - a dictionary with all the parameters (keys and values)

Returns

emu_param (dict) - a dictionary with inputs to the emulator

cosmofuncs.delete_module(module)[source]

Delete Class module - accumulates memory unnecessarily

Param

module (classy.Class) - the Class module

cosmofuncs.dictionary_params(d: dict) → Tuple[dict, dict, dict][source]

A dictionary for storing all the parameters

The parameters are organised in the following order (using CLASS and MontePython notations):

  • omega_cdm

  • omega_b

  • ln10^{10}A_s

  • n_s

  • h

  • M_tot

Param

par (np.ndarray): parameters for the inference

Returns

cosmo (dict) : a dictionary for the cosmology setup

Returns

other (dict) : a dictionary for the neutrino settings

Returns

neutrino (dict) : a dictionary for the neutrino

Returns

nuisance (dict) : a dictionary which contains the baryon feedback parameter

cosmofuncs.ds_ee(qs: list, quant: dict) → numpy.ndarray[source]

Calculates the double sum for the EE power spectrum

Param

qs (list) - a list of the functions Q

Param

quant (dict) - a dictionary containing all precomputed and basic quantities

Returns

dsum (np.ndarray) - the double sum

cosmofuncs.ds_gi(f_gi: numpy.ndarray, quant: dict) → numpy.ndarray[source]

Calculates the double sum for the II power spectrum. In this case, it is a single summation

Param

f_ii (np.ndarray) - an array for the function F_II

Param

quant (dict) - a dictionary containing all precomputed and basic quantities

Returns

dsum (np.ndarray) - the double sum

cosmofuncs.ds_ii(f_ii: numpy.ndarray, quant: dict) → numpy.ndarray[source]

Calculates the double sum for the II power spectrum. In this case, it is a single summation

Param

f_ii (np.ndarray) - an array for the function F_II

Param

quant (dict) - a dictionary containing all precomputed and basic quantities

Returns

dsum (np.ndarray) - the double sum

cosmofuncs.get_critical_density(small_h)[source]

The critical density of the Universe at redshift 0.

Param

small_h (float) - the Hubble parameter

Returns

rho_crit_0 (float) - the critical density at redshift zero

cosmofuncs.get_factor_ia(quant: dict, redshift: numpy.ndarray, amplitude: float, exponent=0.0) → numpy.ndarray[source]

Calculates F(chi) - equation 23 in Kohlinger et al. 2017.

Param

quant (dict) - a dictionary containingthe critical density, omega matter, linear groth rate, Hubble parameter

Param

redshift (np.ndarray) - a vector for the redshift

Param

amplitude (float) - the amplitude due to intrinsic alignment

Param

exponent (float) - an exponential factor (default: 0.0) - not used in inference

cosmofuncs.integration_q_ell(f_ell, chi, order)[source]

Calculate Q_ell for all possible pairs of chi

Param

f_ell (np.ndarray) : array for F_ell(chi) - see notes for further details)

Param

chi (np.ndarray) : array for the comoving radial distance

Param

order (int) : either 0 or 1 or 2

Returns

q_ell (np.ndarray) - array of size nells x nz (see notes for further details)

cosmofuncs.marg_params(d: dict)[source]

Returns different dictionaries to be used at different parts of the likelihood code.

Param

d (dict) - a dictionary with all the parameters (keys and values)

Returns

different dictionaries (based on conditions in the setting file)

cosmofuncs.mk_dict(l1: list, l2: list)[source]

Create a dictionary given a list of string and a list of numbers

Param

l1 (list) - list of string (parameter names)

Param

l2 (list) - list of values (values of each parameter)

Returns

d (dict) - a dictionary consisting of the keys and values

cosmofuncs.nuisance_params(d: dict) → dict[source]

Given a dictionary for all the parameters, this function returns a dictionary only for the inputs to the emulator

Param

d (dict) - a dictionary with all the parameters (keys and values)

Returns

emu_param (dict) - a dictionary with inputs to the emulator

cosmofuncs.ps_ee(index_i: int, index_j: int, heights: dict, dsum: numpy.ndarray) → numpy.ndarray[source]

Calculates the weak lensing power spectrum using the double sum approach

Param

index_i (int) - the i^th tomographic bin

Param

index_j (int) - th j^th tomographic bin

Param

heights (dict) - a dictionary with keys: h0, h1, h2

Param

dsum (np.ndarray) - part of the double sum

Returns

wl_ee (np.ndarray)- the EE weak lensing power spectrum

cosmofuncs.ps_gi(index_i: int, index_j: int, heights: dict, dsum: numpy.ndarray) → numpy.ndarray[source]

Calculates the weak lensing power spectrum using the double sum approach

Param

index_i (int) - the i^th tomographic bin

Param

index_j (int) - th j^th tomographic bin

Param

heights (dict) - a dictionary with keys: h0, h1, h2

Param

dsum (np.ndarray) - part of the double sum

Returns

wl_gi (np.ndarray)- the II weak lensing power spectrum

cosmofuncs.ps_ii(index_i: int, index_j: int, heights: dict, dsum: numpy.ndarray) → numpy.ndarray[source]

Calculates the weak lensing power spectrum using the double sum approach

Param

index_i (int) - the i^th tomographic bin

Param

index_j (int) - th j^th tomographic bin

Param

heights (dict) - a dictionary with keys: h0, h1, h2

Param

dsum (np.ndarray) - part of the double sum

Returns

wl_ii (np.ndarray)- the II weak lensing power spectrum

cosmofuncs.runTime(target: object, func: object, param: dict, timeout: int = 60)[source]

Execute the above function(s) within the allocated time frame

Param

target (object) - the target we want to time

Param

func (object) - the module for calculating the non-linear matter power spectrum

Param

param (dict) - a dictionary of input cosmology

Param

timeout (int) - the alloated time window to allow the code to run

Returns

state (bool) - True if CLASS runs successfully

Returns

results (dict) - if CLASS runs successfully

cosmofuncs.timeOut(func: object, param: dict, q: object) → None[source]

Calculate a (general) function within an allocated time frame

Param

func (object) - the module for calculating the non-linear matter power spectrum

Param

param (dict) - a dictionary of input cosmology

Param

q (object) - the multiprocessing queue

cosmofuncs.timeOutComponents(func: object, param: dict, q: object) → None[source]

Calculate the components of the non-linear matter power spectrum

Param

func (object) - the module for calculating the non-linear matter power spectrum

Param

param (dict) - a dictionary of input cosmology

Param

q (object) - the multiprocessing queue