classylss.binding module

class classylss.binding.Background(ClassEngine engine)

Bases: object

C
G
H0
N_ncdm

The number of distinguishable ncdm (massive neutrino) species.

N_ur

The number of ultra-relativistic species. This is equal to:

N_{ur} = \Omega_{0,ur} / (7/8 (4/11)^{4/3} \Omega_{0,g}).

Neff

Effective number of relativistic species, summed over ultra-relativistic and ncdm species.

Omega0_b

Current density parameter for photons, \Omega_{b,0}.

Omega0_cdm

Current density parameter for cold dark matter, \Omega_{cdm,0}.

Omega0_dcdm

Current density parammeter for decaying cold dark matter, \Omega_{dcdm,0}.

Omega0_fld

Current density parameter for dark energy (fluid) \Omega_{fld, 0}.

Omega0_g

Current density parameter for photons, \Omega_{g,0}.

Omega0_k

Current density parameter for curvaturve, \Omega_{k,0}.

Omega0_lambda

Current density parameter for cosmological constant, \Omega_{\Lambda,0}.

Omega0_m

The sum of density parameters for all non-relativistic components, \Omega_{0,m}. The value differ from Astropy’s; the semantics is identical.

This is equal to:

\Omega_{0,m} = \Omega_{0,b} + \Omega_{0,cdm} + \Omega_{0,ncdm} + \Omega_{0,dcdm} - \Omega_{0,pncdm}.

Omega0_ncdm

Current density parameter for distinguishable (massive) neutrinos for each species as an array, \Omega_{0, ncdm}.

Omega0_ncdm_tot

Current total density parameter of all distinguishable (massive) neutrinos.

Omega0_pncdm
Omega0_pncdm_tot
Omega0_r

Current density parameter of radiation, \Omega_{0,r}. This is equal to:

\Omega_{0,r} = \Omega_{0,g} + \Omega_{0,\nu_r} + \Omega_{0,pncdm}.

Omega0_ur

Current density parameter of ultra-relativistic (massless) neutrinos, \Omega_{0,\nu_r}.

Omega_b(self, z)

Density parameter of baryons.

Omega_cdm(self, z)

Density parameter of cold dark matter.

Omega_fld(self, z)

Density parameter of dark energy (fluid).

Omega_g(self, z)

Density parameter of photons.

Omega_k(self, z)

Density parameter of curvature.

Omega_lambda(self, z)

Density of dark energy (cosmological constant).

Omega_m(self, z)

Density parameter of non-relativistic (matter like) component, including non-relativistic part of massive neutrino. Unit

Omega_ncdm(self, z, species=None)

Density parameter of massive neutrinos.

Omega_pncdm(self, z, species=None)

Return \Omega_{pncdm} as a function redshift.

Omega_r(self, z)

Density parameter of relativistic (radiation like) component, including relativistic part of massive neutrino and massless neutrino.

Omega_ur(self, z)

Density parameter of ultra relativistic neutrinos.

T0_cmb

The current CMB temperature in Kelvins.

T0_ncdm

An array holding the current ncdm temperature in Kelvins for each species.

T_cmb(self, z)

The CMB temperature as a function of redshift.

T_ncdm(self, z)

The ncdm temperature (massive neutrinos) as a function of redshift.

Return shape is (N_ncdm,) if N_ncdm == 1 else (len(z), N_ncdm)

a_max

The maximum scale factor for which results can be computed; it can be greater than 1.0.

a_today

An arbitrary number that sets the reference scaling factor. It shall be 1 usually.

age0

The current age of the universe in gigayears.

angular_diameter_distance(self, z)

