CosmologyToFormat

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

Bases: astropy.io.registry.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

Note

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

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__(format, *args, **kwargs)

Call self as a function.

Methods Documentation

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

Call self as a function.