Python/CDAT for Earth Scientists: Tips and Examples


This is a collection of tips and examples on using Python in the earth sciences, with an emphasis on climate science. We focus solely on standard Python, Numerical Python, and the analysis and plotting routines in the Climate Data Analysis Tools (CDAT) suite. This collection of tips/examples is neither "official" nor comprehensive.

A note from June 2017: While a number of the tips on this site are still useful, this site hasn't really been updated much since the first decade of the 2000's. The community has also moved on: NumPy and not Numerical Python is the array package of choice and CDAT has become UV-CDAT. Python is also now at version 3. Some more recent Python-for-the-atmospheric sciences resources are available or listed at the PyAOS blog.

General Python references (some referenced herein) that have helped me include:

If you have any comments, questions, additions, and corrections for this page, please send me (Johnny Lin) email.

My Python Book Cover Image Advertisement: In 2012, I published the book A Hands-On Introduction to Using Python in the Atmospheric and Oceanic Sciences. If you're new to Python, you may find it useful!



Array Manipulation


File Input/Output

General CDAT

Graphics: General

  • Has anyone written any front-ends to simplify graphing with CDAT?

Graphics: 2-D

Masked Arrays & Variables


Python Language

Acknowledgments: Dean Williams answered a zillion of my questions. Charles Doutriaux, Mike Steder, Alexis Zubrow provided help and guidance. Thanks to Ray Pierrehumbert for his support of this project. The inspiration for this page came from David Fanning's IDL Programming Tips and Tricks page, which is an amazing repository of knowledge for users of the IDL language. This work was carried out partially at the University of Chicago Climate Systems Center, funded by the National Science Foundation (NSF) Information Technology Research Program under grant ATM-0121028. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author and do not necessarily reflect the views of the NSF.

Copyright © 2003-2005 Johnny Lin. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found here.

The Transparent copy of this document is located at

Valid HTML 4.01! Valid CSS! Updated: June 15, 2017 by Johnny Lin <email address>.