What’s New in Astropy 7.1?#
Overview#
Astropy 7.1 is a major release that adds significant new functionality since the 7.0 release.
In particular, this release includes:
Trailing whitespace in Table string columns can now be stripped
Constructing, accessing, and storing covariance matrices for N-dimensional data
Get an astropy built-in frame out of a VOTable’s coosys element
In addition to these major changes, Astropy v7.1 includes a large number of smaller improvements and bug fixes, which are described in the Full Changelog. By the numbers:
919 commits have been added since 7.0
148 issues have been closed since 7.0
333 pull requests have been merged since 7.0
44 people have contributed since 7.0
19 of which are new contributors
Trailing whitespace in Table
string columns can now be stripped#
Strings in FITS binary tables are sometimes padded with trailing whitespace.
It is now possible to remove those when reading a table with
(Q)Table.read("filename.fits", strip_spaces=True)
. The default behavior is
not changed yet to preserve compatibility with codes that might rely on this,
it will change in the next major version (v8.0).
Reading and writing TDAT files with astropy.io.ascii
#
The TDAT format, specified by https://heasarc.gsfc.nasa.gov/docs/software/dbdocs/tdat.html, is now supported by the Unified File Read/Write Interface.
Note that this format is compatible with Table
objects with integer, float,
and/or string data types, but not QTable
objects or other data types.
Constructing, accessing, and storing covariance matrices for N-dimensional data#
We provide a new utility class that provides basic functionality for covariance
matrices associated NDData
objects via the new
Covariance
class. See the full Covariance
documentation.
Fast CSV reader using PyArrow#
We have added a new fast CSV reader that uses the PyArrow CSV reader to read CSV files up to 15 times
faster than astropy.io.ascii
fast reader or the pandas.csv
reader. This
is an excellent option for reading large CSV files when speed and memory performance are
important. For details see PyArrow CSV.
Cosmology traits#
The astropy.cosmology.traits
module hosts various parts of cosmologies, such as the
ScaleFactor
or
TemperatureCMB
. These traits can be used to more
easily construct custom cosmologies by combining different components.
As a simple example, the TemperatureCMB
trait
provides the Tcmb0
property and
Tcmb()
method for computing the
cosmological CMB temperature at specified redshifts. By using this trait, you can add
temperature-related functionality to your custom cosmology class without having to
implement it from scratch.
Here is an example of how to use the ScaleFactor
and
TemperatureCMB
traits in a custom cosmology class:
>>> import astropy.units as u
>>> from astropy.cosmology.traits import ScaleFactor, TemperatureCMB
>>> from astropy.cosmology import Cosmology
>>>
>>> class CustomCosmology(Cosmology, ScaleFactor, TemperatureCMB):
... def __init__(self, H0, Om0, Ode0, Tcmb0=2.725):
... self.H0 = H0
... self.Om0 = Om0
... self.Ode0 = Ode0
... self.Tcmb0 = u.Quantity(Tcmb0, "K")
... super().__init__()
...
... is_flat = False
... # Additional custom methods and properties can be added here
>>> cosmo = CustomCosmology(H0=70, Om0=0.3, Ode0=0.7)
>>> cosmo.scale_factor(0)
<Quantity 1.>
>>> cosmo.Tcmb(1)
<Quantity 5.45 K>
By combining different traits, you can create fully-featured cosmology classes with minimal effort.
Get an astropy built-in frame out of a VOTable’s coosys element#
CooSys
VOTable elements now have a method to_astropy_frame
that returns the
corresponding astropy built-in frame, when possible:
>>> from astropy.io.votable.tree import CooSys
>>> coosys = CooSys(system="ICRS", epoch="J2020")
>>> coosys.to_astropy_frame()
<ICRS Frame>
New astropy.io.votable.dataorigin
module#
This new module extracts provenance information from VOTable header. The information is described in DataOrigin IVOA note: https://www.ivoa.net/documents/DataOrigin/.
DataOrigin includes both the query information (such as publisher, contact, versions, etc.) and the Dataset origin (such as Creator, bibliographic links, URL, etc.).
This API retrieves Metadata from INFO in VOTAble.
Example of output including DataOrigin:
VizieR catalogue (CDS): ex: Planck cold clumps survey in the Orion complex (Liu+, 2012)
>>> from astropy.io.votable import parse
>>> from astropy.io.votable.dataorigin import extract_data_origin
>>> vot = parse("https://vizier.cds.unistra.fr/viz-bin/conesearch/J/ApJS/202/4/clumps?RA=69.36&DEC=16.98&SR=0.5")
>>> print(extract_data_origin(vot))
publisher: CDS
server_software: 7.4.5
service_protocol: ivo://ivoa.net/std/ConeSearch/v1.03
request: https://vizier.cds.unistra.fr/viz-bin/conesearch/J/ApJS/202/4/clumps?RA=69.36&DEC=16.98&SR=0.5
request_date: 2025-03-05T08:48:57
contact: cds-question@unistra.fr
ivoid: ivo://cds.vizier/j/apjs/202/4
citation: doi:10.26093/cds/vizier.22020004
reference_url: https://cdsarc.cds.unistra.fr/viz-bin/cat/J/ApJS/202/4
rights_uri: https://cds.unistra.fr/vizier-org/licences_vizier.html
creator: Liu T.
editor: Astrophysical Journal Supplement (AAS)
cites: bibcode:2012ApJS..202....4L
original_date: 2012
publication_date: 2017-06-29
GAVO: ex: CALIFA Cubes
>>> vot = parse("https://dc.g-vo.org/califa/q3/cubesearch/form?__nevow_form__=genForm&target_name=2MASXJ09065870&MAXREC=100&_FORMAT=VOTable&submit=Go")
>>> print(extract_data_origin(vot))
publisher: The GAVO DC team
server_software: DaCHS/2.10 twistedWeb/22.4.0
request_date: 2025-03-05T08:40:35Z
contact: gavo@ari.uni-heidelberg.de
ivoid: ivo://org.gavo.dc/califa/q3/s,ivo://org.gavo.dc/califa/q3/tables
citation: http://dc.g-vo.org/tableinfo/califadr3.cubes#ti-citing
reference_url: http://dc.g-vo.org/tableinfo/califadr3.cubes
resource_version: 3
rights: CALIFA asks you to acknowledge: "This study uses data provided by the Calar Alto Legacy Integral Field Area (CALIFA) survey (http://califa.caha.es/)." "Based on observations collected at the Centro Astronómico Hispano Alemán (CAHA) at Calar Alto, operated jointly by the Max-Planck-Institut fűr Astronomie and the Instituto de Astrofísica de Andalucía (CSIC)." and to cite both of :bibcode:`2014A&A...569A...1W` and :bibcode:`2012A&A...538A...8S`
creator: Sánchez, F.,The CALIFA collaboration
Access to fit information when using parallel_fit_dask
#
When carrying out parallel modeling of N-dimensional datasets with
parallel_fit_dask()
, it is now possible to use
the fit_info
keyword argument to optionally make it possible to access fit
information for all the fits. For example, when doing:
>>> model_fit = parallel_fit_dask(model=model,
... ...
... fitter=fitter,
... fit_info=True)
it is then possible to access the .fit_info
object on the fitter
which in this case behaves like an array:
>>> fitter.fit_info.shape
(50, 50)
>>> fitter.fit_info.ndim
2
Indexing the fit info will return a specific fit information object, e.g.:
>>> fitter.fit_info[10, 20]
message: The maximum number of function evaluations is exceeded.
success: False
status: 0
fun: [-2.169e-01 -2.398e-01 ... -5.502e-02 2.498e-01]
x: [ 5.352e+02 2.034e+04 3.932e+03]
cost: 0.575174901185717
jac: [[ 3.514e-05 -2.166e-05 9.810e-05]
[ 3.793e-05 -2.329e-05 1.051e-04]
...
[ 1.200e-03 -5.990e-04 2.197e-03]
[ 1.277e-03 -6.343e-04 2.316e-03]]
grad: [-5.634e-06 2.866e-06 -1.092e-05]
optimality: 1.0921480583423703e-05
active_mask: [0 0 0]
nfev: 100
njev: 93
param_cov: [[ 5.965e+08 2.262e+09 2.913e+08]
[ 2.262e+09 8.584e+09 1.106e+09]
[ 2.913e+08 1.106e+09 1.427e+08]]
This is described in detail in Fit information.
Full change log#
To see a detailed list of all changes in version v7.1, including changes in API, please see the Full Changelog.
Contributors to the 7.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.