Scientific computing with python

with an emphasis on ocean modeling.
Python class information can be found here.

Quick one-stop shopping:

Here are some quick links for the folks who have been here before, and (almost) know what they are looking for.

Array types in python:

Plotting tools:

Windowing python (used by e.g., matplotlib):

NetCDF suport:


MATLAB is presently the defacto standard in analysis of ROMS model output. This is in part because MATLAB is the standard analysis tool for observational oceanography (although not always), but mostly because of the Herculean efforts of Rich Signell (with much help from Chuck Denham and John Evans). Signell et al. created a usefull, flexible, and comprehensive set of tools -- even the ones that are hard to write like Seagrid, which sucks less than any other similar tool out there. However, MATLAB's dominance was not predestined. Many other numerical ocean circulation sects use ferret, or some similarly goofy tool. In the early days of ROMS, Hernan Arrango created a suit of tools based on NCAR Graphics, but that never really caught on outside of Rutgers.

There are many things wrong with MATLAB, we all know what they are: memory leaks, slowness, strange postscript, license servers, etc. We all put up with these problems because it has been the best thing out there. It is flexible, dynamic, and once you learn how to think within its framework (i.e., vectorizing) it can be fast and powerful. In short, we use matlab for the same reason we use any tool: there is nothing better available.

In fact, the MATLAB stranglehold is not tight as you might think. There are no aspects of MATLAB that are necessary to model analysis. In particular, there are no essential toolboxes -- the tools that we use for model analysis have been created by the user community, and are available for free. Most notably, these include the MexCDF toolbox and m_map.

Why use python?

Switching to another computer language involves learning a whole new set of programing techniques and writing a new suite of tools. In order make this initial investment in time worthwhile, there needs to be some clear (and large) benefit. I believe python is worth the effort to switch for the following reasons:

Advantages of Python over MATLAB:

The basics:

Pre-installation (These instructions are primarily for Mac OS X, to get you to the point where you can install the tools listed above in the one-stop shopping.) First, you will need to install a python with all the goodies (e.g., Tkinter and readline) installed. In the future, I believe this will be standard, but for now get it at Then you need some sort of windowing (Tk, Wx, or GTK) support. The simplest is perhaps the 'batteries-included distribution of Tcl/Tk Aqua to get Tk. Now, install NumPy/SciPy, matplotlib, and a NetCDF IO utility.

You should be hacking away in no time, but you may wish to learn more about how to actually program in python. I think you will be amazed how easy it is to learn. There are some links to get you started listed on For the programing neophyte, two of my favorites include instant hacking and how to think like a computer scientist. If you already know how to program, check out instant python, a (scientific) Python Short Course, and Python for Science. All of these links are available from the Python Intros section

For an introduction to programing in python using numpy, check out the tutorial and the Cookbook.