Skip to content

Commit

Permalink
fix lint and figure issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kgoebber committed Jul 10, 2023
1 parent 5b6cf9e commit 8320849
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/_templates/overrides/metpy.calc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ Other
azimuth_range_to_lat_lon
find_bounding_indices
find_intersections
find_local_extrema
get_layer
get_layer_heights
get_perturbation
Expand Down
8 changes: 4 additions & 4 deletions src/metpy/plots/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def normalize(x):

def plot_local_extrema(ax, extreme_vals, symbol, plot_val=True, **kwargs):
"""Plot the local extreme (max/min) values of an array.
The behavior of the plotting will have the symbol horizontal/vertical alignment
be center/bottom and any value plotted will be center/top. The text size of plotted
values is 0.65 of the symbol size.
Expand All @@ -309,7 +309,7 @@ def plot_local_extrema(ax, extreme_vals, symbol, plot_val=True, **kwargs):
Returns
-------
Plots local extrema on the plot axes
Other Parameters
----------------
kwargs : `matplotlib.pyplot.Text` properties.
Expand Down Expand Up @@ -345,8 +345,8 @@ def plot_local_extrema(ax, extreme_vals, symbol, plot_val=True, **kwargs):
if plot_val:
ax.text(x, y, symbol, clip_on=True, clip_box=ax.bbox, size=size,
verticalalignment='bottom', **kwargs)
ax.text(x, y, f'{extrema.values:.0f}', clip_on=True, clip_box=ax.bbox, size=textsize,
verticalalignment='top', **kwargs)
ax.text(x, y, f'{extrema.values:.0f}', clip_on=True, clip_box=ax.bbox,
size=textsize, verticalalignment='top', **kwargs)
else:
ax.text(x, y, symbol, clip_on=True, clip_box=ax.bbox, size=size,
**kwargs)
Binary file modified tests/plots/baseline/test_plot_extrema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 8 additions & 13 deletions tests/plots/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ def test_plot_extrema():
data = xr.open_dataset(get_test_data('GFS_test.nc', as_file_obj=False))

Check warning

Code scanning / CodeQL

File is not always closed Warning test

File is opened but is not closed.

mslp = data.Pressure_reduced_to_MSL_msl.squeeze()
relmax2D = find_local_extrema(mslp, 10, 'max').metpy.convert_units('hPa')
relmin2D = find_local_extrema(mslp, 15, 'min').metpy.convert_units('hPa')
relmax2d = find_local_extrema(mslp, 10, 'max').metpy.convert_units('hPa')
relmin2d = find_local_extrema(mslp, 15, 'min').metpy.convert_units('hPa')

fig = plt.figure(1, figsize=(17., 11.))
ax = plt.subplot(111, projection=ccrs.LambertConformal(central_latitude=35,
central_longitude=-100))
fig = plt.figure(figsize=(8., 8.))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.LambertConformal(central_latitude=35,
central_longitude=-100))

# Set extent and plot map lines
ax.set_extent([-124., -70, 20., 60.], ccrs.PlateCarree())
Expand All @@ -180,20 +180,15 @@ def test_plot_extrema():
ax.add_feature(cfeature.STATES.with_scale('50m'),
edgecolor='grey', linewidth=0.5)

# Plot thickness with multiple colors
clevs = (np.arange(0, 5400, 60),
np.array([5400]),
np.arange(5460, 7000, 60))

# Plot MSLP
clevmslp = np.arange(800., 1120., 4)
cs2 = ax.contour(mslp.lon, mslp.lat, mslp.metpy.convert_units('hPa'),
clevmslp, colors='k', linewidths=1.25,
linestyles='solid', transform=ccrs.PlateCarree())
plt.clabel(cs2)

plot_local_extrema(ax, relmax2D, 'H', plot_val=False, color='tab:red',
plot_local_extrema(ax, relmax2d, 'H', plot_val=False, color='tab:red',
transform=ccrs.PlateCarree())
plot_local_extrema(ax, relmin2D, 'L', color='tab:blue', transform=ccrs.PlateCarree())
plot_local_extrema(ax, relmin2d, 'L', color='tab:blue', transform=ccrs.PlateCarree())

return fig
return fig

0 comments on commit 8320849

Please sign in to comment.