Please note that all the SIEpedia's articles address specific issues or questions raised by IAC users, so they do not attempt to be rigorous or exhaustive, and may or may not be useful or applicable in different or more general contexts.
Python for astronomers
Python is becoming one the most used interpreted languages for data analysis, competing directly with well-stablish commercial solutions as Matlab or IDL. Apart from its simple syntax and very smooth learning curve, the main advantage of Python is that you can use it virtually for everything, having modules for database interaction, web development, parallel computing and a long etcetera. Of course, there mature scientific and mathematical libraries.
Beeing Python so extensive, its easy to get lost with all the possible modules and its documentation, because there are many options to do the same. Differing from monolithic-packages as IDL or Matlab, where you have one plotting library, one GUI library, a standard IDE (integrated Development Environment) and so on, all with a common documentation, in Python, as with any general use programming language, you have to choose the modules you need and install them, refering to the documentation of each module separately.
In this guide you will find which are the most common packages and documentation for astronomy and where to obtain them.
Obviously first you need Python itself. If you are using GNU/Linux or a Mac, its already installed by default on this systems. If you have Windows you can install the official package or WinPython (recommended) or Python(x,y) project which apart from Python includes the most common scientific packages and tools.
The main scientific package is Scipy, which includes ODE solvers, linear algebra libraries, interpolation, optimization, etc. Scipy requires Numpy, a powerful arrays library.
- Scipy - The main scientific library
- Numpy - Arrays manipulation library
- Matplotlib - 2D (and basic 3D) plotting library
- IPython - An advanced interactive console
From GNU/Linux, you can try to obtain this packages using the package installer of your distribution (apt-get in Ubuntu/Debian, yum in Fedora or YAST in SUSE). The Python(x,y) package (Windows only) includes all this.
Other scientific modules
- NLopt - Non-Linear optimization library
- lmfit - Non-Linear Least-Square Minimization for Python
- OpenOPT - Numerical optimization framework
It depends on what you want to do, but the most used package for astronomy are:
- Astropy - A community effort to develop a single core package for Astronomy
- Pyfits - FITS images and tables manipulation
- Astrolib modules - Some packages for astronomy, including coords (for celestial coordinates manipulation), asciidata (ascii data tables) and pyWCS a WCSLib wrapper (in alpha state, so far)
- PyRAF - A command language for IRAF writted in Python. It also enable to call IRAF tasks from Python. Requires IRAF.
- APLpy - Astronomical Plotting Library with matplotlib
- ATpy - Astronomical tables library. It supports several formats including Fits, VOtable, IPAC, SQL, etc.
- Asciitable - ASCII table reader
- Kapteyn Package - A very complete and well documented collection of libraries from the Kapteyn Astronomical Institute. It includes coordinate and WCS manipulation, tables and plotting utilities.
- astLib - An astronomical library with modules for coordinates, plotting, statistics and more.
- pywcsgrid2 - Astronomical plotting with matplotlib.
- SAMPy - A SAMP implementation for Python.
- pyregion - A ds9 region files parser.
- CosmoPy - A cosmology package.
- idlsave - An IDL's "save" file format reader (to numpy types). Do not requires IDL.
- A Python Connection to DS9 via XPA
- python-sao - A Python interface to ds9.
- Astropysics - Astrophysics utilities for python
- astrogui - FITS data reduction package (still in alpha phase)
- cosmics.py - L.A.Cosmic algorithm implementation in Python (for cosmic ray detection)
- Alipy - Tool for align a set of dithered FITS images (using pyraf and sextractor)
- Chantipy - A Python interface to the CHIANTI atomic database for astrophysical spectroscopy
- python-montage - A Python wrapper for montage
- NTV - FITS image viewer, similar to atv for idl
- pyTMP - python interface to the TPM (Telescope Pointing Machine) library
- SunyPy: An effort to create an open-source software library for solar physics
- AsPyLib: A python library for FITS image processing, including photometry and astrometry.
- AstroML: A Python module for machine learning and data mining
- pySpecKit: A splot-like spectroscopic analysis toolkit for astronomy
- Astropython - A knowledge base for research in astronomy using Python
Other useful packages
- Sympy - Impressive symbolic calculus module
- Mayavi - A powerful 3D data visualizer (Matplotlib
cannot do only make simple 3D plots)
- f2py - Fortran to Python interface creator
If you don't know anything about Python, just begin with official tutorial, its brief and clear. Then, the main reference for astronomers is the Perry Greenfield and Robert Jedrzejewski's Using Python for interactive data analysis in astronomy tutorial, which covers the Python's basics and all the important astronomical packages with many examples (many thanks Perry and Robert!). Remember that the reference website for scientific packages and documentation is Scipy.org.
Here are documentation of the main scientific packages:
Courses and tutorials
Video tutorials and demonstrations