Loading...
 

Python

Python is a programming language. The advantages for astronomers using Python are:

  • Free
  • 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

Installation

Python is installed by default on a Mac; however, it is generally considered best to install an updated version. See Python Setup for Astronomy

Learning Python

Python Packages for Astronomy

see listing on AstroPython

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:

Switching from IDL

  • Python Switchers Guide
  • Python bindings for IDL routines
    • pyIDL - difficult to install?
    • pIDLy - easier to install but can be inefficient. Works by launching an IDL session as a child application and then passing data between Python and the IDL shell.
    • idlmagic - provides convenient %idl magic functions for IPython and the IPython notebook; uses pIDLy.
  • IDL Save - read IDL save files into python
  • Python Tips

Page last modified on Friday 28 of October, 2016 13:14:16 EDT