Thursday, October 27, 2011

Sing Along with RayP

Ray Pierrehumbert has been teaching a course on the Climate Dynamics of the Earth and other Planets based on his textbook, the Principles of Planetary Climate. For those of you interested (pay attention you in the back), the course lectures are available via webcast with whiteboard, at the course site. To do the exercises the bunnies and the Rabetts will have to learn and install Python (guide here with courseware). So your (and Eli's) assignment is to get the book, install Python, and come up to speed.

Let's try to do this one lecture per week. RayP stops by RR on occasion, so Eli is sure he will help with any questions and there are any number of Python capable bunnies. Remember the only mark in this course is a W.

UPDATE: Good advice and discussion on installing the software below

15 comments:

Anonymous said...

Wow, climate! In python!
The energy barrier to me finally getting started on RayP's book just dropped. (Although I'm pretty much committed to learning R as well.)
Kevin C Mouse.

Anonymous said...

Yeah, I got started on the book, and ran into the problem that my python install isn't quite up to snuff... (namely, I've gotten the Climate Utilities package imported, but can't get the PyNGL package to work. It is very reminiscent of the time I totally failed to get netCDF working on my computer. I have a Macintosh, which makes it more challenging than a Linux box, but it really shouldn't be this hard...)

-MMM

Jonathan Gilligan said...

Note that it's not as simple as just installing Python. You also need to install the NCAR Graphics library and the CLIMT version of the NCAR CCM radiation model (these require building C and FORTRAN code). When I installed the courseware last summer, it took me a couple of days of work getting everything installed because the NCAR libraries kept giving compilation errors and took some tweaking to build properly under Debian.

Once it's properly installed, it's all great stuff, but it did take considerable work to get it installed.

MacOS folks can grab RayP's prebuilt modules for the Mac but Windows and Linux folks face a lot more work.

andrewt said...

If you have a technical background and want to learn enough to get the job done with Python and other tools the software carpentry site is superb: http://software-carpentry.org/

Recovering in the Florida Keys said...

I think I will audit quietly in the back. The netbook doesn't even like Windows 7. I am curious how he deals with variations in local emissivity.

Nick Barnes said...

Hmm, could make a Windows meta-package installer thing including the dependencies. If only I had the time!

Michael Tobis said...

I'm in. If we host it at P3, we can have inline LaTeX in the articles (not supported in the comments, alas).

Anonymous said...

Thanks for all the interest. I have been working on making things easier for people to install. This year, I am having all the students install stuff on their own laptops (having done that for the summer school in Abisko I taught at, and found it worked). In previous years we set it up on a central Linux server and had students access it via x11 (a problem for Windows users, since installing CygWin is a pain).

For the Anonymous and others who were having trouble installing PyNgl, I have some help: I noticed that great as this package is, the installation procedure is difficult, and it is a big barrier on Windows systems (also on Ubuntu linux). SO --- I have written a version of the courseware that uses MatPlotLib. That means that all you need to do is download the Enthought Python distribution, which with one click installs everything you need -- Python, numpy, MatPlotLib graphics -- and works equally well on windows, Mac and Linux. The class is using this, and it is working out well. Enthought is free for academic users, and for non-academic users there's still a free version which has everything you need for my course (though the free version isn't available for 64 bit Windows, evidently).

Because of the wonders of object orientation, you don't need to change any of my courseware; I just overloaded the plot(...) function in ClimateUtilities to produces graphics using MatPlotLib instead of PyNgl. I have updated the instructions on the web site to steer people towards Enthought, which should make things a whole lot easier.

Note that this still doesn't solve the problem of CliMT for Windows users. CliMT is the Python interface to the NCAR radiation model. There are very few of the exercises that need it, but the bunnies here would find it very useful for the sort of things they are concerned with. CliMT involves some FORTRAN code (not mine!) that needs to be compiled. We have built it for the Mac, and building from source on Linux seems to work reliably as long as you have the full version of numpy installed on your system (which includes pyfort), but we don't know enough about Fortran compilers or using pyfort on Windows to do a Windows port. Anybody who manages to do one will have my undying gratitude. Meanwhile, if anybody has trouble building CliMT for Linux please let me know, since that's something I can probably fix. I've built it on a lot of Redhat systems, but have only limited experience with Ubuntu.

