Overview
Here you will find the set of Python scripts I have written for use with the text, along with instructions for installation and a guide to usage. These scripts are used in the Workbook problems, they allow the reader to reproduce essentially all the calculations and figures in the text, and they provide a basic toolkit for original research. Before delving into this material, you should first take care of a basic Python installation and obtain some familiarity with the language
For an quick summary of what you need, see Quick Start. For most users, Quick Start will be sufficient. The material below covers the same territory in more detail. A tarfile of the complete collection of courseware is here. Eventually I will also provide access to a Git repository on GitHub.
The most recent courseware update was October 10, 2014.
Courseware Modules
These are utilities used throughout the courseware. They should be put in a search path where Python can find them regardless of which directory you are working from. The utility routine setpath.py included below takes care of the chore of setting things up so that Python will find the modules; see the Python portal page for a more extensive discussion of where Python looks for modules. These courseware modules are not really meant to be modified by the student, but one can always make a personal copy and customize if desired. Wherever they are put, the student will be able to read them and see how they work. Freedom to Tinker Rules!
Example scripts illustrating the use of the courseware modules are found here.
- setpath.py : This is a utility that modifies the set of paths where Python looks for modules to import, so that the directory where you put the courseware modules will be found no matter what directory you are working from. Just put setpath.py in the same directory as you put the rest of the courseware modules, then run setpath.py while your courseware modules directory is your working directory. Let's say your courseware directory is
/home/MyModules
. If you are doing this using the command line (in any operating system), you would first change your working directory to , using the appropriate command for your OS (e.g.cd /home/MyModules
for Mac or Linux), then typepython setpath.py
. If you are using the Canopy application, you would first open the file/home/MyModules/setpath.py
, use the Canopy window popup menu to specify that you want the working directory changed to the Editor directory, and then run the file in Canopy. You only need to do this one time for each directory you want to add to the search path. You can follow the same procedure if you want to add additional directories to the search path; all your previous specifications will be retained. Note that ifsetpath.py
complains that the .ipython configuration directory can't be found, the user will have to run the Canopy application (and agree to make Canopy the user's default Python) to configure the user's Python environment, and then try again. - ClimateUtilities.py : This is the universally needed handy collection of utilities used throughout the courseware. It provides support for reading and writing files, data manipulation, plotting, and numerical analysis.
- ClimateGraphics.py : This is imported by ClimateUtilities.py. It contains the actual plot functions, which in this version is set up to use PyNgl. If you are using a different graphics package to make plots, this is the only module you need to customize. MatPlotLib graphics is supported by the version below. See the Python Python Graphics page for details. This module is optional if you are only using MatPlotLib
- ClimateGraphicsMPL.py : This version of ClimateGraphics uses MatPlotLib instead of PyNgl to produce graphics. It is imported automatically if PyNgl is not found on your system, and the rest of your scripts will work without any modifications. If you have both PyNgl and MatPlotLib on your system, but prefer to use MatPlotLib, just delete ClimateGraphics.py from your installation (or edit the import statement at the top of ClimateUtilities). See the Python Graphics page for details.
- DummyGraphics.py : This allows the Chapter scripts to be run without modification on systems for which no graphics implementation can be found.
- phys.py : Contains physical constants, properties of gases, and functions needed to compute physical properties (e.g. saturation vapor pressure or moist adiabats)
- planets.py : Contains characteristics of Solar System objects, including all planets and selected satellites. (the Sun isn't yet in there, but I will put it there eventually).
- climt_lite: This is the Python interface to the NCAR CCM radiation module, plus selected other radiation models. This one is a bit more complicated to install, so there isn't a link to a simple script you can just drop into your modules directory. climt_lite is the only utility that needs to be compiled, and if you don't want to take on the build and install process, or run into trouble with this, you can skip this part of the installation since there are relatively few exercises that require use of climt_lite. You can browse the directory containing what is needed to build climt_lite here, but if you actually want to get the full directory and build this extension, you should get it via the full courseware tarfile archive. The build directory for climt_lite is called
CliMT-master
.- To build climt_lite (or the more complete version, climt), you will need a Fortran compiler. The setup script will automatically detect and work with a variety of different compilers, but has been tested most extensively with
gfortran
.gfortran
for Mac OSX can be downloaded here (follow the install instructions on the site, since there are a few Mac Xcode tools you also need to install). - After installing
gfortran
, building climt_lite is as simple as changing your working directory to the build directory (CliMT-master) and executing the commandpython setup.py build --lite
. (You have to do this from a command line. There is currently no way to execute a command like this by executing setup.py from theCanopy editor.) See the README file inCliMT-master
for further information. - After the build is complete, the easiest way to install it is to simply drag (or otherise move) a copy of the directory
CliMT-master/lib/climt_lite
to your modules directory. Note that this means you should wind up with a directory calledclimt_lite
within your modules directory, which contains all the contents of the originalclimt_lite
. Eventually, I will update setup.py so it will do this automatically for you. - climt_lite builds easily on Linux or Mac OSX. It is not currently supported on Windows, but it would probably be possible to get it working there (please let me know if you do).
- climt and climt_lite were developed by Rodrigo Caballero. His own site for this project is here . The main project site describes the comprehensive version of CliMT; CliMT_lite is a stripped-down simplifed version providing access to just the
ccm
andrrtm
radiation models. - An older pre-built 32 bit version of climt_lite for Intel Macs running OS 10.5 is here, and may work with versions of the OS somewhat before and after 10.5. It is provided mainly for users with older Macs running older 32-bit Python installations. All you need to do is download the file, untar it, and then drag two folders to the appropriate places, as described in the README.txt file . I am working on pre-built binaries for newer Macs, but meanwhile if you want to use climt_lite, you'll need to build it yourself or find somebody who can help you do it.
- To build climt_lite (or the more complete version, climt), you will need a Fortran compiler. The setup script will automatically detect and work with a variety of different compilers, but has been tested most extensively with
Chapter Scripts
Each student should have a personal copy of these, in their own home directory. They are meant to be run and modified, to reproduce figures in the text, for further explorations, and for aid in doing the Workbook problems. There are a few Chapter Scripts that are used by chapter scripts in other chapter directories, and you will need to do something to make those available (see the Quick Start page for now). Some chapter scripts access data in the Workbook Datasets. The datapath variable in such scripts needs to be customized to specify where the datasets reside on the system you are using.
Documentation of what each script does is found in the comments embedded in the scripts, and the use of many of these scripts is described in the Workbook problems that need them. Eventually I will provide a comprehensive list of the scripts, their usage, and the figures (and other results) in the text which they were used to produce, as a complement to information of this sort that is already embedded in the individual scripts.