Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for requirements #947

Merged
merged 4 commits into from Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/cross_section.py
Expand Up @@ -89,8 +89,8 @@
# Plot potential temperature using contour, with some custom labeling
theta_contour = ax.contour(cross['lon'], cross['isobaric'], cross['Potential_temperature'],
levels=np.arange(250, 450, 5), colors='k', linewidths=2)
plt.clabel(theta_contour, theta_contour.levels[1::2], fontsize=8, colors='k', inline=1,
inline_spacing=8, fmt='%i', rightside_up=True, use_clabeltext=True, alpha=0.6)
theta_contour.clabel(theta_contour.levels[1::2], fontsize=8, colors='k', inline=1,
inline_spacing=8, fmt='%i', rightside_up=True, use_clabeltext=True)

# Plot winds using the axes interface directly, with some custom indexing to make the barbs
# less crowded
Expand All @@ -104,7 +104,7 @@
ax.set_yscale('symlog')
ax.set_yticklabels(np.arange(1000, 50, -100))
ax.set_ylim(cross['isobaric'].max(), cross['isobaric'].min())
plt.yticks(np.arange(1000, 50, -100))
ax.set_yticks(np.arange(1000, 50, -100))

# Define the CRS and inset axes
data_crs = data['Geopotential_height'].metpy.cartopy_crs
Expand Down
3 changes: 3 additions & 0 deletions examples/gridding/Natural_Neighbor_Verification.py
Expand Up @@ -76,6 +76,7 @@
tri = Delaunay(pts)

fig, ax = plt.subplots(1, 1, figsize=(15, 10))
ax.ishold = lambda: True # Work-around for Matplotlib 3.0.0 incompatibility
delaunay_plot_2d(tri, ax=ax)

for i, zval in enumerate(zp):
Expand Down Expand Up @@ -114,6 +115,7 @@ def draw_circle(ax, x, y, r, m, label):
members, tri_info = geometry.find_natural_neighbors(tri, list(zip(sim_gridx, sim_gridy)))

fig, ax = plt.subplots(1, 1, figsize=(15, 10))
ax.ishold = lambda: True # Work-around for Matplotlib 3.0.0 incompatibility
delaunay_plot_2d(tri, ax=ax)
ax.plot(sim_gridx, sim_gridy, 'ks', markersize=10)

Expand Down Expand Up @@ -166,6 +168,7 @@ def draw_circle(ax, x, y, r, m, label):
vor = Voronoi(list(zip(xp, yp)))

fig, ax = plt.subplots(1, 1, figsize=(15, 10))
ax.ishold = lambda: True # Work-around for Matplotlib 3.0.0 incompatibility
voronoi_plot_2d(vor, ax=ax)

nn_ind = np.array([0, 5, 7, 8])
Expand Down
1 change: 1 addition & 0 deletions examples/gridding/Point_Interpolation.py
Expand Up @@ -26,6 +26,7 @@ def basic_map(proj):
fig = plt.figure(figsize=(15, 10))
add_metpy_logo(fig, 0, 80, size='large')
view = fig.add_axes([0, 0, 1, 1], projection=proj)
view._hold = True # Work-around for CartoPy 0.16/Matplotlib 3.0.0 incompatibility
view.set_extent([-120, -70, 20, 50])
view.add_feature(cfeature.STATES.with_scale('50m'))
view.add_feature(cfeature.OCEAN)
Expand Down
1 change: 1 addition & 0 deletions examples/gridding/Wind_SLP_Interpolation.py
Expand Up @@ -89,6 +89,7 @@
fig = plt.figure(figsize=(20, 10))
add_metpy_logo(fig, 360, 120, size='large')
view = fig.add_subplot(1, 1, 1, projection=to_proj)
view._hold = True # Work-around for CartoPy 0.16/Matplotlib 3.0.0 incompatibility

view.set_extent([-120, -70, 20, 50])
view.add_feature(cfeature.STATES.with_scale('50m'))
Expand Down
80 changes: 46 additions & 34 deletions metpy/plots/tests/test_skewt.py
Expand Up @@ -20,21 +20,25 @@
@pytest.mark.mpl_image_compare(tolerance=0.021, remove_text=True)
def test_skewt_api():
"""Test the SkewT API."""
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)

# Plot the data using normal plotting functions, in this case using
# log scaling in Y, as dictated by the typical meteorological plot
p = np.linspace(1000, 100, 10)
t = np.linspace(20, -20, 10)
u = np.linspace(-10, 10, 10)
skew.plot(p, t, 'r')
skew.plot_barbs(p, u, u)

# Add the relevant special lines
skew.plot_dry_adiabats()
skew.plot_moist_adiabats()
skew.plot_mixing_lines()
with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)

