Astronomical Python (AstroPy)

Promoting the Development and Use
of the Python Programming Language
in Astronomical Research


Intended Audience


Astronomical Modules

AstroPy
The Astropy Project is a community effort to develop a single core package for Astronomy in Python and foster interoperability between Python astronomy packages. It includes PyFits (as astropy.io.fits), a port of pywcs (astropy.wcs), coordinate conversions and many other useful things.
AstroLib
Astronomical coordinate conversions. This package aims to provide much of the IDL "astron" functionality that pertains to coordinate manipulations in an OO framework. Our target user is a typical astronomer who needs to analyze data, work with catalogs, prepare observing proposals, and prepare for observing runs. All coordinate transformations are handled by the TPM (Telescope Pointing Machine) library, which was graciously contributed by Jeff Percival. This will be installed as part of the package installation.
PyFITS
A Python module for reading and writing FITS files. Warning: PyFITS is obsolete; the functionality is now part of AstroPy as astropy.io.fits.
pywcs
Pywcs provides transformations following the SIP conventions, Paper IV table lookup distortion, and the core WCS functionality provided by wcslib. Each of these transformations can be used independently or together in a standard pipeline. Warning: pywcs is apparently obsolete: the functionality is now part of AstroPy as astropy.wcs.
PyRAF
PyRAF is a command language for running IRAF tasks that is based on the Python scripting language. It gives users the ability to run IRAF tasks in an environment that has all the power and flexibility of Python. PyRAF can be installed along with an existing IRAF installation; users can then choose to run either PyRAF or the IRAF CL. PyRAF is a product of the Science Software Branch at the Space Telescope Science Institute.
pySLALIB by Scott M. Ransom
new f2py-generated (and hand-tweaked to eliminate unnecessary function/subroutine arguments) wrappers for the Fortran version of P.T. Wallace's SLALIB positional astronomy library. SLALIB used to be hosted by the STARLINK site, although that service has been suspended. The version of SLALIB included here is 2.5-4 (with several additional tweaks) and is released under the GPL.
RO (including RO.Astro and RO.DS9)
Russell Owen's RO utility package includes RO.Astro for Astronomical coordinates and time conversions, and RO.DS9 for displaying images in the ds9 image viewer. RO.Astro is based on work by Pat Wallace (by permission) and is free for noncommercial use. The rest of the RO package is less restricted.
EphemPy
Modules for interpolating JPL ephemeris tables by Ray Buvel. The main module is pure Python (with numpy). The package also includes a faster version based on Pyrex, for those familiar with Pyrex.
PyAstro
A package by Paul Griffiths to calculate planetary positions, based on the approximate calculations from the JPL.
PyEphem
Brandon Craig Rhodes has ported the core ephemeris library from XEphem to a Python and C module which runs under Linux.
PyGuide
Find and centroid stars. Gives good centroids even for sources with bits missing, such as might be obtained from a slitviewer or coherent fiber bundle. Requires numarray and a distutils-compatible C compiler. By Russell Owen using algorithms developed by Jim Gunn.
PyMIDAS
PyMidas provides an interface from the Python scripting language to the ESO-MIDAS astronomical data processing system. It allows a user to exploit both the rich legacy of MIDAS software and the power of Python scripting in a unified interactive environment which also opens up other Python-based astronomical analysis systems such as PyRAF.
Telarchive and Fetchsdss
Telearchive is a Python command-line program for searching multiple public telescope archives. It takes the name of an astronomical object—or a set of coordinates—and checks the telescope archives to see if they have observations within a user-specified box centered on the object/coordinates. Fetchsdss is specialized for retrieving FITS or JPEG images from the Sloan Digital Sky Survey (Data Release 7). It uses some of the same underlying software as telarchive, and is automatically installed as part of the telarchive package. Both are written by Peter Erwin.
Tardis1D montecarlo spectral synthesis code for supernovae. Code is available on github.
XAssist
XAssist is a project to automate X-ray astrophysics analysis. The intended audience is X-ray astronomers who want assistance with large projects and non-experts simply wanting X-ray data points for spectral energy distribution diagrams, proposals, etc. without wanting to learn X-ray analysis simply for that purpose.
PyNOVAS
With pynovas you can create your own 'Astronomical Almanac' based on the C-version of the NOVAS software of USNO.
sncosmo
A Python package for supernova cosmology. sncosmo provides functionality for using empirical models of supernovae, such as generating synthetic photometry from models and fitting models to photometric light curves.
coordConv
A package for Astronomical coordinate conversions based on slalib that can be used from Python or C++. It includes conversions between ICRS, FK5, FK4, galactic, apparent geocentric, apparent topocentric and "observed" (refracted apparent topocentric) coordinates. It is intended to be accurate enough for control of large telescopes, yet very easy to use. Be warned that it has many dependencies (including slalib, which is the only dependency that is not open source). It could probably easily be modified to depend on SOFA, instead. You should probably start with AstroPy and see if it meets your needs.

