Using Python with Climate Data

Template:Needs Update This page needs updating

At the Melbourne Uni follow-up meeting for the 2013 Software Carpentry workshop Damien Irving showed off several Python libraries for working with climate data. Damien's notes are given below, he also has material available on | his blog.

Hi all,

Thanks for coming to the Software Carpentry boot camp follow up session this afternoon. Below is a summary of the text that I showed at the end, including the various links that I promised. If you're struggling with Python at all, feel free to look through my bitbucket repository for useful examples ( At the 'cdat_tutorial' directory in that repository, you'll see the example code that I used today.



  • excellent interactive development environment (IDE)
  • use dir() and ? to explore objects
  • use pdb for debugging
  • use ! to run any command at the system shell
  • on abyss: /usr/local/uvcdat/1.2.0rc1/bin/ipython


import cdms2

import cdutil

import genutil

import regrid2

  • for regirdding

import MV2

  • for masked arrays
  • it's a copy of, but the data keep their attributes

import matplotlib

  • for all plotting (timeseries, spatial maps, etc)
  • from mpl_toolkits.basemap import Basemap, for spatial maps
  • from mpl_toolkits.basemap import shiftgrid, for longitude axis fiddling
  • documentation:

programming tips

  • use the argparse module for parsing the command line
  • create your own modules to avoid duplication of code
  • use docstrings as your primary documentation method
  • use pylint to test the quality of your code