# Plot the data using normal plotting functions, in this case using
# log scaling in Y, as dictated by the typical meteorological plot
p = np.linspace(1000, 100, 10)
t = np.linspace(20, -20, 10)
u = np.linspace(-10, 10, 10)
skew.plot(p, t, 'r')
skew.plot_barbs(p, u, u)

skew.ax.set_xlim(-20, 30)
skew.ax.set_ylim(1000, 100)

# Add the relevant special lines
skew.plot_dry_adiabats()
skew.plot_moist_adiabats()
skew.plot_mixing_lines()

return fig

Expand Down Expand Up @@ -73,26 +77,32 @@ def test_profile():
def test_skewt_shade_cape_cin(test_profile):
"""Test shading CAPE and CIN on a SkewT plot."""
p, t, tp = test_profile
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)
skew.plot(p, t, 'r')
skew.plot(p, tp, 'k')
skew.shade_cape(p, t, tp)
skew.shade_cin(p, t, tp)
skew.ax.set_xlim(-50, 50)

with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)
skew.plot(p, t, 'r')
skew.plot(p, tp, 'k')
skew.shade_cape(p, t, tp)
skew.shade_cin(p, t, tp)
skew.ax.set_xlim(-50, 50)

return fig


@pytest.mark.mpl_image_compare(tolerance={'1.4': 1.70}.get(MPL_VERSION, 0.), remove_text=True)
def test_skewt_shade_area(test_profile):
"""Test shading areas on a SkewT plot."""
p, t, tp = test_profile
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)
skew.plot(p, t, 'r')
skew.plot(p, tp, 'k')
skew.shade_area(p, t, tp)
skew.ax.set_xlim(-50, 50)

with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)
skew.plot(p, t, 'r')
skew.plot(p, tp, 'k')
skew.shade_area(p, t, tp)
skew.ax.set_xlim(-50, 50)

return fig


Expand All @@ -111,12 +121,14 @@ def test_skewt_shade_area_invalid(test_profile):
def test_skewt_shade_area_kwargs(test_profile):
"""Test shading areas on a SkewT plot with kwargs."""
p, t, tp = test_profile
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)
skew.plot(p, t, 'r')
skew.plot(p, tp, 'k')
skew.shade_area(p, t, tp, facecolor='m')
skew.ax.set_xlim(-50, 50)

with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
fig = plt.figure(figsize=(9, 9))
skew = SkewT(fig)
skew.plot(p, t, 'r')
skew.plot(p, tp, 'k')
skew.shade_area(p, t, tp, facecolor='m')
skew.ax.set_xlim(-50, 50)
return fig


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -52,7 +52,7 @@
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
install_requires=['matplotlib>=1.4', 'numpy>=1.11.0', 'scipy>=0.14',
'pint>=0.8', 'xarray>=0.10.7', 'enum34;python_version<"3.4"',
'pooch==0.1'],
'pooch==0.1.*'],
extras_require={
'cdm': ['pyproj>=1.9.4'],
'dev': ['ipython[all]>=3.1'],
Expand Down
10 changes: 5 additions & 5 deletions tutorials/xarray_tutorial.py
Expand Up @@ -205,6 +205,7 @@

# Let's add a projection and coastlines to it
ax = plt.axes(projection=ccrs.LambertConformal())
ax._hold = True # Work-around for CartoPy 0.16/Matplotlib 3.0.0 incompatibility
data['height'].loc[time[0]].loc[{vertical.name: 500.}].plot(ax=ax, transform=data_crs)
ax.coastlines()
plt.show()
Expand Down Expand Up @@ -232,13 +233,12 @@

# Plot heights and temperature as contours
h_contour = ax.contour(x, y, data_level['height'], colors='k', levels=range(5400, 6000, 60))
h_contour_label = plt.clabel(h_contour, fontsize=8, colors='k', inline=1, inline_spacing=8,
fmt='%i', rightside_up=True, use_clabeltext=True)
h_contour.clabel(fontsize=8, colors='k', inline=1, inline_spacing=8,
fmt='%i', rightside_up=True, use_clabeltext=True)
t_contour = ax.contour(x, y, data_level['temperature'], colors='xkcd:deep blue',
levels=range(248, 276, 2), alpha=0.8, linestyles='--')
t_contour_label = plt.clabel(t_contour, fontsize=8, colors='xkcd:deep blue', inline=1,
inline_spacing=8, fmt='%i', rightside_up=True,
use_clabeltext=True, alpha=0.8)
t_contour.clabel(fontsize=8, colors='xkcd:deep blue', inline=1, inline_spacing=8,
fmt='%i', rightside_up=True, use_clabeltext=True)

# Add geographic features
ax.add_feature(cfeature.LAND.with_scale('50m'), facecolor=cfeature.COLORS['land'])
Expand Down