<jupyter_start><jupyter_text>[ATM 623: Climate Modeling](../index.ipynb)[<NAME>](http://www.atmos.albany.edu/facstaff/brose/index.html), University at Albany Lecture 6: A Brief Review of Radiation  Warning: content out of date and not maintainedYou really should be looking at [The Climate Laboratory book](https://brian-rose.github.io/ClimateLaboratoryBook) by <NAME>, where all the same content (and more!) is kept up to date.***Here you are likely to find broken links and broken code.***  About these notes:This document uses the interactive [`Jupyter notebook`](https://jupyter.org) format. The notes can be accessed in several different ways:- The interactive notebooks are hosted on `github` at https://github.com/brian-rose/ClimateModeling_courseware- The latest versions can be viewed as static web pages [rendered on nbviewer](http://nbviewer.ipython.org/github/brian-rose/ClimateModeling_courseware/blob/master/index.ipynb)- A complete snapshot of the notes as of May 2017 (end of spring semester) are [available on Brian's website](http://www.atmos.albany.edu/facstaff/brose/classes/ATM623_Spring2017/Notes/index.html).[Also here is a legacy version from 2015](http://www.atmos.albany.edu/facstaff/brose/classes/ATM623_Spring2015/Notes/index.html).Many of these notes make use of the `climlab` package, available at https://github.com/brian-rose/climlab<jupyter_code>#  Ensure compatibility with Python 2 and 3
from __future__ import print_function, division<jupyter_output><empty_output><jupyter_text>Contents1. [Emission temperature and lapse rates](section1)2. [Solar Radiation](section2)3. [Terrestrial Radiation and absorption spectra](section3) ____________ 1. Emission temperature and lapse rates____________ Planetary energy balance is the foundation for all climate modeling. So far we have expressed this through a globally averaged budget$$C \frac{d T_s}{dt} = (1-\alpha) Q - OLR$$and we have written the OLR in terms of an emission temperature $T_e$ where by definition$$ OLR = \sigma T_e^4 $$ Using values from the observed planetary energy budget, we found that $T_e = 255$ KThe emission temperature of the planet is thus about 33 K colder than the mean surface temperature (288 K).  Where in the atmosphere do we find $T = T_e = 255$ K?That's about -18ºC.Let's plot **global, annual average observed air temperature** from NCEP reanalysis data.<jupyter_code>%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
## The NOAA ESRL server is shutdown! January 2019
ncep_url = "http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/ncep.reanalysis.derived/"
ncep_air = xr.open_dataset( ncep_url + "pressure/air.mon.1981-2010.ltm.nc",
                          decode_times=False)
#url = 'http://apdrc.soest.hawaii.edu:80/dods/public_data/Reanalysis_Data/NCEP/NCEP/clima/pressure/air'
#air = xr.open_dataset(url)
## The name of the vertical axis is different than the NOAA ESRL version..
#ncep_air = air.rename({'lev': 'level'})
print( ncep_air)
#  Take global, annual average and convert to Kelvin
coslat = np.cos(np.deg2rad(ncep_air.lat))
weight = coslat / coslat.mean(dim='lat')
Tglobal = (ncep_air.air * weight).mean(dim=('lat','lon','time'))
Tglobal
#  a "quick and dirty" visualization of the data
Tglobal.plot()<jupyter_output><empty_output><jupyter_text>Let's make a better plot.Here we're going to use a package called `metpy` to automate plotting this temperature profile in a way that's more familiar to meteorologists: a so-called *skew-T* plot.<jupyter_code>from metpy.plots import SkewT
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig, rotation=30)
skew.plot(Tglobal.level, Tglobal, color='black', linestyle='-', linewidth=2, label='Observations')
skew.ax.set_ylim(1050, 10)
skew.ax.set_xlim(-75, 45)
# Add the relevant special lines
skew.plot_dry_adiabats(linewidth=0.5)
skew.plot_moist_adiabats(linewidth=0.5)
#skew.plot_mixing_lines()
skew.ax.legend()
skew.ax.set_title('Global, annual mean sounding from NCEP Reanalysis', 
             fontsize = 16)<jupyter_output>/Users/br546577/anaconda3/envs/climlab-courseware/lib/python3.7/site-packages/pint/quantity.py:1377: UnitStrippedWarning: The unit of the quantity is stripped.
  warnings.warn("The unit of the quantity is stripped.", UnitStrippedWarning)<jupyter_text>Note that surface temperature in global mean is indeed about 288 K or 15ºC as we keep saying.So where do we find temperature $T_e=255$ K or -18ºC?Actually in mid-troposphere, near 500 hPa or about 5 km height.We can infer that much of the outgoing longwave radiation actually originates far above the surface. Recall that our observed global energy budget diagram shows 217 out of 239 W m$^{-2}$ total OLR emitted by the atmosphere and clouds, only 22 W m$^{-2}$ directly from the surface.This is due to the **greenhouse effect**.  So far we have dealt with the greenhouse in a very artificial way in our energy balance model by simply assuming $$ \text{OLR} = \tau \sigma T_s^4 $$i.e., the OLR is reduced by a constant factor from the value it would have if the Earth emitted as a blackbody at the surface temperature.Now it's time to start thinking a bit more about how the radiative transfer process actually occurs in the atmosphere, and how to model it. ____________ 2. Solar Radiation____________Let's plot a spectrum of solar radiation.For details, see code in notebook!<jupyter_code>#  Using pre-defined code for the Planck function from the climlab package
