FlatLambdaCDM¶
- class astropy.cosmology.FlatLambdaCDM(H0, Om0, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=<Quantity 0. eV>, Ob0=None, *, name=None, meta=None)[source]¶
Bases:
FlatFLRWMixin
,LambdaCDM
FLRW cosmology with a cosmological constant and no curvature.
This has no additional attributes beyond those of FLRW.
- Parameters:
- H0
python:float
or scalar astropy:quantity-like [:ref: ‘frequency’] Hubble constant at z = 0. If a float, must be in [km/sec/Mpc].
- Om0
python:float
Omega matter: density of non-relativistic matter in units of the critical density at z=0.
- Tcmb0
python:float
or scalar astropy:quantity-like [:ref: ‘temperature’], optional Temperature of the CMB z=0. If a float, must be in [K]. Default: 0 [K]. Setting this to zero will turn off both photons and neutrinos (even massive ones).
- Neff
python:float
, optional Effective number of Neutrino species. Default 3.04.
- m_nuastropy:quantity-like [:ref: ‘energy’, :ref: ‘mass’] or numpy:array_like, optional
Mass of each neutrino species in [eV] (mass-energy equivalency enabled). If this is a scalar Quantity, then all neutrino species are assumed to have that mass. Otherwise, the mass of each species. The actual number of neutrino species (and hence the number of elements of m_nu if it is not scalar) must be the floor of Neff. Typically this means you should provide three neutrino masses unless you are considering something like a sterile neutrino.
- Ob0
python:float
orpython:None
, optional Omega baryons: density of baryonic matter in units of the critical density at z=0. If this is set to None (the default), any computation that requires its value will raise an exception.
- name
python:str
orpython:None
(optional, keyword-only) Name for this cosmological object.
- metapython:mapping or
python:None
(optional, keyword-only) Metadata for the cosmology, e.g., a reference.
- H0
Examples
>>> from astropy.cosmology import FlatLambdaCDM >>> cosmo = FlatLambdaCDM(H0=70, Om0=0.3)
The comoving distance in Mpc at redshift z:
>>> z = 0.5 >>> dc = cosmo.comoving_distance(z)
To get an equivalent cosmology, but of type
astropy.cosmology.LambdaCDM
, useastropy.cosmology.FlatFLRWMixin.nonflat
.>>> cosmo.nonflat LambdaCDM(H0=70.0 km / (Mpc s), Om0=0.3, ...
Attributes Summary
Hubble constant as an
Quantity
at z=0.Number of effective neutrino species.
Omega baryon; baryonic matter density/critical density at z=0.
Omega dark energy; dark energy density/critical density at z=0.
Omega dark matter; dark matter density/critical density at z=0.
Omega gamma; the density/critical density of photons at z=0.
Omega curvature; the effective curvature density/critical density at z=0.
Omega matter; matter density/critical density at z=0.
Omega nu; the density/critical density of neutrinos at z=0.
Omega total; the total density/critical density at z=0.
Temperature of the CMB as
Quantity
at z=0.Temperature of the neutrino background as
Quantity
at z=0.Critical density as
Quantity
at z=0.Transform object to a
Cosmology
.Dimensionless Hubble constant: h = H_0 / 100 [km/sec/Mpc].
Does this cosmology have at least one massive neutrino species?
Hubble distance as
Quantity
.Hubble time as
Quantity
.Return
True
, the cosmology is flat.Mass of neutrino species.
The name of the Cosmology instance.
Return the equivalent non-flat-class instance of this cosmology.
Read and parse data to a
Cosmology
.Transform this Cosmology to another format.
Write this Cosmology object out in the specified format.
Methods Summary
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
.Otot
(z)The total density parameter at redshift
z
.Tcmb
(z)Return the CMB temperature at redshift
z
.Tnu
(z)Return the neutrino temperature at redshift
z
.Integrand of the absorption distance [1].
absorption_distance
(z, /)Absorption distance at redshift
z
.age
(z)Age of the universe in Gyr at redshift
z
.Angular diameter distance in Mpc at a given redshift.
angular_diameter_distance_z1z2
(z1, z2)Angular diameter distance between objects at 2 redshifts.
Angular separation in arcsec corresponding to a comoving kpc at redshift
z
.Angular separation in arcsec corresponding to a proper kpc at redshift
z
.clone
(*[, meta, to_nonflat])Returns a copy of this object with updated parameters, as specified.
Comoving line-of-sight distance in Mpc at a given redshift.
Comoving transverse distance in Mpc at a given redshift.
Comoving volume in cubic Mpc at redshift
z
.Critical density in grams per cubic cm at redshift
z
.Evaluates the redshift dependence of the dark energy density.
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)Function used to calculate \(\frac{1}{H_z}\).
is_equivalent
(other, /, *[, format])Check equivalence between Cosmologies.
Separation in transverse comoving kpc corresponding to an arcminute at redshift
z
.Separation in transverse proper kpc corresponding to an arcminute at redshift
z
.The lookback distance is the light travel time distance to a given redshift.
Lookback time in Gyr to redshift
z
.Integrand of the lookback time (equation 30 of [1]).
Luminosity distance in Mpc at redshift
z
.Neutrino density function relative to the energy density in photons.
scale_factor
(z)Scale factor at redshift
z
.w
(z)Returns dark energy equation of state at redshift
z
.Attributes Documentation
- 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.
- Otot0¶
Omega total; the total density/critical density at z=0.
- from_format¶
Transform object to a
Cosmology
.This function provides the Cosmology interface to the Astropy unified I/O layer. This allows easily parsing supported data formats using syntax such as:
>>> from astropy.cosmology import Cosmology >>> cosmo1 = Cosmology.from_format(cosmo_mapping, format='mapping')
When the
from_format
method is called from a subclass the subclass will provide a keyword argumentcosmology=<class>
to the registered parser. The method uses this cosmology class, regardless of the class indicated in the data, and sets parameters’ default values from the class’ signature.Get help on the available readers using the
help()
method:>>> Cosmology.from_format.help() # Get help and list supported formats >>> Cosmology.from_format.help('<format>') # Get detailed help on a format >>> Cosmology.from_format.list_formats() # Print list of available formats
See also: https://docs.astropy.org/en/stable/io/unified.html
- Parameters:
- obj
object
The object to parse according to ‘format’
- *args
Positional arguments passed through to data parser.
- format
python:str
orpython:None
, optional keyword-only Object format specifier. For
None
(default) CosmologyFromFormat tries to identify the correct format.- **kwargs
Keyword arguments passed through to data parser. Parsers should accept the following keyword arguments:
- cosmologythe class (or string name thereof) to use / check when
constructing the cosmology instance.
- obj
- Returns:
- h¶
Dimensionless Hubble constant: h = H_0 / 100 [km/sec/Mpc].
- has_massive_nu¶
Does this cosmology have at least one massive neutrino species?
- is_flat¶
Return
True
, the cosmology is flat.
- m_nu¶
Mass of neutrino species.
- meta¶
- name¶
The name of the Cosmology instance.
- nonflat¶
- read¶
Read and parse data to a
Cosmology
.This function provides the Cosmology interface to the Astropy unified I/O layer. This allows easily reading a file in supported data formats using syntax such as:
>>> from astropy.cosmology import Cosmology >>> cosmo1 = Cosmology.read('<file name>')
When the
read
method is called from a subclass the subclass will provide a keyword argumentcosmology=<class>
to the registered read method. The method uses this cosmology class, regardless of the class indicated in the file, and sets parameters’ default values from the class’ signature.Get help on the available readers using the
help()
method:>>> Cosmology.read.help() # Get help reading and list supported formats >>> Cosmology.read.help(format='<format>') # Get detailed help on a format >>> Cosmology.read.list_formats() # Print list of available formats
See also: https://docs.astropy.org/en/stable/io/unified.html
- Parameters:
- *args
Positional arguments passed through to data reader. If supplied the first argument is typically the input filename.
- format
python:str
(optional, keyword-only) File format specifier.
- **kwargs
Keyword arguments passed through to data reader.
- Returns:
- to_format¶
Transform this Cosmology to another format.
This function provides the Cosmology interface to the astropy unified I/O layer. This allows easily transforming to supported data formats using syntax such as:
>>> from astropy.cosmology import Planck18 >>> Planck18.to_format("mapping") {'cosmology': astropy.cosmology.core.FlatLambdaCDM, 'name': 'Planck18', 'H0': <Quantity 67.66 km / (Mpc s)>, 'Om0': 0.30966, ...
Get help on the available representations for
Cosmology
using thehelp()
method:>>> Cosmology.to_format.help() # Get help and list supported formats >>> Cosmology.to_format.help('<format>') # Get detailed help on format >>> Cosmology.to_format.list_formats() # Print list of available formats
- Parameters:
- format
python:str
Format specifier.
- *args
Positional arguments passed through to data writer. If supplied the first argument is the output filename.
- **kwargs
Keyword arguments passed through to data writer.
- format
- write¶
Write this Cosmology object out in the specified format.
This function provides the Cosmology interface to the astropy unified I/O layer. This allows easily writing a file in supported data formats using syntax such as:
>>> from astropy.cosmology import Planck18 >>> Planck18.write('<file name>')
Get help on the available writers for
Cosmology
using thehelp()
method:>>> Cosmology.write.help() # Get help writing and list supported formats >>> Cosmology.write.help(format='<format>') # Get detailed help on format >>> Cosmology.write.list_formats() # Print list of available formats
- Parameters:
- *args
Positional arguments passed through to data writer. If supplied the first argument is the output filename.
- format
python:str
(optional, keyword-only) File format specifier.
- **kwargs
Keyword arguments passed through to data writer.
Methods Documentation
- H(z)¶
Hubble parameter (km/s/Mpc) at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- H
Quantity
[:ref: ‘frequency’] Hubble parameter at each input redshift.
- H
- Ob(z)¶
Return the density parameter for baryonic matter at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Ob
ndarray
orpython:float
The density of baryonic matter relative to the critical density at each redshift. Returns
float
if the input is scalar.
- Ob
- Raises:
ValueError
If
Ob0
isNone
.
- Ode(z)¶
Return the density parameter for dark energy at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Ode
ndarray
orpython:float
The density of non-relativistic matter relative to the critical density at each redshift. Returns
float
if the input is scalar.
- Ode
- Odm(z)¶
Return the density parameter for dark matter at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Odm
ndarray
orpython:float
The density of non-relativistic dark matter relative to the critical density at each redshift. Returns
float
if the input is scalar.
- Odm
- Raises:
ValueError
If
Ob0
isNone
.
Notes
This does not include neutrinos, even if non-relativistic at the redshift of interest.
- Ogamma(z)¶
Return the density parameter for photons at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Ogamma
ndarray
orpython:float
The energy density of photons relative to the critical density at each redshift. Returns
float
if the input is scalar.
- Ogamma
- Ok(z)¶
Return the equivalent density parameter for curvature at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Ok
ndarray
orpython:float
The equivalent density parameter for curvature at each redshift. Returns
float
if the input is scalar.
- Ok
- Om(z)¶
Return the density parameter for non-relativistic matter at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Om
ndarray
orpython:float
The density of non-relativistic matter relative to the critical density at each redshift. Returns
float
if the input is scalar.
- Om
Notes
This does not include neutrinos, even if non-relativistic at the redshift of interest; see
Onu
.
- Onu(z)¶
Return the density parameter for neutrinos at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Onu
ndarray
orpython:float
The energy density of neutrinos relative to the critical density at each redshift. Note that this includes their kinetic energy (if they have mass), so it is not equal to the commonly used \(\sum \frac{m_{\nu}}{94 eV}\), which does not include kinetic energy. Returns
float
if the input is scalar.
- Onu
- Otot(z)¶
The total density parameter at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshifts.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Otot
ndarray
orpython:float
Returns float if input scalar. Value of 1.
- Otot
- Tcmb(z)¶
Return the CMB temperature at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Tcmb
Quantity
[:ref: ‘temperature’] The temperature of the CMB in K.
- Tcmb
- Tnu(z)¶
Return the neutrino temperature at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- Tnu
Quantity
[:ref: ‘temperature’] The temperature of the cosmic neutrino background in K.
- Tnu
- abs_distance_integrand(z)¶
Integrand of the absorption distance [1].
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- X
python:float
orarray
The integrand for the absorption distance.
- X
References
- absorption_distance(z, /)¶
Absorption distance at redshift
z
.This is used to calculate the number of objects with some cross section of absorption and number density intersecting a sightline per unit redshift path ([1], [2]).
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
python:float
orndarray
Absorption distance (dimensionless) at each input redshift. Returns
float
if input scalar,ndarray
otherwise.
- d
References
- age(z)¶
Age of the universe in Gyr at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- t
Quantity
[:ref: ‘time’] The age of the universe in Gyr at each input redshift.
- t
See also
z_at_value
Find the redshift corresponding to an age.
- angular_diameter_distance(z)¶
Angular diameter distance in Mpc 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
([1], [2], [3]).- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
[:ref: ‘length’] Angular diameter distance in Mpc at each input redshift.
- d
References
- angular_diameter_distance_z1z2(z1, z2)¶
Angular diameter distance between objects at 2 redshifts.
Useful for gravitational lensing, for example computing the angular diameter distance between a lensed galaxy and the foreground lens.
- Parameters:
- z1, z2Quantity-like [‘redshift’], numpy:array_like, or
Number
Input redshifts. For most practical applications such as gravitational lensing,
z2
should be larger thanz1
. The method will work forz2 < z1
; however, this will return negative distances.
- z1, z2Quantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
The angular diameter distance between each input redshift pair. Returns scalar if input is scalar, array else-wise.
- d
- arcsec_per_kpc_comoving(z)¶
Angular separation in arcsec corresponding to a comoving kpc at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- theta
Quantity
[:ref: ‘angle’] The angular separation in arcsec corresponding to a comoving kpc at each input redshift.
- theta
- arcsec_per_kpc_proper(z)¶
Angular separation in arcsec corresponding to a proper kpc at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- theta
Quantity
[:ref: ‘angle’] The angular separation in arcsec corresponding to a proper kpc at each input redshift.
- theta
- clone(*, meta: Optional[Mapping] = None, to_nonflat: bool = None, **kwargs: Any)¶
Returns a copy of this object with updated parameters, as specified.
This cannot be used to change the type of the cosmology, except for changing to the non-flat version of this cosmology.
- Parameters:
- metapython:mapping or
python:None
(optional, keyword-only) Metadata that will update the current metadata.
- to_nonflatbool or
python:None
, optional keyword-only Whether to change to the non-flat version of this cosmology.
- **kwargs
Cosmology parameter (and name) modifications. If any parameter is changed and a new name is not given, the name will be set to “[old name] (modified)”.
- metapython:mapping or
- Returns:
- newcosmo
Cosmology
subclass instance A new instance of this class with updated parameters as specified. If no arguments are given, then a reference to this object is returned instead of copy.
- newcosmo
Examples
To make a copy of the
Planck13
cosmology with a different matter density (Om0
), and a new name:>>> from astropy.cosmology import Planck13 >>> Planck13.clone(name="Modified Planck 2013", Om0=0.35) FlatLambdaCDM(name="Modified Planck 2013", H0=67.77 km / (Mpc s), Om0=0.35, ...
If no name is specified, the new name will note the modification.
>>> Planck13.clone(Om0=0.35).name 'Planck13 (modified)'
The keyword ‘to_nonflat’ can be used to clone on the non-flat equivalent cosmology.
>>> Planck13.clone(to_nonflat=True) LambdaCDM(name="Planck13", ...
>>> Planck13.clone(H0=70, to_nonflat=True) LambdaCDM(name="Planck13 (modified)", H0=70.0 km / (Mpc s), ...
With ‘to_nonflat’
True
,Ode0
can be modified.>>> Planck13.clone(to_nonflat=True, Ode0=1) LambdaCDM(name="Planck13 (modified)", H0=67.77 km / (Mpc s), Om0=0.30712, Ode0=1.0, ...
- comoving_distance(z)¶
Comoving line-of-sight distance in Mpc 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.
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
[:ref: ‘length’] Comoving distance in Mpc to each input redshift.
- d
- comoving_transverse_distance(z)¶
Comoving transverse distance in Mpc 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 if \(\Omega_k\) is zero (as in the current concordance Lambda-CDM model).- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
[:ref: ‘length’] Comoving transverse distance in Mpc at each input redshift.
- d
Notes
This quantity is also called the ‘proper motion distance’ in some texts.
- comoving_volume(z)¶
Comoving volume in cubic Mpc at redshift
z
.This is the volume of the universe encompassed by redshifts less than
z
. For the case of \(\Omega_k = 0\) it is a sphere of radiuscomoving_distance
but it is less intuitive if \(\Omega_k\) is not.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- V
Quantity
Comoving volume in \(Mpc^3\) at each input redshift.
- V
- critical_density(z)¶
Critical density in grams per cubic cm at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- rho
Quantity
Critical density in g/cm^3 at each input redshift.
- rho
- de_density_scale(z)¶
Evaluates the redshift dependence of the dark energy density.
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- I
ndarray
orpython:float
The scaling of the energy density of dark energy with redshift. Returns
float
if the input is scalar.
- I
Notes
The scaling factor, I, is defined by \(\rho(z) = \rho_0 I\), and in this case is given by \(I = 1\).
- differential_comoving_volume(z)¶
Differential comoving volume at redshift z.
Useful for calculating the effective comoving volume. For example, allows for integration over a comoving volume that has a sensitivity function that changes with redshift. The total comoving volume is given by integrating
differential_comoving_volume
to redshiftz
and multiplying by a solid angle.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- dV
Quantity
Differential comoving volume per redshift per steradian at each input redshift.
- dV
- distmod(z)¶
Distance modulus at redshift
z
.The distance modulus is defined as the (apparent magnitude - absolute magnitude) for an object at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- distmod
Quantity
[:ref: ‘length’] Distance modulus at each input redshift, in magnitudes.
- distmod
See also
z_at_value
Find the redshift corresponding to a distance modulus.
- efunc(z)[source]¶
Function used to calculate H(z), the Hubble parameter.
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- E
ndarray
orpython:float
The redshift scaling of the Hubble constant. Returns
float
if the input is scalar. Defined such that \(H(z) = H_0 E(z)\).
- E
- inv_efunc(z)[source]¶
Function used to calculate \(\frac{1}{H_z}\).
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- E
ndarray
orpython:float
The inverse redshift scaling of the Hubble constant. Returns
float
if the input is scalar. Defined such that \(H_z = H_0 / E\).
- E
- is_equivalent(other: Any, /, *, format: _FormatType = False) bool ¶
Check equivalence between Cosmologies.
Two cosmologies may be equivalent even if not the same class. For example, an instance of
LambdaCDM
might have \(\Omega_0=1\) and \(\Omega_k=0\) and therefore be flat, likeFlatLambdaCDM
.- Parameters:
- other
Cosmology
subclass instance, positional-only The object to which to compare.
- formatbool or
python:None
orpython:str
, optional keyword-only Whether to allow, before equivalence is checked, the object to be converted to a
Cosmology
. This allows, e.g. aTable
to be equivalent to a Cosmology.False
(default) will not allow conversion.True
orNone
will, and will use the auto-identification to try to infer the correct format. Astr
is assumed to be the correct format to use when converting.format
is broadcast to match the shape ofother
. Note that the cosmology arguments are not broadcast againstformat
, so it cannot determine the output shape.
- other
- Returns:
- bool
True if cosmologies are equivalent, False otherwise.
Examples
Two cosmologies may be equivalent even if not of the same class. In this examples the
LambdaCDM
hasOde0
set to the same value calculated inFlatLambdaCDM
.>>> import astropy.units as u >>> from astropy.cosmology import LambdaCDM, FlatLambdaCDM >>> cosmo1 = LambdaCDM(70 * (u.km/u.s/u.Mpc), 0.3, 0.7) >>> cosmo2 = FlatLambdaCDM(70 * (u.km/u.s/u.Mpc), 0.3) >>> cosmo1.is_equivalent(cosmo2) True
While in this example, the cosmologies are not equivalent.
>>> cosmo3 = FlatLambdaCDM(70 * (u.km/u.s/u.Mpc), 0.3, Tcmb0=3 * u.K) >>> cosmo3.is_equivalent(cosmo2) False
Also, using the keyword argument, the notion of equivalence is extended to any Python object that can be converted to a
Cosmology
.>>> from astropy.cosmology import Planck18 >>> tbl = Planck18.to_format("astropy.table") >>> Planck18.is_equivalent(tbl, format=True) True
The list of valid formats, e.g. the
Table
in this example, may be checked withCosmology.from_format.list_formats()
.As can be seen in the list of formats, not all formats can be auto-identified by
Cosmology.from_format.registry
. Objects of these kinds can still be checked for equivalence, but the correct format string must be used.>>> tbl = Planck18.to_format("yaml") >>> Planck18.is_equivalent(tbl, format="yaml") True
- kpc_comoving_per_arcmin(z)¶
Separation in transverse comoving kpc corresponding to an arcminute at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
[:ref: ‘length’] The distance in comoving kpc corresponding to an arcmin at each input redshift.
- d
- kpc_proper_per_arcmin(z)¶
Separation in transverse proper kpc corresponding to an arcminute at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
[:ref: ‘length’] The distance in proper kpc corresponding to an arcmin at each input redshift.
- d
- lookback_distance(z)¶
The lookback distance is the light travel time distance to a given redshift. It is simply c * lookback_time. It may be used to calculate the proper distance between two redshifts, e.g. for the mean free path to ionizing radiation.
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
[:ref: ‘length’] Lookback distance in Mpc
- d
- lookback_time(z)¶
Lookback time in Gyr to redshift
z
.The lookback time is the difference between the age of the Universe now and the age at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- t
Quantity
[:ref: ‘time’] Lookback time in Gyr to each input redshift.
- t
See also
z_at_value
Find the redshift corresponding to a lookback time.
- lookback_time_integrand(z)¶
Integrand of the lookback time (equation 30 of [1]).
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- I
python:float
orarray
The integrand for the lookback time.
- I
References
- luminosity_distance(z)¶
Luminosity distance in Mpc 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 [1].- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- d
Quantity
[:ref: ‘length’] Luminosity distance in Mpc at each input redshift.
- d
See also
z_at_value
Find the redshift corresponding to a luminosity distance.
References
[1]Weinberg, 1972, pp 420-424; Weedman, 1986, pp 60-62.
- nu_relative_density(z)¶
Neutrino density function relative to the energy density in photons.
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- f
ndarray
orpython:float
The neutrino density scaling factor relative to the density in photons at each redshift. Only returns
float
if z is scalar.
- f
Notes
The density in neutrinos is given by
\[\rho_{\nu} \left(a\right) = 0.2271 \, N_{eff} \, f\left(m_{\nu} a / T_{\nu 0} \right) \, \rho_{\gamma} \left( a \right)\]where
\[f \left(y\right) = \frac{120}{7 \pi^4} \int_0^{\infty} \, dx \frac{x^2 \sqrt{x^2 + y^2}} {e^x + 1}\]assuming that all neutrino species have the same mass. If they have different masses, a similar term is calculated for each one. Note that
f
has the asymptotic behavior \(f(0) = 1\). This method returns \(0.2271 f\) using an analytical fitting formula given in Komatsu et al. 2011, ApJS 192, 18.
- scale_factor(z)¶
Scale factor at redshift
z
.The scale factor is defined as \(a = 1 / (1 + z)\).
- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- a
ndarray
orpython:float
Scale factor at each input redshift. Returns
float
if the input is scalar.
- a
- w(z)¶
Returns dark energy equation of state at redshift
z
.- Parameters:
- zQuantity-like [‘redshift’], numpy:array_like, or
Number
Input redshift.
- zQuantity-like [‘redshift’], numpy:array_like, or
- Returns:
- w
ndarray
orpython:float
The dark energy equation of state. Returns
float
if the input is scalar.
- w
Notes
The dark energy equation of state is defined as \(w(z) = P(z)/\rho(z)\), where \(P(z)\) is the pressure at redshift z and \(\rho(z)\) is the density at redshift z, both in units where c=1. Here this is \(w(z) = -1\).