astropy v5.1 Release Notes
Release Date: 2022-05-23 // over 3 years ago-
๐ New Features
astropy.coordinates
The ephemeris used in
astropy.coordinatescan now be set to any version of the JPL ephemeris available from https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/. [#12541]Angle.to_string()now accepts the'latex_inline'unit format. [#13056]
astropy.cosmology
๐ Cosmology instance can be parsed from or converted to a YAML string using the new "yaml" format in Cosmology's
to/from_formatI/O. [#12279]Register "astropy.row" into Cosmology's to/from format I/O, allowing a Cosmology instance to be parse from or converted to an Astropy Table Row. [#12313]
๐ฏ A method
clonehas been added toParameterto quickly deep copy the object and change any constructor argument. A supporting equality method is added, andrepris enhanced to be able to roundtrip --eval(repr(Parameter()))-- if the Parameter's arguments can similarly roundtrip. Parameter's arguments are made keyword-only. [#12479]โ Add methods
OtotandOtot0to FLRW cosmologies to calculate the total energy density of the Universe. [#12590]โ Add property
is_flatto cosmologies to calculate the curvature of the Universe.Cosmologyis now an abstract class and subclasses must override the abstract propertyis_flat. [#12606]For converting a cosmology to a mapping, two new boolean keyword arguments are added:
cosmology_as_strfor turning the class reference to a string, instead of the class object itself, andmove_from_metato merge the metadata with the rest of the returned mapping instead of adding it as a nested dictionary. [#12710]Register format "astropy.cosmology" with Cosmology I/O. [#12736]
Cosmological equivalency (
Cosmology.is_equivalent) can now be extended to any Python object that can be converted to a Cosmology, using the new keyword argumentformat. This allows e.g. a properly formatted Table to be equivalent to a Cosmology. [#12740]โ The new module
cosmology/tests/helper.pyhas been added to provide tools for testing the cosmology module and related extensions. [#12966]A new property
nonflathas been added to flat cosmologies (FlatCosmologyMixinsubclasses) to get an equivalent cosmology, but of the corresponding non-flat class. [#13076]๐ฏ
clonehas been enhanced to allow for flat cosmologies to clone on the equivalent non-flat cosmology. [#13099]cosmologyfile I/O uses the Unified Table I/O interface, which has added support for reading and writing file paths of the form~/file.ecsvor~<username>/file.ecsv, referring to the home directory of the current user or the specified user, respectively. [#13129]
astropy.io.ascii ^
Simplify the way that the
convertersargument ofio.ascii.readis provided. Previously this required wrapping each data type as the tuple returned by theio.ascii.convert_numpy()function and ensuring that the value is alist. With this update you can writeconverters={'col1': bool}to force conversion as aboolinstead of the previous syntaxconverters={'col1': [io.ascii.convert_numpy(bool)]}. Note that this update is back-compatible with the old behavior. [#13073]โ Added support in
io.asciifor reading and writing file paths of the form~/file.csvor~<username>/file.csv, referring to the home directory of the current user or the specified user, respectively. [#13130]
astropy.io.fits ^
๐ Add option
unit_parse_stricttoastropy.io.fits.connect.read_table_fitsto enable warnings or errors about invalid FITS units when usingastropy.table.Table.read. The default for this new option is"warn", which means warnings are now raised for columns with invalid units. [#11843]๐ Changes default FITS behavior to use buffered I/O rather than unbuffered I/O for performance reasons. [#12081]
astropy.io.fits.Headernow has a method to calculate the size (in bytes) of the data portion (with or without padding) following that header. [#12110]
astropy.io.misc ^
๐ Allow serialization of model unit equivalencies. [#10198]
Built-in Cosmology subclasses can now be converted to/from YAML with the functions
dumpandloadinastropy.io.misc.yaml. [#12279]โ Add asdf support for
Cosine1D,Tangent1D,ArcSine1D,ArcCosine1D, andArcTangent1Dmodels. [#12895]โ Add asdf support for
Spline1Dmodels. [#12897]
astropy.io.registry
- โ Added support to the Unified Table I/O interface for reading and writing file
paths of the form
~/file.csvor~<username>/file.csv, referring to the home directory of the current user or the specified user, respectively. [#13129]
astropy.modeling ^
โ Add new fitters based on
scipy.optimize.least_squaresmethod of non-linear least-squares optimization: [#12051]TRFLSQFitterusing the Trust Region Reflective algorithm.LMLSQFitterusing the Levenberg-Marquardt algorithm (implemented byscipy.optimize.least_squares).DogBoxLSQFitterusing the dogleg algorithm.
Enable direct use of the
ignoredfeature ofModelBoundingBoxby users in addition to its use as part of enablingCompoundBoundingBox. [#12384]Switch
modeling.projectionsto useastropy.wcs.Prjprmwrapper internally and provide access to theastropy.wcs.Prjprmstructure. [#12558]โ Add error to non-finite inputs to the
LevMarLSQFitter, to protect against soft scipy failure. [#12811]๐ Allow the
Ellipse2DandSersic2Dtheta parameter to be input as an angular quantity. [#13030]โ Added
Schechter1Dmodel. [#13116]
astropy.nddata ^
โ Add support for converting between uncertainty types. This uncertainty conversion system uses a similar flow to the coordinate subsystem, where Cartesian is used as the common system. In this case, variance is used as the common system. [#12057]
The
as_image_hduoption is now available forCCDData.to_hduandCCDData.write. This option allows the user to get anImageHDUas the first item of the returnedHDUList, instead of the defaultPrimaryHDU. [#12962]File I/O through
nddata.CCDDatauses the Unified I/O interface, which has added support for reading and writing file paths of the form~/file.csvor~<username>/file.csv, referring to the home directory of the current user or the specified user, respectively. [#13129]
astropy.table ^
A new keyword-only argument
kindwas added to theTable.sortmethod to specify the sort algorithm. [#12637]๐ Columns which are
numpystructured arrays are now fully supported, effectively allowing tables within tables. This applies toColumn,MaskedColumn, andQuantitycolumns. These structured data columns can be stored in ECSV, FITS, and HDF5 formats. [#12644]๐ Improve the performance of
np.searchsortedby a factor of 1000 for a bytes-typeColumnwhen the search value isstror an array ofstr. This happens commonly for string data stored in FITS or HDF5 format files. [#12680]โ Add support for using mixin columns in group aggregation operations when the mixin supports the specified operation (e.g.
np.sumworks forQuantitybut notTime). In cases where the operation is not supported the code now issues a warning and drops the column instead of raising an exception. [#12825]โ Added support to the Unified Table I/O interface for reading and writing file paths of the form
~/file.csvor~<username>/file.csv, referring to the home directory of the current user or the specified user, respectively. [#13129]
astropy.time ^
- โ Add support for calling
numpy.linspace()with twoTimeinstances to generate a or multiple linearly spaced set(s) of times. [#13132]
astropy.units ^
structured_to_unstructuredandunstructured_to_structuredinnumpy.lib.recfunctionsnow work with Quantity. [#12486]Implement multiplication and division of LogQuantities and numbers [#12566]
๐ New
doppler_redshiftequivalency to convert between Doppler redshift and radial velocity. [#12709]โ Added the
wherekeyword argument to themean(),var(),std()andnansum()methods ofastropy.units.Quantity. Also added theintialkeyword argument toastropy.units.Quantity.nansum(). [#12891]โ Added "Maxwell" as a unit for magnetic flux to the CGS module. [#12975]
Quantity.to_string()andFunctionUnitBase.to_string()now accept the'latex_inline'unit format. The output ofStructuredUnit.to_string()when called withformat='latex_inline'is now more consistent with the output when called withformat='latex'. [#13056]
astropy.utils ^
โ Added the
wherekeyword argument to themean(),var(),std(),any(), andall()methods ofastropy.utils.masked.MaskedNDArray. [#12891]๐ Improve handling of unavailable IERS-A (predictive future Earth rotation) data in two ways. First, allow conversions with degraded accuracy if the IERS-A data are missing or do not cover the required time span. This is done with a new config item
conf.iers_degraded_accuracywhich specifies the behavior when times are outside the range of IERS table. The options are 'error' (raise anIERSRangeError, default), 'warn' (issue aIERSDegradedAccuracyWarning) or 'ignore' (ignore the problem). Second, the logic for auto-downloads was changed to guarantee that no matter what happens with the IERS download operations, only warnings will be issued. [#13052]
astropy.wcs ^
astropy.wcs.Celprmandastropy.wcs.Prjprmhave been added to allow access to lower level WCSLIB functionality and to allow direct access to thecelandprjmembers ofWcsprm. [#12514]โ Add
temporalproperties for convenient access of/selection of/testing for theTIMEaxis introduced in WCSLIB version 7.8. [#13094]
API Changes
astropy.coordinates
- The
dms_to_degreesandhms_to_hoursfunctions (and implicitly tuple-based initialization ofAngle) is now deprecated, as it was difficult to be sure about the intent of the user for signed values of the degrees/hours, minutes, and seconds. [#13162]
astropy.cosmology
The already deprecated
Planck18_arXiv_v2has been removed. UsePlanck18instead [#12354]default_cosmology.get_cosmology_from_stringis deprecated and will be removed in two minor versions. Usegetattr(astropy.cosmology, <str>)instead. [#12375]๐ In I/O, conversions of Parameters move more relevant information from the Parameter to the Column. The default Parameter
format_specis changed from".3g"to"". [#12612]๐ Units of redshift are added to
z_reionin built-in realizations' metadata. [#12624]Cosmology realizations (e.g.
Planck18) and parameter dictionaries are now lazily loaded from source files. [#12746]The Cosmology Parameter argument "fmt" for specifying a format spec has been deprecated in favor of using the built-in string representation from the Parameter's value's dtype. [#13072]
astropy.io.ascii ^
- When reading an ECSV file, changed the type checking
to issue an
InvalidEcsvDatatypeWarninginstead of raising aValueErrorexception if thedatatypeof a column is not recognized in the ECSV standard. This also applies to older versions of ECSV files which used to silently proceed but now warn first. [#12841]
astropy.io.fits ^
โ Removed deprecated
clobberargument from functions inastropy.io.fits. [#12258]โ Add
-s/--sortargument tofitsheaderto sort the fitsort-mode output. [#13106]
astropy.io.misc ^
- ๐ฆ Deprecate asdf in astropy core in favor of the asdf-astropy package. [#12903, #12930]
astropy.modeling ^
- Made
astropy.modeling.fitting._fitter_to_model_paramsandastropy.modeling.fitting._model_to_fit_paramspublic methods. [#12585]
astropy.table ^
๐ Change the repr of the Table object to replace embedded newlines and tabs with
r'\n'andr'\t'respectively. This improves the display of such tables. [#12631]A new keyword-only argument
kindwas added to theTable.sortmethod to specify the sort algorithm. The signature ofTable.sortwas modified so that thereverseargument is now keyword-only. Previouslyreversecould be specified as the second positional argument. [#12637]๐ Changed behavior when a structured
numpy.ndarrayis added as a column to aTable. Previously this was converted to aNdarrayMixinsubclass ofndarrayand added as a mixin column. This was because saving as a file (e.g. HDF5, FITS, ECSV) was not supported for structured array columns. Now a structurednumpy.ndarrayis added to the table as a nativeColumnand saving to file is supported. [#13236]
โ astropy.tests ^
โ Backward-compatible import of
astropy.tests.disable_internethas been removed; usepytest_remotedata.disable_internetfrompytest-remotedatainstead. [#12633]โ Backward-compatible import of
astropy.tests.helper.remote_datahas been removed; usepytest.mark.remote_datafrompytest-remotedatainstead. [#12633]๐ The following are deprecated and will be removed in a future release. Use
pytestwarning and exception handling instead: [#12633]astropy.io.ascii.tests.common.raisesastropy.tests.helper.catch_warningsastropy.tests.helper.ignore_warningsastropy.tests.helper.raisesastropy.tests.helper.enable_deprecations_as_exceptionsastropy.tests.helper.treat_deprecations_as_exceptions
โ Backward-compatible plugin
astropy.tests.plugins.displayhas been removed; usepytest-astropy-headerinstead. [#12633]
astropy.time ^
- Creating an
~astropy.time.TimeDeltaobject with numerical inputs that do not have a unit and without specifying an explicit format, for exampleTimeDelta(5), now results in a~astropy.time.TimeDeltaMissingUnitWarning. This also affects statements likeTime("2020-01-01") + 5orTime("2020-01-05") - Time("2020-01-03") < 5, which implicitly transform the right-hand side into an~astropy.time.TimeDeltainstance. [#12888]
๐ Bug Fixes
astropy.coordinates
- The machinery that makes observatory locations available as
EarthLocationobjects is now smarter about processing observatory names from its data files. More names are available for use and the empty string is no longer considered to be a valid name. [#12721]
astropy.io.ascii ^
๐ Fixed
io.asciiread and write functions for most formats to correctly handle data fields with embedded newlines for both the fast and pure-Python readers and writers. [#12631]๐ Fix an issue when writing
Timetable columns to a file when the timeformatis one ofdatetime,datetime64, orymdhms. Previously, writing aTimecolumn with one of these formats could result in an exception or else an incorrect output file that cannot be read back in. [#12842]
astropy.io.fits ^
โ Add a
mask_invalidoption toTable.readto allow deactivating the masking of NaNs in float columns and empty strings in string columns. This option is necessary to allow effective use of memory-mapped reading withmemmap=True. [#12544]๐ Fix
CompImageHeader.clear(). [#13102]
astropy.modeling ^
- ๐ Bugfix for
ignorefunctionality failing inModelBoundingBoxwhen usingignoreoption alongside passing bounding box data as tuples. [#13032]
astropy.table ^
Fixed a bug in
Table.show_in_browserusing thejsviewer=Trueoption to display the table with sortable columns. Previously the sort direction arrows were not being shown due to missing image files for the arrows. [#12716]๐ Fix an issue when writing
Timetable columns to a file when the timeformatis one ofdatetime,datetime64, orymdhms. Previously, writing aTimecolumn with one of these formats could result in an exception or else an incorrect output file that cannot be read back in. [#12842]๐ Fixed a bug where it is not possible to set the
.info.formatproperty of a table structured column and get formatted output. [#13233]๐ Fixed a bug when adding a masked structured array to a table. Previously this was auto-converted to a
NdarrayMixinwhich loses the mask. With this fix the data are added to the table as aMaskedColumnand the mask is preserved. [#13236]
astropy.time ^
- ๐ Fix an issue when writing
Timetable columns to a file when the timeformatis one ofdatetime,datetime64, orymdhms. Previously, writing aTimecolumn with one of these formats could result in an exception or else an incorrect output file that cannot be read back in. [#12842]
astropy.utils ^
๐ Fixed a bug which caused
numpy.interpto produce incorrect results whenMaskedarrays were passed. [#12978]๐ Fixed HAS_YAML not working as intended. [#13066]
astropy.wcs ^
Convert
NoConvergenceerrors to warnings inworld_to_pixel_valuesso that callers can work at least with the non converged solution. [#11693]๐ฆ Expose the ability to select TIME axis introduced in WCSLIB version 7.8. [#13062]
Do not call
wcstabonwcscopyand copywtbmembers from the original WCS. [#13063]โก๏ธ Updated bundled WCSLIB version to 7.11. This update together with 7.10 includes bug fixes to
tabini()andtabcpy()as well as several print formatting enhancements. For a full list of changes - see http://www.atnf.csiro.au/people/mcalabre/WCS/CHANGES [#13171]Fixed error that occurred in
WCS.world_to_pixelforWCSobjects with a spectral axis and observer location information when passing aSpectralCoordthat had missing observer or target information. [#13228]
Previous changes from v5.0.4
-
๐ Bug Fixes
astropy.modeling ^
- ๐ Fixed the
Gaussian2Dbounding_boxwhenthetais an angularQuantity. [#13021]
astropy.utils ^
- Reverted
astropy.utils.iers.iers.IERS_A_URLtomaia.usno.navy.mildomain instead of NASA FTP to work around server issues. [#13004]
Other Changes and Additions
- ๐ Updated bundled WCSLIB to version 7.9 with several bugfixes and added
support for time coordinate axes in
wcsset()andwcssub(). The four-digit type code for the time axis will have the first digit set to 4, i.e., four digit code will be 4xxx where x is a digit 0-9. For a full list of bug fixes see https://www.atnf.csiro.au/people/mcalabre/WCS/CHANGES [#12994]
- ๐ Fixed the