from climlab.utils.thermo import Planck_wavelength
# approximate emission temperature of the sun in Kelvin
Tsun = 5780.
# boundaries of visible region in nanometers
UVbound = 390.
IRbound = 700.
#  array of wavelengths
wavelength_nm = np.linspace(0.1, 3500, 400)
to_meters = 1E-9  # conversion factor
label_size = 16
fig, ax = plt.subplots(figsize=(14,7))
ax.plot(wavelength_nm, 
         Planck_wavelength(wavelength_nm * to_meters, Tsun))
ax.grid()
ax.set_xlabel('Wavelength (nm)', fontsize=label_size)
ax.set_ylabel('Spectral radiance (W sr$^{-1}$ m$^{-3}$)', fontsize=label_size)
#  Mask out points outside of this range
wavelength_vis = np.ma.masked_outside(wavelength_nm, UVbound, IRbound)
#  Shade the visible region
ax.fill_between(wavelength_vis, Planck_wavelength(wavelength_vis * to_meters, Tsun))
title = 'Blackbody emission curve for the sun (T = {:.0f} K)'.format(Tsun)
ax.set_title(title, fontsize=label_size);
ax.text(280, 0.8E13, 'Ultraviolet', rotation='vertical', fontsize=12)
ax.text(500, 0.8E13, 'Visible', rotation='vertical', fontsize=16, color='w')
ax.text(800, 0.8E13, 'Infrared', rotation='vertical', fontsize=12);<jupyter_output>/Users/br546577/anaconda3/envs/climlab-courseware/lib/python3.7/site-packages/climlab/utils/thermo.py:208: RuntimeWarning: overflow encountered in exp
  return 2*kBoltzmann**5*T**5/hPlanck**4/c_light**3*u**5/(exp(u)-1)<jupyter_text>- Spectrum peaks in the visible range- most energy at these wavelength.- No coincidence that our eyes are sensitive to this range of wavelengths!- Longer wavelengths called “infrared”, shorter wavelengths called “ultraviolet”.The shape of the spectrum is a fundamental characteristic of radiative emissions(think about the color of burning coals in a fire – cooler = red, hotter = white) Theory and experiments tell us that both the total flux of emitted radiation, and the wavelength of maximum emission, depend only on the temperature of the source!The theoretical spectrum was worked out by Max Planck and is therefore known as the “Planck” spectrum (or simply blackbody spectrum).<jupyter_code>fig, ax = plt.subplots(figsize=(14,7))
wavelength_um = wavelength_nm / 1000
for T in [24000,12000,6000,3000]:
    ax.plot(wavelength_um, 
         (Planck_wavelength(wavelength_nm * to_meters, T) / T**4),
           label=str(T) + ' K')
