What's New in Astropy 8.0?

SiempreViernes1 pts0 comments

What’s New in Astropy 8.0? — Astropy v8.0.1

Skip to main content

Back to top

Ctrl+K

Search<br>Ctrl+K

System Settings

Light

Dark

GitHub

Search<br>Ctrl+K

System Settings

Light

Dark

GitHub

Astropy v8.0.1

What’s New in Astropy 8.0?#

Overview#

Astropy 8.0 is a release that adds significant new functionality since<br>the 7.2 release.

In particular, this release includes:

Cosmology

CODATA 2022 is now default in constants

Table formats

Overhaul of cache and configuration path discovery mechanism

Write table indices to FITS, HDF5 and ECSV formats

Variable-length array logical columns in FITS

Fast Lomb-Scargle: Low Rank Approximation

Preserving NULL values in FITS logical columns

Table display and pandas conversion

FITS string column changes

New imshow_simple_norm convenience function

Parsing vector strings into Quantity

Deprecation of the built-in test runner

NumPy 2.0 is now required

In addition to these major changes, Astropy v8.0 includes a large number of<br>smaller improvements and bug fixes, which are described in the Full Changelog.<br>By the numbers:

1014 commits have been added since v7.2

179 issues have been closed since v7.2

364 pull requests have been merged since v7.2

70 people have contributed since v7.2

37 of which are new contributors

Full change log#

To see a detailed list of all changes in version v8.0, including changes in<br>API, please see the Full Changelog.

Cosmology#

The astropy.cosmology module has several updates in this release.

Module Simplification#

The deprecated module-level shim files in astropy.cosmology have been removed. These<br>compatibility modules were originally deprecated in v7.1. With this release, all<br>cosmology classes and functions must be imported directly from astropy.cosmology.

The following deprecated modules have been removed:

astropy.cosmology.connect

astropy.cosmology.core

astropy.cosmology.flrw

astropy.cosmology.funcs

astropy.cosmology.parameter

Migration Guide

If your code was still using the old import paths, you need to update them to import<br>directly from astropy.cosmology.

Before:

from astropy.cosmology.flrw import FlatLambdaCDM<br>from astropy.cosmology.core import Cosmology<br>from astropy.cosmology.funcs import z_at_value

After:

from astropy.cosmology import Cosmology, FlatLambdaCDM, z_at_value

Cosmology Traits#

The traits module provides reusable components, called<br>traits, that encapsulate specific cosmological properties or<br>behaviors. For example, the NeutrinoComponent trait<br>provides the neutrino component and related methods.<br>By combining these traits, you can easily construct custom cosmology classes with<br>precisely the features you need, without having to reimplement common functionality.<br>Here is an example of how to use the<br>NeutrinoComponent trait in custom cosmology classes:

>>> import numpy as np<br>>>> from astropy import units as u<br>>>> from astropy.cosmology import Cosmology<br>>>> from astropy.cosmology.traits import TemperatureCMB, NeutrinoComponent<br>>>> NEUTRINO_FERMI_DIRAC_CORRECTION = 0.22710731766 # 7/8 (4/11)^4/3<br>>>><br>>>> class SimpleNeutrinoCosmology(Cosmology, TemperatureCMB, NeutrinoComponent):<br>... '''Minimal cosmology demonstrating NeutrinoComponent trait.'''<br>... def __init__(self, Tcmb0=2.7255, Neff=3.046, Ogamma0=5e-5):<br>... self.Tcmb0 = u.Quantity(Tcmb0, "K")<br>... self.Neff = Neff<br>... self.Ogamma0 = Ogamma0<br>... super().__init__()<br>... @property<br>... def has_massive_nu(self):<br>... return False<br>... @property<br>... def Onu0(self):<br>... return NEUTRINO_FERMI_DIRAC_CORRECTION * self.Neff * self.Ogamma0<br>... def nu_relative_density(self, z):<br>... return NEUTRINO_FERMI_DIRAC_CORRECTION * self.Neff * np.ones_like(np.asarray(z))<br>... def Ogamma(self, z):<br>... return self.Ogamma0 * (np.asarray(z) + 1.0) ** 4<br>... @property<br>... def is_flat(self):<br>... return True<br>>>><br>>>> cosmo = SimpleNeutrinoCosmology()<br>>>> cosmo.Tnu0

>>> cosmo.has_massive_nu<br>False<br>>>> cosmo.Onu0<br>3.4...e-05<br>>>> cosmo.Onu(0)<br>np.float64(3.4...e-05)<br>>>> cosmo.Tnu(1)

Machine Readable Table (MRT) I/O#

The astropy.cosmology module now supports reading and writing cosmological<br>objects in the Machine Readable Table (MRT) format. This adds MRT to the<br>existing I/O options for cosmology, which include YAML, ECSV, HTML, and LaTeX<br>formats.

MRT format is commonly used in astronomical publications and data archives. You<br>can now save and load cosmological parameters using the .read() and<br>.write() methods with format="ascii.mrt":

from astropy.cosmology import Planck18

# Write to MRT file<br>Planck18.write("cosmology.mrt")

# Read from MRT file<br>cosmo = Cosmology.read("cosmology.mrt")

Note that since MRT format does not preserve table metadata, the cosmology class<br>is included as a column in the table rather than in metadata (similar to HTML<br>and LaTeX formats). Multi-dimensional columns (such as neutrino masses) are<br>automatically JSON-encoded when writing and decoded when reading.

Angular diameter distance between two redshifts#

The angular_diameter_distance() method now...

cosmology astropy self from import table

Related Articles