CosmologyToFormat#

class astropy.cosmology.connect.CosmologyToFormat(instance: Cosmology, cls: type[Cosmology])[source]#

Bases: UnifiedReadWrite

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 the help() 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:
formatstr

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.

Methods Summary

__call__()

Call self as a function.

Methods Documentation

__call__(format: Literal['astropy.cosmology'], *args: Any, **kwargs: Any) Cosmology[source]#
__call__(format: Literal['astropy.model'], *args: Any, **kwargs: Any) _CosmologyModel
__call__(format: Literal['astropy.row'], *args: Any, **kwargs: Any) Row
__call__(format: Literal['astropy.table'], *args: Any, **kwargs: Any) Table
__call__(format: Literal['mapping'], *args: Any, cls: _MT, **kwargs: Any) _MT
__call__(format: Literal['mapping'], *args: Any, **kwargs: Any) dict[str, Any]
__call__(format: Literal['yaml'], *args: Any, **kwargs: Any) str
__call__(format: str, *args: Any, **kwargs: Any) Any

Call self as a function.