<jupyter_start><jupyter_text>HodographsUnidata Python Workshop Questions1. What is a hodograph?1. How can MetPy plot hodographs?1. How can the style of the hodographs be modified to encode other information? Objectives1. Obtain upper air data1. Make a simple hodograph1. Annotate the hodograph with wind vectors1. Color the plot (continuous)1. Color the plot (segmented)  Obtain upper air dataJust as we learned in the siphon basics and upper air and skew-T notebook, we need to obtain upperair data to plot. We are going to stick with September 10, 2017 at 00Z for Key West, Fl. If you need a review on obtaining upper air data, please review those lessons.<jupyter_code>from datetime import datetime

from metpy.units import pandas_dataframe_to_unit_arrays
from siphon.simplewebservice.wyoming import WyomingUpperAir

df = WyomingUpperAir.request_data(datetime(1998, 10, 4, 0), 'OUN')
data = pandas_dataframe_to_unit_arrays(df)<jupyter_output><empty_output><jupyter_text>Top  Make a Simple HodographThe hodograph is a plot of the wind shear in the sounding. It is constructed by drawing the winds as vectors from the origin and connecting the heads of those vectors. MetPy makes this simple!<jupyter_code>import matplotlib.pyplot as plt
from metpy.plots import Hodograph
%matplotlib inline
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1)

h = Hodograph(ax, component_range=60.)
h.add_grid(increment=20)
h.plot(data['u_wind'], data['v_wind'], color='tab:red')<jupyter_output><empty_output><jupyter_text>It's relatively common to not want or need to display the entire sounding on a hodograph. Let's limit these data to the lowest 10km and plot it again.<jupyter_code>import metpy.calc as mpcalc
from metpy.units import units
_, u_trimmed, v_trimmed, speed_trimmed, height_trimmed = mpcalc.get_layer(data['pressure'], data['u_wind'],
                                                          data['v_wind'], data['speed'], data['height'],
                                                          heights=data['height'], depth=10 * units.km)
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1)

h = Hodograph(ax, component_range=30.)
h.add_grid(increment=10)
h.plot(u_trimmed, v_trimmed, color='tab:red')<jupyter_output><empty_output><jupyter_text>Annotate the hodograph with wind vectorsIt may be useful when introducing hodographs to actually show the wind vectors on the plot. The `wind_vectors` method does exactly this. It is often necessary to decimate the wind vectors for the plot to be intelligible.<jupyter_code>h.wind_vectors(u_trimmed[::3], v_trimmed[::3])
fig<jupyter_output><empty_output><jupyter_text>We can also set the limits to be asymmetric to beter utilize the plot space.<jupyter_code>ax.set_xlim(-10, 30)
ax.set_ylim(-10, 20)
fig<jupyter_output><empty_output><jupyter_text>Color the plot (continuous)We can color the line on the hodograph by another variable as well. In the simplest case it will be "continuously" colored, changing with the value of the variable such as windspeed.<jupyter_code>fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1)

h = Hodograph(ax, component_range=30.)
h.add_grid(increment=10)
h.plot_colormapped(u_trimmed, v_trimmed, speed_trimmed)
from metpy.plots import colortables
import numpy as np

fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1)

norm, cmap = colortables.get_with_range('Carbone42', np.min(speed_trimmed), np.max(speed_trimmed))

h = Hodograph(ax, component_range=30.)
h.add_grid(increment=10)
h.plot_colormapped(u_trimmed, v_trimmed, speed_trimmed, cmap=cmap, norm=norm)<jupyter_output><empty_output><jupyter_text>Color the plot (segmented)It may be useful when introducing hodographs to actually show the wind vectors on the plot. The `wind_vectors` method does exactly this. It is often necessary to decimate the wind vectors for the plot to be intelligible. We can also color the hodograph based on another variable - either continuously or in a segmented way. Here we'll color the hodograph by height above ground level.<jupyter_code>fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1)

boundaries = np.array([0, 1, 3, 5, 8]) * units.km
colors = ['tab:red', 'tab:green', 'tab:blue', 'tab:olive']

# Since we want to do things in terms of AGL, we need to make AGL heights
agl = height_trimmed - height_trimmed[0]

h = Hodograph(ax, component_range=30.)
h.add_grid(increment=10)
h.plot_colormapped(u_trimmed, v_trimmed, agl, bounds=boundaries, colors=colors)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09292035398230089, 'fraction_numerical': 0.02013274336283186, 'mean_word_length': 5.244475138121547, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '8784', 'license': 'MIT', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1447, 'n_words': 492, 'path': 'notebooks/Skew_T/Hodograph.ipynb', 'repo_name': 'helsing97/Unidata-Workshop', 'size': '4520'}