Reputation: 107
I've recently switched from Basemap to Cartopy and am having some trouble plotting wind vectors. I've got a North Polar Stereographic projection (central_longitude=-100.0) with extent [-180,180,10,90]. I have a netCDF dataset with u,v wind values every 0.5 deg latitude and longitude.
If I plot the barbs using slice to manually skip a certain number (since the data is too dense to plot all of it), I get what appears to be a correct representation of the field (see first image below):
sknum = 15
skip=(slice(None,None,sknum),slice(None,None,sknum))
ax.barbs(lons[skip], lats[skip], u[skip],v[skip], length=6,
sizes=dict(emptybarb=0.25, spacing=.2, height=0.5),
zorder = 20,
linewidth=0.95, transform= ccrs.PlateCarree())
However, this method looks a bit unnatural and is too dense near the pole. Using the regrid_shape feature of cartopy gives me a worse error (see second image), with rows of the same vector over and over.
ax.barbs(lons, lats, u,v, length=6,
sizes=dict(emptybarb=0.25, spacing=.2, height=0.5),
zorder = 20,
linewidth=0.95, transform= ccrs.PlateCarree(), regrid_shape=20)
Is this a bug for regrid_shape under this projection, am I doing something wrong, and/or is there another way for me to get natural-looking vectors?
Upvotes: 2
Views: 2607
Reputation: 3333
This seems to be a problem transforming vectors at the poles for this projection. If you remove the pole points from your input data the regridding will work as expected. It doesn't really make sense to plot a vector field that is multi-valued at the pole anyway, especially not in this projection where the pole is a single point, so you won't be doing anything untoward by removing data at the pole.
Upvotes: 1