Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 5 additions & 1 deletion lib/iris/plot.py
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -873,6 +873,10 @@ 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.
Expand Down
20 changes: 20 additions & 0 deletions lib/iris/tests/integration/plot/test_vector_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E127 continuation line over-indented for visual indent

lon = DimCoord(np.arange(0, 360, res), 'longitude',
units='degrees_east')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E127 continuation line over-indented for visual indent

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')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E127 continuation line over-indented for visual indent

v_cube = Cube(v_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)],
standard_name='northward_wind')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E127 continuation line over-indented for visual indent

u_cube.coord('longitude').circular = True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also set circular=True for v_cube?
I know we don't explicitly do a compatibility check for the u_cube and v_cube as it is still a TODO but once that is fixed, it would throw up an error about the longitude coordinates being different on u_cube and v_cube.

Also, you could do it when you initialise the lon, i.e.:

lon = DimCoord(np.arange(0, 360, res), 'longitude',
                       units='degrees_east', circular=True)

As that would apply to both u_cube and v_cube


self.plot('circular', u_cube, v_cube,
coords=('longitude', 'latitude'))


class TestQuiver(MixinVectorPlotCases, tests.GraphicsTest):
def setUp(self):
Expand Down