2016-01-23 63 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)

它現在。