Conference site » Proceedings

Introductory to Scientific computing with Python tutorial

UPDATE: Please note change of rooms below. The introductory tutorials will be held at Moore 070 and the advanced at Beckman (the original plan was the reverse). The Registration Desk will be open daily in the Beckman Institute Courtyard, 7:30 a.m. - 9:00 a.m. This is also where the coffee break service will be provided.


Scientists and engineers who are familiar with computers and basic numerical computing.


The introductory tutorial will take place in 070 Moore (in the subbasement, two floors down from street level). You can see it marked on this map of the campus that lists all relevant buildings for the conference. Interactive and printable maps of the Caltech campus can also be found on Caltech's website, on those maps Moore is building #93.


  • Attendees are expected to bring along their laptops fully setup with the necessary software. We suggest installing EPD or Python(x,y). If you install Python(x,y) be sure to install the Full Edition which includes the Advanced Python Modules. The various software required are:
    • Python, version 2.5 or above,
    • numpy, version 1.2 or above,
    • scipy, version 0.7 or above,
    • IPython, version 0.8 or above,
    • matplotlib, version 0.9 or above,
    • Mayavi, version, 3.1 or above.
  • Once you have installed these packages, you may want to download and run this checklist script. It will do some sanity checks on your system, and if it finds a problem, it will generate a reasonably detailed report you can mail for help. We will try to assist you with fixing any problems you may run into before the actual conference starts, to save time and hassles.
  • Attendees are expected to be comfortable using the command line on their OS. If you are not comfortable with the command line, see this tutorial for an introductory lesson.
  • Attendees are expected to be comfortable using a programming editor of their choosing, which also supports Python. Some recommended editors:
    • Windows: notepad++
    • OSX: TextWrangler, TextMate
    • linux: gedit (gnome), kate (KDE)
    • All operating systems: Emacs, Vim.
  • The tutorials assume the audience has done some programming in Matlab (or similar) and is comfortable with basic numerical computing in these environments.
  • No prior programming experience with Python is expected. However, attendees are strongly encouraged to go through the official Python tutorial before attending the Introductory Tutorial. This material will be reviewed during the course, but only briefly. We recommend working through these chapters:
    • Chapter 1: Whetting Your Appetite
    • Chapter 2.1: The Python Interpreter
    • Chapter 3: Introduction to Python
    • Chapter 4.1-4.6: Python Flow Control
    • Chapter 5.1, 5.1.1, 5.1.2, 5.3, 5.5, 5.6: Python Data Structures
    • Chapter 6.0 (not 6.1): Basics on Python Modules
    • Chapter 7.0, 7.2, 7.2.1: Input and Output in Python
  • Attendees are encouraged to read the Numpy Tutorial.


At the end of the course participants will be:

  1. able to write reasonable quality, procedural Python programs.
  2. broadly exposed to several of the relevant Python packages for numerical computing like ipython (interactive data exploration), numpy (arrays), scipy (numerics), matplotlib (high quality 2D plotting), and mayavi's mlab (simple 3D plotting) in order to write code for typical scientific computing tasks involving numerical algorithms, data analysis, data exploration and visualization.
  3. understand the general tools, workflow and best practices involved in writing good quality, tested, Python programs for scientific computing.

Structure of tutorial

The course will be completely hands on. All of the lecture material will expect users to type along and the sessions will be punctuated with exercises. The solutions for these exercises will also be discussed.



  • Morning:
    • 8:00-8:30. Optional startup session where the organizers will try to assist with any last-minute setup or installation problems.
    • 8:30-10:20. Intro to Python: Gael Varoquaux, Christopher Burns
      • Quick IPython introduction: the workflow
      • Basic types:
        • scalar types: int, float, complex
        • Collections: list and dictionaries (and tuples, sets, ...)
      • Control flow: if, for, range, while, break, continue
      • Functions: definitions, arguments, docstrings, ...
    • 10:20-10:40. Break.
    • 10:40-12:30. Intro to Python (continued): Gael Varoquaux, Christopher Burns
      • Exceptions handling in Python
      • Reusing your code: creating modules, '__main__'.
      • Standalone scripts, command line arguments.
      • I/O, file handling
      • Standard library and general utilities.
      • Timing
  • Lunch break (on your own): 12:30-2:00.
  • Afternoon:
    • 2:00-2:30. Debugging: Christopher Burns
      • effective strategies and effective debugger usage
      • print statements
      • %debug in IPython
    • 2:30-3:00. Testing: Stefan van der Walt
      • the concept: using testing properties of code via a function
      • doctests
    • 3:00-3:50. Basic numpy arrays: Stefan van der Walt
      • The array, an n-dimensional object
      • vectorizing for speed and ease
    • 3:50-4:10. Break.
    • 4:10-4:30. Basic plotting with matplotlib: Mike Droettboom
      • plotting 1D arrays: points and lines,
      • plotting 2D arrays: images
    • 4:30-5:00. More numpy: Stefan van der Walt
      • The memory model
      • dtypes
      • views and copies
      • Array creation
    • 5:00-6:00. Spill-over and Q & A session.


  • Morning:
    • 8:00-8:30. Optional startup session where the organizers will try to assist with any last-minute setup or installation problems.
    • 8:30-9:30. More matplotlib: Mike Droettboom
      • customizing colors, styles
      • legend
      • matplotlibrc
      • math text
    • 9:30-10:20. More numpy: Perry Greenfield
      • advanced indexing
      • use of where
      • zen, examples of vectorizing
      • ieee special number and error handling (5 min)
      • masked arrays (10-15 min)
    • 10:20-10:40. Break.
    • 10:40-11:30. More numpy (continued) Perry Greenfield
    • 11:30-12:00. Basic 3d plots with mlab: Gael Varoquaux
      • 3D plotting functions
      • their keyword arguments
      • the GUI
  • Lunch break (on your own): 12:30-2:00.
  • Afternoon:
    • 2:00-3:50. Using scipy for numerics: David Cournapeau, Eric Jones
      • Linear algebra
      • random numbers
      • FFT
      • special functions
      • Root finding
      • Quadrature
      • ODEs
    • 3:50-4:10. Break.
    • 4:10-5:30. The Whole Enchilada: Eric Jones
      • Largish assignment to tie all of the above together.
    • 5:30-6:00. Q & A Session