<commit_before>.. _whatsnew-5.1:

**************************
What's New in Astropy 5.1?
**************************

Overview
========

Astropy 5.1 is a major release that adds significant new functionality since
the 5.0 LTS release.

In particular, this release includes:

* :ref:`whatsnew-5.1-cosmology`
* :ref:`whatsnew-doppler-redshift-eq`
* :ref:`whatsnew-io-ascii-converters`
* :ref:`whatsnew-structured-columns`

.. _whatsnew-5.1-cosmology:

Updates to ``Cosmology``
========================

:class:`~astropy.cosmology.Cosmology` is now an abstract base class,
and subclasses must override the abstract property ``is_flat``.
For :class:`~astropy.cosmology.FLRW`, ``is_flat`` checks that ``Ok0=0`` and
``Otot0=1``.

Astropy v5.0 introduced Cosmological equivalency -- with method
:meth:`~astropy.cosmology.Cosmology.is_equivalent` -- where two cosmologies may
be equivalent even if not of the same class. For example, an instance of
:class:`~astropy.cosmology.LambdaCDM` might have :math:`\Omega_0=1` and
:math:`\Omega_k=0` and therefore be flat, like ``FlatLambdaCDM``.
Now the keyword argument ``format`` is added to extend the notion of
equivalence to any Python object that can be converted to a Cosmology.

    >>> from astropy.cosmology import Planck18
    >>> tbl = Planck18.to_format("astropy.table")
    >>> Planck18.is_equivalent(tbl, format=True)
    True

The list of valid formats, e.g. the Table in this example, may be
checked with ``Cosmology.from_format.list_formats()``


