2018-09-05 15:52:38 -06:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2023-05-22 12:58:35 -06:00
"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",
2018-09-05 15:52:38 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"[1 Imports](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#imports)<br> \n",
"[2 EDEX Connection](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#edex-connection)<br> \n",
" [2.1 Initial EDEX Connection](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#initial-edex-connection)<br> \n",
" [2.2 Setting Additional Request Parameters](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#setting-additional-request-parameters)<br> \n",
" [2.3 Available Location Names](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#available-location-names)<br> \n",
" [2.4 Setting the Location Name](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#setting-the-location-name)<br> \n",
"[3 Filtering by Time](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Sounding.html#filtering-by-time)<br> \n",
"[4 Get the Data!](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#get-the-data)<br> \n",
"[5 Use the Data!](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#use-the-data)<br> \n",
" [5.1 Prepare Data Objects](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#prepare-data-objects)<br> \n",
" [5.2 Convert Units](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#convert-units)<br> \n",
"[6 Plot the Data!](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#plot-the-data)<br> \n",
"[7 See Also](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#see-also)<br> \n",
" [7.1 Related Notebooks](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#related-notebooks)<br> \n",
" [7.2 Additional Documentation](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html#additional-documentation)<br> "
]
},
{
"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. "
2018-09-05 15:52:38 -06:00
]
},
{
"cell_type": "code",
2023-05-22 12:58:35 -06:00
"execution_count": 1,
2018-09-06 12:12:07 -06:00
"metadata": {},
2023-05-22 12:58:35 -06:00
"outputs": [],
2018-09-05 15:52:38 -06:00
"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",
2023-05-22 12:58:35 -06:00
"from metpy.calc import wind_components, lcl, parcel_profile\n",
2018-09-05 15:52:38 -06:00
"from metpy.plots import SkewT, Hodograph\n",
2023-05-22 12:58:35 -06:00
"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",
2018-09-05 15:52:38 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"---"
]
},
{
"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",
2018-09-06 13:05:37 -06:00
"DataAccessLayer.changeEDEXHost(\"edex-cloud.unidata.ucar.edu\")\n",
2018-09-05 15:52:38 -06:00
"request = DataAccessLayer.newDataRequest()\n",
"\n",
"# Set data type\n",
2023-05-22 12:58:35 -06:00
"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",
2018-09-05 15:52:38 -06:00
"SIGT_PARAMS = set(['prSigT', 'tpSigT', 'tdSigT'])\n",
2023-05-22 12:58:35 -06:00
"request.setParameters(\"staElev\", \"staName\")\n",
2018-09-05 15:52:38 -06:00
"request.getParameters().extend(MAN_PARAMS)\n",
2023-05-22 12:58:35 -06:00
"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": [
"<div class=\"alert-info\">\n",
"<b>Note:</b> It is important to note the location names are listed by their WMO Station ID. Their corresponding location and site identifier can be looked up in <a href=\"https://data.un.org/Data.aspx?d=CLINO&f=ElementCode%3a15%3bCountryCode%3aUS&c=2,5,6,7,10,15,18,19,20,22,24,26,28,30,32,34,36,38,40,42,44,46&s=CountryName:asc,WmoStationNumber:asc,StatisticCode:asc&v=1\"> this table from UNdata</a>.\n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['21824', '21946', '24266', '24343', '24641', '24688', '24959', '25123', '25703', '25913', '31004', '31088', '31300', '31369', '31510', '31538', '31770', '31873', '32061', '32098', '32150', '32389', '32477', '32540', '32618', '47122', '47138', '47158', '47401', '47412', '47582', '47646', '47678', '47807', '47827', '47909', '47918', '47945', '47971', '47991', '70026', '70133', '70200', '70219', '70231', '70261', '70273', '70308', '70316', '70326', '70350', '70361', '70398', '70414', '71043', '71081', '71082', '71109', '71119', '71603', '71722', '71802', '71811', '71815', '71816', '71823', '71845', '71867', '71906', '71907', '71909', '71913', '71917', '71924', '71925', '71926', '71934', '71945', '71957', '71964', '72201', '72202', '72206', '72208', '72210', '72214', '72215', '72230', '72233', '72235', '72240', '72248', '72249', '72250', '72251', '72261', '72265', '72274', '72293', '72305', '72317', '72318', '72327', '72340', '72357', '72363', '72364', '72365', '72376', '72381', '72388', '72393', '72402', '72403', '72426', '72440', '72451', '72456', '72469', '72476', '72489', '72493', '72501', '72518', '72520', '72528', '72558', '72562', '72572', '72582', '72597', '72632', '72634', '72645', '72649', '72659', '72662', '72672', '72681', '72694', '72712', '72747', '72764', '72768', '72776', '72786', '72797', '74004', '74005', '74006', '74389', '74455', '74560', '74794', '78016', '78384', '78397', '78486', '78526', '78583', '78866', '78954', '78970', '78988', '80001', '91165', '91212', '91285', '91334', '91348', '91366', '91376', '91408', '91413', '91610', '91643', '91680', '91765', '94120', '94203', '94299', '94332', '94461', '94510', '94578', '94637', '94638', '94653', '94659', '94672', '94711', '94776', '94995', '94996']\n"
]
}
],
"source": [
2018-09-06 12:12:07 -06:00
"locations = DataAccessLayer.getAvailableLocationNames(request)\n",
"locations.sort()\n",
2023-05-22 12:58:35 -06:00
"print(locations)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2.4 Setting the Location Name\n",
2018-09-05 15:52:38 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"In this case we're setting the location name to the ID for `KLBF` which is the North Platte Regional Airport/Lee Bird, Field in Nebraska."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
2018-09-05 15:52:38 -06:00
"# Set station ID (not name)\n",
2023-05-22 12:58:35 -06:00
"request.setLocationNames(\"72562\") #KLBF"
]
},
{
"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": [
"## 3 Filtering by Time\n",
2018-09-05 15:52:38 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"Models produce many different time variants during their runs, so let's limit the data to the most recent time and forecast run."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
2018-09-05 15:52:38 -06:00
"# Get all times\n",
2023-05-22 12:58:35 -06:00
"datatimes = DataAccessLayer.getAvailableTimes(request)"
]
},
{
"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": [
"## 4 Get the Data!\n",
"\n",
"Here we can now request our data response from the EDEX server with our defined time filter.\n",
2018-09-05 15:52:38 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"Printing out some data from the first object in the response array can help verify we received the data we were interested in."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"parms = ['staElev', 'staName']\n",
"site = 72562\n",
"geom = POINT (-100.7005615234375 41.14971923828125)\n",
"datetime = 2023-05-19 12:00:00\n",
"reftime = May 19 23 12:00:00 GMT\n",
"fcstHour = 0\n",
"period = (May 19 23 12:00:00 , May 19 23 12:00:00 )\n"
]
}
],
"source": [
2018-09-05 15:52:38 -06:00
"# Get most recent record\n",
"response = DataAccessLayer.getGeometryData(request,times=datatimes[-1].validPeriod)\n",
2023-05-22 12:58:35 -06:00
"obj = response[0]\n",
"\n",
"print(\"parms = \" + str(obj.getParameters()))\n",
"print(\"site = \" + str(obj.getLocationName()))\n",
"print(\"geom = \" + str(obj.getGeometry()))\n",
"print(\"datetime = \" + str(obj.getDataTime()))\n",
"print(\"reftime = \" + str(obj.getDataTime().getRefTime()))\n",
"print(\"fcstHour = \" + str(obj.getDataTime().getFcstTime()))\n",
"print(\"period = \" + str(obj.getDataTime().getValidPeriod()))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Top](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html)\n",
2018-09-05 15:52:38 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5 Use the Data!\n",
"\n",
"Since we filtered on time, and requested the data in the previous cell, we now have a `response` object we can work with.\n",
"\n",
"### 5.1 Prepare data objects\n",
"\n",
"Here we construct arrays for each parameter to plot (temperature, pressure, and wind components).\n",
"After populating each of the arrays, we sort and mask missing data."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
2018-09-05 15:52:38 -06:00
"# Initialize data arrays\n",
"tdMan,tpMan,prMan,wdMan,wsMan = np.array([]),np.array([]),np.array([]),np.array([]),np.array([])\n",
"prSig,tpSig,tdSig = np.array([]),np.array([]),np.array([])\n",
"manGeos = []\n",
"sigtGeos = []\n",
"\n",
"# Build arrays\n",
"for ob in response:\n",
2018-10-09 13:39:16 -06:00
" parm_array = ob.getParameters()\n",
2018-09-06 12:12:07 -06:00
" if set(parm_array) & MAN_PARAMS:\n",
2018-09-05 15:52:38 -06:00
" manGeos.append(ob)\n",
2018-10-05 17:09:43 -06:00
" prMan = np.append(prMan,ob.getNumber(\"prMan\"))\n",
2018-10-15 16:29:13 -06:00
" tpMan, tpUnit = np.append(tpMan,ob.getNumber(\"tpMan\")), ob.getUnit(\"tpMan\")\n",
" tdMan, tdUnit = np.append(tdMan,ob.getNumber(\"tdMan\")), ob.getUnit(\"tdMan\")\n",
2018-10-05 17:09:43 -06:00
" wdMan = np.append(wdMan,ob.getNumber(\"wdMan\"))\n",
2018-10-15 16:29:13 -06:00
" wsMan, wsUnit = np.append(wsMan,ob.getNumber(\"wsMan\")), ob.getUnit(\"wsMan\")\n",
2018-09-05 15:52:38 -06:00
" continue\n",
2018-09-06 12:12:07 -06:00
" if set(parm_array) & SIGT_PARAMS:\n",
2018-09-05 15:52:38 -06:00
" sigtGeos.append(ob)\n",
2018-10-05 17:09:43 -06:00
" prSig = np.append(prSig,ob.getNumber(\"prSigT\"))\n",
" tpSig = np.append(tpSig,ob.getNumber(\"tpSigT\"))\n",
" tdSig = np.append(tdSig,ob.getNumber(\"tdSigT\"))\n",
2018-09-05 15:52:38 -06:00
" continue\n",
"\n",
"# Sort mandatory levels (but not sigT levels) because of the 1000.MB interpolation inclusion\n",
"ps = prMan.argsort()[::-1]\n",
"wpres = prMan[ps]\n",
"direc = wdMan[ps]\n",
"spd = wsMan[ps]\n",
"tman = tpMan[ps]\n",
"dman = tdMan[ps]\n",
"\n",
"# Flag missing data\n",
"prSig[prSig <= -9999] = np.nan\n",
"tpSig[tpSig <= -9999] = np.nan\n",
"tdSig[tdSig <= -9999] = np.nan\n",
"wpres[wpres <= -9999] = np.nan\n",
"tman[tman <= -9999] = np.nan\n",
"dman[dman <= -9999] = np.nan\n",
"direc[direc <= -9999] = np.nan\n",
2023-05-22 12:58:35 -06:00
"spd[spd <= -9999] = np.nan"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2 Convert Units\n",
2018-09-05 15:52:38 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"We need to modify the units several of the data parameters are returned in. Here we convert Temperature from Fahrenheit to Celcius, convert pressure to milibars, and extract wind for both the u and v directional components in Knots and Radians. "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
2018-09-05 15:52:38 -06:00
"# assign units\n",
"p = (prSig/100) * units.mbar\n",
"wpres = (wpres/100) * units.mbar\n",
2020-09-03 13:28:04 -06:00
"u,v = wind_components(spd * units.knots, np.deg2rad(direc))\n",
2018-09-05 15:52:38 -06:00
"\n",
2020-09-03 13:34:50 -06:00
"if tpUnit == 'K':\n",
2018-10-15 16:29:13 -06:00
" T = (tpSig-273.15) * units.degC\n",
" Td = (tdSig-273.15) * units.degC\n",
" tman = tman * units.degC\n",
2023-05-22 12:58:35 -06:00
" dman = dman * units.degC"
]
},
{
"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": [
"## 6 Plot the Data!\n",
2018-10-15 16:29:13 -06:00
"\n",
2023-05-22 12:58:35 -06:00
"Create and display SkewT and Hodograph plots using MetPy."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAqIAAAJRCAYAAACeB9VEAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOydeVhU1RuA38OOICLu4oLirpWlZmbumlppmlmaqWWb2WKrZZvtadm+aruppWXlkpZLauZWWupPRFBRRERwA5Qd5vz+uIONyM7ce2fmnvd55mGYuc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9YuKWUvKWUtKeVAtO4LJRa1QohL0Qr6CVLKNWUc3ocq9PMVQkwAngT6SSlLK46j0PryOf5DdQn/3cqPwuH2qr2A96eYAWL2vq9JnH87tuixLi7SsncxxfTBtbc0bkW7hVxe5qD9Q1DpnDpQ9Ge7I1q/zm1SSpuU8m97fP3RBmdFABuEEMeAH4EGQps1IKLwAPb+lSMp+27FeZ8553+GVSUBrSU31OERaL/T4MgJtIK2vcN2NeR/gyXhv9vz1wN77MUpcG4wXwvO72KgUCgUTkEVov+xHK1lpLz0Bn4vpXWqUthvG/4IPC+EqCaEaIfW8qIH9wO/A2uEEPUcXvcRQgQ4PC4Y/CO0QVpj0VoQT1Y2ACnlQbTPvbgpjqqjFeXH7TE9x4WtcHPQBn8MRRsJXSxCIwDtnwfsXv4O719sf62aEOIxtNa7r0o4Vge0FqUHpJRLi7znJYS4RwhR037Oy9FmFiixWLUPJAmwf+tnj0PY3xuDdht1gJQyrqRjANhbZXcA0+zHGI5WHBb2zZyH1urVw97y9yLwY5E+pY7MAZ6xu7RBu71
"text/plain": [
"<Figure size 720x864 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
2018-09-05 15:52:38 -06:00
"# Create SkewT/LogP\n",
2018-10-09 13:39:16 -06:00
"plt.rcParams['figure.figsize'] = (10, 12)\n",
2018-09-05 15:52:38 -06:00
"skew = SkewT()\n",
"skew.plot(p, T, 'r', linewidth=2)\n",
"skew.plot(p, Td, 'g', linewidth=2)\n",
"skew.plot_barbs(wpres, u, v)\n",
"skew.ax.set_ylim(1000, 100)\n",
2018-09-06 12:12:07 -06:00
"skew.ax.set_xlim(-60, 30)\n",
2018-09-05 15:52:38 -06:00
"\n",
"title_string = \" T(F) Td \" \n",
2018-10-05 17:09:43 -06:00
"title_string += \" \" + str(ob.getString(\"staName\"))\n",
2018-09-05 15:52:38 -06:00
"title_string += \" \" + str(ob.getDataTime().getRefTime())\n",
2018-10-05 17:09:43 -06:00
"title_string += \" (\" + str(ob.getNumber(\"staElev\")) + \"m elev)\"\n",
2018-09-05 15:52:38 -06:00
"title_string += \"\\n\" + str(round(T[0].to('degF').item(),1))\n",
"title_string += \" \" + str(round(Td[0].to('degF').item(),1))\n",
"plt.title(title_string, loc='left')\n",
"\n",
"# Calculate LCL height and plot as black dot\n",
2018-09-06 12:12:07 -06:00
"lcl_pressure, lcl_temperature = lcl(p[0], T[0], Td[0])\n",
"skew.plot(lcl_pressure, lcl_temperature, 'ko', markerfacecolor='black')\n",
2018-09-05 15:52:38 -06:00
"\n",
"# Calculate full parcel profile and add to plot as black line\n",
"prof = parcel_profile(p, T[0], Td[0]).to('degC')\n",
"skew.plot(p, prof, 'k', linewidth=2)\n",
"\n",
"# An example of a slanted line at constant T -- in this case the 0 isotherm\n",
"l = skew.ax.axvline(0, color='c', linestyle='--', linewidth=2)\n",
"\n",
"# Draw hodograph\n",
"ax_hod = inset_axes(skew.ax, '30%', '30%', loc=3)\n",
"h = Hodograph(ax_hod, component_range=max(wsMan))\n",
"h.add_grid(increment=20)\n",
"h.plot_colormapped(u, v, spd)\n",
"\n",
"# Show the plot\n",
"plt.show()"
]
2023-05-22 12:58:35 -06:00
},
{
"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": [
"## 7 See Also\n",
"\n",
"### 7.1 Related Notebooks\n",
"\n",
"* [Grid Levels and Parameters](https://unidata.github.io/python-awips/examples/generated/Grid_Levels_and_Parameters.html)\n",
"* [Model Sounding Data](http://unidata.github.io/python-awips/examples/generated/Model_Sounding_Data.html)\n",
"* [Forecast Model Vertical Sounding](http://unidata.github.io/python-awips/examples/generated/Forecast_Model_Vertical_Sounding.html)\n",
"\n",
"### 7.2 Additional Documentation\n",
"\n",
"**python-awips:**\n",
"\n",
"* [awips.DataAccessLayer](http://unidata.github.io/python-awips/api/DataAccessLayer.html)\n",
"* [awips.PyGeometryData](http://unidata.github.io/python-awips/api/PyGeometryData.html)\n",
"\n",
"**matplotlib:**\n",
"\n",
"* [matplotlib.pyplot](https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.html)\n",
"\n",
"**MetPy**\n",
"\n",
"* [metpy.wind_components](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.wind_components.html)\n",
"* [metpy.lcl](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.lcl.html) (Lifted Condensation Level)\n",
"* [metpy.parcel_profile](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.parcel_profile.html)\n",
"* [metpy.skewt](https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.SkewT.html)\n",
"* [metpy.hodograph](https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.Hodograph.html)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Top](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html)\n",
"\n",
"---"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
2018-09-05 15:52:38 -06:00
}
],
"metadata": {
"kernelspec": {
2018-09-06 12:12:07 -06:00
"display_name": "Python 3",
2018-09-05 15:52:38 -06:00
"language": "python",
2018-09-06 12:12:07 -06:00
"name": "python3"
2018-09-05 15:52:38 -06:00
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
2018-09-06 12:12:07 -06:00
"version": 3
2018-09-05 15:52:38 -06:00
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
2018-09-06 12:12:07 -06:00
"pygments_lexer": "ipython3",
2023-05-22 12:58:35 -06:00
"version": "3.9.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
2018-09-05 15:52:38 -06:00
}
},
"nbformat": 4,
2018-09-06 12:12:07 -06:00
"nbformat_minor": 1
2018-09-05 15:52:38 -06:00
}