From 5f655f4ccb57ed26c65b325da8e0d67637c77e08 Mon Sep 17 00:00:00 2001 From: "stephen.worsley" Date: Wed, 21 Aug 2019 15:05:02 +0100 Subject: [PATCH 1/6] Fix circular quiver plots --- lib/iris/plot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/iris/plot.py b/lib/iris/plot.py index 88f89cc79a..46ce82314b 100644 --- a/lib/iris/plot.py +++ b/lib/iris/plot.py @@ -873,6 +873,11 @@ def _map_common(draw_method_name, arg_func, mode, cube, plot_defn, y = np.append(y, y[:, 0:1], axis=1) x = np.append(x, x[:, 0:1] + 360 * direction, axis=1) data = ma.concatenate([data, data[:, 0:1]], axis=1) + if '_v_data' in kwargs: + v_data = kwargs['_v_data'] + v_data = ma.concatenate([v_data, v_data[:, 0:1]], axis=1) + kwargs['_v_data'] = v_data + # Replace non-cartopy subplot/axes with a cartopy alternative and set the # transform keyword. From 2f38a70d78abedbe8827ba90dc30948dce78d480 Mon Sep 17 00:00:00 2001 From: "stephen.worsley" Date: Wed, 21 Aug 2019 15:16:20 +0100 Subject: [PATCH 2/6] Fix circular quiver plots --- lib/iris/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iris/plot.py b/lib/iris/plot.py index 46ce82314b..3be7a39560 100644 --- a/lib/iris/plot.py +++ b/lib/iris/plot.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2010 - 2018, Met Office +# (C) British Crown Copyright 2010 - 2019, Met Office # # This file is part of Iris. # From d47fc7a56b5618651e020299c7333d446d614fd8 Mon Sep 17 00:00:00 2001 From: "stephen.worsley" Date: Wed, 21 Aug 2019 15:55:20 +0100 Subject: [PATCH 3/6] Edit whitespace --- lib/iris/plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/iris/plot.py b/lib/iris/plot.py index 3be7a39560..43cf206e0e 100644 --- a/lib/iris/plot.py +++ b/lib/iris/plot.py @@ -878,7 +878,6 @@ def _map_common(draw_method_name, arg_func, mode, cube, plot_defn, v_data = ma.concatenate([v_data, v_data[:, 0:1]], axis=1) kwargs['_v_data'] = v_data - # Replace non-cartopy subplot/axes with a cartopy alternative and set the # transform keyword. kwargs = _ensure_cartopy_axes_and_determine_kwargs(x_coord, y_coord, From 936a7e74b838e39023cd79534fd3902ef158f062 Mon Sep 17 00:00:00 2001 From: "stephen.worsley" Date: Wed, 21 Aug 2019 16:15:45 +0100 Subject: [PATCH 4/6] Added a test --- .../integration/plot/test_vector_plots.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/iris/tests/integration/plot/test_vector_plots.py b/lib/iris/tests/integration/plot/test_vector_plots.py index 497ff3549d..196ddee95c 100644 --- a/lib/iris/tests/integration/plot/test_vector_plots.py +++ b/lib/iris/tests/integration/plot/test_vector_plots.py @@ -167,6 +167,26 @@ def test_fail_unsupported_coord_system(self): self.plot('2d_rotated', u_cube, v_cube, coords=('longitude', 'latitude')) + def test_circular_longitude(self): + # Test circular longitude does not cause a crash. + res = 5 + lat = DimCoord(np.arange(-90, 91, res), 'latitude', + units='degrees_north') + lon = DimCoord(np.arange(0, 360, res), 'longitude', + units='degrees_east') + nlat = len(lat.points) + nlon = len(lon.points) + u_arr = np.ones((nlat, nlon)) + v_arr = np.ones((nlat, nlon)) + u_cube = Cube(u_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)], + standard_name='eastward_wind') + v_cube = Cube(v_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)], + standard_name='northward_wind') + u_cube.coord('longitude').circular = True + + self.plot('circular', u_cube, v_cube, + coords=('longitude', 'latitude')) + class TestQuiver(MixinVectorPlotCases, tests.GraphicsTest): def setUp(self): From fa7f0560016b93f3bde968913a0d1587b67c9789 Mon Sep 17 00:00:00 2001 From: "stephen.worsley" Date: Wed, 21 Aug 2019 16:18:06 +0100 Subject: [PATCH 5/6] Fix whitespace --- lib/iris/tests/integration/plot/test_vector_plots.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/iris/tests/integration/plot/test_vector_plots.py b/lib/iris/tests/integration/plot/test_vector_plots.py index 196ddee95c..412695db56 100644 --- a/lib/iris/tests/integration/plot/test_vector_plots.py +++ b/lib/iris/tests/integration/plot/test_vector_plots.py @@ -171,17 +171,17 @@ def test_circular_longitude(self): # Test circular longitude does not cause a crash. res = 5 lat = DimCoord(np.arange(-90, 91, res), 'latitude', - units='degrees_north') + units='degrees_north') lon = DimCoord(np.arange(0, 360, res), 'longitude', - units='degrees_east') + units='degrees_east') nlat = len(lat.points) nlon = len(lon.points) u_arr = np.ones((nlat, nlon)) v_arr = np.ones((nlat, nlon)) u_cube = Cube(u_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)], - standard_name='eastward_wind') + standard_name='eastward_wind') v_cube = Cube(v_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)], - standard_name='northward_wind') + standard_name='northward_wind') u_cube.coord('longitude').circular = True self.plot('circular', u_cube, v_cube, From 36c0fdc4fe6083b01028dff32f147d27285629c6 Mon Sep 17 00:00:00 2001 From: "stephen.worsley" Date: Fri, 30 Aug 2019 13:35:39 +0100 Subject: [PATCH 6/6] Test with circular longitude in both coords --- lib/iris/tests/integration/plot/test_vector_plots.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/iris/tests/integration/plot/test_vector_plots.py b/lib/iris/tests/integration/plot/test_vector_plots.py index 412695db56..7785cc65ed 100644 --- a/lib/iris/tests/integration/plot/test_vector_plots.py +++ b/lib/iris/tests/integration/plot/test_vector_plots.py @@ -173,7 +173,7 @@ def test_circular_longitude(self): lat = DimCoord(np.arange(-90, 91, res), 'latitude', units='degrees_north') lon = DimCoord(np.arange(0, 360, res), 'longitude', - units='degrees_east') + units='degrees_east', circular=True) nlat = len(lat.points) nlon = len(lon.points) u_arr = np.ones((nlat, nlon)) @@ -182,7 +182,6 @@ def test_circular_longitude(self): standard_name='eastward_wind') v_cube = Cube(v_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)], standard_name='northward_wind') - u_cube.coord('longitude').circular = True self.plot('circular', u_cube, v_cube, coords=('longitude', 'latitude'))