What’s New in Astropy 1.1?


Astropy 1.1 is a major release that adds significant new functionality since the 1.0.x series of releases.

In particular, this release includes:

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

  • 685 issues have been closed since v1.0

  • 408 pull requests have been merged since v1.0

  • 161 distinct people have contributed code

New features in celestial coordinates package

The Astronomical Coordinate Systems (astropy.coordinates) sub-package now includes the following new coordinate frames:

  • de Vaucouleur Supergalactic coordinates, implemented via the Supergalactic frame.

  • Ecliptic coordinates, implemented via the GeocentricTrueEcliptic, BarycentricTrueEcliptic, and HeliocentricTrueEcliptic frames. These coordinates are still experimental, and should be used with care. We would welcome any testing and feedback regarding the accuracy of these transformations from users familiar with these frames.

  • Precessed Geocentric coordinates, which is based on GCRS, but precessed to a requested mean equinox, implemented via the PrecessedGeocentric frame.

In addition, the sub-package now includes the get_constellation() function and the SkyCoord get_constellation() method, which can be used to determine the constellation that a coordinate is in.

Algorithms for choosing histogram bins

The Astrostatistics Tools (astropy.stats) and Data Visualization (astropy.visualization) sub-packages now include functions to help automatically select histogram bins, including reference rules such as Scott’s rule and Freedman & Diaconis’s rule, and Bayesian models such as Knuth’s rule and Bayesian Blocks:



For more information, see the Choosing Histogram Bins section.

New features in table package

Table interface to Pandas

The pandas package is a package for high performance data analysis of table-like structures that is complementary to the Table class in Astropy.

In order to be able to easily exchange data between the Table class and the pandas DataFrame class (the main data structure in pandas), the Table class now includes two methods, to_pandas() and from_pandas().

To demonstrate these, we can create a simple table which we convert to a pandas DataFrame:

>>> from astropy.table import Table
>>> t = Table()
>>> t['a'] = [1, 2, 3, 4]
>>> t['b'] = ['a', 'b', 'c', 'd']
>>> df = t.to_pandas()
>>> df
   a  b
0  1  a
1  2  b
2  3  c
3  4  d
>>> type(df)
<class 'pandas.core.frame.DataFrame'>

A pandas DataFrame can also easily be converted to an Astropy Table:

>>> t2 = Table.from_pandas(df)
>>> t2
<Table length=4>
  a      b
int64 string8
----- -------
    1       a
    2       b
    3       c
    4       d

For more information, see Interfacing with the pandas package.

Table indexing

The table sub-package now supports creation of one or more table indices which internally sort the rows of the table based on the index column(s). This concept is commonly used in database tables to enhance performance and ensure data integrity.

The astropy implementation of indexing provides methods for creating the index, accessing rows based on key value or location in the sorted index, and maintaining the index when the table is updated (for instance by adding a new data row).

As an example, to create an index on a table and retrieve a value:

>>> from astropy.table import Table
>>> t = Table(rows=[('Mary', 48),
                    ('Jim', 37),
                    ('Jane', 26),
                    ('Fred', 50)],
              names=('name', 'age'))
>>> t.add_index('name')
>>> t.loc['Jim']['age']

Note that the table indexing engine is new and is not yet considered stable, so it is not recommended for use in production code at this time. For more information, see Table indexing.

Table and column info

The table sub-package now supports a flexible mechanism to return summary information about a table and columns. For the table of ages defined above:

>>> t.info
<Table length=4>
name dtype
---- -----
name  str4
 age int64

>>> t['age'].info('stats')
name = age
mean = 40.25
std = 9.60143218484
min = 26
max = 50
n_bad = 0
length = 4

For more information, see Summary information.

show_in_notebook method

Table now has a show_in_notebook() method that makes viewing tables in Jupyter/IPython notebooks more convenient. Simply call the method at the bottom of a cell (or use the IPython.display.display() function), and the output of the cell will show the table with a searchable, sortable, and resizable interface similar to what’s available by doing tab.show_in_browser(jsviewer=True).

New Units

The Units and Quantities (astropy.units) sub-package now includes support for logarithmic units such as magnitudes, decibels, and dex:

>>> from astropy import units as u
>>> logg = 5. * u.dex(u.cm / u.s**2)
>>> logg.value
>>> logg.physical
<Quantity 100000.0 cm / s2>

For more information, see Magnitudes and other Logarithmic Units.

In addition, the following units have been added:

  • Furlongs (imperial.furlong)

  • Mil (imperial.mil)

  • Stone (imperial.stone)

  • Earth mass (units.M_earth) and Jupiter mass (units.M_jup)

Finally, quantity arrays can now be used in Matplotlib, which will recognize the unit and plot the quantities correctly (see Plotting quantities for more details on how to enable this).

Improvements to cosmology sub-package

The Cosmological Calculations (astropy.cosmology) sub-package now includes the Planck 2015 cosmology, and in addition includes significant performance improvements (20-40x) for distance calculations, for all the cosmologies provided.

Deprecation and backward-incompatible changes

The v1.1.x series of releases will be the last one supporting Python 2.6. Starting with Astropy v1.2, Python 2.7 or later will be required.

2D Cutout Images

The astropy.nddata.utils module now includes a Cutout2D class to create a postage stamp cutout image from a 2D array. Image cutouts can be generated using either pixel or SkyCoord positions. The cutout shapes can be specified in either angular or pixel units. If an optional WCS object is input, then the Cutout2D object will contain an updated WCS corresponding to the cutout array.

For more information, see 2D Cutout Images.

Other significant changes

The World Coordinate System (astropy.wcs) sub-package now supports (and includes) WCSLIB 5.x, which implements support for the distortion representations described in [Paper IV: Representations of distortions in FITS world coordinate systems](https://www.atnf.csiro.au/people/mcalabre/WCS/) by Calabretta et al, including TPV and SIP. Note that for now, Astropy still uses a custom implementation of the SIP distortions rather than the ones from WCSLIB, but we plan to change this over in the future.

The Time and Dates (astropy.time) sub-package now includes support for time strings formatted using the FITS convention, e.g. '2000-01-02T03:04:05(TDB)'.

Full change log

To see a detailed list of all changes in version v1.1, including changes in API, please see the Full Changelog.