--raypierre

David B. Benson said...

I read the book, straight through. I then went back to study the book Understood much more the second time. Some some topics a third time through will be required.

Great book on a difficult subject.

Anonymous said...

In my previous post, I forgot to mention that to use MatPlotLib, you need to download the latest version of ClimateUtilities.py, and also my new graphics driver ClimateGraphicsMPL.py . The courseware will then automatically use MatPlotLib if it can't find Ngl.

The MatPlotLib interactive graphics window doesn't work gracefully with idle, but works very well with ipython -pylab. I did pull some tricks with the event loop driver (you don't want to know) to configure MatPlotLib to work better with idle, but on Macs you have to start idle with idle -n (you don't want to know) in order to be able to get your command prompt back after graphics is displayed. Somebunnies have learned a lot more about the handling of MouseDownInAppWindow than they ever thought they'd be able to stomach. Still on a bit of a learning curve regarding whether this trick works for idle on Windows.

--Raypierre

Anonymous said...

By the way, we're on the quarter system at U. of Chicago, and quarters are short. Hence, this quarter only covers Chapters 1-3,with just a bit of the real gas stuff from Ch. 4. I will teach an advanced Rad Trans course in Winter, based on Chapter 4, and as much of Ch5 (scattering) as I can fit in, but I haven't decided whether to webcast that one yet. The technical hitch is that Ch4 involves some heavy-lifting mathematics that needs more board space (and smaller writing) than my current smartboard can handle.

--raypierre

Anonymous said...

Great idea Eli! I will definitely participate. The book is very good. Slow reading for me but that's fine. I can't work on software installation until 9 November and by then you guys will have it all worked out ;). The rest is all fun. Who's afraid of a couple integral equations? I have a good picture of forward scattering that I will have to post somewhere at that point in the course. As mt says, some LaTeX would surely help although thinking is the main required activity.

- Pete Dunkelberg

raypierre said...

A few tips for those installing the software:

*When I added support for MatPlotLib graphics I forgot to take out an error message from the courseware; if Ngl isn't there, it imported MatPlotLib correctly, but still gave you the message you couldn't use graphics. It was harmless (but confusing) but I've uploaded a corrected version of ClimateGraphics.py that gets rid of the confusing error message.

*Rodrigo and I are still working on simplifying the build/install procedure for CliMT_lite . Even for the Mac pre-build, we have the problem that there's a gfortran library dependency we haven't been able to get rid of (suggestions anybody?), so we distribute the correct libg and tell people where to put it by hand. Either we need to get rid of the dependency, or at least figure out how to set the libpaths so that shared libraries are looked for in some different place than they were on the machine where the build was done. For the build on the Mac, we are still having trouble getting the build procedure to work properly for the 64 bit build, which is why we are only distributing the 32 bit binary for now (which works fine even if you are running a 64 bit OS on the Mac -- haven't tried CliMT on 10.7 yet, though). The correct place to put the gfortran library is described in the README file in the tarball of the pre-build for Mac.

*On RedHat linux with gfortran installed, the build of CliMT should be easy since we use distutils , which automatically detects the compiler and sets the correct flags. It's as simple as going into the CliMT directory, doing python setup.py , then moving the result to someplace in your PYTHONPATH. Should automatically work with other compilers as well. Note that you need to have the full version of numpy (which includes pyfort) installed, in order to do the build.

--Raypierre

Hank Roberts said...

> a free version which has everything you need for my course
http://enthought.com/repo/free/

Nick Barnes said...

My copy of the book arrived while I was away on a business trip. If I have a minute over the weekend I'll look at the Windows/Fortran difficulties which RayP mentions.