Astronomical Python (AstroPy)

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


Intended Audience


Astronomical Modules

AstroLib
Astronomical coordinate conversions. This package is intended 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.
PyRAF
PyRAF is a new 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
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: routines for time and coordinate conversion and RO.DS9 for displaying images in the ds9 image viewer. RO is written in pure Python, but requires the Numeric package (and RO.DS9 requires numarray). Eventually it will all switch to numarray. 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. Does not include a setup.py script; to install, copy the package to site-packages or put it on your Python path.
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 module to calculate approximate planetary positions (accuracy is less than a degree in most cases) based on Peter Duffett-Smith's "Practical Astronomy with your calculator". By Pavlos Christoforou. The original link has been dead for some time but Noel Gorelick found an archived copy that I am serving.
PyEphem
Brandon Craig Rhodes has ported 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.
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.
XIMGFIT
XIMGFIT is a Python program for fitting FITS images with spatial models with an emphasis on X-Ray images. Written by Andy Ptak
AstroLabe
A subroutine library and sample applications which implement techniques from "Astronomical Algorithms" by Jean Meeus. It includes the full VSOP87d planetary model. The Python and C++ branches are independent of each other. The code has been tested on Linux and NT.
PyNOVAS
With pynovas you can create your own 'Astronomical Almanac' based on the C-version of the NOVAS software of USNO.

Number crunching

NumPy
Efficiently manipulate large n-dimensional arrays of data and also offer the ability to offload array computations in custom C/C++ extensions.
There are also two older array packages that are similar to NumPy which you may encounter in existing code but which should not be used for new work:
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.

Interactive Plotting and Data Analysis Packages (incomplete)

HippoDraw
A highly interactive plotting and data analysis environment. Written in C++ using Qt, but includes a Python interface.
matplotlib
A 2D plotting package which produces publication quality figures in a variety of GUI environments and hardcopy formats.Very cross-platform. Easy to use for interactive data analysis.
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.

FITS-Related Modules

PyFITS
A Python module for reading FITS files. This module is also part of PyRAF (see below). PyFITS requires NumPy.
pCFITSIO (no known valid link)
Norbert Pirzkal's Python wrappers for the HEASARC CFITSIO library. He has also apparently written a Python C-wrapper for the Starlink SLALIB library, but I don't have a link.
Andrew Williams' FITS reader
A simple reader for FITS header cards written in pure Python.

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. To subscribe, send mail to majordomo@stsci.edu with the following as the message body (the link should fill this in for you):
subscribe astropy
You will be sent a confirmation request to which you must respond before being added to the list. As usual, requests to unsubscribe should go to the same address (not the mailing list itself).
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 tutorial that illustrates how Python can be used to analyze and visualize astronomical data (much like one can do in IDL).
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.
The Python Newsgroup comp.lang.python
A newsgroup for discussing the Python 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.