This is an archival dump of old wiki content --- see for current material

This tutorial has been written by Perry Greenfield and Robert Jedrzejewski to illustrate how one can use Python to do interactive data analysis in astronomy (in much the same style as is now popular with IDL). The focus is initially in showing someone how to get going quickly in using Python to do interactive tasks, and only later on teaching details of how to program in Python.

The version of the tutorial available on this page now uses numpy. If you wish to download the numarray version, you can download it from /Numarray, but there are very few reasons to use that version any longer.

Using the tutorial for fields other than astronomy

Most of the tutorial is pretty generic. The great majority of examples use astronomical data but do not require any astronomical expertise." Those that want to use this tutorial and who aren't in astronomy should skip sections 1.7, 1.8, 3.5 and 4.10.

Comments on how to improve the tutorial are welcome (perry at

Data and scripts for examples and exercises

The following gzipped tar files contain data files and scripts used by the tutorial examples and exercises. There are two different tar files to choose from. The first is complete, but quite large. The second has everything the first has except the acs.fits file and is considerably smaller.

Download complete set of data and scripts (114 MB)

Download all except acs.fits (3.2 MB)

Contents of gzipped tar files:

 Data for examples and exercises:
  pix.fits (Tutorial 1)
  fuse.fits (Tutorial 2)
  table2.fits (Tutorial 2)
  nicmos.fits (Tutorial 3)
  acs.fits (Tutorial 3), only included in larger download
  tut3f1.fits (Tutorial 3 exercise)
  alpha_boo_iue.fits (for use with Tutorial 5 exercise 2)
 Scripts and modules:
 Examples from Tutorial 3:
 Examples from Tutorial 5:

Software needed to run examples:

To run the IRAF-related examples one needs to install IRAF and PyRAF as well.

A few examples use functions that are included with o numarray but are not included with numpy. These have been moved to scipy.stsci and scipy.ndimage (part of scipy: The stsci_python distribution will includes these, but unfortunately, that version will not be released until June or July 2007. In the meantime, one can follow this link to install these without installing all of scipy: (

Solutions to exercises

Note that many approaches are possible with most of the exercises. The following are intended just to show one way they can be done.

SciPy: Additional_Documentation/Astronomy_Tutorial (last edited 2015-10-24 17:48:25 by anonymous)