Reputation: 1061
I'm trying to plot 250 hPa geopotential heights, 1000 hPa precipitable water, and 250 hPa winds over a north Pacific projection. When trying to use barbs, I don't get an error, but the barbs don't physically show up on the map. I think it may have something to do with the projection of my data onto the cartopy projection, but I'm quite new to cartopy and don't quite understand what is happening. If someone notices that my projections in general are screwed up, I wouldn't mind some direction. Thanks!
def plotMap():
proj = ccrs.LambertConformal(central_longitude=-165, central_latitude=30, standard_parallels=[53])
fig, ax = plt.subplots(subplot_kw=dict(projection=proj))
ax.set_extent([235 ,160 , 5, 60], crs=ccrs.PlateCarree())
ax.add_feature(cfeature.LAND, facecolor='0.9')
ax.add_feature(cfeature.LAKES, alpha=0.9)
ax.add_feature(cfeature.BORDERS, zorder=10)
ax.add_feature(cfeature.COASTLINE, zorder=10)
states_provinces = cfeature.NaturalEarthFeature(category='cultural',
name='admin_1_states_provinces_lines', scale='50m', facecolor='none')
ax.add_feature(states_provinces, edgecolor='gray', zorder=10)
ax.gridlines(xlocs=np.arange(0,361,20), ylocs=np.arange(-80,90,20))
return fig, ax
fig, ax = plotMap()
hght_levels = np.arange(9500,11250,250)
hght_contour=ax.contour(lon, lat, g, colors='k', levels=hght_levels,
linewidths=1, zorder=3, transform = ccrs.PlateCarree())
wind_levels = np.arange(0, 110, 10)
wind_contour = ax.contour(lon, lat, wind, levels = wind_levels,
linewidths=5, zorder=0.8, transform = ccrs.PlateCarree())
pwat_levels = np.linspace(0, 50, 9)
pwat_contour = ax.contourf(lon, lat, pwat, levels = pwat_levels,
cmap=plt.cm.plasma, zorder=1.0, transform =
ccrs.PlateCarree())
cb = plt.colorbar(pwat_contour, shrink=0.5)
cb.set_ticklabels(pwat_levels)
urel = u.values*1.944
vrel = v.values*1.944
ax.barbs(lon, lat, urel, vrel, regrid_shape=12 transform=ccrs.LambertConformal())
plt.clabel(hght_contour, hght_levels, zorder=20, inline=1,inline_spacing=3,
fmt='%1i', fontsize=12)
fig
Upvotes: 1
Views: 703
Reputation: 5843
Your projection on the call barbs
gives the transform
argument as LambertConformal()
, but it looks like you're passing in latitude and longitude values for position. Change transform
to PlateCarree()
, as you use in the other plot methods.
Upvotes: 2