2016-01-23 47 views
0

数据我试图绘制使用pygrib GFS数据的简单温度图。我使用的示例从下面的链接: -matplotlib一点儿也不情节上底图

http://jswhit.github.io/pygrib/docs/index.html http://polar.ncep.noaa.gov/waves/examples/usingpython.shtml

这里是我试图做示例代码: -

import pygrib 
import matplotlib.pyplot as plt 
from mpl_toolkits.basemap import Basemap 
import numpy as np 

grib = 'data/gfs.t00z.pgrb2f00' 
grbs = pygrib.open(grib) 

grbs.seek(0) 
grb = grbs.select(name='Temperature')[0] 
data, lats, lons = grb.data(lat1=0,lat2=35,lon1=60,lon2=100) 
print data # <<--- This has some values but not plotted in the map. 
m = Basemap(projection='merc', llcrnrlat=0, urcrnrlat=35,\ 
       llcrnrlon=60, urcrnrlon=100, resolution='c') 

x, y = m(lats, lons) 
m.drawcoastlines() 
cs = m.pcolor(x, y, np.squeeze(data)) 
m.colorbar(cs, location='bottom', pad="10%") 
plt.title('Simple temperature plot from GRiB') 
plt.show() 

终端输出显示数据的上'的可用性数据'变量: -

python2.7 grib_plot.py 
[[ 225.8 225.8 225.8 ..., 225.9 225.8 225.7] 
[ 225.7 225.7 225.6 ..., 225.8 225.8 225.7] 
[ 225.6 225.6 225.5 ..., 225.8 225.8 225.8] 
..., 
[ 229.1 229.1 229.1 ..., 231.1 230.8 230.6] 
[ 228.3 228.5 228.8 ..., 231.3 230.7 230.5] 
[ 227.4 227.8 228.3 ..., 231.6 231.1 230.8]] 

但是,由此产生的图像不显示temperatu的绘图再

sample grib data temp plot

任何有助于解决这一问题表示赞赏。

回答

0

这是我的不好,我用错编码。它应该是

x, y = m(lons, lats)

它现在。