ax.legend(fontsize=label_size)
ax.set_xlabel('Wavelength (um)', fontsize=label_size)
ax.set_ylabel('Normalized spectral radiance (W sr$^{-1}$ m$^{-3}$ K$^{-4}$)', fontsize=label_size)
ax.set_title("Normalized blackbody emission spectra $T^{-4} B_{\lambda}$ for different temperatures");<jupyter_output><empty_output><jupyter_text>Going from cool to warm:- total emission increases- maximum emission occurs at shorter wavelengths.The **integral of these curves over all wavelengths** gives us our familiar $\sigma T^4$ Mathematically it turns out that $$ λ_{max} T = \text{constant} $$(known as Wien’s displacement law). By fitting the observed solar emission to a blackbody curve, we can deduce that the emission temperature of the sun is about 6000 K.Knowing this, and knowing that the solar spectrum peaks at 0.6 micrometers, we can calculate the wavelength of maximum terrestrial radiation as$$ λ_{max}^{Earth} = 0.6 ~ \mu m \frac{6000}{255} = 14 ~ \mu m $$This is in the far-infrared part of the spectrum. ____________ 3. Terrestrial Radiation and absorption spectra____________  Terrestrial versus solar wavelengthsNow let's look at normalized blackbody curves for Sun and Earth:<jupyter_code>fig, ax = plt.subplots(figsize=(14,7))
wavelength_um = np.linspace(0.1, 200, 10000)
wavelength_meters = wavelength_um / 1E6

for T in [6000, 255]:
    ax.semilogx(wavelength_um, 
         (Planck_wavelength(wavelength_meters, T) / T**4 * wavelength_meters),
           label=str(T) + ' K')
ax.legend(fontsize=label_size)
ax.set_xlabel('Wavelength (um)', fontsize=label_size)
ax.set_ylabel('Normalized spectral radiance (W sr$^{-1}$ m$^{-2}$ K$^{-4}$)', fontsize=label_size)
ax.set_title("Normalized blackbody emission spectra $T^{-4} \lambda B_{\lambda}$ for the sun ($T_e = 6000$ K) and Earth ($T_e = 255$ K)",
            fontsize=label_size);<jupyter_output><empty_output><jupyter_text>There is essentially no overlap between the two spectra.**This is the fundamental reason we can discuss the solar “shortwave” and terrestrial “longwave” radiation as two distinct phenomena.**In reality all radiation exists on a continuum of different wavelengths. But in climate science we can get a long way by thinking in terms of a very simple “two-stream” approximation (short and longwave). We’ve already been doing this throughout the course so far!  Atmospheric absorption spectraNow look at the atmospheric **absorption spectra**.(fraction of radiation at each wavelength that is absorbed on a single vertical path through the atmosphere)  *Figure reproduced from <NAME> Plumb (2008): Atmosphere, Ocean, and Climate Dynamics* - Atmosphere is almost completely transparent in the visible range, right at the peak of the solar spectrum- Atmosphere is very opaque in the UV- Opacity across the IR spectrum is highly variable!- Look at the gases associated with various absorption features:- Main players include H$_2$O, CO$_2$, N$_2$O, O$_2$.- Compare to major constituents of atmosphere, in decreasing order:     - 78% N$_2$    - 21% O$_2$    - 1% Ar    - H$_2$O (variable)  - The dominant constituent gases N$_2$ and O$_2$ are nearly completely transparent across the entire spectrum (there are O$_2$ absorption features in far UV, but little energy at these wavelengths).- The greenhouse effect mostly involves trace constituents:     - O$_3$ = 500 ppb    - N$_2$O = 310 ppb    - CO$_2$ = 400 ppm (but rapidly increasing!)    - CH$_4$ = 1.7 ppm- Note that most of these are tri-atomic molecules! There are fundamental reasons for this: these molecules have modes of rotational and vibration that are easily excited at IR wavelengths. See courses in radiative transfer! [Back to ATM 623 notebook home](../index.ipynb) ____________ Version information____________<jupyter_code>%load_ext version_information
%version_information numpy, matplotlib, xarray, metpy, climlab<jupyter_output>Loading extensions from ~/.ipython/extensions is deprecated. We recommend managing extensions like any other Python packages, in site-packages.
{'fraction_non_alphanumeric': 0.09828009828009827, 'fraction_numerical': 0.027111751249682285, 'mean_word_length': 5.219178082191781, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '246682', 'license': 'MIT', 'n_tokens_mistral': 3803, 'n_tokens_neox': 3445, 'n_words': 1318, 'path': 'Lectures/Lecture06 -- Radiation.ipynb', 'repo_name': 'brian-rose/ClimateModeling_courseware', 'size': '11823'}