{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ClimateMatchAcademy/course-content/blob/main/tutorials/W1D5_ClimateModeling/instructor/W1D5_Tutorial1.ipynb)   \"Open\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "# **Tutorial 1 : A Simple Greenhouse Model**\n", "\n", "**Week 1, Day 5, Climate Modeling**\n", "\n", "**Content creators:** Jenna Pearson\n", "\n", "**Content reviewers:** Dionessa Biton, Younkap Nina Duplex, Zahra Khodakaramimaghsoud, Will Gregory, Peter Ohue, Derick Temfack, Yunlong Xu, Peizhen Yang, Chi Zhang, Ohad Zivan\n", "\n", "**Content editors:** Brodie Pearson, Abigail Bodner, Ohad Zivan, Chi Zhang\n", "\n", "**Production editors:** Wesley Banfield, Jenna Pearson, Chi Zhang, Ohad Zivan\n", "\n", "**Our 2023 Sponsors:** NASA TOPS and Google DeepMind\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "# **Tutorial Objectives**\n", "\n", "In this tutorial students will learn about blackbody radiation and greenhouse models for energy emitted from Earth.\n", "\n", "By the end of this tutorial students will be able to:\n", "\n", "- Understand what an emission temperature is, and how to find it given observed outgoing longwave radiation.\n", "- Modify the blackbody radiation model to include the greenhouse effect.\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "# **Setup**\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {} }, "outputs": [], "source": [ "# imports\n", "import holoviews as hv\n", "import panel as pn\n", "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Figure settings\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form", "execution": {}, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "# @title Figure settings\n", "import ipywidgets as widgets # interactive display\n", "\n", "%config InlineBackend.figure_format = 'retina'\n", "plt.style.use(\n", " \"https://raw.githubusercontent.com/ClimateMatchAcademy/course-content/main/cma.mplstyle\"\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Video 1: Speaker Introduction\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form", "execution": {}, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "# @title Video 1: Speaker Introduction\n", "# Tech team will add code to format and display the video" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Video 2: A Simple Greenhouse Model\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form", "execution": {}, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "# @title Video 2: A Simple Greenhouse Model\n", "# Tech team will add code to format and display the video" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "# **Section 1 : A Radiating Earth**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "## **Section 1.1 Planck's Law**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "All objects with a temperature emit **[electromagnetic radiation](https://www.noaa.gov/jetstream/satellites/electromagnetic-waves)**. This energy travels through space in the form of waves. In the lecture we discussed that blackbody radiation is a model of how Earth loses radiative energy to space. Although this is not a perfect model for Earth, we will use it as a basis to understand Earth's energy balance throughout tutorials 1-4. If we suppose Earth behaves as a perfect blackbody, then it emits energy at all wavelengths according to **[Planck's Law](https://glossary.ametsoc.org/wiki/Planck%27s_radiation_law)**:\n", "\n", "\\begin{align}\n", "B(\\lambda,T) = \\frac{2 h c^2}{\\lambda^5}\\frac{1}{e^{hc/(\\kappa T)}-1}\n", "\\end{align}\n", "\n", "where $h = 6.626075 \\times 10^{-34} J s$ is Planck's constant, $c= 2.99792 \\times 108 m s^{-1}$ is the speed of light, and $\\kappa = 1.3804 \\times 10^{23} W K^{-1}$ is Boltzmann's constant.\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "### **Interactive Demo 1.1**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "This interactive demo will allow you to visualize how to blackbody curve changes as Earth warms and cools relative to it's current surface temperature of about 288K. Use the slide bar to adjust the emission temperature. Give the code few seconds to replot before choosing a new temperature.\n", "\n", "No need to worry about understanding the code here - this is conceptual.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Make sure you execute this cell to enable the widget!\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form", "execution": {}, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "# @markdown Make sure you execute this cell to enable the widget!\n", "\n", "hv.extension(\"bokeh\")\n", "\n", "# define constants used in Planck's Law\n", "h = 6.626075e-34 # J s\n", "c = 2.99792e8 # m s^-1\n", "k = 1.3804e-23 # W K^-1\n", "\n", "\n", "# define the function for Planck's Law depedent on wavelength (lambda) and temeprature (T)\n", "def planck(wavelength, temperature):\n", " a = 2.0 * h * c**2\n", " b = h * c / (wavelength * k * temperature)\n", " intensity = a / ((wavelength**5) * (np.exp(b) - 1.0))\n", "\n", " lpeak = (2.898 * 1e-3) / temperature\n", "\n", " return intensity\n", "\n", "\n", "def update_plot(emiss_temp):\n", " # generate x-axis in increments from 1um to 100 micrometer in 1 nm increments\n", " # starting at 1 nm to avoid wav = 0, which would result in division by zero.\n", " wavelengths = np.arange(1e-6, 50e-6, 1e-9)\n", "\n", " # get the blackbody curve and peak emission wavelength for 288 K\n", " intensity288 = planck(wavelengths, 288)\n", "\n", " # get the blackbody curve and peak emission wavelength for selected temperature\n", " intensity = planck(wavelengths, emiss_temp)\n", "\n", " # # get the intensity at peak wavelength to limit the lines\n", " # Ipeak,_ = planck(lpeak,emission_temperature)\n", " # Ipeak288,_ = planck(lpeak288,288)\n", "\n", " # curves output\n", " vary = zip(wavelengths * 1e6, intensity)\n", " init_val = zip(wavelengths * 1e6, intensity288)\n", "\n", " # Specified individually\n", " list_of_curves = [\n", " hv.Curve(init_val, label=\"T=\" + str(emiss_temp) + \"K\").opts(ylim=(0, 1.0e7)),\n", " hv.Curve(vary, label=\"T=288K\").opts(ylim=(0, 1.0e7)),\n", " ]\n", "\n", " bb_plot = hv.Overlay(list_of_curves).opts(\n", " height=300,\n", " width=600,\n", " xlabel=\"Wavelength (μm)\",\n", " ylabel=\"B(λ,T) (W/(m³ steradian)\",\n", " title=\"Spectral Radiance\",\n", " )\n", "\n", " return bb_plot\n", "\n", "\n", "emiss_temp_widget = pn.widgets.IntSlider(\n", " name=\"Emission Temperature\", value=288, start=250, end=300\n", ")\n", "bound_plot = pn.bind(update_plot, emiss_temp=emiss_temp_widget)\n", "\n", "pn.Row(emiss_temp_widget, bound_plot)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "### **Questions 1.1: Climate Connection**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "1. Recall from Tutorial 1 on Week 1 Day 3 the **electromagnetic spectrum** (shown below), which displays the different wavelengths of electromagnetic energy. According to our model and noting that 1 micrometer = $10^{-6}$ meters, with a surface temperature of 288K what type of radiation does Earth primarily emit at?\n", "\n", "![Diagram of the Electromagnetic Spectrum](https://upload.wikimedia.org/wikipedia/commons/thumb/3/30/EM_spectrumrevised.png/1920px-EM_spectrumrevised.png)\n", "Diagram of the Electromagnetic Spectrum. (Credit: [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/thumb/3/30/EM_spectrumrevised.png/1920px-EM_spectrumrevised.png))\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {} }, "outputs": [], "source": [ "# to_remove explanation\n", "\n", "\"\"\"\n", "1. Infrared.\n", "\"\"\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "## **Section 1.2: The Stefan-Boltzmann Law**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "If we integrate Planck's Law over all wavelengths and outward angles of emission, the total **outgoing longwave radiation (OLR)** for a given **emission temperature** ($\\mathbf{T}$) follows the **[Stefan-Boltzmann Law](https://glossary.ametsoc.org/wiki/Stefan-boltzmann_law)**.\n", "\n", "\\begin{align}\n", "OLR = \\sigma T^4\n", "\\end{align}\n", "\n", "Where the [Stefan-Boltzmann constant](https://glossary.ametsoc.org/wiki/Stefan-boltzmann_constant) $\\sigma = 5.67 \\times 10^{-8} W m^{-2} K^{-4}$.\n", "\n", "Rearranging the equation above, we can solve for the emission temperature of Earth, $T$.\n", "\n", "\\begin{align}\n", "T = \\sqrt[4]{\\frac{OLR}{\\sigma}}\n", "\\end{align}\n", "\n", "Using $OLR = 239 W m^{-2}$, we can calcuate this using python.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {}, "executionInfo": { "elapsed": 33, "status": "ok", "timestamp": 1681268100158, "user": { "displayName": "Jenna Pearson", "userId": "05648130581702734913" }, "user_tz": 420 } }, "outputs": [], "source": [ "# define the Stefan-Boltzmann Constant, noting we are using 'e' for scientific notation\n", "sigma = 5.67e-8 # W m^-2 K^-4\n", "\n", "# define the outgoing longwave radiation based on observations from the IPCC AR6 Figure 7.2\n", "OLR = 239 # W m^-2\n", "\n", "# plug into equation\n", "T = (OLR / sigma) ** (1 / 4)\n", "\n", "# display answer\n", "print(\"Emission Temperature: \", T, \"K or\", T - 273, \"C\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "### **Questions 1.2: Climate Connection**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "1. How does this compare to the actual global mean surface temperature of ~288 $K$ / 15 $C$?\n", "2. Using $T = 288 K$ would you expect the corresponding outgoing longwave radiation to be higher or lower than the observed 239 $W m^{-2}$?\n", "3. What could be accounted for in this model to make it more realistic?\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {} }, "outputs": [], "source": [ "# to_remove explanation\n", "\n", "\"\"\"\n", "1. The calculated emission temperature of approximately 255 K or -18.2 C is significantly lower than the actual global mean surface temperature of approximately 288 K or 15 C.\n", "2. We would expect the corresponding outgoing longwave radiation to be higher than the observed 239 W/m², according to the Stefan-Boltzmann law.\n", "3. As the video explains, this simple model doesn't account for the atmospheric greenhouse effect due to greenhouse gases that absorb radiation at these wavelengths.\n", "\"\"\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "### **Coding Exercises 1.2**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "1. By modifying the code above and solving for OLR, find the outgoing longwave radiation expected for the observed surface temperature of $288 K$. This should help you answer Question 2 above.\n" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "execution": {}, "executionInfo": { "elapsed": 31, "status": "ok", "timestamp": 1681268100161, "user": { "displayName": "Jenna Pearson", "userId": "05648130581702734913" }, "user_tz": 420 } }, "source": [ "```python\n", "# define the Stefan-Boltzmann Constant, noting we are using 'e' for scientific notation\n", "sigma = ...\n", "\n", "# define the global mean surface temperature based on observations\n", "T = ...\n", "\n", "# plug into equation\n", "OLR = ...\n", "\n", "# display answer\n", "print(\"OLR: \", OLR, \"W m^2\")\n", "\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {}, "executionInfo": { "elapsed": 27, "status": "ok", "timestamp": 1681268100162, "user": { "displayName": "Jenna Pearson", "userId": "05648130581702734913" }, "user_tz": 420 } }, "outputs": [], "source": [ "# to_remove solution\n", "\n", "# define the Stefan-Boltzmann Constant, noting we are using 'e' for scientific notation\n", "sigma = 5.67e-8 # W m^-2 K^-4\n", "\n", "# define the global mean surface temperature based on observations\n", "T = 288 # K\n", "\n", "# plug into equation\n", "OLR = sigma * (T**4)\n", "\n", "# display answer\n", "print(\"OLR: \", OLR, \"W m^2\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "# **Section 2 : The Greenhouse Effect**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "The expected surface temperature using the blackbody radiation model is much colder than we observe it to be. In this model we assumed there is nothing that lies between Earth's surface and space that interacts with Earth's emitted radiation. From the initial lecture on the global energy budget we know this is not true. Earth has an atmosphere, and within it are many gases that interact with radiation in the infrared range at which Earth primarily emits. The effect of these gases on radiation, called the **[greenhouse effect](https://glossary.ametsoc.org/wiki/Greenhouse_effect#:~:text=As%20used%20in%20the%20field,absorb%20and%20emit%20infrared%20radiation.)**, is what warms earth to a habitable temperature.\n", "\n", "The gases that are responsible for this ([carbon dioxide](https://glossary.ametsoc.org/wiki/Carbon_dioxide), [water vapor](https://glossary.ametsoc.org/wiki/Water_vapor), [methane](https://glossary.ametsoc.org/wiki/Methane), [ozone](https://glossary.ametsoc.org/wiki/Ozone), [nitrous oxide](https://glossary.ametsoc.org/wiki/Nitrous_oxide), and [chloroflourocarbons](https://glossary.ametsoc.org/wiki/Chlorofluorocarbons)) are termed **[greenhouse gases](https://glossary.ametsoc.org/wiki/Greenhouse_gases)**. The figure below shows the contributions to the global surface air temperature change relative to 1750. We can see that all of these gases have contributed positively, that is towards warming Earth. Also note that the total curve tracks the volcano curve quite well until around the 1850s when industrialization took hold. The total and volcanic curves begin to deviate here, and after the mid 1900s the total curve begins tracking the total anthropogenic curve instead.\n", "\n", "![Attributed global surface air temperature change (GSAT)](https://www.ipcc.ch/report/ar6/wg1/downloads/figures/IPCC_AR6_WGI_Figure_7_8.png) \n", "Figure 7.8 | Attributed global surface air temperature change (GSAT) from 1750 to 2019 produced using the two-layer emulator (Supplementary Material 7.SM.2), forced with ERF derived in this chapter (displayed in Figure 2.10) and climate response constrained to assessed ranges for key climate metrics described in Cross-Chapter Box 7.1. The results shown are the medians from a 2237-member ensemble that encompasses uncertainty in forcing and climate response (year-2019 best estimates and uncertainties are shown in Figure 7.7 for several components). Temperature contributions are expressed for carbon dioxide (CO2), methane (CH4), nitrous oxide (N2O), other well-mixed greenhouse gases (WMGHGs), ozone (O3), aerosols, and other anthropogenic forcings, as well as total anthropogenic, solar, volcanic, and total forcing. Shaded uncertainty bands showvery likely (5–95%)ranges. Further details on data sources and processing are available in the chapter data table (Table 7.SM.14). (Credit [IPCC](https://www.ipcc.ch/report/ar6/wg1/downloads/figures/IPCC_AR6_WGI_Figure_7_8.png))\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "As shown above, greenhouse gases are incredibly important for regulating Earth's energy balance and temperature. A first approach is to model the greenhouse effect on outgoing longwave radiation (OLR) to space by adding a transmissivity coefficient. The **transmissivity coeficient (**$\\mathbf{\\tau}$**)** is the fraction of\n", "the radiation emitted from Earth that actually makes it to space. This coefficient $\\mathbf{\\tau}$ is a number that lies between 0 and 1, and represents the _effects_ of all the greenhouse gases on radiation, rather than including them explicity in the model. This approach is called a **[parametrization](https://glossary.ametsoc.org/wiki/Parameterization)**.\n", "\n", "Applying this to the original model for blackbody radiation, the modified model is\n", "\n", "\\begin{align}\n", "OLR = \\tau \\sigma T^4\n", "\\end{align}\n", "\n", "Using $OLR = 239 W m^{-2}$ and $T = 288 K$, we can estimate $\\tau$.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {}, "executionInfo": { "elapsed": 22, "status": "ok", "timestamp": 1681268100163, "user": { "displayName": "Jenna Pearson", "userId": "05648130581702734913" }, "user_tz": 420 } }, "outputs": [], "source": [ "# define the Stefan-Boltzmann Constant, noting we are using 'e' for scientific notation\n", "sigma = 5.67e-8 # W m^-2 K^-4\n", "\n", "# define the outgoing longwave radiation based on observations from the IPCC AR6 Figure 7.2\n", "OLR = 239 # W m^-2\n", "\n", "# define the emission temperature based on observtions of global mean surface temperature\n", "T = 288 # K\n", "\n", "# plug into equation\n", "tau = OLR / (sigma * T**4) # unitless number between 0 and 1\n", "\n", "# display answer\n", "print(\"Transmissivity Coefficient: \", tau)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "### **Questions 2.1: Climate Connection**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "1. For a generic planet, what could be said about the planet's atmosphere when $\\tau$ is close to 1? Close to 0? Use the OLR seen at the top of the atmosphere in your answer.\n", "2. In terms of energy received from the sun, what does only modifying the _OLR_ to account for the greenhouse effect imply? Are there any greenhouse gases you think would make this implication problematic?\n", "3. Is there any other part of the atmosphere aside from greenhouse gases that we have not discussed that would also affect $\\tau$?\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {} }, "outputs": [], "source": [ "# to_remove explanation\n", "\n", "\"\"\"\n", "1. When tau is close to 1, it would mean a nearly transparant atmosphere, and most of the OLR reaches the top of the atmosphere. The equation simplifies to the original Stefan-Boltzmann law when tau is exactly equal to 1.\n", " When tau is close to zero, it means a very opaque atmosphere and almost no OLR makes it to the top of the atmosphere. Almost all the OLR is absorbed, and no radiation would leave Earth's atmosphere when tau is 0.\n", "2. It implies that Earth's atmosphere is transparent to the sun's radiation. This is not exactly true, for example ozone interacts with ultraviolet light from the sun.\n", " However, Earth's atmosphere does absorb largely in the infrared.\n", "3. Clouds, aerosols, and scattering just to name a few.\n", "\"\"\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "### **Coding Exercises 2.1**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "1. Using list comprehension, calculate the OLR for three values of $\\tau = 0.2,0.6114,0.8$. Then plot this on a bar chat to compare. This should help you answer question 1 above. Hint: what is [list comprehension](https://foundations.projectpythia.org/foundations/quickstart.html#lists)?\n" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "execution": {}, "executionInfo": { "elapsed": 401, "status": "ok", "timestamp": 1681268104208, "user": { "displayName": "Jenna Pearson", "userId": "05648130581702734913" }, "user_tz": 420 } }, "source": [ "```python\n", "# define the Stefan-Boltzmann Constant, noting we are using 'e' for scientific notation\n", "sigma = ...\n", "\n", "# define the emission temperature based on observtions of global mean surface temperature\n", "T = ...\n", "\n", "# define values of tau\n", "tau = ...\n", "\n", "# get values of OLR from tau using list comprehension\n", "OLR = ...\n", "\n", "# convert tau to list of strings using list comprehension so we can create a categorical plot\n", "tau = ...\n", "\n", "fig, ax = plt.subplots()\n", "_ = ...\n", "ax.set_xlabel(\"Transmissivity\")\n", "ax.set_ylabel(\"Outgoing Longwave Radiation ($W m^{-2}$)\")\n", "\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {}, "executionInfo": { "elapsed": 5, "status": "ok", "timestamp": 1681268133545, "user": { "displayName": "Jenna Pearson", "userId": "05648130581702734913" }, "user_tz": 420 } }, "outputs": [], "source": [ "# to_remove solution\n", "\n", "# define the Stefan-Boltzmann Constant, noting we are using 'e' for scientific notation\n", "sigma = 5.67e-8 # W m^-2 K^-4\n", "\n", "# define the emission temperature based on observtions of global mean surface temperature\n", "T = 288 # K\n", "\n", "# define values of tau\n", "tau = [0.2, 0.6127, 0.8]\n", "\n", "# get values of OLR from tau using list comprehension\n", "OLR = [t * sigma * (T**4) for t in tau]\n", "\n", "# convert tau to list of strings using list comprehension so we can create a categorical plot\n", "tau = [str(t) for t in tau]\n", "\n", "fig, ax = plt.subplots()\n", "_ = ax.bar(tau, OLR, color=\"#67ada9\")\n", "ax.set_xlabel(\"Transmissivity\")\n", "ax.set_ylabel(\"Outgoing Longwave Radiation ($W m^{-2}$)\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "# **Bonus: Blackbody Radiation Coding Exercise**\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "By defining a function for Planck's Law, plot the blackbody radiation curve for the sun, assuming an emission temperature of 5800K. Underlay an approximation of the visible range from the electromagnetic spectrum. This exercise should help you understand why we see in color as well as why the sun's radiation headed towards Earth is called incoming shortwave radiation.\n" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "execution": {} }, "source": [ "```python\n", "# define the emission temperature of the sun\n", "T_sun = ...\n", "\n", "\n", "# define constants used in Planck's Law\n", "h = 6.626075e-34 # J s\n", "c = 2.99792e8 # m s^-1\n", "k = 1.3804e-23 # W K^-1\n", "\n", "\n", "# define the function for Planck's Law that returns the intensity as well\n", "# as the peak wavelength defined by Wien's Law\n", "def planck(wavelength, temperature):\n", " ...\n", " intensity = ...\n", " lpeak = ...\n", " return intensity, lpeak\n", "\n", "\n", "# generate x-axis in increments from 1um to 100 micrometer in 1 nm increments\n", "# starting at 1 nm to avoid wav = 0, which would result in division by zero.\n", "wavelengths = np.arange(1e-7, 4e-6, 1e-9)\n", "\n", "# intensity and peak radiating wavelength at different temperatures\n", "intensity, lpeak = planck(wavelengths, T_sun)\n", "\n", "# get the intensity at peak wavelength to limit the lines\n", "Ipeak, _ = planck(lpeak, T_sun)\n", "\n", "# plot an approximation of the visible range by defining a dictionary with\n", "# wavelength ranges and colors\n", "rainbow_dict = {\n", " (0.4, 0.44): \"#8b00ff\",\n", " (0.44, 0.46): \"#4b0082\",\n", " (0.46, 0.5): \"#0000ff\",\n", " (0.5, 0.57): \"#00ff00\",\n", " (0.57, 0.59): \"#ffff00\",\n", " (0.59, 0.62): \"#ff7f00\",\n", " (0.62, 0.75): \"#ff0000\",\n", "}\n", "for wv_range, rgb in rainbow_dict.items():\n", " plt.axvspan(*wv_range, color=rgb, ec=\"none\")\n", "\n", "fig, ax = plt.subplots()\n", "# add in wiens law\n", "_ = ...\n", "\n", "# plot intensity curve\n", "_ = ...\n", "\n", "ax.set_xlabel(\"Wavelength ($\\mu m$)\", fontsize=20, labelpad=30)\n", "ax.set_ylabel(\"$B_\\lambda(\\lambda,T)$ $(W/(m^3 steradian)$\", fontsize=20)\n", "\n", "ax.set_title(\"Spectral Radiance\")\n", "\n", "# add legend\n", "ax.legend(bbox_to_anchor=(0.5, 0.5))\n", "\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "execution": {} }, "outputs": [], "source": [ "# to_remove solution\n", "\n", "# define the emission temperature of the sun\n", "T_sun = 5800 # K\n", "\n", "# define constants used in Planck's Law\n", "h = 6.626075e-34 # J s\n", "c = 2.99792e8 # m s^-1\n", "k = 1.3804e-23 # W K^-1\n", "\n", "\n", "# define the function for Planck's Law that returns the intensity as well\n", "# as the peak wavelength defined by Wien's Law\n", "def planck(wavelength, temperature):\n", " a = 2.0 * h * c**2\n", " b = h * c / (wavelength * k * temperature)\n", " intensity = a / ((wavelength**5) * (np.exp(b) - 1.0))\n", "\n", " lpeak = (2.898 * 1e-3) / temperature\n", "\n", " return intensity, lpeak\n", "\n", "\n", "# generate x-axis in increments from 1um to 100 micrometer in 1 nm increments\n", "# starting at 1 nm to avoid wav = 0, which would result in division by zero.\n", "wavelengths = np.arange(1e-7, 4e-6, 1e-9)\n", "\n", "# intensity and peak radiating wavelength at different temperatures\n", "intensity, lpeak = planck(wavelengths, T_sun)\n", "\n", "# get the intensity at peak wavelength to limit the lines\n", "Ipeak, _ = planck(lpeak, T_sun)\n", "\n", "\n", "# plot an approximation of the visible range by defining a dictionary with\n", "# wavelength ranges and colors\n", "rainbow_dict = {\n", " (0.4, 0.44): \"#8b00ff\",\n", " (0.44, 0.46): \"#4b0082\",\n", " (0.46, 0.5): \"#0000ff\",\n", " (0.5, 0.57): \"#00ff00\",\n", " (0.57, 0.59): \"#ffff00\",\n", " (0.59, 0.62): \"#ff7f00\",\n", " (0.62, 0.75): \"#ff0000\",\n", "}\n", "for wv_range, rgb in rainbow_dict.items():\n", " plt.axvspan(*wv_range, color=rgb, ec=\"none\")\n", "\n", "\n", "fig, ax = plt.subplots()\n", "# add in wiens law\n", "_ = ax.vlines(x=lpeak * 1e6, ymin=0, ymax=Ipeak, color=\"k\", ls=\"--\", lw=3)\n", "\n", "\n", "# plot intensity curve\n", "_ = ax.plot(\n", " wavelengths * 1e6, intensity, lw=4, label=\"T=\" + str(T_sun) + \"K\", color=\"k\"\n", ")\n", "\n", "\n", "ax.set_xlabel(\"Wavelength ($\\mu m$)\", fontsize=20, labelpad=30)\n", "ax.set_ylabel(\"$B_\\lambda(\\lambda,T)$ $(W/(m^3 steradian)$\", fontsize=20)\n", "\n", "ax.set_title(\"Spectral Radiance\")\n", "\n", "# add legend\n", "ax.legend(bbox_to_anchor=(0.5, 0.5))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": { "execution": {} }, "source": [ "# **Summary**\n", "\n", "In this tutorial, we've learned about the principles of blackbody and greenhouse radiation models, which are crucial to understanding Earth's energy emission. We explored the concept of emission temperature and how it's calculated using observed outgoing longwave radiation. We discovered that the simple blackbody model needs to be augmented by considering the greenhouse effect to accurately represent Earth's observed surface temperature. This led us to incorporate the transmissivity coefficient, a representation of greenhouse gases' impact, into our model.\n" ] } ], "metadata": { "colab": { "collapsed_sections": [], "include_colab_link": true, "name": "W1D5_Tutorial1", "provenance": [], "toc_visible": true }, "kernel": { "display_name": "Python 3", "language": "python", "name": "python3" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.12" } }, "nbformat": 4, "nbformat_minor": 4 }