{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Calculating Weighting Functions with HR\n", "\n", "In this example we calculate weighting functions for ozone in a one-dimensional atmosphere using the HR model. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sasktran as sk\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from sasktran.geometry import VerticalImage\n", "\n", "tanalts_km = np.arange(10, 50, 1)\n", "\n", "# First recreate our geometry and atmosphere classes\n", "geometry = VerticalImage()\n", "geometry.from_sza_saa(sza=60, saa=60, lat=0, lon=0, tanalts_km=tanalts_km, mjd=54372, locallook=0,\n", " satalt_km=600, refalt_km=20)\n", "\n", "atmosphere = sk.Atmosphere()\n", "\n", "atmosphere['ozone'] = sk.Species(sk.O3OSIRISRes(), sk.Labow())\n", "atmosphere['air'] = sk.Species(sk.Rayleigh(), sk.MSIS90())\n", "\n", "# Set the species to calculate the weighting function for\n", "atmosphere.wf_species = 'ozone'\n", "\n", "# And now make the engine\n", "engine = sk.EngineHR(geometry=geometry, atmosphere=atmosphere)\n", "\n", "# Choose some wavelengths to do the calculation at\n", "engine.wavelengths = [330]\n", "\n", "# Set up where we want to calculate the WF\n", "# Here we do 1000 m shells centered at 500m, 1500m, 2500m, ...\n", "wf_alts_m = np.arange(500, 55000, 1000)\n", "engine.options['wfheights'] = wf_alts_m\n", "engine.options['wfwidths'] = np.ones_like(wf_alts_m) * 1000\n", "\n", "# And do the calculation\n", "radiance, wf = engine.calculate_radiance()\n", "\n", "# wf is shape [wavelength, lines of sight, perturbation]\n", "plt.plot(wf[0, :, :].T, wf_alts_m)\n", "plt.xlabel('dI/dn')\n", "plt.ylabel('Altitude [m]')\n", "\n", "plt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python [default]", "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": 2 }