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=67.66 km / (Mpc s), Om0=0.30966, ...

Methods Summary

get()

Get the current science state value.

get_cosmology_from_string(arg)

Deprecated since version 5.0.

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 get_cosmology_from_string(arg)[source]

Deprecated since version 5.0: The get_cosmology_from_string method is deprecated and may be removed in a future version. Use get instead.

Return a cosmology instance from a string.

classmethod set(value)

Set the current science state value.

classmethod validate(value: Optional[Union[Cosmology, str]]) Optional[Cosmology][source]

Return a Cosmology given a value.

Parameters:
valuepython:None, python:str, or Cosmology
Returns:
Cosmology instance
Raises:
TypeError

If value is not a string or Cosmology.