default_cosmology#

class astropy.cosmology.default_cosmology[source]#

Bases: ScienceState

The default cosmology to use.

To change it:

>>> from astropy.cosmology import default_cosmology, WMAP7
>>> with default_cosmology.set(WMAP7):
...     # WMAP7 cosmology in effect
...     pass

Or, you may use a string:

>>> with default_cosmology.set('WMAP7'):
...     # WMAP7 cosmology in effect
...     pass

To get the default cosmology:

>>> default_cosmology.get()
FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>,
              Om0=0.30966, ...

Methods Summary

get()

Get the current science state value.

set(value)

Set the current science state value.

validate(value)

Return a Cosmology given a value.

Methods Documentation

classmethod get()#

Get the current science state value.

classmethod set(value)#

Set the current science state value.

classmethod validate(value: Cosmology | str | None) Cosmology | None[source]#

Return a Cosmology given a value.

Parameters:
valueNone, str, or Cosmology
Returns:
Cosmology instance
Raises:
TypeError

If value is not a string or Cosmology.