你好地球科学江南体育网页版社区,gydF4y2Ba
我是一个初学者Python程序员试图阴谋一个时间步长10米表面风从ECMWF ERA5我抓起的数据再分析单一数据集在Python 3.8.1 mac (mac OS莫哈韦10.14.6)。我有一些麻烦,我技术上的风矢量图的密度,从我的代码产生的情节附近产生一个黑色屏幕。下面是我在工作的代码。注意,情节也会显示平均海平面压力从一个时间步,我已经能够情节这成功。gydF4y2Ba
进口pygrib进口numpy np matplotlib导入。pyplot mpl_toolkits plt。技术从mpl_toolkits进口技术。技术进口shiftgrid # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #有用链接https://confluence.ecmwf.int/display/CKB/How,我发现这些代码# + +和+ +情节+格丽+文件Python +和+ matplotlib # //www.hoelymoley.com/questions/7012/plotting-wind-barbs-in-python # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - plt.clf()图= plt。图(figsize =(10,10)) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #设置基础图的纬度/经度坐标投影(默认投影=圆柱equadistant) lllon = -170 lllat = 10 urlon = -110 urlat = 61 #纬度/经度坐标以及策划时间间隔设置为轴画纬度/经度情节latmin = 0 latmax = 70 lonmin = -180 lonmax = -100 latinterval = 20 loninterval = 20 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #创建技术和添加一些地理内容为绘图数据创建一个好的起点bmap =基础图(llcrnrlon = lllon llcrnrlat = lllat urcrnrlon = urlon urcrnrlat = urlat分辨率= f, epsg = 3311) bmap.drawcoastlines(线宽= 2,zorder = 1) bmap。drawstates(线宽= 2,zorder = 1) bmap.drawcountries(线宽= 2,zorder = 1) bmap.drawlsmask (land_color =‘白’,ocean_color =‘白’,湖泊=‘假’,分辨率= f) bmap.drawparallels (np。不等(latmin latmax latinterval),标签=(1,0,0,0),颜色=“k”,输入textcolor =“k”,线宽= 2,字形大小= 14)bmap.drawmeridians (np。不等(lonmax铂金生产商lonmin loninterval),标签=[0,0,0,1],颜色=“k”,输入textcolor =“k”,线宽= 2,字形大小= 14)# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #读ERA5格丽= '下载文件并抓住MSLP值文件。格丽的grb = pygrib.open(文件)grb_mslp = grbs.select () [2] # MSLP 2012-03-26 = grb_mslp @00UTC数据。值# MSLP值在Pa # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #设置绘图参数经度和背阔肌。转变朗投影是-180年到180年(0 - 360)#创建均匀间隔的使用,网格点的经度。int (grb (Ni)) = 1440(360/0.25)朗= np.linspace(浮动(grb_mslp [' longitudeOfFirstGridPointInDegrees ']), \浮动(grb_mslp [' longitudeOfLastGridPointInDegrees ']), int (grb_mslp['倪']))#创建等间距的背阔肌使用的第一个网格点。int (grb (Nj)) = 721 (180 /。25+ 1) lats = np.linspace(float(grb['latitudeOfFirstGridPointInDegrees']), \ float(grb['latitudeOfLastGridPointInDegrees']), int(grb_mslp['Nj']) ) #Grid shifting of lons. Not exactly sure how function works. data, lons = shiftgrid(180., data, lons, start=False) grid_lon, grid_lat = np.meshgrid(lons, lats) #regularly spaced 2D grid. Still not sure how this works. #--------------------------------------------------------------------------------------------- #Plotting MSLP on basemap x,y = bmap(grid_lon,grid_lat) #Pass ERA5 lat/lon to basemap cs = bmap.contour(x,y,data/100,10,colors='r') #Plot MSLP contours. Divide by 100 = mb plt.clabel(cs,inline=1,inline_spacing=5,fontsize=10,fmt='%1.1f') #Add labels to contours #--------------------------------------------------------------------------------------------- #Repeat process for other parameters until I figure out a better method grb_uwind = grbs.select()[0] #U 10m wind component for 2012-03-26 @00UTC grb_vwind = grbs.select()[1] #V 10m wind component for 2012-03-26 @00UTC data_uwind = grb_uwind.values #U 10m wind values in m/s data_vwind = grb_vwind.values #V 10m wind values in m/s #--------------------------------------------------------------------------------------------- #Plotting wind on basemap x,y = bmap(grid_lon,grid_lat) #Pass ERA5 lat/lon to basemap barbs = plt.quiver(x,y,data_uwind,data_vwind) #Plot 10m wind in m/s
唯一的解决办法我在试图阴谋每50数据点使用的符号:gydF4y2Ba
倒刺= plt.quiver (x (:: 50), y (:: 50), data_uwind [:: 50], data_vwind[:: 50]) #情节每50 10 m风m / sgydF4y2Ba
但是这个结果没有几乎没有地图。会有人有一个想法,我怎么可能接近这个问题不正确?会是最好的试着猜和检查各种值情节而不是每50点?gydF4y2Ba
我衷心地感谢任何建议如何继续。谢谢你花时间读这篇文章。gydF4y2Ba
Google Drive格丽文件链接:gydF4y2Bahttps://drive.google.com/file/d/1XEuatdp5piyTIiADgZhxFHQ1_WghMwPJ/view?usp=sharinggydF4y2Ba