API

Top level user functions:

Cosmology([H0, Om0, Ob0, Ode0, w0, Tcmb0, …]) Dict-like object for cosmological parameters and related calculations
Cosmology.clone(**kwargs) Returns a copy of this object, potentially with some changes.
Cosmology.from_astropy(cosmo[, n_s, sigma8]) Return a Cosmology instance from an astropy cosmology
Cosmology.to_class([transfer, linear_power_file]) Convert the object to a pyRSD.pygcl.Cosmology instance in order to interface with the CLASS code

There are builtin, default Cosmology objects available:

Name Source H0 Om Flat
WMAP5 Komatsu et al. 2009 70.2 0.277 Yes
WMAP7 Komatsu et al. 2011 70.4 0.272 Yes
WMAP9 Hinshaw et al. 2013 69.3 0.287 Yes
Planck13 Planck Collab 2013, Paper XVI 67.8 0.307 Yes
Planck15 Planck Collab 2015, Paper XIII 67.7 0.307 Yes

The Cosmology class inherits the following attributes from the astropy.cosmology.FLRW class:

H0 Return the Hubble constant as an ~astropy.units.Quantity at z=0
Neff Number of effective neutrino species
Ob0 Omega baryon; baryonic matter density/critical density at z=0
Ode0 Omega dark energy; dark energy density/critical density at z=0
Odm0 Omega dark matter; dark matter density/critical density at z=0
Ogamma0 Omega gamma; the density/critical density of photons at z=0
Ok0 Omega curvature; the effective curvature density/critical density at z=0
Om0 Omega matter; matter density/critical density at z=0
Onu0 Omega nu; the density/critical density of neutrinos at z=0
Tcmb0 Temperature of the CMB as ~astropy.units.Quantity at z=0
Tnu0 Temperature of the neutrino background as ~astropy.units.Quantity at z=0
critical_density0 Critical density as ~astropy.units.Quantity at z=0
h Dimensionless Hubble constant: h = H_0 / 100 [km/sec/Mpc]
has_massive_nu Does this cosmology have at least one massive neutrino species?
hubble_distance Hubble distance as ~astropy.units.Quantity
hubble_time Hubble time as ~astropy.units.Quantity
m_nu Mass of neutrino species

The Cosmology class inherits the following methods from the astropy.cosmology.FLRW class:

H(z) Hubble parameter (km/s/Mpc) at redshift z.
Ob(z) Return the density parameter for baryonic matter at redshift z.
Ode(z) Return the density parameter for dark energy at redshift z.
Odm(z) Return the density parameter for dark matter at redshift z.
Ogamma(z) Return the density parameter for photons at redshift z.
Ok(z) Return the equivalent density parameter for curvature at redshift z.
Om(z) Return the density parameter for non-relativistic matter at redshift z.
Onu(z) Return the density parameter for neutrinos at redshift z.
Tcmb(z) Return the CMB temperature at redshift z.
Tnu(z) Return the neutrino temperature at redshift z.
abs_distance_integrand(z) Integrand of the absorption distance.
absorption_distance(z) Absorption distance at redshift z.
age(z) Age of the universe in Gyr at redshift z.
angular_diameter_distance(z) Angular diameter distance in Mpc at a given redshift.
angular_diameter_distance_z1z2(z1, z2) Angular diameter distance between objects at 2 redshifts.
arcsec_per_kpc_comoving(z) Angular separation in arcsec corresponding to a comoving kpc at redshift z.
arcsec_per_kpc_proper(z) Angular separation in arcsec corresponding to a proper kpc at redshift z.
comoving_distance(z) Comoving line-of-sight distance in Mpc at a given redshift.
comoving_transverse_distance(z) Comoving transverse distance in Mpc at a given redshift.
comoving_volume(z) Comoving volume in cubic Mpc at redshift z.
critical_density(z) Critical density in grams per cubic cm at redshift z.
de_density_scale(z) Evaluates the redshift dependence of the dark energy density.
differential_comoving_volume(z) Differential comoving volume at redshift z.
distmod(z) Distance modulus at redshift z.
efunc(z) Function used to calculate H(z), the Hubble parameter.
inv_efunc(z) Inverse of efunc.
kpc_comoving_per_arcmin(z) Separation in transverse comoving kpc corresponding to an arcminute at redshift z.
kpc_proper_per_arcmin(z) Separation in transverse proper kpc corresponding to an arcminute at redshift z.
lookback_distance(z) The lookback distance is the light travel time distance to a given redshift.
lookback_time(z) Lookback time in Gyr to redshift z.
lookback_time_integrand(z) Integrand of the lookback time.
luminosity_distance(z) Luminosity distance in Mpc at redshift z.
nu_relative_density(z) Neutrino density function relative to the energy density in photons.
scale_factor(z) Scale factor at redshift z.
w(z) The dark energy equation of state.

