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
kwargsuses the (now deprecated) signature ofCosmologyprior to version 0.2.6.If using the deprecated syntax, this returns the necessary arguments for the new signature, and
Noneotherwise.
-
nbodykit.cosmology.cosmology.compile_args(args)[source]¶ Compile the input args of Cosmology object to the input parameters (pars) to a
Cosmologyobject.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_kwargsattribute 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_kas 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_cdmis translated toOmega_cdmas 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_fldvalues.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_ncdmvalue (0.71611 K), designed to give m/omega of 93.14 eV, and you wish to haveN_eff=3.046in the early universe, thenN_uris 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
kvalue 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(self, \*\*kwargs)Create a new cosmology based on modification of self, with the input keyword parameters changed.
from_astropy(cosmo, \*\*kwargs)Initialize and return a
Cosmologyobject from a subclass ofastropy.cosmology.FLRW.from_dict(pars)Creates a Cosmology from a pars dictionary.
from_file(filename, \*\*kwargs)Initialize a
Cosmologyobject from the CLASS parameter filematch(self[, sigma8, Omega0_cb, Omega0_m])Creates a new cosmology that matches a derived parameter.
to_astropy(self)Initialize and return a subclass of
astropy.cosmology.FLRWfrom theCosmologyclass.Attributes
Methods
-
Omega0_cb¶ The total density of CDM and Baryon.
This is not an input CLASS parameter. To scale
Omega0_cb, usematch().
-
__iter__(self)[source]¶ Allows dict() to be used on class. Use
from_dict()to reconstruct an instance.
-
clone(self, **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
kwargsadjusted- Return type
-
classmethod
from_astropy(cosmo, **kwargs)[source]¶ Initialize and return a
Cosmologyobject 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),parsmust not contain any convenient names defined here.
-
classmethod
from_file(filename, **kwargs)[source]¶ Initialize a
Cosmologyobject from the CLASS parameter file
-
match(self, 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
- Returns
- Return type
A new cosmology parameter where the derived parameter matches the given constrain.
-
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_sto achieve the desiredsigma8.
-
to_astropy(self)[source]¶ Initialize and return a subclass of
astropy.cosmology.FLRWfrom theCosmologyclass.- Returns
the astropy class holding the cosmology values
- Return type
subclass of
astropy.cosmology.FLRW