Climate Science: Modeling Earth’s Climate in Python
Summary
Students build a suite of box climate models in which each new version adds another layer of climate feedbacks, with scaffolding and prompts to guide the way. The models are written in Python within a Jupyter Notebook coding environment.
Learning Goals
Students are offered the means to acquire a rigorous understanding of the atmosphere, oceans, and land, as the three primary reservoirs ("boxes") of carbon governing Earth's climate. As the course progresses, modeled mechanisms of carbon exchange between these reservoirs become increasingly focused on nonlinear feedbacks governing these exchanges, including temperature-dependent Henry's Law equilibrium of CO2 between the atmosphere and oceans, ice/albedo feedback, and CO2 fertilization. Principles of radiative balance are also emphasized throughout. A working version of the most sophisticated version of the model is available at https://cambio.fly.dev/.
Students complete the course having constructed a working climate model capable of making realistic predictions of how Earth's climate is likely to respond to future pathways of greenhouse gas emissions, paired with a solid conceptual framework of the mechanisms underlying that response. Skills developed during these activities include the ability to faithfully translate mathematical formulas into computer code, skill at solving (numerically) a system of ordinary differential equations, and extensive practice at using graphics to interpret the results of those solutions.
Context for Use
The Python Jupyter Notebooks shared here form the backbone of a semester-long course in modeling Earth's climate taught at undergraduate/community colleges over the past several years. Although most students who have taken these courses have upper-level (15-16) standing, students at all college levels have done well. The course has been taught by a single instructor in classes up to about 30 students; for larger class sizes, a course assistant would likely be needed. Typical class time allocations are about 1/2 lecture, and 1/2 hands-on work at a laptop computer. Typically, 1-3 modules are engaged in per week, with additional time set aside for exams/interviews, student presentations, and examination of causes and impacts of climate change; the course as a whole has therefore spanned up to 15 weeks. While no prior knowledge of computer programming is expected, it is important for students to possess rudimentary (100-level) algebra skills.
Description and Teaching Materials
Code can be found at https://github.com/sneshyba/meclib/tree/main. Folders at that site include the following:
- examples_of_python_scripts
- examples_of_python_notebooks
- student_notebooks_for_a_15_week_course
Running these codes will require several Python packages be installed. This can be done by a command-line entry such as
python -m pip install numpy matplotlib pandas pint meclib
A Python add-on, called nbgrader (see this link) can be used by instructors to generate tailored student versions of python notebooks from instructor versions. Instructor versions are available from the authors on request via the SERC feedback link.
Files supporting in-class (lecture) parts of the activities, such as introduction of relevant geophysical ideas and tips on how to complete notebooks, are available from the authors via the SERC feedback link.
Teaching Notes and Tips
One strategy for managing the tasks associated with generating, modifying, grading, and providing feedback to students, is for instructors to request from the authors a pre-built virtual machine (VM). The VM can be hosted by free server software (such as virtualbox), and can be made accessible by students via their browsers (e.g., Firefox or Safari) on a local area network (LAN). A Python add-on, nbgrader, comes pre-installed in the VM. Two key capabilities of nbgrader are 1) editing instructor versions of assignments, and (at the click of a button) generating student versions from them, and 2) managing online student submissions, and giving online feedback. Challenges we have encountered in going this route include securing dedicated server hardware, and arranging for student accounts to have LAN permission to access it, both of which may require the assistance of IT staff.
An alternative is to direct students to an online server, like CoCalc or Colab. Both support Jupyter Notebooks, and (in the case of Colab) a limited range of nbgrader capabilities. Challenges we have encountered in going this route include version conflicts between the provided Python Notebooks with versions of Python on these online servers, and the awkwardness of having to use some method other than nbgrader -- for example, an institutional course management system -- to distribute and collect student work.
Another alternative is for instructors to install a Jupyter Notebook environment on their laptops, and require that students do the same. Free, user-friendly installation packages, such as Anaconda, are readily available for this purpose. Instructors who choose this route can install nbgrader on their machines for the purpose of generating student versions from them. Challenges we have encountered in going this route include (again) version conflicts, and the awkwardness of having to use some method other than nbgrader to distribute and collect student work.
The authors are happy to help with any of these options, via a request on the SERC feedback link.
References and Resources
A paper in the Bulletin of the American Meteorological Society discussing the pedagogy and science behind these exercises is under review.