What’s New in Astropy 6.1?#
Overview#
Astropy 6.1 is a minor release that adds significant new functionality since the 6.0 release.
In particular, this release includes:
In addition to these major changes, Astropy 6.1 includes a large number of smaller improvements and bug fixes, which are described in the Full Changelog. By the numbers:
759 commits have been added since 6.0
188 issues have been closed since 6.0
316 pull requests have been merged since 6.0
54 people have contributed since 6.0
16 of which are new contributors
Updated minimum Python version to 3.10#
The minimum required version of Python has been upgraded to 3.10. This is in line with the NumPy deprecation policy.
Order-dependent angular separations now come with warnings#
Angular separation between two points depends on the point of view.
For example, during a lunar eclipse and for an observer on the Earth the Sun
and the Moon will be in (more-or-less) opposite directions, but at the same
time for an observer at the Earth-Sun L2 point (where Gaia and James Webb Space
Telescope are) the Sun and the Moon will be (more-or-less) in the same
direction.
The separation()
method
automatically converts a coordinate given to it to the frame of the coordinate
it belongs to, so the separation can be different if the coordinates are
swapped.
Such transformations are now accompanied by an appropriate warning:
>>> from astropy import units as u
>>> from astropy.coordinates import SkyCoord
>>> icrs = SkyCoord(0 * u.deg, 0 * u.deg, 10 * u.pc)
>>> gcrs = SkyCoord(0 * u.deg, 0 * u.deg, 380_000 * u.km, frame="gcrs")
>>> icrs.separation(gcrs)
<Angle 100.67116925 deg>
NonRotationTransformationWarning: transforming other coordinates from
<GCRS Frame (obstime=J2000.000, obsgeoloc=(0., 0., 0.) m,
obsgeovel=(0., 0., 0.) m / s)> to <ICRS Frame>. Angular separation can
depend on the direction of the transformation.
>>> gcrs.separation(icrs)
<Angle 0.0010732 deg>
NonRotationTransformationWarning: transforming other coordinates from
<ICRS Frame> to <GCRS Frame (obstime=J2000.000, obsgeoloc=(0., 0., 0.) m,
obsgeovel=(0., 0., 0.) m / s)>. Angular separation can depend on the
direction of the transformation.
The warning is not emitted if the coordinate transformation is a pure rotation because such transformations do not change the origin of the coordinate frames, so the angular separation does not depend on the order of the coordinates:
>>> galactic = SkyCoord(0 * u.deg, 0 * u.deg, 10 * u.pc, frame="galactic")
>>> icrs.separation(galactic)
<Angle 93.14572374 deg>
>>> galactic.separation(icrs)
<Angle 93.14572374 deg>
It is possible to suppress the warning:
>>> icrs.separation(gcrs, origin_mismatch="ignore")
<Angle 100.67116925 deg>
It is also possible to forbid non-rotation transformations:
>>> icrs.separation(gcrs, origin_mismatch="error")
Traceback (most recent call last):
...
astropy.coordinates.errors.NonRotationTransformationError: refusing to
transform other coordinates from <GCRS Frame (obstime=J2000.000,
obsgeoloc=(0., 0., 0.) m, obsgeovel=(0., 0., 0.) m / s)> to <ICRS Frame>
because angular separation can depend on the direction of the transformation
Pure rotations will still succeed:
>>> galactic.separation(icrs, origin_mismatch="error")
<Angle 93.14572374 deg>
io.ascii
uses 64-integers by default for integer columns#
ascii
now uses a 64-bit integer field by
default when reading a column of integer numeric data. This changes the default behavior
on Windows and potentially 32-bit architectures. Previously on those platforms, table
columns with any long integers which overflowed the 32-bit integer would be returned
as string columns. The new default behavior is consistent with numpy
v2 and pandas
.
Changes to semantics of copy=
keyword arguments#
Public APIs that expose a copy
argument and that previously set False
as a default value now use None
instead if numpy
v2 or newer is installed.
This is because in numpy
v2, the meaning of the copy
argument was changed,
with copy=False
now indicating that a copy should never be made, while
copy=None
is used for the previous meaning of “avoid a copy if possible”.
This includes:
astropy.units.Quantity
astropy.utils.Masked
astropy.table.Column
astropy.time.Time
astropy.coordinates.SkyCoord
While this change ensures the default behaviour of astropy has not changed,
code that explicitly passes copy=False
to many of astropy’s classes
may need adjustments where the intention was to forbid unnecessary copies
but allow the ones that couldn’t be avoided.
For portability across different versions of Numpy, we recommend that these
instances of False
be replaced with a COPY_IF_NEEDED
constant defined
as follow:
COPY_IF_NEEDED = False if np.__version__.startswith("1.") else None
Cosmology
is now a dataclass()
#
The Cosmology
class is
now a dataclass()
. This means that the dataclasses
machinery
can be used to work with Cosmology
objects. For example:
>>> from dataclasses import asdict, fields, replace
>>> from astropy.cosmology import Planck18
>>> replace(Planck18, name="modified", Ob0=0.05)
FlatLambdaCDM(name='modified', ..., Ob0=0.05)
>>> asdict(Planck18)
{'name': 'Planck18', 'meta': ..., 'H0': <Quantity 67.66 km / (Mpc s)>, ...
>>> [f.name for f in fields(Planck18)]
['name', 'meta', 'H0', 'Om0', 'Ode0', 'Tcmb0', 'Neff', 'm_nu', 'Ob0']
Also, it is now possible to create new Cosmology
subclasses
using make_dataclass()
:
>>> from dataclasses import make_dataclass, field, fields
>>> from astropy.cosmology import Cosmology
>>> NewC = make_dataclass("NewC", [("newfield", float, field(default=None))],
... bases=(Cosmology,), frozen=True, eq=False)
>>> [f.name for f in fields(NewC)]
['name', 'meta', 'newfield']
Full change log#
To see a detailed list of all changes in version 6.1, including changes in API, please see the Full Changelog.
Contributors to the 6.1 release#
The people who have contributed to the code for this release are:
|
|
|
|
Where a * indicates that this release contains their first contribution to astropy.