Skip to content

Commit

Permalink
Added tests for coloring the hodograph by different variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilson14 committed Aug 2, 2017
1 parent 178d726 commit cb95bfb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions metpy/plots/tests/test_skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,44 @@ def test_skewt_barb_color():
skew.plot_barbs(p, u, u, c=u)

return fig


@pytest.mark.mpl_image_compare(tolerance=0, remove_text=True)
def test_hodograph_plot_layers():
"""Test hodograph colored height layers with interpolation."""
u = np.arange(5, 65, 5) * units('knot')
v = np.arange(-5, -65, -5) * units('knot')
h = [178, 213, 610, 656, 721, 914, 1060,
1219, 1372, 1412, 1512, 1524] * units('meter')
p = [978, 974, 930, 925, 918, 897, 882,
865, 850, 846, 836, 834.8] * units('hPa')
colors = ['red', 'green']
levels = [0, 500, 1000] * units('meter')
fig = plt.figure(figsize=(9, 9))
ax = fig.add_subplot(1, 1, 1)
hodo = Hodograph(ax, component_range=80)
hodo.add_grid(increment=20, color='k')
hodo.plot_layers(u, v, h, bounds=levels, colors=colors)

return fig


@pytest.mark.mpl_image_compare(tolerance=0, remove_text=True)
def test_hodograph_plot_arbitrary_layer():
"""Test hodograph colored layers for arbitrary variables without interpolation."""
u = np.arange(5, 65, 5) * units('knot')
v = np.arange(-5, -65, -5) * units('knot')
speed = np.sqrt(u ** 2 + v ** 2)
h = [178, 213, 610, 656, 721, 914, 1060,
1219, 1372, 1412, 1512, 1524] * units('meter')
p = [978, 974, 930, 925, 918, 897, 882,
865, 850, 846, 836, 834.8] * units('hPa')
colors = ['red', 'green','blue']
levels = [0, 10, 20, 30] * units('knot')
fig = plt.figure(figsize=(9, 9))
ax = fig.add_subplot(1, 1, 1)
hodo = Hodograph(ax, component_range=80)
hodo.add_grid(increment=20, color='k')
hodo.plot_colormapped(u, v, speed, bounds=levels, colors=colors)

return fig

0 comments on commit cb95bfb

Please sign in to comment.