{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Skew-T's\n",
"## Requesting Upper Air Data from Siphon and Plotting a Skew-T with MetPy\n",
"### Based on Unidata's MetPy Monday \\# 15 -17 YouTube links:
https://www.youtube.com/watch?v=OUTBiXEuDIU;
https://www.youtube.com/watch?v=oog6_b-844Q;
https://www.youtube.com/watch?v=b0RsN9mCY5k"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Import the libraries we need"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.gridspec as gridspec\n",
"from mpl_toolkits.axes_grid1.inset_locator import inset_axes\n",
"import metpy.calc as mpcalc\n",
"from metpy.plots import Hodograph, SkewT\n",
"from metpy.units import units, pandas_dataframe_to_unit_arrays\n",
"from datetime import datetime, timedelta\n",
"import pandas as pd\n",
"from siphon.simplewebservice.wyoming import WyomingUpperAir"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Next we use methods from the datetime library to determine the latest time, and then use it to select the most recent date and time that we'll use for our selected Skew-T."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"now = datetime.now()\n",
"\n",
"curr_year = now.year\n",
"curr_month = now.month\n",
"curr_day = now.day\n",
"curr_hour = now.hour\n",
"\n",
"print(f\"Current time is: {now}\")\n",
"print(f\"Current year, month, date, hour: {curr_year}, {curr_month}, {curr_day}, {curr_hour}\")\n",
"\n",
"if (curr_hour > 13) :\n",
" raob_hour = 12\n",
" hr_delta = curr_hour - 12\n",
"elif (curr_hour > 1):\n",
" raob_hour = 0\n",
" hr_delta = curr_hour - 0\n",
"else:\n",
" raob_hour = 12\n",
" hr_delta = curr_hour + 12\n",
"\n",
"raob_time = now - timedelta(hours=hr_delta)\n",
"\n",
"raob_year = raob_time.year\n",
"raob_month = raob_time.month\n",
"raob_day = raob_time.day\n",
"raob_hour = raob_time.hour\n",
"\n",
"print(f\"Time of RAOB is: {raob_year}, {raob_month}, {raob_day}, {raob_hour}\")\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Construct a datetime object that we will use in our query to the data server. Note what it looks like."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"query_date = datetime(raob_year,raob_month,raob_day,raob_hour)\n",
"query_date"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### If desired, we can choose a past date and time."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"#current = True\n",
"current = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"if (current == False):\n",
" query_date = datetime(2025, 4, 2, 18)\n",
" \n",
"raob_timeStr = query_date.strftime(\"%Y-%m-%d %H UTC\")\n",
"raob_timeTitle = query_date.strftime(\"%H00 UTC %-d %b %Y\")\n",
"print(raob_timeStr)\n",
"print(raob_timeTitle)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Select our station and query the data server."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"station = 'ILX'\n",
"\n",
"df = WyomingUpperAir.request_data (query_date,station)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
No data available for YYYY-MM-DD HHZ for station XXX
, you may have specified an incorrect date or location, or there just might not have been a successful RAOB at that date and time.503 Server Error
, try requesting the sounding again. The Wyoming server does not handle simultaneous requests well. Usually the request will eventually work. skew.ax.axvline
, color must be singular.Additionally, some of the skew-T attributes (e.g. the shaded area between -12 and -18 C) may not be relevant (e.g., a warm-season convective case). Comment out those you don't wish to show.
\n", "