A short course in Python
Department of Earth System Science, Tsinghua University

A quick introduction and practical examples of Python programming to climate science problems. The exercises are taken from various iterations of the Atmosphere–Ocean Interactions class. Some of the files are large. If you find any errors or have suggestions, please contact me directly.

Note (16 April 2022): the cloud links have expired and no longer work. I am in the process of updating these examples and moving them to a different system but please feel free to contact me with requests in the meantime.

  1. Introduction to the Python programming environment (native data types and structures, functions and modules, numpy, basic plots)
    [notes and examples (zip: 0.5MB)]
  2. Continuing introduction to Python (csv, dynamical modeling, more numpy and plotting, gsw)
    [notes and examples (zip: 3MB)]
  3. Python Data Analysis Library (pandas, seaborn)
    [notes and examples (zip: 0.7MB)]
  4. The SciTools suite (iris, cartopy) and some basic metpy
    [notes and examples (zip: 5MB)]
  5. A practical example based on this paper (netCDF4, linear regression, significance testing, maps)
    [notes and examples (zip: 15MB)]
  6. Climate data analysis with xarray
    [examples with all data (zip: 317MB) or limited data (zip: 50MB)]
  7. EOFs with xarray or iris
    [examples with all data (zip: 56MB)] or limited data (zip: 17MB)]
  8. Windspharm with xarray or iris
    [examples with all data (zip: 344MB)] or limited data (zip: 13MB)]
  9. Time series filtering and analysis
    [examples with all data (zip: 137MB)] or limited data (zip: 2MB)]