CosmologyFromFormat¶
- class astropy.cosmology.connect.CosmologyFromFormat(instance, cosmo_cls)[source]¶
Bases:
UnifiedReadWrite
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 argumentcosmology=<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:>>> Cosmology.from_format.help() # Get help and list supported formats >>> Cosmology.from_format.help('<format>') # Get detailed help on a format >>> Cosmology.from_format.list_formats() # Print list of available formats
See also: https://docs.astropy.org/en/stable/io/unified.html
- Parameters:
- obj
object
The object to parse according to ‘format’
- *args
Positional arguments passed through to data parser.
- format
python:str
orpython:None
, optional keyword-only Object format specifier. For
None
(default) CosmologyFromFormat tries to identify the correct format.- **kwargs
Keyword arguments passed through to data parser. Parsers should accept the following keyword arguments:
- cosmologythe class (or string name thereof) to use / check when
constructing the cosmology instance.
- obj
- Returns:
Methods Summary
__call__
(obj, *args[, format])Call self as a function.
Methods Documentation