CosmologyRead

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

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

Note

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

Parameters
*args

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

formatstr (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

mapping

Yes

No

No

Methods Summary

__call__(*args, **kwargs)

Call self as a function.

Methods Documentation

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

Call self as a function.