CosmologyRead

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

Bases: UnifiedReadWrite

Read and parse data to a Cosmology.

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

>>> from astropy.cosmology import Cosmology
>>> cosmo1 = Cosmology.read('<file name>')

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

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

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

See also: https://docs.astropy.org/en/stable/io/unified.html

Parameters:
*args

Positional arguments passed through to data reader. If supplied the first argument is typically the input filename.

formatpython:str (optional, keyword-only)

File format specifier.

**kwargs

Keyword arguments passed through to data reader.

Returns:
outCosmology subclass instance

Cosmology corresponding to file contents.

Notes

The available built-in formats are:

Format

Read

Write

Auto-identify

astropy.cosmology

Yes

Yes

Yes

astropy.model

Yes

Yes

Yes

astropy.row

Yes

Yes

Yes

astropy.table

Yes

Yes

Yes

mapping

Yes

Yes

Yes

yaml

Yes

No

No

Methods Summary

__call__(*args, **kwargs)

Call self as a function.

Methods Documentation

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

Call self as a function.