Getting Started with Python for Astronomy
There are a lot of Astronomical Python pages out there already. Why another one? Because none of the current pages seem to do a very good job of summarizing how to get started. This page is written from the perspective of someone in the middle of the transition from IDL to Python, and still figuring out this strange new world where objects actually work right.
The EssentialsYou'll need at a bare minimum
- Python! While recent Macs do come with Python installed, you can also get an updated version from MacPython. It seems like much of the precompiled software expects this new version - I wasn't able to install SciPy properly until I updated to MacPython. Some people have suggested the pre-build Enthought Python Distribution is a better approach but I've not tried that yet on a Mac. Seems to work OK on a Windows box in one test, though.
- The iPython interactive interpreter. (way better than the IDL command line! Tab completion, hurrah!) You can most easily get this via python's excellent easy_install feature. Just type: easy_install readline ipython at the command prompt on your favorite Mac or Unix box.
- SciPy, NumPy, and Matplotlib. Get them from here and learn how to get started. If you have installed MacPython, you should be able to download and use the precompiled installer .DMG images for SciPy and NumPy. I installed Matplotlib from source, but there are also binaries available for that. See these instructions.
- The famous Tutorial on interactive data analysis in Python by Greenfield and Jedzejewski.
- and you will probably find the AstroPy mailing list and its archives to be informative & useful.
Getting Started with Python on a Mac
- Get an up-to-date Python from the official release page
- Get the precompiled binary Numpy and Scipy installers from here.
- Get Matplotlib. Best is to get a precompiled binary from the download link at the right side of the matplotlib home page.
- Get iPython. I found that I had to install this from source after installing Matplotlib to get the -pylab option working properly. (2010-05-03)
- Install from source: pywcs PyFITS numdisplay
- Install with easy_install: readline aplpy atpy
- Open questions/Issues: Problems installing python-montage from easy_install ?? Installing from source worked fine.
How do I....?This section will eventually contain links to best practices Python code snipped for how to...
- Do aperture photometry?
- Reduce simple imaging data?
- Work with color maps? See here.
And here's an IDL-to-python color table mapping:
IDL Python 0 - BW Linear gist_gray 1 - Blue/white ? 3 - Red Temp gist_heat