Angular diameter distance in :math:`mathrm{Mpc}/h at a given redshift.

This gives the proper (sometimes called ‘physical’) transverse distance corresponding to an angle of 1 radian for an object at redshift z.

It is equal to the comoving transverse distance divided by 1+z.

See eq. 18 of astro-ph/9905116 for D_A(z).

comoving_distance(self, z)

Comoving line-of-sight distance in \mathrm{Mpc}/h at a given redshift.

The comoving distance along the line-of-sight between two objects remains constant with time for objects in the Hubble flow.

See eq. 15 of astro-ph/9905116 for D_C(z).

comoving_transverse_distance(self, z)

Comoving transverse distance in \mathrm{Mpc}/h at a given redshift.

This value is the transverse comoving distance at redshift z corresponding to an angular separation of 1 radian. This is the same as the comoving distance in a flat universe.

See eq. 16 of astro-ph/9905116 for D_M(z).

compute_for_z(self, z, int column)
data
efunc(self, z)

Function giving E(z), where the Hubble parameter is defined as H(z) = H_0 E(z).

efunc_prime(self, z)

Function giving dE(z) / da.

h

The dimensionless Hubble parameter.

hubble_function(self, z)

The Hubble function in CLASS units. Users should use efunc() instead.

hubble_function_prime(self, z)

d H / d tau ; d tau / da = 1 / (a ** 2 H) in class units; use efunc_prime() instead

luminosity_distance(self, z)

Luminosity distance in \mathrm{Mpc}/h at redshift z.

This is the distance to use when converting between the bolometric flux from an object at redshift z and its bolometric luminosity.

It is equal to the comoving transverse distance times 1+z.

See eq. 21 of astro-ph/9905116 for D_L(z).

m_ncdm

The masses of the distinguishable ncdm (massive neutrino) species, in units of eV.

p_ncdm(self, z, species=None)

Pressure of non-relative part of massive neutrino.

rho_b(self, z)

Density of baryons \rho_b as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_cdm(self, z)

Density of cold dark matter \rho_{cdm} as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_crit(self, z)

Critical density excluding curvature \rho_cs as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

This is defined as:

\rho_c(z) = \frac{3 H(z)^2}{8 \pi G}.

rho_fld(self, z)

Density of dark energy fluid \rho_{fld} as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_g(self, z)

Density of photons \rho_g as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_k(self, z)

Density of curvature \rho_k as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

Note: this is defined such that

\rho_\mathrm{crit} = \rho_\mathrm{tot} + \rho_k

rho_lambda(self, z)

Density of cosmological constant \rho_\Lambda as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_m(self, z)

Density of matter \rho_b as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_ncdm(self, z, species=None)

Density of non-relativistic part of massive neutrinos \rho_{ncdm} as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_r(self, z)

Density of radiation \rho_r as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

rho_tot(self, z)

Total density \rho_\mathrm{tot} as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}. It is usually close to 27.76.

rho_ur(self, z)

Density of ultra-relativistic radiation (massless neutrinos) \rho_{ur} as a function of redshift, in units of 10^{10} (M_\odot/h) (Mpc/h)^{-3}.

scale_independent_growth_factor(self, z)

Return the scale invariant growth factor D(a) for CDM perturbations.

This is the quantity defined by CLASS as index_bg_D in the background module.

scale_independent_growth_rate(self, z)

The scale invariant growth rate d\mathrm{ln}D/d\mathrm{ln}a for CDM perturbations.

This is the quantity defined by CLASS as index_bg_f in the background module.

tau(self, z)

Conformal time, equal to comoving distance when K = 0.0 (flat universe). In units of \mathrm{Mpc} as in CLASS.

time(self, z)

Proper time (age of universe) in gigayears.

w0_fld

Current fluid equation of state parameter, w_{0,fld}.

wa_fld

Fluid equation of state derivative, w_{a,fld}.

exception classylss.binding.ClassBadValueError

Bases: ValueError

Raised when Class could not compute the cosmology at this point.

This will be caught by the parameter extraction code to give an extremely unlikely value to this point

class classylss.binding.ClassEngine(pars={})

Bases: object

parameter_file
exception classylss.binding.ClassParserError

Bases: ValueError

exception classylss.binding.ClassRuntimeError

Bases: RuntimeError

class classylss.binding.Perturbs(ClassEngine engine)

Bases: object

P_z_max

The input parameter specifying the maximum redshift measured for power spectra.

gauge

The gauge name as a string.

k_max_for_pk

The input parameter specifying the maximum k value to compute spectra for in h \mathrm{Mpc}^{-1}.

class classylss.binding.Primordial(ClassEngine engine)

Bases: object

get_pk(self, k, mode='linear')

The primoridal spectrum at k. The units are such that:

P_L = 2 \pi^2 / k^3 T^2(k) P_\mathrm{primordial}

Parameters:

k : array_like

wavenumbers in h \mathrm{Mpc}^{-1} units.

get_primordial(self)

Return the primordial scalar and/or tensor spectrum depending on ‘modes’. ‘output’ must be set to something, e.g. ‘tCl’.

Returns:

primordial :

dictionary containing k-vector and primordial scalar and tensor P(k).

class classylss.binding.Spectra(ClassEngine engine)

Bases: object

A_s

The scalar amplitude of the primordial power spectrum at k_\mathrm{pivot}.

P_k_max

The maximum k value measured for power spectra in h \mathrm{Mpc}^{-1}.

P_k_min

The minimum k value for which power spectra have been computed in h \mathrm{Mpc}^{-1}.

This is computed from the ln_k array of the Spectra module.

data
get_pk(self, k, z)

Primary Power spectrum result (non-linear if enabled) on k and z array. K in h/Mpc units.

get_pklin(self, k, z)

Linear Power spectrum result (linear even if non-linear is enabled) on k and z array. K in h/Mpc units.

get_transfer(self, z, output_format='class')

Return the density and/or velocity transfer functions for all initial conditions today. You must include ‘dCl’ and ‘vCl’ in the list of ‘output’. The transfer functions can also be computed at higher redshift z provided that ‘z_pk’ has been set and that z is inside the region spanned by ‘z_pk’.

This function is not vectorized; because it returns a vector when ic_size is greater than 1, and I don’t understand ic_size.

Parameters:

z : redshift (default = 0)

output_format : (‘class’ or ‘camb’) Format transfer functions according to

CLASS convention (default) or CAMB convention.

Returns:

tk : array_like, containing transfer functions. Unlike CLASS, k here is in Mpc/h Units.

Note

With different cosmology the values of ‘k’ may be different.

has_pk_matter

Boolean flag specifying whether matter power spectra have been requested as output.

k_pivot

The primordial power spectrum pivot scale, where the primordial power is equal to A_s. Units of h \mathrm{Mpc}^{-1}.

ln_1e10_A_s

Return \log(10^{10}A_s).

n_s

The tilt of the primordial power spectrum.

nonlinear

Boolean flag specifying whether the power spectrum is nonlinear.

sigma8

The amplitude of matter fluctuations at z=0.

sigma8_z(self, z)

Return \sigma_8(z).

class classylss.binding.Thermo(ClassEngine engine)

Bases: object

rs_drag

The comoving sound horizon at baryon drag, in \mathrm{Mpc}/h.

rs_rec

The comoving sound horizon at recombination, z=z_\mathrm{rec}. Units of \mathrm{Mpc}/h.

tau_reio

The reionization optical depth.

theta_s

The sound horizon angle at recombination, equal to r_s(z_\mathrm{rec}) / D_a(z_\mathrm{rec}).

z_drag

The baryon drag redshift.

z_rec

The redshift at which the visibility reaches its maximum; equals the recombination redshift.

z_reio

The reionization redshift.

classylss.binding.val2str(val)