Getting you and your laptop ready for ATM 623

For this class we need several different bits and pieces of software. Everything we need is free and should run on Mac, Windows and Linux. Your task is to go through all the following steps and familiarize yourself with all these different tools.

Installing Python software

  • Install Anaconda Python with Python version 2.7
  • Familiarize yourself with the conda package and environment manager that comes with Anaconda Python. Here is a great quick tutorial.
  • Use conda to install these packages (if you don't have them already):
    • netcdf4
    • xarray

Fortran compiler

Although we will be working in Python, some of the underlying model components are written in Fortran. You don't need to know anything about the Fortran language, but you will need a compiler on your computer to build the software. I suggest installing gfortran, which is free and should work on everyone's laptop.

There is more than one way to get gfortran on your laptop. Here are some options depending on your operating system.

Another possibility is installing it with conda, using

conda install gcc

(gcc is the 'GNU compiler collection'). HOWEVER I don't think this is available on Windows, and in my experience it is problematic on Mac OS X.

git version control software

We will be using git to manage changes in our source code. Do the following:

  • Make sure that git is installed on your computer. If you are using Mac or Linux it is probably already there. You can download the software here.
  • What is version control, what is git, and how do you use it? Teach yourself a few basics. There are many tutorials and learning resources on the web. Here is one simple tutorial.

If you encounter problems with any of the above, please first do your best to resolve the problem on your own using online help. Then, when you are really stumped, please email me with a detailed description of your problem.

The jupyter notebook

Most of our interactive Python work will happen inside of the so-called Jupyter notebook. The notebook lets you write and execute Python scripts inside a web browser, in a document that combines Python code, graphics, and nicely formatted text. It is a very useful tool for organizing a scientific workflow because the code remains tied to the text descriptions and the actual results.

You can easily create a new notebook by doing this on your command line:

jupyter notebook

Your browser will open with the jupyter console window. Click on the New button and select Python from the drop-down menu. A new empty notebook will open. Play around with entering and running some Python code, such as

num = 1
print 'This is Python program number {}'.format(num)

In the next cell try entering this code:

num += 1
print 'This is Python program number {}'.format(num)

A quick demonstration that variables you define in one cell remain in memory when you execute another cell.

Now select your second cell, hit shift+enter to run it again. What result do you get? Does that make sense?

If you want, you can choose a file name for your new notebook by clicking where it says 'Untitled' at the top of the window.

Lecture notes in jupyter notebook format

For ATM 623 I distribute a complete set of lecture notes in the Jupyter format. We are going to use git to download a complete copy of the notes, and also manage all the changes that will occur during the semester. Do the following from a command line:

  • Move to a directory where you want to keep the notes.
  • type the following:
git clone
  • This will create a new git repository called ClimateModeling_courseware on your file system. Inside you will find a complete copy of all my notes.
  • Change directories to move inside the ClimateModeling_courseware directory.
  • Create a new branch of the notes! You want to do this so that the master branch of your notes will not be modified from my version. On your new branch you'll be able to make changes while you play with the code, and then easily switch back to the original version without losing any information.
  • To do this (should look familiar if you went over a git tutorial):
git branch [whatever name you like]
git checkout [the name you just chose]
  • On your new branch, start up the notes by entering
jupyter notebook index.ipynb

Your first reading assignment: Lectures 1 and 2

Because I am away for the AMS meeting during the first week of class, you will be responsible for going through the first two lectures on your own. Please read carefully and play around with the code examples. Have a close look at the global energy budget figure in Lecture 1. We will come back to this frequently throughout the course.

When we meet in person for the first time on January 31, please come with any questions about the concepts, the mathematics, and the code.

A look ahead: the climlab package

Most of our work in ATM 623 will use a custom package called climlab designed for interactive climate modeling with Python. If you look ahead in the notes you will see import climlab in most of the notebooks. I will give you a formal introduction to climlab later. If you want to get started, here's how to install climlab:

  • Navigate to wherever you want to keep the code repository.
  • Get the source code:
git clone
  • Move into the climlab directory
  • Build and install the software by entering
python install
  • This will invoke your Fortran compiler to build the radiation models, and install all the Python software in your current Python environment.
  • If you want to make sure the software is working properly, you can run the automatic test suite by entering
py.test -v

This will take a little while to run, but if you end up with all green 'Passed' notices, then everything is good.

I anticipate some hiccups with getting climlab up and running on everyone's laptops! Don't worry if you encounter problems here. We will deal with this a little later.