Cosmology calculator. Cosmology calculator based originally on http://www.kempner.net/cosmic.php and featuring time and redshift conversion functions from Enzo.
yt.utilities.cosmology.
Cosmology
(hubble_constant=0.71, omega_matter=0.27, omega_lambda=0.73, omega_curvature=0.0, unit_registry=None, unit_system='cgs', use_dark_factor=False, w_0=1.0, w_a=0.0)[source]¶Bases: object
Create a cosmology calculator to compute cosmological distances and times.
For an explanation of the various cosmological measures, see, for example Hogg (1999, http://xxx.lanl.gov/abs/astroph/9905116).
WARNING: Cosmological distance calculations return values that are either in the comoving or proper frame, depending on the specific quantity. For simplicity, the proper and comoving frames are set equal to each other within the cosmology calculator. This means that for some distance value, x, x.to(“Mpc”) and x.to(“Mpccm”) will be the same. The user should take care to understand which reference frame is correct for the given calculation.
Parameters: 


Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.hubble_time(0.0).in_units("Gyr"))
angular_diameter_distance
(z_i, z_f)[source]¶Following Hogg (1999), the angular diameter distance is ‘the ratio of an object’s physical transverse size to its angular size in radians.’
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.angular_diameter_distance(0., 1.).in_units("Mpc"))
angular_scale
(z_i, z_f)[source]¶The proper transverse distance between two points at redshift z_f observed at redshift z_i per unit of angular separation.
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.angular_scale(0., 1.).in_units("kpc / arcsec"))
arr
¶comoving_radial_distance
(z_i, z_f)[source]¶The comoving distance along the line of sight to on object at redshift, z_f, viewed at a redshift, z_i.
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.comoving_radial_distance(0., 1.).in_units("Mpccm"))
comoving_transverse_distance
(z_i, z_f)[source]¶When multiplied by some angle, the distance between two objects observed at redshift, z_f, with an angular separation given by that angle, viewed by an observer at redshift, z_i (Hogg 1999).
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.comoving_transverse_distance(0., 1.).in_units("Mpccm"))
comoving_volume
(z_i, z_f)[source]¶“The comoving volume is the volume measure in which number densities of nonevolving objects locked into Hubble flow are constant with redshift.” – Hogg (1999)
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.comoving_volume(0., 1.).in_units("Gpccm**3"))
critical_density
(z)[source]¶The density required for closure of the Universe at a given redshift in the proper frame.
Parameters:  z (float) – Redshift. 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.critical_density(0.).in_units("g/cm**3"))
>>> print(co.critical_density(0).in_units("Msun/Mpc**3"))
expansion_factor
(z)[source]¶The ratio between the Hubble parameter at a given redshift and redshift zero.
This is also the primary function integrated to calculate the cosmological distances.
get_dark_factor
(z)[source]¶This function computes the additional term that enters the expansion factor when using nonstandard dark energy. See Dolag et al 2004 eq. 7 for ref (but note that there’s a typo in his eq. There should be no negative sign).
At the moment, this only works using the parameterization given in Linder 2002 eq. 7: w(a) = w0 + wa(1  a) = w0 + wa * z / (1+z). This gives rise to an analytic expression. It is also only functional for Gadget simulations, at the moment.
Parameters:  z (float) – Redshift 

hubble_distance
()[source]¶The distance corresponding to c / h, where c is the speed of light and h is the Hubble parameter in units of 1 / time.
hubble_parameter
(z)[source]¶The value of the Hubble parameter at a given redshift.
Parameters:  z (float) – Redshift. 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.hubble_parameter(1.0).in_units("km/s/Mpc"))
hubble_time
(z, z_inf=1000000.0)[source]¶The age of the Universe at a given redshift.
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.hubble_time(0.).in_units("Gyr"))
See also
lookback_time
(z_i, z_f)[source]¶The difference in the age of the Universe between the redshift interval z_i to z_f.
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.lookback_time(0., 1.).in_units("Gyr"))
luminosity_distance
(z_i, z_f)[source]¶The distance that would be inferred from the inversesquare law of light and the measured flux and luminosity of the observed object.
Parameters: 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.luminosity_distance(0., 1.).in_units("Mpc"))
quan
¶t_from_z
(z)[source]¶Compute the age of the Universe from redshift. This is based on Enzo’s CosmologyComputeTimeFromRedshift.C, but altered to use physical units. Similar to hubble_time, but using an analytical function.
Parameters:  z (float) – Redshift. 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.t_from_z(0.).in_units("Gyr"))
See also
z_from_t
(my_time)[source]¶Compute the redshift from time after the big bang. This is based on Enzo’s CosmologyComputeExpansionFactor.C, but altered to use physical units.
Parameters:  my_time (float) – Age of the Universe in seconds. 

Examples
>>> from yt.utilities.cosmology import Cosmology
>>> co = Cosmology()
>>> print(co.z_from_t(4.e17))