A new property ``nonflat`` has been added to flat cosmologies
(:class:`astropy.cosmology.FlatCosmologyMixin` subclasses) to get an equivalent
cosmology, but of the corresponding non-flat class.

    >>> Planck18.nonflat
    LambdaCDM(name="Planck18", H0=67.66 km / (Mpc s), ...


:meth:`astropy.cosmology.FlatCosmologyMixin.clone` has been enhanced to allow
for flat cosmologies to clone on the equivalent non-flat cosmology. For example,

    >>> Planck18.clone(to_nonflat=True, Ode0=1)
    LambdaCDM(name="Planck18 (modified)", H0=67.66 km / (Mpc s), Om0=0.30966, Ode0=1.0, ...


.. _whatsnew-doppler-redshift-eq:

``doppler_redshift`` equivalency
================================

New :func:`astropy.units.equivalencies.doppler_redshift` is added to
provide conversion between Doppler redshift and radial velocity.

.. _whatsnew-io-ascii-converters:

Specifying data types when reading ASCII tables
===============================================

The syntax for specifying the data type of columns when reading a table using
:func:`astropy.io.ascii.read` has been simplified considerably. For instance,
to force every column in a table to be read as a ``float`` you can now do:

    >>> from astropy.table import Table
    >>> t = Table.read('table.dat', format='ascii', converters={'*': float})  # doctest: +SKIP

Previously, doing the same data type specification required using the
:func:`~astropy.io.ascii.convert_numpy` function and providing the ``dict``
value as a ``list`` even for only one element::

    >>> from astropy.io.ascii import convert_numpy
    >>> t = Table.read('table.dat', format='ascii',
    ...                converters={'*': [convert_numpy(float)]})  # doctest: +SKIP

Note that the previous syntax is still supported for backwards compatibility
and there is no intent to remove this. See :ref:`io-ascii-read-converters` for
details.

.. _whatsnew-structured-columns:

Structured Columns
==================

Columns which are ``numpy`` structured arrays are now fully supported,
effectively allowing tables within tables. This applies to |Column|,
|MaskedColumn|, and |Quantity| columns, and includes possible structured
units. These structured data columns can be stored in ECSV, FITS, and HDF5
formats.

Full change log
===============

To see a detailed list of all changes in version v5.1, including changes in
API, please see the :ref:`changelog`.

Renamed/removed functionality
=============================
<commit_msg>Add what's new entry<commit_after>.. _whatsnew-5.1:

**************************
What's New in Astropy 5.1?
**************************

Overview
========

Astropy 5.1 is a major release that adds significant new functionality since
the 5.0 LTS release.

In particular, this release includes:

* :ref:`whatsnew-5.1-cosmology`
* :ref:`whatsnew-doppler-redshift-eq`
* :ref:`whatsnew-io-ascii-converters`
* :ref:`whatsnew-structured-columns`
* :ref:`whatsnew-fitters`

.. _whatsnew-5.1-cosmology:

Updates to ``Cosmology``
========================

:class:`~astropy.cosmology.Cosmology` is now an abstract base class,
and subclasses must override the abstract property ``is_flat``.
For :class:`~astropy.cosmology.FLRW`, ``is_flat`` checks that ``Ok0=0`` and
``Otot0=1``.

Astropy v5.0 introduced Cosmological equivalency -- with method
:meth:`~astropy.cosmology.Cosmology.is_equivalent` -- where two cosmologies may
be equivalent even if not of the same class. For example, an instance of
:class:`~astropy.cosmology.LambdaCDM` might have :math:`\Omega_0=1` and
:math:`\Omega_k=0` and therefore be flat, like ``FlatLambdaCDM``.
Now the keyword argument ``format`` is added to extend the notion of
equivalence to any Python object that can be converted to a Cosmology.

    >>> from astropy.cosmology import Planck18
    >>> tbl = Planck18.to_format("astropy.table")
    >>> Planck18.is_equivalent(tbl, format=True)
    True

The list of valid formats, e.g. the Table in this example, may be
checked with ``Cosmology.from_format.list_formats()``


A new property ``nonflat`` has been added to flat cosmologies
(:class:`astropy.cosmology.FlatCosmologyMixin` subclasses) to get an equivalent
cosmology, but of the corresponding non-flat class.

    >>> Planck18.nonflat
    LambdaCDM(name="Planck18", H0=67.66 km / (Mpc s), ...


:meth:`astropy.cosmology.FlatCosmologyMixin.clone` has been enhanced to allow
for flat cosmologies to clone on the equivalent non-flat cosmology. For example,

    >>> Planck18.clone(to_nonflat=True, Ode0=1)
    LambdaCDM(name="Planck18 (modified)", H0=67.66 km / (Mpc s), Om0=0.30966, Ode0=1.0, ...


.. _whatsnew-doppler-redshift-eq:

``doppler_redshift`` equivalency
================================

New :func:`astropy.units.equivalencies.doppler_redshift` is added to
provide conversion between Doppler redshift and radial velocity.

.. _whatsnew-io-ascii-converters:

Specifying data types when reading ASCII tables
===============================================

The syntax for specifying the data type of columns when reading a table using
:func:`astropy.io.ascii.read` has been simplified considerably. For instance,
to force every column in a table to be read as a ``float`` you can now do:

    >>> from astropy.table import Table
    >>> t = Table.read('table.dat', format='ascii', converters={'*': float})  # doctest: +SKIP

Previously, doing the same data type specification required using the
:func:`~astropy.io.ascii.convert_numpy` function and providing the ``dict``
value as a ``list`` even for only one element::

    >>> from astropy.io.ascii import convert_numpy
    >>> t = Table.read('table.dat', format='ascii',
    ...                converters={'*': [convert_numpy(float)]})  # doctest: +SKIP

Note that the previous syntax is still supported for backwards compatibility
and there is no intent to remove this. See :ref:`io-ascii-read-converters` for
details.

.. _whatsnew-structured-columns:

Structured Columns
==================

Columns which are ``numpy`` structured arrays are now fully supported,
effectively allowing tables within tables. This applies to |Column|,
|MaskedColumn|, and |Quantity| columns, and includes possible structured
units. These structured data columns can be stored in ECSV, FITS, and HDF5
formats.

.. _whatsnew-fitters:

New fitters have been added
===========================

New fitters have been added to :mod:`~astropy.modeling.fitting` based around the available
algorithms provided by `scipy.optimize.least_squares`, which is now the recommended
least-squares optimization algorithm from scipy. These new fitters are:

* :class:`~astropy.modeling.fitting.TRFLSQFitter`, which uses the Trust Region Reflective (TRF)
  algorithm.
* :class:`~astropy.modeling.fitting.LMLSQFitter`, which uses the Levenburg-Marquardt (LM) algorithm,
  via the :func:`scipy.optimize.lease_squares` function.
* :class:`~astropy.modeling.fitting.DogBoxLSQFitter`, which uses the dogleg algorithm.

Full change log
===============

To see a detailed list of all changes in version v5.1, including changes in
API, please see the :ref:`changelog`.

Renamed/removed functionality
=============================

{'fraction_non_alphanumeric': 0.15885899814471244, 'fraction_numerical': 0.013914656771799629, 'mean_word_length': 4.993745656706046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '196437', 'n_tokens_mistral': 2745, 'n_tokens_neox': 2531, 'n_words': 873}