From 83fc42de913861cc9add74090f1d4816892bc518 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Tue, 27 Aug 2024 10:29:27 -0600 Subject: [PATCH] Fix broken link --- .../upperair_soundings.ipynb | 194 ++++++++++++++++-- .../upperair_soundings.py | 2 +- .../tutorials/upperair_soundings.rst.txt | 2 +- v1.6/tutorials/upperair_soundings.html | 2 +- 4 files changed, 183 insertions(+), 17 deletions(-) diff --git a/v1.6/_downloads/cdca3e0cb8a2930cccab0e29b97ef52a/upperair_soundings.ipynb b/v1.6/_downloads/cdca3e0cb8a2930cccab0e29b97ef52a/upperair_soundings.ipynb index 4c45fc2ba74..19ed473d23e 100644 --- a/v1.6/_downloads/cdca3e0cb8a2930cccab0e29b97ef52a/upperair_soundings.ipynb +++ b/v1.6/_downloads/cdca3e0cb8a2930cccab0e29b97ef52a/upperair_soundings.ipynb @@ -4,7 +4,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\n# Upper Air Sounding Tutorial\n\nUpper air analysis is a staple of many synoptic and mesoscale analysis\nproblems. In this tutorial we will gather weather balloon data, plot it,\nperform a series of thermodynamic calculations, and summarize the results.\nTo learn more about the Skew-T diagram and its use in weather analysis and\nforecasting, checkout [this](http://www.pmarshwx.com/research/manuals/AF_skewt_manual.pdf)\nair weather service guide.\n" + "\n", + "# Upper Air Sounding Tutorial\n", + "\n", + "Upper air analysis is a staple of many synoptic and mesoscale analysis\n", + "problems. In this tutorial we will gather weather balloon data, plot it,\n", + "perform a series of thermodynamic calculations, and summarize the results.\n", + "To learn more about the Skew-T diagram and its use in weather analysis and\n", + "forecasting, checkout [this](https://unidata.github.io/MetPy/latest/_static/USAF_SkewT_manual.pdf)\n", + "air weather service guide.\n" ] }, { @@ -15,14 +23,25 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\nfrom mpl_toolkits.axes_grid1.inset_locator import inset_axes\nimport pandas as pd\n\nimport metpy.calc as mpcalc\nfrom metpy.cbook import get_test_data\nfrom metpy.plots import Hodograph, SkewT\nfrom metpy.units import units" + "import matplotlib.pyplot as plt\n", + "from mpl_toolkits.axes_grid1.inset_locator import inset_axes\n", + "import pandas as pd\n", + "\n", + "import metpy.calc as mpcalc\n", + "from metpy.cbook import get_test_data\n", + "from metpy.plots import Hodograph, SkewT\n", + "from metpy.units import units" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Getting Data\n\nUpper air data can be obtained using the siphon package, but for this tutorial we will use\nsome of MetPy's sample data. This event is the Veterans Day tornado outbreak in 2002.\n\n" + "## Getting Data\n", + "\n", + "Upper air data can be obtained using the siphon package, but for this tutorial we will use\n", + "some of MetPy's sample data. This event is the Veterans Day tornado outbreak in 2002.\n", + "\n" ] }, { @@ -33,7 +52,14 @@ }, "outputs": [], "source": [ - "col_names = ['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed']\n\ndf = pd.read_fwf(get_test_data('nov11_sounding.txt', as_file_obj=False),\n skiprows=5, usecols=[0, 1, 2, 3, 6, 7], names=col_names)\n\n# Drop any rows with all NaN values for T, Td, winds\ndf = df.dropna(subset=('temperature', 'dewpoint', 'direction', 'speed'\n ), how='all').reset_index(drop=True)" + "col_names = ['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed']\n", + "\n", + "df = pd.read_fwf(get_test_data('nov11_sounding.txt', as_file_obj=False),\n", + " skiprows=5, usecols=[0, 1, 2, 3, 6, 7], names=col_names)\n", + "\n", + "# Drop any rows with all NaN values for T, Td, winds\n", + "df = df.dropna(subset=('temperature', 'dewpoint', 'direction', 'speed'\n", + " ), how='all').reset_index(drop=True)" ] }, { @@ -44,14 +70,32 @@ }, "outputs": [], "source": [ - "# We will pull the data out of the example dataset into individual variables and\n# assign units.\n\np = df['pressure'].values * units.hPa\nT = df['temperature'].values * units.degC\nTd = df['dewpoint'].values * units.degC\nwind_speed = df['speed'].values * units.knots\nwind_dir = df['direction'].values * units.degrees\nu, v = mpcalc.wind_components(wind_speed, wind_dir)" + "# We will pull the data out of the example dataset into individual variables and\n", + "# assign units.\n", + "\n", + "p = df['pressure'].values * units.hPa\n", + "T = df['temperature'].values * units.degC\n", + "Td = df['dewpoint'].values * units.degC\n", + "wind_speed = df['speed'].values * units.knots\n", + "wind_dir = df['direction'].values * units.degrees\n", + "u, v = mpcalc.wind_components(wind_speed, wind_dir)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Thermodynamic Calculations\n\nOften times we will want to calculate some thermodynamic parameters of a\nsounding. The MetPy calc module has many such calculations already implemented!\n\n* **Lifting Condensation Level (LCL)** - The level at which an air parcel's\n relative humidity becomes 100% when lifted along a dry adiabatic path.\n* **Parcel Path** - Path followed by a hypothetical parcel of air, beginning\n at the surface temperature/pressure and rising dry adiabatically until\n reaching the LCL, then rising moist adiabatially.\n\n" + "## Thermodynamic Calculations\n", + "\n", + "Often times we will want to calculate some thermodynamic parameters of a\n", + "sounding. The MetPy calc module has many such calculations already implemented!\n", + "\n", + "* **Lifting Condensation Level (LCL)** - The level at which an air parcel's\n", + " relative humidity becomes 100% when lifted along a dry adiabatic path.\n", + "* **Parcel Path** - Path followed by a hypothetical parcel of air, beginning\n", + " at the surface temperature/pressure and rising dry adiabatically until\n", + " reaching the LCL, then rising moist adiabatially.\n", + "\n" ] }, { @@ -62,14 +106,43 @@ }, "outputs": [], "source": [ - "# Calculate the LCL\nlcl_pressure, lcl_temperature = mpcalc.lcl(p[0], T[0], Td[0])\n\nprint(lcl_pressure, lcl_temperature)\n\n# Calculate the parcel profile.\nparcel_prof = mpcalc.parcel_profile(p, T[0], Td[0]).to('degC')" + "# Calculate the LCL\n", + "lcl_pressure, lcl_temperature = mpcalc.lcl(p[0], T[0], Td[0])\n", + "\n", + "print(lcl_pressure, lcl_temperature)\n", + "\n", + "# Calculate the parcel profile.\n", + "parcel_prof = mpcalc.parcel_profile(p, T[0], Td[0]).to('degC')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Basic Skew-T Plotting\n\nThe Skew-T (log-P) diagram is the standard way to view rawinsonde data. The\ny-axis is height in pressure coordinates and the x-axis is temperature. The\ny coordinates are plotted on a logarithmic scale and the x coordinate system\nis skewed. An explanation of skew-T interpretation is beyond the scope of this\ntutorial, but here we will plot one that can be used for analysis or\npublication.\n\nThe most basic skew-T can be plotted with only five lines of Python.\nThese lines perform the following tasks:\n\n1. Create a ``Figure`` object and set the size of the figure.\n\n2. Create a ``SkewT`` object\n\n3. Plot the pressure and temperature (note that the pressure,\n the independent variable, is first even though it is plotted on the y-axis).\n\n4. Plot the pressure and dewpoint temperature.\n\n5. Plot the wind barbs at the appropriate pressure using the u and v wind\n components.\n\n" + "## Basic Skew-T Plotting\n", + "\n", + "The Skew-T (log-P) diagram is the standard way to view rawinsonde data. The\n", + "y-axis is height in pressure coordinates and the x-axis is temperature. The\n", + "y coordinates are plotted on a logarithmic scale and the x coordinate system\n", + "is skewed. An explanation of skew-T interpretation is beyond the scope of this\n", + "tutorial, but here we will plot one that can be used for analysis or\n", + "publication.\n", + "\n", + "The most basic skew-T can be plotted with only five lines of Python.\n", + "These lines perform the following tasks:\n", + "\n", + "1. Create a ``Figure`` object and set the size of the figure.\n", + "\n", + "2. Create a ``SkewT`` object\n", + "\n", + "3. Plot the pressure and temperature (note that the pressure,\n", + " the independent variable, is first even though it is plotted on the y-axis).\n", + "\n", + "4. Plot the pressure and dewpoint temperature.\n", + "\n", + "5. Plot the wind barbs at the appropriate pressure using the u and v wind\n", + " components.\n", + "\n" ] }, { @@ -80,14 +153,30 @@ }, "outputs": [], "source": [ - "# Create a new figure. The dimensions here give a good aspect ratio\nfig = plt.figure(figsize=(9, 9))\nskew = SkewT(fig)\n\n# Plot the data using normal plotting functions, in this case using\n# log scaling in Y, as dictated by the typical meteorological plot\nskew.plot(p, T, 'r', linewidth=2)\nskew.plot(p, Td, 'g', linewidth=2)\nskew.plot_barbs(p, u, v)\n\n# Show the plot\nplt.show()" + "# Create a new figure. The dimensions here give a good aspect ratio\n", + "fig = plt.figure(figsize=(9, 9))\n", + "skew = SkewT(fig)\n", + "\n", + "# Plot the data using normal plotting functions, in this case using\n", + "# log scaling in Y, as dictated by the typical meteorological plot\n", + "skew.plot(p, T, 'r', linewidth=2)\n", + "skew.plot(p, Td, 'g', linewidth=2)\n", + "skew.plot_barbs(p, u, v)\n", + "\n", + "# Show the plot\n", + "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Advanced Skew-T Plotting\n\nFiducial lines indicating dry adiabats, moist adiabats, and mixing ratio are\nuseful when performing further analysis on the Skew-T diagram. Often the\n0C isotherm is emphasized and areas of CAPE and CIN are shaded.\n\n" + "## Advanced Skew-T Plotting\n", + "\n", + "Fiducial lines indicating dry adiabats, moist adiabats, and mixing ratio are\n", + "useful when performing further analysis on the Skew-T diagram. Often the\n", + "0C isotherm is emphasized and areas of CAPE and CIN are shaded.\n", + "\n" ] }, { @@ -98,14 +187,52 @@ }, "outputs": [], "source": [ - "# Create a new figure. The dimensions here give a good aspect ratio\nfig = plt.figure(figsize=(9, 9))\nskew = SkewT(fig, rotation=30)\n\n# Plot the data using normal plotting functions, in this case using\n# log scaling in Y, as dictated by the typical meteorological plot\nskew.plot(p, T, 'r')\nskew.plot(p, Td, 'g')\nskew.plot_barbs(p, u, v)\nskew.ax.set_ylim(1000, 100)\nskew.ax.set_xlim(-40, 60)\n\n# Plot LCL temperature as black dot\nskew.plot(lcl_pressure, lcl_temperature, 'ko', markerfacecolor='black')\n\n# Plot the parcel profile as a black line\nskew.plot(p, parcel_prof, 'k', linewidth=2)\n\n# Shade areas of CAPE and CIN\nskew.shade_cin(p, T, parcel_prof, Td)\nskew.shade_cape(p, T, parcel_prof)\n\n# Plot a zero degree isotherm\nskew.ax.axvline(0, color='c', linestyle='--', linewidth=2)\n\n# Add the relevant special lines\nskew.plot_dry_adiabats()\nskew.plot_moist_adiabats()\nskew.plot_mixing_lines()\n\n# Show the plot\nplt.show()" + "# Create a new figure. The dimensions here give a good aspect ratio\n", + "fig = plt.figure(figsize=(9, 9))\n", + "skew = SkewT(fig, rotation=30)\n", + "\n", + "# Plot the data using normal plotting functions, in this case using\n", + "# log scaling in Y, as dictated by the typical meteorological plot\n", + "skew.plot(p, T, 'r')\n", + "skew.plot(p, Td, 'g')\n", + "skew.plot_barbs(p, u, v)\n", + "skew.ax.set_ylim(1000, 100)\n", + "skew.ax.set_xlim(-40, 60)\n", + "\n", + "# Plot LCL temperature as black dot\n", + "skew.plot(lcl_pressure, lcl_temperature, 'ko', markerfacecolor='black')\n", + "\n", + "# Plot the parcel profile as a black line\n", + "skew.plot(p, parcel_prof, 'k', linewidth=2)\n", + "\n", + "# Shade areas of CAPE and CIN\n", + "skew.shade_cin(p, T, parcel_prof, Td)\n", + "skew.shade_cape(p, T, parcel_prof)\n", + "\n", + "# Plot a zero degree isotherm\n", + "skew.ax.axvline(0, color='c', linestyle='--', linewidth=2)\n", + "\n", + "# Add the relevant special lines\n", + "skew.plot_dry_adiabats()\n", + "skew.plot_moist_adiabats()\n", + "skew.plot_mixing_lines()\n", + "\n", + "# Show the plot\n", + "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Adding a Hodograph\n\nA hodograph is a polar representation of the wind profile measured by the rawinsonde.\nWinds at different levels are plotted as vectors with their tails at the origin, the angle\nfrom the vertical axes representing the direction, and the length representing the speed.\nThe line plotted on the hodograph is a line connecting the tips of these vectors,\nwhich are not drawn.\n\n" + "## Adding a Hodograph\n", + "\n", + "A hodograph is a polar representation of the wind profile measured by the rawinsonde.\n", + "Winds at different levels are plotted as vectors with their tails at the origin, the angle\n", + "from the vertical axes representing the direction, and the length representing the speed.\n", + "The line plotted on the hodograph is a line connecting the tips of these vectors,\n", + "which are not drawn.\n", + "\n" ] }, { @@ -116,7 +243,46 @@ }, "outputs": [], "source": [ - "# Create a new figure. The dimensions here give a good aspect ratio\nfig = plt.figure(figsize=(9, 9))\nskew = SkewT(fig, rotation=30)\n\n# Plot the data using normal plotting functions, in this case using\n# log scaling in Y, as dictated by the typical meteorological plot\nskew.plot(p, T, 'r')\nskew.plot(p, Td, 'g')\nskew.plot_barbs(p, u, v)\nskew.ax.set_ylim(1000, 100)\nskew.ax.set_xlim(-40, 60)\n\n# Plot LCL as black dot\nskew.plot(lcl_pressure, lcl_temperature, 'ko', markerfacecolor='black')\n\n# Plot the parcel profile as a black line\nskew.plot(p, parcel_prof, 'k', linewidth=2)\n\n# Shade areas of CAPE and CIN\nskew.shade_cin(p, T, parcel_prof, Td)\nskew.shade_cape(p, T, parcel_prof)\n\n# Plot a zero degree isotherm\nskew.ax.axvline(0, color='c', linestyle='--', linewidth=2)\n\n# Add the relevant special lines\nskew.plot_dry_adiabats()\nskew.plot_moist_adiabats()\nskew.plot_mixing_lines()\n\n# Create a hodograph\n# Create an inset axes object that is 40% width and height of the\n# figure and put it in the upper right hand corner.\nax_hod = inset_axes(skew.ax, '40%', '40%', loc=1)\nh = Hodograph(ax_hod, component_range=80.)\nh.add_grid(increment=20)\nh.plot_colormapped(u, v, wind_speed) # Plot a line colored by wind speed\n\n# Show the plot\nplt.show()" + "# Create a new figure. The dimensions here give a good aspect ratio\n", + "fig = plt.figure(figsize=(9, 9))\n", + "skew = SkewT(fig, rotation=30)\n", + "\n", + "# Plot the data using normal plotting functions, in this case using\n", + "# log scaling in Y, as dictated by the typical meteorological plot\n", + "skew.plot(p, T, 'r')\n", + "skew.plot(p, Td, 'g')\n", + "skew.plot_barbs(p, u, v)\n", + "skew.ax.set_ylim(1000, 100)\n", + "skew.ax.set_xlim(-40, 60)\n", + "\n", + "# Plot LCL as black dot\n", + "skew.plot(lcl_pressure, lcl_temperature, 'ko', markerfacecolor='black')\n", + "\n", + "# Plot the parcel profile as a black line\n", + "skew.plot(p, parcel_prof, 'k', linewidth=2)\n", + "\n", + "# Shade areas of CAPE and CIN\n", + "skew.shade_cin(p, T, parcel_prof, Td)\n", + "skew.shade_cape(p, T, parcel_prof)\n", + "\n", + "# Plot a zero degree isotherm\n", + "skew.ax.axvline(0, color='c', linestyle='--', linewidth=2)\n", + "\n", + "# Add the relevant special lines\n", + "skew.plot_dry_adiabats()\n", + "skew.plot_moist_adiabats()\n", + "skew.plot_mixing_lines()\n", + "\n", + "# Create a hodograph\n", + "# Create an inset axes object that is 40% width and height of the\n", + "# figure and put it in the upper right hand corner.\n", + "ax_hod = inset_axes(skew.ax, '40%', '40%', loc=1)\n", + "h = Hodograph(ax_hod, component_range=80.)\n", + "h.add_grid(increment=20)\n", + "h.plot_colormapped(u, v, wind_speed) # Plot a line colored by wind speed\n", + "\n", + "# Show the plot\n", + "plt.show()" ] } ], @@ -141,4 +307,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} diff --git a/v1.6/_downloads/cf626a06a2e16be83be26aa926cd5642/upperair_soundings.py b/v1.6/_downloads/cf626a06a2e16be83be26aa926cd5642/upperair_soundings.py index 107ecdda1d8..4b73cd90ea5 100644 --- a/v1.6/_downloads/cf626a06a2e16be83be26aa926cd5642/upperair_soundings.py +++ b/v1.6/_downloads/cf626a06a2e16be83be26aa926cd5642/upperair_soundings.py @@ -10,7 +10,7 @@ problems. In this tutorial we will gather weather balloon data, plot it, perform a series of thermodynamic calculations, and summarize the results. To learn more about the Skew-T diagram and its use in weather analysis and -forecasting, checkout `this `_ +forecasting, checkout `this `_ air weather service guide. """ diff --git a/v1.6/_sources/tutorials/upperair_soundings.rst.txt b/v1.6/_sources/tutorials/upperair_soundings.rst.txt index 9127caab1e0..49e345c1edb 100644 --- a/v1.6/_sources/tutorials/upperair_soundings.rst.txt +++ b/v1.6/_sources/tutorials/upperair_soundings.rst.txt @@ -26,7 +26,7 @@ Upper air analysis is a staple of many synoptic and mesoscale analysis problems. In this tutorial we will gather weather balloon data, plot it, perform a series of thermodynamic calculations, and summarize the results. To learn more about the Skew-T diagram and its use in weather analysis and -forecasting, checkout `this `_ +forecasting, checkout `this `_ air weather service guide. .. GENERATED FROM PYTHON SOURCE LINES 16-27 diff --git a/v1.6/tutorials/upperair_soundings.html b/v1.6/tutorials/upperair_soundings.html index b923cfb7117..8d8287885e1 100644 --- a/v1.6/tutorials/upperair_soundings.html +++ b/v1.6/tutorials/upperair_soundings.html @@ -551,7 +551,7 @@ problems. In this tutorial we will gather weather balloon data, plot it, perform a series of thermodynamic calculations, and summarize the results. To learn more about the Skew-T diagram and its use in weather analysis and -forecasting, checkout this +forecasting, checkout this air weather service guide.

import matplotlib.pyplot as plt
 from mpl_toolkits.axes_grid1.inset_locator import inset_axes