Astronomical Python (AstroPy)
Promoting the Development and Use
of the Python Programming Language
in Astronomical Research
Intended Audience
- Astronomers interested development of an interactive data analysis environment in Python.
- Amateur astronomers interested in astronomical analysis tools that can run on computer systems within their budget.
- Students and teachers interested in a free and easy-to-use programming language for teaching.
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.
- PyFITS
- A Python module for reading FITS files. This module is also part of PyRAF (see below). PyFITS requires NumPy.
- 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.
- 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 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 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.
- 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.
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.
- 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. It does not require IDL to work. It converts IDL variables to Python types, IDL arrays to NumPy arrays, and IDL structures to NumPy record arrays.
- 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:
- Numeric is the original numeric array package. It is no longer maintained, having been superseded by NumPy. Note that it was also called NumPy, so beware of confusion with the current NumPy package.
- numarray is a successor to Numeric. It is no longer maintained, having been superseded by NumPy.
- HippoDraw
- A highly interactive plotting and data analysis environment. Written in C++ using Qt, but includes a Python interface.
- 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.
- 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.
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 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.
- 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.