Astropy: A Community Python Package for Astronomy

The rapid adoption of Python by the astronomical community was starting to make it a victim of its own success, with fragmented development of Python packages across different groups. Thus began  the Astropy project began in 2011, with an ambitious goal to coordinate Python development across various groups and simplify installation and usage for astronomers. These ambitious goals have been met and are summarized in the paper Astropy: A Community Python Package for Astronomy, prepared by the Astropy Collaboration. The Astropy webpage provides download and build instructions for the current release, version 0.2.4, and complete documentation. It is released under a “3-clause” BSD-type license – the package may be used for any purpose, as long as the copyright is acknowledged and warranty disclaimers are given.

The Astropy project has delivered a core astropy package that includes much of the astronomical functionality needed by astronomers day-to-day. The package thus complements more general purpose Python data analysis packages such as NumPy and SciPy. Astropy also supports affiliated packages,which are not part of the core package for reasons of specialization, compatibility of licensing, maturity of code etc. Examples are a wrapper around the Montage image-mosaic package, and the Ginga viewer for interactive visualization of FITS images.

The driver for the core package is that it contains concise code readable by non-specialists in Python, with interfaces developed by the astronomy community to support typical astronomy workflows. This driver requires the development of code with clean and consistent API’s, with thorough integration and testing of code written by 30 distributed developers. The collaboration required a careful development process, described below.

The development used the GitHub source hosting platform as its centerpiece, with the astropy code stored on a git repository; changes are implemented through pull requests, where code is staged for review by others before integration into the main code base. Not all code is accepted – new features have to be justified and consensus is needed for approval of new code.  The collaboration makes use of continuous integration, which runs several thousand tests of under various configuration. Extensive tests of new code are performed with the Jenkins and Travis continuous integration platforms. In addition, users can submit proposed changes to bugs.  Moreover, proposals for updates to documentation can be made through a browser without knowledge of the git version control system.

The primary functionality, described in detail in the paper, covers these areas:

  • Units and unit conversions.
  • Absolute dates and times.
  • Celestial coordinate systems.
  • Tabular and gridded data.
  • Support for common astronomical file formats.
  • World Coordinate System transformations.
  • Cosmological calculations.

An example of time conversion (Fig 3 in the paper) is given below:


Supported data formats include FITS, with full World Coordinate system support, specialized ASCII tables (e.g IPAC column delimited, IRAF DAOPhot, LaTeX), and VOTables.

The collaboration is active, and plans the following functionality, quoted verbatim from the paper:

  • Improving interoperability between packages, which includes for example seamlessly integrating the astropy.units framework across all sub-packages.
  • Adding support for NumPy arrays in the coordinates sub-package, which will allow the efficient representa- tion and conversions of coordinates in large datasets
  • Supporting more file formats for reading and writing Table and NDData objects
  • Implementing a Virtual Observatory cone search tool (Williams et al. 2011)
  •  Implementing a generalized model-fitting framework
  • Implementing statistical functions commonly used in Astronomy
This entry was posted in Astronomy, cyberinfrastructure, information sharing, Open Access, programming, Python, software engineering, software maintenance, software sustainability and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s