Cartopy 倒钩无法正常工作
Cartopy barbs not working properly
我正在尝试绘制北太平洋投影上的 250 hPa 位势高度、1000 hPa 可降水量和 250 hPa 风。尝试使用倒钩时,我没有收到错误,但倒钩并没有实际显示在地图上。我认为这可能与我的数据投影到 cartopy 投影有关,但我对 cartopy 很陌生,不太明白发生了什么。如果有人注意到我的总体预测被搞砸了,我不会介意一些方向。谢谢!
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
The plot
您对调用 barbs
的投影将 transform
参数作为 LambertConformal()
,但看起来您正在传递位置的纬度和经度值。将 transform
更改为 PlateCarree()
,就像您在其他绘图方法中使用的那样。
我正在尝试绘制北太平洋投影上的 250 hPa 位势高度、1000 hPa 可降水量和 250 hPa 风。尝试使用倒钩时,我没有收到错误,但倒钩并没有实际显示在地图上。我认为这可能与我的数据投影到 cartopy 投影有关,但我对 cartopy 很陌生,不太明白发生了什么。如果有人注意到我的总体预测被搞砸了,我不会介意一些方向。谢谢!
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
The plot
您对调用 barbs
的投影将 transform
参数作为 LambertConformal()
,但看起来您正在传递位置的纬度和经度值。将 transform
更改为 PlateCarree()
,就像您在其他绘图方法中使用的那样。