Available Cosmologies

cosmology.Planck13 = {'H0': 67.77, 'Neff': 3.046, 'Ob0': 0.048252, 'Om0': 0.30712, 'Tcmb0': 2.7255, 'flat': True, 'm_nu': array([0. , 0. , 0.06]), 'n_s': 0.9611, 'name': 'Planck13', 'sigma8': 0.8288, 'w0': -1.0}
cosmology.Planck15 = {'H0': 67.74, 'Neff': 3.046, 'Ob0': 0.0486, 'Om0': 0.3075, 'Tcmb0': 2.7255, 'flat': True, 'm_nu': array([0. , 0. , 0.06]), 'n_s': 0.9667, 'name': 'Planck15', 'sigma8': 0.8159, 'w0': -1.0}
cosmology.WMAP5 = {'H0': 70.2, 'Neff': 3.04, 'Ob0': 0.0459, 'Om0': 0.277, 'Tcmb0': 2.725, 'flat': True, 'm_nu': array([0., 0., 0.]), 'n_s': 0.962, 'name': 'WMAP5', 'sigma8': 0.817, 'w0': -1.0}
cosmology.WMAP7 = {'H0': 70.4, 'Neff': 3.04, 'Ob0': 0.0455, 'Om0': 0.272, 'Tcmb0': 2.725, 'flat': True, 'm_nu': array([0., 0., 0.]), 'n_s': 0.967, 'name': 'WMAP7', 'sigma8': 0.81, 'w0': -1.0}
cosmology.WMAP9 = {'H0': 69.32, 'Neff': 3.04, 'Ob0': 0.04628, 'Om0': 0.2865, 'Tcmb0': 2.725, 'flat': True, 'm_nu': array([0., 0., 0.]), 'n_s': 0.9608, 'name': 'WMAP9', 'sigma8': 0.82, 'w0': -1.0}

pyRSD.rsd.cosmology.Cosmology

class pyRSD.rsd.cosmology.Cosmology(H0=67.6, Om0=0.31, Ob0=0.0486, Ode0=0.69, w0=-1.0, Tcmb0=2.7255, Neff=3.04, m_nu=0.0, n_s=0.9667, sigma8=0.8159, flat=False, name=None)

Dict-like object for cosmological parameters and related calculations

An extension of the astropy.cosmology framework that can store additional, orthogonal parameters and behaves like a read-only dictionary

The class relies on astropy.cosmology as the underlying “engine” for calculation of cosmological quantities. This “engine” is stored as engine and supports LambdaCDM and wCDM, and their flat equivalents

Any attributes or functions of the underlying astropy engine can be directly accessed as attributes or keys of this class

Note

A default set of units is assumed, so attributes stored internally as astropy.units.Quantity instances will be returned here as numpy arrays. Those units are:

  • temperature: K
  • distance: Mpc
  • density: g/cm^3
  • neutrino mass: eV
  • time: Gyr
  • H0: Mpc/km/s

Warning

This class does not currently support a non-constant dark energy equation of state

clone(**kwargs)

Returns a copy of this object, potentially with some changes.

Returns:

newcos : Subclass of FLRW

A new instance of this class with the specified changes.

Notes

This assumes that the values of all constructor arguments are available as properties, which is true of all the provided subclasses but may not be true of user-provided ones. You can’t change the type of class, so this can’t be used to change between flat and non-flat. If no modifications are requested, then a reference to this object is returned.

Examples

To make a copy of the Planck15 cosmology with a different Omega_m and a new name:

>>> from astropy.cosmology import Planck15
>>> cosmo = Cosmology.from_astropy(Planck15)
>>> newcos = cosmo.clone(name="Modified Planck 2013", Om0=0.35)
classmethod from_astropy(cosmo, n_s=0.9667, sigma8=0.8159, **kwargs)

Return a Cosmology instance from an astropy cosmology

Parameters:

cosmo : subclass of astropy.cosmology.FLRW

the astropy cosmology instance

**kwargs :

extra key/value parameters to store in the dictionary

to_class(transfer=0, linear_power_file=None, **class_config)

Convert the object to a pyRSD.pygcl.Cosmology instance in order to interface with the CLASS code

Parameters:

**class_config : key/value pairs

keywords to pass to the CLASS engine; defaults are z_max_pk=2.0 and P_k_max_h/Mpc=20.0

Returns:

cosmo : pygcl.Cosmology

the pygcl Cosmology object which interfaces with CLASS