Skip to content

Commit

Permalink
deploy: fd37141
Browse files Browse the repository at this point in the history
  • Loading branch information
jukent committed Dec 6, 2023
1 parent 805c21b commit d3cb481
Show file tree
Hide file tree
Showing 18 changed files with 443 additions and 309 deletions.
2 changes: 1 addition & 1 deletion README.html
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ <h3>Running on Your Own Machine<a class="headerlink" href="#running-on-your-own-

By the <a href="https://projectpythia.org/">Project Pythia</a> Community.

Last updated on 5 December 2023.
Last updated on 6 December 2023.
</p>
</div>
</div>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 79 additions & 14 deletions _sources/notebooks/skewt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from mpl_toolkits.axes_grid1.inset_locator import inset_axes\n",
"import pandas as pd\n",
"\n",
"from metpy.plots import SkewT\n",
"import metpy.calc as mpcalc"
"from metpy.plots import SkewT, Hodograph\n",
"import metpy.calc as mpcalc\n",
"from metpy.units import units"
]
},
{
Expand All @@ -89,8 +91,8 @@
"from datetime import datetime\n",
"from siphon.simplewebservice.wyoming import WyomingUpperAir\n",
"\n",
"date = datetime(2023, 11, 20, 12)\n",
"station = 'GJT'\n",
"date = datetime(2023, 7, 7, 0)\n",
"station = 'JAX'\n",
"df = WyomingUpperAir.request_data(date, station)\n",
"```"
]
Expand All @@ -99,7 +101,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We've already done this for you and saved the data in a file, `notebooks/data/gjt_sounding.csv` for you to use. We'll use that file's data for the rest of the notebook"
"We've already done this for you and saved the data in a file, `notebooks/data/jax_sounding.csv` for you to use. We'll use that file's data for the rest of the notebook"
]
},
{
Expand All @@ -108,7 +110,7 @@
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('data/gjt_sounding.csv')\n",
"df = pd.read_csv('data/jax_sounding.csv')\n",
"df"
]
},
Expand All @@ -118,6 +120,7 @@
"metadata": {},
"outputs": [],
"source": [
"h = df['height'].values\n",
"p = df['pressure'].values\n",
"T = df['temperature'].values\n",
"Td = df['dewpoint'].values\n",
Expand Down Expand Up @@ -150,9 +153,9 @@
"skewt = SkewT(fig=fig, rotation=45)\n",
"\n",
"# plot sounding data\n",
"skewt.plot(p, T, 'r') # air temperature\n",
"skewt.plot(p, Td, 'b') # dew point\n",
"skewt.plot_barbs(p, u, v) # wind barbs"
"skewt.plot(p, T, 'r') # air temperature\n",
"skewt.plot(p, Td, 'b') # dew point\n",
"skewt.plot_barbs(p[p >= 100], u[p >= 100], v[p >= 100]) # wind barbs"
]
},
{
Expand Down Expand Up @@ -181,10 +184,10 @@
"For air temperature and dew point, we can use the standard `plot` method. The `SkewT` object provides a wrapper around matplotlib's `plot` method, and can be used in the same way. Note that even though pressure is on the y-axis, we still provide it as the first argument to `plot` because it is the independent variable. \n",
"\n",
"```python\n",
"skewt.plot_barbs(p, u, v) # wind barbs\n",
"skewt.plot_barbs(p[p >= 100], u[p >= 100], v[p >= 100]) # wind barbs\n",
"```\n",
"\n",
"Finally, we use `SkewT`'s [`plot_barbs`](https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.SkewT.html#metpy.plots.SkewT.plot_barbs) method to add the wind barbs to the right side of the plot. This is a wrapper around matplotlib's [`barbs`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.barbs.html#matplotlib.pyplot.barbs) method that applies the appropriate transformation and positions the barbs as expected for a Skew-T plot.\n",
"Finally, we use `SkewT`'s [`plot_barbs`](https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.SkewT.html#metpy.plots.SkewT.plot_barbs) method to add the wind barbs to the right side of the plot. This is a wrapper around matplotlib's [`barbs`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.barbs.html#matplotlib.pyplot.barbs) method that applies the appropriate transformation and positions the barbs as expected for a Skew-T plot. Note that we only plot the wind barbs for pressure levels greater than 100 hPa. This is just to keep the wind barbs from extending off the plot.\n",
"\n",
"In addition to the elements we have added specifically, you can see that the `SkewT` object also added some of the structural elements we discussed previously. By default, `SkewT` adds the horizontal pressure and skewed temperature lines. "
]
Expand All @@ -210,7 +213,7 @@
"# plot sounding data\n",
"skewt.plot(p, T, 'r') # air temperature\n",
"skewt.plot(p, Td, 'b') # dew point\n",
"skewt.plot_barbs(p, u, v) # wind barbs\n",
"skewt.plot_barbs(p[p >= 100], u[p >= 100], v[p >= 100]) # wind barbs\n",
"\n",
"# add dry adiabats, moist adiabats, and mixing ratio lines\n",
"skewt.plot_dry_adiabats()\n",
Expand Down Expand Up @@ -262,7 +265,7 @@
"skewt.plot_mixing_lines(linewidth=0.5)\n",
"\n",
"# add axis and figure titles\n",
"plt.title(df['station'][0] + ' ' + df['time'][0])\n",
"plt.title(df['station'][0] + ' ' + str(df['time'][0]))\n",
"plt.xlabel('temperature (degC)')\n",
"plt.ylabel('pressure (hPa)')"
]
Expand All @@ -275,12 +278,74 @@
"- changed the figsize to `figsize=(8,12)`\n",
"- removed the `rotation` kwarg from the `SkewT` object to allow the upper air temp and dew point lines to be seen without being cut off or expanding the x-axis limits\n",
"- `skewt.ax.set_ylim(1000, 10)`: sets the y-axis limits to 1000 hPa at the bottom and 10 hPa at the top to include the entire sounding\n",
"- `skewt.plot_barbs(p[::5], u[::5], v[::5])`: plots every fifth wind barb to reduce clutter\n",
"- `skewt.plot_barbs(p[::5], u[::5], v[::5])`: plots every fifth wind barb to reduce clutter, also removes limiting the wind barbs to pressure levels greater than 100 hPa\n",
"- reduced the linewidth of the dry adiabats, moist adiabats, and mixing ratio lines to 0.5\n",
"- added axes labels\n",
"- added a title including the station name and date of the sounding pulled from the data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Additional Skew-T Options\n",
"There are a few additional options that can be used to customize the appearance of the Skew-T plot that we haven't covered here. For more information, check out the [MetPy documentation](https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.SkewT.html).\n",
"\n",
"Here's a few quick examples of some of those additional options:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure(figsize=(15, 4))\n",
"\n",
"# set up some subplots\n",
"skewt_plots = []\n",
"for i in range(0,4):\n",
" skewt_plots.append(SkewT(fig=fig, subplot=(1,4,i+1), rotation=45))\n",
" skewt_plots[i].plot(p, T, 'r') # air temperature\n",
" skewt_plots[i].plot(p, Td, 'b') # dew point\n",
" skewt_plots[i].plot_barbs(p[::5], u[::5], v[::5], length=5, linewidth=0.5)\n",
" skewt_plots[i].plot_dry_adiabats(linewidth=0.5)\n",
" skewt_plots[i].plot_moist_adiabats(linewidth=0.5)\n",
" skewt_plots[i].plot_mixing_lines(linewidth=0.5)\n",
" skewt_plots[i].ax.set_xlabel('')\n",
" skewt_plots[i].ax.set_ylabel('')\n",
"\n",
"# calculate LCL and parcel profile\n",
"lcl_p, lcl_t = mpcalc.lcl(p[0]*units.hPa, T[0]*units.degC, Td[0]*units.degC)\n",
"lcl_prof = mpcalc.parcel_profile(p*units.hPa, T[0]*units.degC, Td[0]*units.degC).to('degC')\n",
"\n",
"\n",
"# LCL and parcel profile skew-T\n",
"skewt_plots[0].ax.set_title('LCL and Parcel Profile')\n",
"skewt_plots[0].plot(p, lcl_prof, 'k')\n",
"skewt_plots[0].plot(lcl_p, lcl_t, 'ko')\n",
"\n",
"\n",
"# add constant temperature line at t=0\n",
"skewt_plots[1].ax.set_title('Constant T Line at 0$^\\circ$C')\n",
"skewt_plots[1].ax.axvline(0, color='k', ls='--')\n",
"\n",
"\n",
"# shade CAPE and CIN\n",
"skewt_plots[2].ax.set_title('Shade CAPE and CIN')\n",
"skewt_plots[2].plot(p, lcl_prof, 'k')\n",
"skewt_plots[2].shade_cin(p*units.hPa, T*units.degC, lcl_prof, Td*units.degC)\n",
"skewt_plots[2].shade_cape(p*units.hPa, T*units.degC, lcl_prof)\n",
"\n",
"\n",
"# Hodograph\n",
"skewt_plots[3].ax.set_title('Hodograph')\n",
"ax_hod = inset_axes(skewt_plots[3].ax, '30%', '30%')\n",
"hod = Hodograph(ax_hod, component_range=50)\n",
"hod.add_grid(increment=10)\n",
"hod.plot_colormapped(u, v, h)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
2 changes: 1 addition & 1 deletion genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ <h1 id="index">Index</h1>

By the <a href="https://projectpythia.org/">Project Pythia</a> Community.

Last updated on 5 December 2023.
Last updated on 6 December 2023.
</p>
</div>
</div>
Expand Down
Loading

0 comments on commit d3cb481

Please sign in to comment.