{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# ENV/ATM 415: Climate Laboratory\n", "\n", "[Brian E. J. Rose](http://www.atmos.albany.edu/facstaff/brose/index.html), University at Albany\n", "\n", "# Lecture 1: Climate models, the global energy budget and Fun with Python" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Contents\n", "\n", "1. [What is a Climate Model?](#section1)\n", "2. [The observed global energy budget](#section2)\n", "3. [Using Python to compute emission to space](#section3)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "____________\n", "\n", "\n", "## 1. What is a Climate Model?\n", "____________" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "Let's be a little pedantic and decompose that question:\n", "\n", "- what is Climate?\n", "- what is a Model?" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "**Climate** is\n", "\n", "- statistics of weather, e.g. space and time averages of temperature and precip.\n", "- (statistics might also mean higher-order stats: variability etc)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "A **model** is\n", "\n", " - not easy to define!" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "Wikipedia: http://en.wikipedia.org/wiki/Conceptual_model\n", "\n", "> In the most general sense, a model is anything used in any way to represent anything else. Some models are physical objects, for instance, a toy model which may be assembled, and may even be made to work like the object it represents. Whereas, a conceptual model is a model made of the composition of concepts, that thus exists only in the mind. Conceptual models are used to help us know, understand, or simulate the subject matter they represent." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "George E. P. Box (statistician):\n", "> Essentially, all models are wrong, but some are useful.”" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "From the Climate Modelling Primer, 4th ed (McGuffie and Henderson-Sellers):\n", "\n", "> In the broadest sense, models are for learning about the world (in our case, the climate) and the learning takes place in the contruction and the manipulation of the model, as anyone who has watched a child build idealised houses or spaceships with Lego, or built with it themselves, will know. Climate models are, likewise, idealised representations of a complicated and complex reality through which our understanding of the climate has significantly expanded. All models involve some ignoring, distoring and approximating, but gradually they allow us to build understanding of the system being modelled. A child's Lego construction typically contains the essential elements of the real objects, improves with attention to detail, helps them understand the real world, but is never confused with the real thing." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### A minimal definition of a climate model\n", "\n", "*A representation of the exchange of energy between the Earth system and space, and its effects on average surface temperature.*\n", "\n", "(what average?) \n", "\n", "Note the focus on **planetary energy budget**. That’s the key to all climate modeling." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "____________\n", "\n", "\n", "## 2. The observed global energy budget\n", "____________\n", "\n", "The figure below shows current best estimates of the *global, annual mean* energy fluxes through the climate system.\n", "\n", "We will look at many of these processes in detail throughout the course." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "![alt text](http://www.atmos.albany.edu/facstaff/brose/classes/ENV415_Spring2018/images/GlobalEnergyBudget.png)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Things to note:\n", "\n", "### On the shortwave side\n", "\n", "- global mean albedo is 101.9 W m$^{-2}$ / 341.3 W m$^{-2}$ = 0.299\n", "- Reflection off clouds = 79 W m$^{-2}$\n", "- Off surface = 23 W m$^{-2}$\n", " - 3 times as much reflection off clouds as off surface\n", " \n", "Why?? Think about both areas of ice and snow, and the fact that sunlight has to travel through cloudy atmosphere to get to the ice and snow. Also there is some absorption of shortwave by the atmosphere.\n", "\n", "- Atmospheric absorption = 78 W m$^{-2}$\n", "(so about the same as reflected by clouds)\n", "\n", "QUESTION: Which gases contribute to shortwave absorption?\n", "\n", "- O$_3$ and H$_2$O mostly.\n", "- We will look at this later." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### On the longwave side\n", "\n", "- Observed emission from the SURFACE is 396 W m$^{-2}$\n", "- very close to the blackbody emission $\\sigma T^4$ at $T = 288$ K (the global mean surface temperature).\n", "- BUT emission to space is much smaller = 239 W m$^{-2}$\n", "\n", "QUESTION: What do we call this? (greenhouse effect)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Look at net numbers…\n", "\n", "- Net absorbed = 0.9 W m$^{-2}$\n", "- Why?\n", "- Where is that heat going?\n", "\n", "Note, the exchanges of energy between the surface and the atmosphere are complicated, involve a number of different processes. We will look at these more carefully later." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Additional points:\n", "\n", "- Notice that this is a budget of energy, not temperature.\n", "- We will need to discuss the connection between the two\n", "- **Clouds** affect both longwave and shortwave sides of the budget.\n", "- **WATER** is involved in many of the terms: \n", "\n", " - evaporation\n", " - latent heating (equal and opposite in the global mean)\n", " - clouds\n", " - greenhouse effect\n", " - atmospheric SW absorption\n", " - surface reflectivity (ice and snow)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "### Discussion point\n", "\n", "How might we expect some of the terms in the global energy budget to vary under anthropogenic climate change?" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "____________\n", "\n", "\n", "## 3. Using Python to compute emission to space\n", "____________" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*Most of what follows is intended as a \"fill in the blanks\" exercise. We will practice writing some Python code while discussing the physical process of longwave emission to space.*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Suppose the Earth behaves like a **blackbody radiator** with effective global mean **emission temperature $T_e$**.\n", "\n", "Then\n", "\n", "$$ OLR = \\sigma T_e^4 $$\n", "\n", "where OLR = \"Outgoing Longwave Radiation\", and $\\sigma = 5.67 \\times 10{-8}$ W m$^{-2}$ K$^{-4}$ the Stefan-Boltzmann constant\n", "\n", "**We can just take this as a definition of the emission temperature.**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Looking back at the observations, the global, annual mean value for OLR is 238.5 W m$^{-2}$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Calculate the emission temperature $T_e$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Rerranging the Stefan-Boltzmann law we get\n", "\n", "$$ T_e = \\left(\\frac{\\text{OLR}}{\\sigma} \\right)^{\\frac{1}{4}} $$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First just use Python like a hand calculator to calculate $T_e$ iteractively:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Try typing a few different ways, with and without whitespace." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 1\n", "\n", "extra spaces are ignored! " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "But typing numbers interactively is tedious and error prone. Let's define a variable called `sigma`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 2\n", "\n", "We can define new variables interactively. Variables let us give names to things. Names make our code easy to understand." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Thoughts on emission temperature\n", "\n", "What value did we find for the emission temperature $T_e$? How does it compare to the actual global mean surface temperature?\n", "\n", "*Is the blackbody radiator a good model for the Earth's emission to space?*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### A simple greenhouse model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The emission to space is lower because of the greenhouse effect, which we will study in detail later. \n", "\n", "For now, just introduce a basic concept:\n", "\n", "*Only a fraction of the surface emission makes it out to space.* \n", "\n", "We will model the OLR as\n", "\n", "$$ \\text{OLR} = \\tau \\sigma T_s^4 $$\n", "\n", "where $\\tau$ is a number we will call the **transmissivity** of the atmosphere.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's fit this model to observations:\n", "\n", "$$ \\tau = \\frac{\\text{OLR}}{\\sigma T_s^4} $$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "tau = 238.5 / sigma / 288**4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Try calculating OLR for a warmer Earth at 292 K:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Naturally the emission to space is higher. By how much has it increased for this 4 degree warming?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Answer: 13.5 W m$^{-2}$. Okay but this is tedious and prone to error.\n", "What we really want to do is **define a reusable function**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note a few things:\n", "\n", "-\tThe colon at the end of the first line indicates that there is more coming.\n", "-\tThe interpreter automatically indents the code for us (after the colon)\n", "-\tThe interpreter automatically colors certain key words\n", "-\tWe need to hit return one more time at the end to finish our function\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 3\n", "\n", "**Indentations are not ignored! They serve to group together several lines of code.**\n", "\n", "we will see plenty of examples of this – in this case, the indentation lets the interpreter know that the code is all part of the function definition." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 4: \n", "\n", "`def` is a keyword that defines a function. \n", "\n", "Just like a mathematical function, a Python function takes one or more input arguments, performs some operations on those inputs, and gives back some resulting value. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Python fact 5: \n", "\n", "`return` is a keyword that defines what value will be returned by the function." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once a function is defined, we can call it interactively:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# print(OLR(288), OLR(292), OLR(292)-OLR(288))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 6\n", "\n", "** The `#` symbol is used for comments in Python code. **\n", "\n", "The interpreter will ignore anything that follows `#` on a line of code." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 7:\n", "\n", "`print` is a function that causes the value of an expression (or a list of expressions) to be printed to the screen.\n", "\n", "(Don’t always need it, because by default the interpreter prints the output of the last statement to the screen, as we have seen).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note also that we defined variables named sigma and epsilon inside our OLR function. \n", "\n", "What happens if you try to `print(epsilon)`? " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 8: \n", "\n", "**Variables defined in functions do not exist outside of that function.**\n", "\n", "Try declaring `sigma = 2`, then `print(sigma)`. And try computing `OLR(288)` again. Did anything change?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that we didn’t really **need** to define those variables inside the function. We could have written the function in one line.\n", "\n", "But sometimes using named variables *makes our code much easier to read and understand!*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Arrays with `numpy`\n", "\n", "Now let’s try some array calculations:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#import numpy as np\n", "#T = np.linspace(230, 300, 10)\n", "#print T" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- We have just created an array object. \n", "- The `linspace` function creates an array of numbers evenly spaced between the start and end points. \n", "- The third argument tells Python how many elements we want." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will use the `numpy` package all the time. It is the basic workhorse of scientific computing with Python. We can't do much with arrays of numbers." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Does our `OLR` function work on an array of temperature values?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let’s assign these values to a new variable." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "OLR = OLR(T)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now try again to compute `OLR(288)`\n", "\n", "What do you get?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python fact 9: Assigning a value to a named variable overwrites whatever was already assigned to that name. \n", "\n", "Python is also case sensitive. If we had used `olr` to store the array, there would be no conflict." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let’s re-enter our function. Start typing `def` and then hit the “up arrow” key. What happens?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The editor gives us lots of useful keyboard shortcuts. \n", "\n", "Here it’s looking up the last expression we entered that began with `def`. Saves a lot of time and typing!\n", "\n", "Re-enter the function." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What happens if you use the `up arrow` without typing anything first?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Also, try typing `history`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is very handy. The Python console is taking notes for you! " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2" } }, "nbformat": 4, "nbformat_minor": 1 }