def basemap_barbs_mercator(u,v,lat,lon):
# lon/lat extents
lons = (np.amin(lon), np.amax(lon))
lats = (np.amin(lat), np.amax(lat))
# construct spherical mercator projection for region of interest
m = Basemap(projection='merc',llcrnrlat=lats[0], urcrnrlat=lats[1],
llcrnrlon=lons[0],urcrnrlon=lons[1])
#vmin,vmax = np.nanmin(grid),np.nanmax(grid)
fig = plt.figure(frameon=False,figsize=(12,8),dpi=72*4)
plt.axis('off')
m.quiver(lon,lat,u,v,latlon=True)
str_io = StringIO.StringIO()
plt.savefig(str_io,bbox_inches='tight',format='png',pad_inches=0,transparent=True)
plt.close()
numpy_bounds = [ (lons[0],lats[0]),(lons[1],lats[0]),(lons[1],lats[1]),(lons[0],lats[1]) ]
float_bounds = [ (float(x), float(y)) for x,y in numpy_bounds ]
return str_io.getvalue(), float_bounds
评论列表
文章目录