Skip to main content
`Ctrl`+`K`

# CosmologyToFormat

class astropy.cosmology.io.CosmologyToFormat(instance, cls)

  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:
    format `python:str`

      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)

    Call self as a function.