Python for Astronomers



October 2008 - January 2009
Reinhold Schaaf and Manuel Metz




The course

Python for Astronomers

is held at the CIP room of the Argelander Institute. Due to large demand, two parallel courses are held on Wednesdays 9:30-11:00, and on Thursdays 14:30-16:00, starting October 29/30, and will comprise ten lessons.

Python is a computer language that is becoming both more and more popular among and important for scientists, especially for astronomers.  It makes the solution of everyday problems easy but is powerful enough for large and sophisticated programs. Several astronomical program packages have been implemented in Python, other established programs get adapted to be used from Python as a user-friendly and extensible interface.

For more information see the Announcement of the course.

Course Materials

Presentation of classes as pdf:

  • Lecture 1 Introduction; Numbers, Variables, math, while (R.Schaaf)
  • Lecture 2 Strings; Indexes and slices (R.Schaaf)
  • Lecture 3 a Lists, for loops, file I/O (R.Schaaf)
  • Lecture 3 b Numpy (M.Metz)
  • Lecture 4 Script files, if statement, truth, equality and identity, tuples, dictionaries (R.Schaaf)
  • Lecture 5 More on numpy (M.Metz)
  • Lecture 6 Matplotlib (M.Metz)
  • Lecture 7 Functions and modules (R.Schaaf)
  • Lecture 8 a Errors and exceptions (R.Schaaf)
  • Lecture 8 b More on numpy & matplotlib (M.Metz)
  • Lecture 9 Classes and instances; the Python Standard Library (R.Schaaf)
  • Lecture 10 a Inheritance, operator overloading (R.Schaaf)
  • Lecture 10 b Scipy; Python 3 (M.Metz)

Other:

Usefull links

Unix tutorials:

Tutorials for vi and emacs:

Shell tutorials:

Official Python websites:

Python documentation and tutorials:

Some books we like:

"Learning Python"
Learning Python by M.Lutz, O'Reilly

A good introduction into Python for "both absolute beginners, and crusty programming veterans". We think this statement from the book is true! Now in the 3rd edition.

The book is also freely available online at Safari Books online

Python Cookbook
Python Cookbook by A.Martelli, A.M.Ravebscroft, and D.Ascher, O'Reilly

Great collection of recipes for Python programmers, contributed by Python community members. Very helpful to get the job done!

This book is also freely available online at Safari Books online
Programming Python
Programming Python by M.Lutz, O'Reilly

On 1600 pages, "this book teaches application-level programming with Python. That is, it is about what you can do with the language once you've mastered its fundamentals."

Also freely available online at Safari Books online
Python in a nutshell Python in a nutshell by A.Martelli, O'Reilly

"A quick reference to Python itself, the most commonly used parts of its vast standard library, and some of the most popular and useful third-party modules and packages, covering a wide range of application areas, including web and network programming, GUIs, XML handling, database interactions, and high-speed numeric computing."

Also freely available online at Safari Books online

Miscellaneous links: