{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "
\n", "\"Unidata\n", "
\n", "\n", "

Primer Exercises

\n", "

Unidata Python Workshop

\n", "\n", "
\n", "
\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercises 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using the function `pressure_to_height_std`, can you calculate the height of the 700 millibar level assuming a standard atmosphere?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What is the `windchill` when the temperature is 263K and the winds are blowing at 20 m/s? (Bonus points: find it in Fahrenheit)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using only values from `metpy.constants`, what is the dry adiabatic lapse rate? ($\\Gamma_d = \\frac{g}{C_{pd}}$)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercises 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Heat index is only defined for temperatures >= 80F and relative humidity values >= 40%. Using the data generated below, use boolean indexing to extract the data where heat index has a valid value." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Our import for numpy and metpy\n", "import numpy as np\n", "from metpy.units import units\n", "\n", "# Here's the \"data\"\n", "np.random.seed(19990503) # Make sure we all have the same data\n", "temp = (20 * np.cos(np.linspace(0, 2 * np.pi, 100)) +\n", " 80 + 2 * np.random.randn(100)) * units.degF\n", "rh = (np.abs(20 * np.cos(np.linspace(0, 4 * np.pi, 100)) +\n", " 50 + 5 * np.random.randn(100))) * units('percent')\n", "\n", "\n", "# Create a mask for the two conditions described above\n", "# good_heat_index = \n", "\n", "\n", "\n", "# Use this mask to grab the temperature and relative humidity values that together\n", "# will give good heat index values\n", "# temp[] ?\n", "\n", "\n", "# BONUS POINTS: Plot only the data where heat index is defined by\n", "# inverting the mask (using `~mask`) and setting invalid values to np.nan" ] } ], "metadata": { "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.6" } }, "nbformat": 4, "nbformat_minor": 2 }