class astropy.cosmology.connect.CosmologyFromFormat(instance, cosmo_cls)[source]


Transform object to a Cosmology.

This function provides the Cosmology interface to the Astropy unified I/O layer. This allows easily parsing supported data formats using syntax such as:

>>> from astropy.cosmology import Cosmology
>>> cosmo1 = Cosmology.from_format(cosmo_mapping, format='mapping')

When the from_format method is called from a subclass the subclass will provide a keyword argument cosmology=<class> to the registered parser. The method uses this cosmology class, regardless of the class indicated in the data, and sets parameters’ default values from the class’ signature.

Get help on the available readers using the help() method:

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

See also:


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


The object to parse according to ‘format’


Positional arguments passed through to data parser.

formatstr (optional, keyword-only)

Object format specifier.


Keyword arguments passed through to data parser.

outCosmology subclass instance

Cosmology corresponding to obj contents.

Methods Summary

__call__(obj, *args, **kwargs)

Call self as a function.

Methods Documentation

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

Call self as a function.