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.
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!
Numeric
arrays? Can you concatenate along
"extra" dimensions like you can in IDL?where
in IDL and
find
in MATLAB)?and
and or
operations on arrays?print
command?Numeric
/numarray
functions?vcs.getcolors
function?Numeric
array?imagesc
function and make plots with
color bars that are scaled over the same range?plot
method
x|yrev
keyword work to reverse the axis?plot
keyword
name
?MA
vs.
Numeric
?MA
have a default missing value?Numeric
/numarray
functions?Numeric
/numarray
functions?