Skip to content

iplt.quiver reshapes u but not v if longitude coordinate is circular #3340

@SimonPeatman

Description

@SimonPeatman

Following a question raised on the Google Group: https://groups.google.com/forum/#!topic/scitools-iris/_w4QkS00wLU

If you do a quiver plot using Cubes with longitude coordinates which are "circular", _map_common copies the column of values at 0deg longitude and appends it to the end as 360deg longitude. However, it does this for the u data but not the v data. Therefore, the two arrays have different shapes so _vector_component_args then crashes.

e.g.:

# Imports
import numpy as np
import iris
import iris.plot as iplt
import matplotlib.pyplot as plt

# Create lat and lon coordinates
res = 5
lat = iris.coords.DimCoord(np.arange(-90, 91, res), 'latitude',
                           units='degrees_north')
lon = iris.coords.DimCoord(np.arange(0, 360, res), 'longitude',
                           units='degrees_east')

# Create u and v Cubes
nlat = len(lat.points)
nlon = len(lon.points)
u_arr = np.ones((nlat, nlon))
v_arr = np.ones((nlat, nlon))
u = iris.cube.Cube(u_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)],
                   standard_name='eastward_wind')
v = iris.cube.Cube(v_arr, dim_coords_and_dims=[(lat, 0), (lon, 1)],
                   standard_name='northward_wind')

# Try plotting
ax1 = plt.subplot(211)
iplt.quiver(u, v)   # This one works

# Try making the longitude coordinate "circular", then plot again
lon.circular = True
ax2 = plt.subplot(212)
iplt.quiver(u, v)   # This one crashes

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions