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 stsci.edu).
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.
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: interp.py radial.py coins.py laplace.py nearest.py Examples from Tutorial 5: sortedlist.py sdict.py spec1.py spec2.py
Software needed to run examples:
numdisplay (http://stsdas.stsci.edu/numdisplay/) (for displaying images to display programs such as DS9 or ximtool
DS9 (http://hea-www.harvard.edu/RD/ds9/) (for non-matplotlib image display 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: http://www.scipy.org). 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: (http://www.urbansim.org/opus/nightly_release/docs/scipy.html)
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.