Skip to content

Commit

Permalink
Merge pull request #2140 from kgoebber/bug_fix_2137
Browse files Browse the repository at this point in the history
fix bug 2137 use scale with barbs
  • Loading branch information
dcamron authored Oct 8, 2021
2 parents 3441247 + 7a47fce commit aad32f3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/metpy/plots/declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,8 +1423,8 @@ def griddata(self):
if self.plot_units is not None:
data_subset_u = data_subset_u.metpy.convert_units(self.plot_units)
data_subset_v = data_subset_v.metpy.convert_units(self.plot_units)
self._griddata_u = data_subset_u
self._griddata_v = data_subset_v
self._griddata_u = data_subset_u * self.scale
self._griddata_v = data_subset_v * self.scale

return (self._griddata_u, self._griddata_v)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions tests/plots/test_declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,36 @@ def test_declarative_barb_gfs():
return pc.figure


@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.607)
@needs_cartopy
def test_declarative_barb_scale():
"""Test making a contour plot."""
data = xr.open_dataset(get_test_data('GFS_test.nc', as_file_obj=False))

barb = BarbPlot()
barb.data = data
barb.level = 300 * units.hPa
barb.field = ['u-component_of_wind_isobaric', 'v-component_of_wind_isobaric']
barb.skip = (3, 3)
barb.earth_relative = False
barb.scale = 2

panel = MapPanel()
panel.area = 'us'
panel.projection = 'data'
panel.layers = ['coastline', 'borders', 'usstates']
panel.plots = [barb]

pc = PanelContainer()
pc.size = (8, 8)
pc.panels = [panel]
pc.draw()

barb.level = 700 * units.hPa

return pc.figure


@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.466)
@needs_cartopy
def test_declarative_barb_gfs_knots():
Expand Down

0 comments on commit aad32f3

Please sign in to comment.