/ebm_1d

This is a Python 3 version of a one-dimensional energy balance model from the edX course "Climate Change: The Science and Global Impact", by Dr. Michael Mann.

Primary LanguagePythonMIT LicenseMIT

Contents

License: MIT Build Status CircleCI Github Lint and Test

Introduction

Iin 2019 I took an online course, "Climate Change: The Science and Global Impact", by Dr. Michael Mann. If you're looking for a gentle introduction to climate modeling and what it predicts for our planet, I highly recommend the course.

For a software developer Module 3 was especially interesting. It offered a little math, a little geometry, and a video presentation of a one-dimensional energy balance model (1D EBM). In the video I could see snippets of what appeared to be Matlab code.

I froze the video, jotted down a couple of function names, and started trying to learn where that code lived.

I probably could have found answers more quickly by first reviewing the module Readings. Still, I eventually learned that several of the illustrations in the course videos, as well as the code for the 1D EBM, traced back to "The Climate Modelling Primer", by Kendal McGuffie and Ann Henderson-Sellers.

The book explained that the model had been re-implemented in many programming languages over the years. To better understand how the model worked, I decided to translate it for myself.

From Matlab to Python 3

This repository contains a variant of the 1D EBM written for Python 3.10. It uses PySide6 for the GUI, together with numpy and Pillow (the latter for generating albedo texture images).

The code in this repository is based on the Matlab implementation. I also found a JavaScript implementation, underlying an interactive online version of the 1D EBM that's part of an online textbook:

Goosse H., P.Y. Barriat, W. Lefebvre, M.F. Loutre and V. Zunz, (2008-2010). Introduction to climate dynamics and climate modeling.

The Matlab implementation represents Earth's shape in a curious way. The JavaScript implementation faithfully mimics the Matlab code.

This Python translation represents earth's geometry differently. Yet, as far as I can tell, all three models exhibit hysteresis, and all illustrate climate tipping points, in the same way.

Getting Started

To run the main program you'll need to install the packages listed in requirements.txt.

Then

$ python one_dim_ebm.py

Screenshot

What am I looking at?

My UI skills are almost as rusty as my PyQt skills. In particular the following points may not be obvious.

The chart shows global average temperature (°C) on the y axis, and solar multiplier value on the x axis. As explained in the edX course video, the "rising" and "falling" lines show how global average temperature varies as the solar multiplier varies, first from its minimum to its maximum, and then from maximum to minimum. The underlying code solves for each new temperature given the current model state (temperature by latitude band) and solar multiplier.

When you move your mouse across the chart, the depictions of the planetary sphere update to show the planetary albedo, for rising and falling solar multiplier "trajectories", at the mouse's current location on the chart.