Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions lib/iris/tests/integration/plot/test_vector_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ def test_2d_plain_latlon(self):
ax.set_global()
self.check_graphic()

def test_2d_plain_latlon_on_polar_map(self):
# Test 2d vector plotting onto a different projection.
u_cube, v_cube = self._latlon_uv_cubes(sample_2d_latlons())
ax = plt.axes(projection=ccrs.NorthPolarStereo())
self.plot("latlon_2d_polar", u_cube, v_cube, coords=("longitude", "latitude"))
ax.coastlines(resolution="110m", color="red")
self.check_graphic()

def test_2d_rotated_latlon(self):
# Test plotting vectors in a rotated latlon coord system.
u_cube, v_cube = self._latlon_uv_cubes(sample_2d_latlons(rotated=True))
Expand Down Expand Up @@ -188,19 +180,47 @@ def _nonlatlon_xyuv():
return x, y, u, v

@staticmethod
def _latlon_uv_cubes(grid_cube):
def _latlon_uv_cubes(grid_cube, scale_factor=30):
# Increase the range of wind speeds used in the barbs test to test all
# barbs shapes
u_cube, v_cube = MixinVectorPlotCases._latlon_uv_cubes(grid_cube)
scale_factor = 30
u_cube.data *= scale_factor
v_cube.data *= scale_factor
return u_cube, v_cube

def plot_function_to_test(self):
return barbs

def test_2d_plain_latlon_on_polar_map(self):
# Test 2d vector plotting onto a different projection.

# use a scale factor that ensures the barb vector magnitudes fall
# sufficiently within the default matplotlib barb bins in order to
# avoid floating point issues where barbs flip/flop between bins.
#
# TODO: if the barb tests prove to be volatile to floating-point
# flip/flopping, then we could back-out this specialization and
# re-spin the barbs imagehash with a common scale_factor=30.1 for
# all TestBarbs tests.
scale_factor = 30.1

u_cube, v_cube = self._latlon_uv_cubes(
sample_2d_latlons(), scale_factor=scale_factor
)
ax = plt.axes(projection=ccrs.NorthPolarStereo())
self.plot("latlon_2d_polar", u_cube, v_cube, coords=("longitude", "latitude"))
ax.coastlines(resolution="110m", color="red")
self.check_graphic()


class TestQuiver(MixinVectorPlotCases, _shared_utils.GraphicsTest):
def plot_function_to_test(self):
return quiver

def test_2d_plain_latlon_on_polar_map(self):
# Test 2d vector plotting onto a different projection.
u_cube, v_cube = self._latlon_uv_cubes(sample_2d_latlons())
ax = plt.axes(projection=ccrs.NorthPolarStereo())
self.plot("latlon_2d_polar", u_cube, v_cube, coords=("longitude", "latitude"))
ax.coastlines(resolution="110m", color="red")
self.check_graphic()
Loading
Loading