class astropy.cosmology.connect.CosmologyToFormat(instance, cls)[source]


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:

>>>  # Get help and list supported formats
>>>'<format>')  # Get detailed help on format
>>> Cosmology.to_format.list_formats()  # Print list of available formats


to_format() and write() currently access the same registry. This will be deprecated and formats intended for write should not be used here. Use to confirm that the format may be used to convert a Cosmology.


Format specifier.


Positional arguments passed through to data writer. If supplied the first argument is the output filename.


Keyword arguments passed through to data writer.

Methods Summary

__call__(format, *args, **kwargs)

Call self as a function.

Methods Documentation

__call__(format, *args, **kwargs)[source]

Call self as a function.