从数据中提取点的更简单方法?

Easier way to extract points from data?

我正在分析天气模型的输出,使用 python 模块 netCDF4 并使用 mpl_toolkits 底图制作图像。

我做了一些气压等高线图,这很容易。现在想给风加个倒钩,结果是a plot with only wind over the seas. After some fiddling around, I discovered that the basemap function fillcontinents() actually overlays these wind barbs, even though the barbs function is called later. So, removing the fillcontinents() function gave all wind barbs as wanted.

有没有办法填满大陆,但我所有的倒钩仍然在情节中?

我的代码看起来有点像这样(我遗漏了一些图形参数,它们对我的问题并不重要):

from netCDF4 import Dataset
from mpl_toolkits.basemap import Basemap
import numpy as np

file = 'W:/projects/wrfout_d01_2013-10-27_120000'
data = Dataset(file)

# Load grid
longrid = data.variables['XLONG'][:].squeeze() # Removes time dimension
latgrid = data.variables['XLAT'][:].squeeze()

# Load surface pressure
p_surf = data.variables['PSFC'][:].squeeze()

# Load wind components
u = data.variables['U10'][:].squeeze()
v = data.variables['V10'][:].squeeze()

m = Basemap(projection='cyl', resolution='l',
                    llcrnrlat= 42., llcrnrlon= -12.,
                    urcrnrlat= 57., urcrnrlon= 12.)
m.drawcountries()
m.drawcoastlines()
m.fillcontinents('#FAF0E6') ### Blanking out this line gives barbs over land
m.drawmeridians(np.arange(-180,180,10),labels=[0,0,1,1])
m.drawparallels(np.arange(-90,90,10),labels=[1,0,0,0])

x,y = m(longrid,latgrid)
ct = m.contour(x,y,p_surf, colors='#1C8CFC') ### So far, so good
ct.clabel(fmt='%1i')

m.barbs(x,y,u,v)

plt.savefig('p_surf-barbs-map.png')

在 Paul 的帮助下,我找到了解决方案:

绘制倒钩时,添加一个具有高值(我使用 100)的变量 zorder,如下所示:

m.barbs(x, y, u, v, zorder=100)