About Python

In this course we will be working extensively with a computer programming language called Python.

Python is a general-purpose high-level interpreted language that is now being used by many people in the geosciences. Benefits of Python include:

  • It's easy to learn.
  • The code tends to be simple and easy to read.
  • It can run on just about any computer, maybe even your smartphone.
  • You can run your code interactively, so it's great for exploring and learning about your data.
  • Lots of packages are available for powerful scientific computing and graphics.
  • It's completely free and open-source.

Anaconda Python

To get started, you need to install Python on your computer. We are going to use a program called Anaconda. Anaconda is a complete scientific Python environment including Python itself, a handy editor for reading and writing code, an interactive "shell" where you can run your code, and access to all the scientific Python libraries we will need.

To download and install Anaconda, go to this page. Installers and instructions are available for Windows, Mac and Linux. IMPORTANT: You will see the option to install either Python 2.7 or Python 3.5. Choose Python 2.7. Some of the scientific libraries we will use are not yet compatible with Python 3.5.

Python resources

Here are some links to useful Python-related resources.

  • A Hands-On Introduction to Using Python in the Atmospheric and Oceanic Sciences, by Johnny Wei-Bing Lin. A very nice short course in Python written specifically for students and researchers in Atmospheric and Oceanic Sciences. The entire book is available as free pdf downloads from the website (the author requests donations, and a print version is also for sale).
  • Principles of Planetary Climate, by Raymond T. Pierrehumbert. The website companion to a comprehensive textbook on climate physics. A lot of climate-related python code can be found here under "Courseware".
  • Learn Python the Hard Way, by Zed A. Shaw. A great introduction to Python for beginners with little or no programming experience. Not specific to atmospheric science. This introductory note spells out the importance of trial and error, and avoiding the temptation to copy and paste code (which tends to teach you very little).

Learning Python the Hard Way

I happen to think that learning any kind of programming is best done by trial and error, and I will structure the assignments accordingly. The advice on this page sums up my feelings quite well: "The Hard Way is Easier"