Python is a programming language. The advantages for astronomers using Python are:
- write once, run anywhere (unlike C or C++, don't need to manually recompile)
- All in one programming/plotting (replacement for IDL).
- Faster than IDL, slower than C but more user friendly.
- Gives full access to historical IRAF algorithms via PyRAF
- Used for Hubble/ALMA pipelines.
- Many statistics/numerical recipes packages available.
- Makes nicer plots than IDL... what you see is what you get, even in postscript (unlike IDL).
Disadvantages are largely the large historical code bases that exist in astronomy and that are written in Fortran, C, or IDL. Python can interface with these. Also, Python is a relatively new language, so documentation is still under development, especially for the plotting packages. Finally, for the absolute fastest performance, a compiled language such as C is still probably faster; however, there are many efforts underway on high-performance computing with Python.
For more on "Why Python?", see
Python is installed by default on a Mac; however, it is generally considered best to install an updated version. See Python Setup for Astronomy.
- CodeCademy's Python track
- Dive Into Python (and Dive Into Python 3)
- Scientific Python Lecture Notes
- Learn Python the Hard Way
- Python Tutorial For Astronomers Who Use IDL
- Ferguson_Pyraf.pdf - just getting start guide to python and pyraf
- Very useful min-book on scientific computing with python by Hunter and Perez
- Here is a list of tutorials compiled on the AstroStat BLOG
- Tutorial on Interactive Data Analysis (PDF) by Greenfield and Jedrzejewski. Data and scripts for examples and exercises.
- Python Style Guide for writing stylish and readable code.
- Why Astronomers Should Use Python has a good collection of tutorial links
- Python users in Astronomy facebook group for questions as they come up
Python Packages for Astronomy
- Parallel computing with python
- yt - Analysis and visualization of adaptive mesh refinement simulations (blog post)
Plotting in Python
Although there are many plotting packages in Python, by far the most commonly used for research is matplotlib. You can find several links to examples here. Additionally, here are some interesting and unique links regarding plotting in python:
- documentation for matplotlib
- Non-Standard Diagrams with Python and Quartz (a.k.a. energy level diagrams)
- sample plots on the matplotlib website.
- cookbook hosted at scipy.org
Switching from IDL
- Python Switchers Guide
- Python bindings for IDL routines
- IDL Save - read IDL save files into python
- Python Tips