nbodykit.cosmology.cosmology¶
Functions
|
Convert an astropy cosmology object to a dictionary of parameters suitable for initializing a Cosmology object. |
|
|
|
Check if |
|
Compile the input args of Cosmology object to the input parameters (pars) to a |
|
|
|
merge moreargs into args. |
Decorator that adds the |
Classes
|
A cosmology calculator based on the CLASS binding in |
- nbodykit.cosmology.cosmology.astropy_to_dict(cosmo)[source]¶
Convert an astropy cosmology object to a dictionary of parameters suitable for initializing a Cosmology object.
- nbodykit.cosmology.cosmology.check_deprecated_init(args, kwargs)[source]¶
Check if
kwargs
uses the (now deprecated) signature ofCosmology
prior to version 0.2.6.If using the deprecated syntax, this returns the necessary arguments for the new signature, and
None
otherwise.
- nbodykit.cosmology.cosmology.compile_args(args)[source]¶
Compile the input args of Cosmology object to the input parameters (pars) to a
Cosmology
object.A variety of defaults are set to tune CLASS for quantities used in large scale structures.
- Difference between pars and args:
anything that is valid pars is also valid args.
after replacing our customizations in args, we get pars.
Note that CLASS will check for additional conflicts.
see
merge_args()
- nbodykit.cosmology.cosmology.merge_args(args, moreargs)[source]¶
merge moreargs into args.
Those defined in moreargs takes priority than those defined in args.
see
compile_args()
- nbodykit.cosmology.cosmology.store_user_kwargs()[source]¶
Decorator that adds the
_user_kwargs
attribute to the class to track which arguments the user actually supplied.
- class nbodykit.cosmology.cosmology.Cosmology(h=0.67556, T0_cmb=2.7255, Omega0_b=0.0482754208891869, Omega0_cdm=0.26377065934278865, N_ur=None, m_ncdm=[0.06], P_k_max=10.0, P_z_max=100.0, gauge='synchronous', n_s=0.9667, nonlinear=False, verbose=False, **kwargs)[source]¶
A cosmology calculator based on the CLASS binding in
classylss
.It is a collection of all method provided by the CLASS interfaces. The object is immutable. To obtain an instance with a new set of parameters use
clone()
ormatch()
.The individual interfaces can be accessed too, such that c.Spectra.get_transfer and c.get_transfer are identical.
Important
A default set of units is assumed. Those units are:
temperature: \(\mathrm{K}\)
distance: \(h^{-1} \mathrm{Mpc}\)
wavenumber: \(h \mathrm{Mpc}^{-1}\)
power: \(h^{-3} \mathrm{Mpc}^3\)
density: \(10^{10} (M_\odot/h) (\mathrm{Mpc}/h)^{-3}\)
neutrino mass: \(\mathrm{eV}\)
time: \(\mathrm{Gyr}\)
\(H_0\): \((\mathrm{km} \ \mathrm{s^{-1}}) / (h^{-1} \ \mathrm{Mpc})\)
Notes
The default configuration assumes a flat cosmology, \(\Omega_{0,k}=0\). Pass
Omega0_k
as a keyword to specify the desired non-flat curvature.For consistency of variable names, the present day values can be passed with or without ‘0’ postfix, e.g.,
Omega0_cdm
is translated toOmega_cdm
as CLASS always uses the names without 0 as input parameters.By default, a cosmological constant (
Omega0_lambda
) is assumed, with its density value inferred by the curvature condition.Non-cosmological constant dark energy can be used by specifying the
w0_fld
,wa_fld
, and/orOmega_fld
values.To pass in CLASS parameters that are not valid Python argument names, use the dictionary/keyword arguments trick, e.g.
Cosmology(..., **{'temperature contributions': 'y'})
Cosmology(**dict(c))
is not supposed to work; useCosmology.from_dict(dict(c))
.
- Parameters
h (float) – the dimensionless Hubble parameter
T0_cmb (float) – the temperature of the CMB in Kelvins
Omega0_b (float) – the current baryon density parameter, \(\Omega_{b,0}\). Currently unrealistic cosmology where Omega_b == 0 is not supported.
Omega0_cdm (float) – the current cold dark matter density parameter, \(\Omega_{cdm,0}\)
N_ur (float) – the number of ultra-relativistic (massless neutrino) species; the default number is inferred based on the number of massive neutrinos via the following logic: if you have respectively 1,2,3 massive neutrinos and use the default
T_ncdm
value (0.71611 K), designed to give m/omega of 93.14 eV, and you wish to haveN_eff=3.046
in the early universe, thenN_ur
is set to 2.0328, 1.0196, 0.00641, respectively.m_ncdm (list, None) – the masses (in eV) for all massive neutrino species; an empty list should be passed for no massive neutrinos. The default is a single massive neutrino with mass of 0.06 eV
P_k_max (float) – the maximum
k
value to compute power spectrum results to, in units of \(h/Mpc\)P_z_max (float) – the maximum redshift to compute power spectrum results to
gauge (str,) – either synchronous or newtonian
n_s (float) – the tilt of the primordial power spectrum
nonlinear (bool) – whether to compute nonlinear power spectrum results via HaloFit
verbose (bool) – whether to turn on the default CLASS logging for all submodules
**kwargs – extra keyword parameters to pass to CLASS. Mainly used to pass-in parameter names that are not valid Python function argument names, e.g.
temperature contributions
, ornumber count contributions
. Users should be wary of configuration options that may conflict with the base set of parameters. To override parameters, chain the result withclone()
.
- Attributes
Methods
clone
(**kwargs)Create a new cosmology based on modification of self, with the input keyword parameters changed.
from_astropy
(cosmo, **kwargs)Initialize and return a
Cosmology
object from a subclass ofastropy.cosmology.FLRW
.from_dict
(pars)Creates a Cosmology from a pars dictionary.
from_file
(filename, **kwargs)Initialize a
Cosmology
object from the CLASS parameter filematch
([sigma8, Omega0_cb, Omega0_m])Creates a new cosmology that matches a derived parameter.
Initialize and return a subclass of
astropy.cosmology.FLRW
from theCosmology
class.Attributes
Methods
- property Omega0_cb¶
The total density of CDM and Baryon.
This is not an input CLASS parameter. To scale
Omega0_cb
, usematch()
.
- __iter__()[source]¶
Allows dict() to be used on class. Use
from_dict()
to reconstruct an instance.
- clone(**kwargs)[source]¶
Create a new cosmology based on modification of self, with the input keyword parameters changed.
- Parameters
**kwargs – keyword parameters to adjust
- Returns
a copy of self, with the input
kwargs
adjusted- Return type
- classmethod from_astropy(cosmo, **kwargs)[source]¶
Initialize and return a
Cosmology
object from a subclass ofastropy.cosmology.FLRW
.- Parameters
cosmo (subclass of
astropy.cosmology.FLRW
.) – the astropy cosmology instance**kwargs – extra keyword parameters to pass when initializing; they shall not be in conflict with the parameters inferred from cosmo. To override parameters, chain the result with
clone()
.
- Returns
the initialized cosmology object
- Return type
- classmethod from_dict(pars)[source]¶
Creates a Cosmology from a pars dictionary.
This is a rather ‘raw’ API. The dictionary must be readable by ClassEngine. Unlike
Cosmology(**args)
,pars
must not contain any convenient names defined here.
- classmethod from_file(filename, **kwargs)[source]¶
Initialize a
Cosmology
object from the CLASS parameter file
- match(sigma8=None, Omega0_cb=None, Omega0_m=None)[source]¶
Creates a new cosmology that matches a derived parameter. This is different from clone, where CLASS parameters are used.
Note that we only supoort matching one derived parameter at a time, because the matching is in general non-commutable.
- Parameters
- Return type
A new cosmology parameter where the derived parameter matches the given constrain.
- property sigma8¶
The amplitude of matter fluctuations at \(z=0\) in a sphere of radius \(r = 8 \ h^{-1}\mathrm{Mpc}\).
This is not an input CLASS parameter. To scale
sigma8
, usematch()
, which adjusts scalar amplitudeA_s
to achieve the desiredsigma8
.
- to_astropy()[source]¶
Initialize and return a subclass of
astropy.cosmology.FLRW
from theCosmology
class.- Returns
the astropy class holding the cosmology values
- Return type
subclass of
astropy.cosmology.FLRW