Number Crunching and Visualization

matplotlib
matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. matplotlib can be used in python scripts, the python and ipython shell (a la matlab or mathematica), web application servers, and six graphical user interface toolkits
NumPy
Efficiently manipulate large n-dimensional arrays of data and also offer the ability to offload array computations in custom C/C++ extensions.
SciPy Scientific Tools for Python
SciPy supplements the NumPy module, gathering a variety of high level science and engineering modules together as a single package. SciPy includes modules for graphics and plotting, optimization, integration, special functions, signal and image processing, genetic algorithms, ODE solvers, and others.
iPython
IPython provides a rich architecture for interactive computing with a powerful interactive shell, browser-based notebook, interactive data visualization and tools for parallel computing.
yt
Detailed data analysis and visualizations. The yt project aims to produce an integrated science environment for collaboratively asking and answering astrophysical questions. To do so, it will encompass the creation of initial conditions, the execution of simulations, and the detailed exploration and visualization of the resultant data. It will also provide a standard framework based on physical quantities interoperability between codes.
IDLSave
A pure python module to import variables from IDL "save" files into python. Warning: this package is obsolete; the functionality has been merged into SciPy as scipy.io.idl.
Veusz plotting package
Veusz is a scientific plotting package designed to produce publication-ready Postscript output. It is written in Python and uses PyQt and numarray. Veusz provides a GUI, command line and scripting interface to its plotting facilities.
APLpy
APLpy (the Astronomical Plotting Library in Python) is a Python module aimed at producing publication-quality plots of astronomical imaging data in FITS format. The module uses Matplotlib, a powerful and interactive plotting package. It is capable of creating output files in several graphical formats, including EPS, PDF, PS, PNG, and SVG.
SAO Image DS9 and XPA
DS9 is an astronomical image and data visualization application. It supports FITS images and binary tables, multiple frame buffers, region manipulation, and many scale algorithms and colormaps. It provides for easy communication with external analysis tasks and is highly configurable and extensible via XPA and SAMP. The Mac version uses XQuarts/X11 for display.
ginga
Ginga is a viewer for astronomical data FITS files. It is written in python and intended to be easily extensible and controllable from python. It can use GTK, Qt or matplotlib for display.
glue
Glue is a Python framework to link visualizations of multiple related datasets. Its goal is to let users easily inter-compare data across several files.
python-sao
This project is aimed to provide a python interface for some programs developed by Smithsonian Astrophysical Observatory(SAO). One of the main goal is to communicate with ds9 from python shell via the XPA protocol. It provides a python wrapper for subset of XPA library and python module for ds9 based on the XPA module.
PyXPA
PyXPA is a Python interface to the XPA library.
XPA
A very basic Python module for reading and writing region lists from SAOtng and SAOds9 image viewers, using the X Public Access mechanism. Can also use XPA to instruct the viewer to display a given filename.
HippoDraw
A highly interactive plotting and data analysis environment. Written in C++ using Qt, but includes a Python interface. Unfortunately this package appears to be dead. The main site is still up, but links to software are mostly dead.

Other Resources

AstroPy Mailing List
A mailing list for discussing the use of Python in Astronomy. This mailing list is maintained by Paul Barrett at the Space Telescope Science Institute.
StatPy
A collection of resources to help you do statistical computing with Python, with a special emphasis on statistics in astronomy.
Using Python for Interactive Data Analysis
A 2005 tutorial that illustrates how Python can be used to analyze and visualize astronomical data.
Python.org
Information about the Python language, including downloads, documentation and an excellent tutorial.
See What is Python? for a nice overview of the language.
Astronomy Questions?
Ask a High Energy Astronomer.

This page is maintained by Russell Owen of the University of Washington's Astronomy Department. The previous web maintainer was Dr. William T."Tom" Bridgman at NASA.