{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Python-AWIPS Tutorial Notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"\n",
"# Objectives\n",
"\n",
"* Retrieve an Upper Air vertical profile from EDEX\n",
"* Plot a Skew-T/Log-P chart with [Matplotlib](https://matplotlib.org/) and [MetPy](https://unidata.github.io/MetPy/latest/index.html)\n",
"* Understand the **bufrua** plugin returns separate objects for parameters at *mandatory levels* and at *significant temperature levels*\n",
" * *Significant temperature levels* are used to plot the pressure, temperature and dewpoint lines\n",
" * *Mandatory levels* are used to plot the wind profile\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Table of Contents\n",
"\n",
"[1 Imports](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#imports)
\n",
"[2 EDEX Connection](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#edex-connection)
\n",
" [2.1 Initial EDEX Connection](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#initial-edex-connection)
\n",
" [2.2 Setting Additional Request Parameters](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#setting-additional-request-parameters)
\n",
" [2.3 Available Location Names](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#available-location-names)
\n",
" [2.4 Setting the Location Name](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#setting-the-location-name)
\n",
"[3 Filtering by Time](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Sounding.html#filtering-by-time)
\n",
"[4 Get the Data!](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#get-the-data)
\n",
"[5 Use the Data!](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#use-the-data)
\n",
" [5.1 Prepare Data Objects](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#prepare-data-objects)
\n",
" [5.2 Convert Units](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#convert-units)
\n",
"[6 Plot the Data!](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#plot-the-data)
\n",
"[7 See Also](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#see-also)
\n",
" [7.1 Related Notebooks](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#related-notebooks)
\n",
" [7.2 Additional Documentation](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#additional-documentation)
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1 Imports\n",
"\n",
"The imports below are used throughout the notebook. Note the first import is coming directly from python-awips and allows us to connect to an EDEX server. The subsequent imports are for data manipulation and visualization. "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from awips.dataaccess import DataAccessLayer\n",
"import matplotlib.pyplot as plt\n",
"from mpl_toolkits.axes_grid1.inset_locator import inset_axes\n",
"import numpy as np\n",
"from metpy.calc import wind_components, lcl, parcel_profile\n",
"from metpy.plots import SkewT, Hodograph\n",
"from metpy.units import units"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Top](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html)\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2 EDEX Connection\n",
"\n",
"### 2.1 Initial EDEX Connection\n",
"\n",
"First we establish a connection to Unidata's public EDEX server. With that connection made, we can create a [new data request object](http://unidata.github.io/python-awips/api/IDataRequest.html) and set the data type to ***bufrua***, and define additional parameters and an identifier on the request."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Set the edex server\n",
"DataAccessLayer.changeEDEXHost(\"edex-cloud.unidata.ucar.edu\")\n",
"request = DataAccessLayer.newDataRequest()\n",
"\n",
"# Set data type\n",
"request.setDatatype(\"bufrua\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2.2 Setting Additional Request Parameters\n",
"\n",
"Here we populate arrays of all the parameters that will be necessary for plotting the Skew-T. The `MAN_PARAMS` are the *mandatory levels* and the `SIGT_PARAMS` are the *significant temperature* parameters that were both mentioned in the [objectives section](#Objectives) above. \n",
"\n",
"Also request the station name and ID to use in the figure title later on."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"MAN_PARAMS = set(['prMan', 'tpMan', 'tdMan', 'wdMan', 'wsMan'])\n",
"SIGT_PARAMS = set(['prSigT', 'tpSigT', 'tdSigT'])\n",
"request.setParameters(\"staElev\", \"staName\")\n",
"request.getParameters().extend(MAN_PARAMS)\n",
"request.getParameters().extend(SIGT_PARAMS)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2.3 Available Location Names\n",
"When working with a new data type, it is often useful to investigate all available options for a particular setting. Shown below is how to see all available location names for a data request with type **bufrua**. This step is not necessary if you already know exactly what the location ID you're interested in is."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"