本文整理汇总了Python中matplotlib.toolkits.basemap.Basemap.makegrid方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.makegrid方法的具体用法?Python Basemap.makegrid怎么用?Python Basemap.makegrid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.makegrid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: projection
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import makegrid [as 别名]
from matplotlib.toolkits.basemap import Basemap, interp
from pylab import *
import cPickle
# read in data on lat/lon grid.
datadict = cPickle.load(open('500hgt.pickle','rb'))
hgt = datadict['data']; lons = datadict['lons']; lats = datadict['lats']
# set up map projection (lambert azimuthal equal area).
m = Basemap(-150.,-20.,30.,-20.,
resolution='c',area_thresh=10000.,projection='laea',
lat_0=90.,lon_0=-105.)
# interpolate to map projection grid.
nx = 101
ny = 101
lonsout, latsout = m.makegrid(nx,ny)
# get rid of negative lons.
lonsout = where(lonsout < 0., lonsout + 360., lonsout)
hgt = interp(hgt,lons,lats,lonsout,latsout)
dx = (m.xmax-m.xmin)/(nx-1)
dy = (m.ymax-m.ymin)/(ny-1)
x = m.xmin+dx*indices((ny,nx))[1,:,:]
y = m.ymin+dy*indices((ny,nx))[0,:,:]
#m = Basemap(lons[0],lats[0],lons[-1],lats[-1],\
# resolution='c',area_thresh=10000.,projection='cyl')
#x, y = meshgrid(lons, lats)
fig = figure(figsize=(8,8))
plots = ['contour','pcolor']
示例2: m
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import makegrid [as 别名]
pylab.subplot(211)
ax = pylab.gca()
# draw coastlines, state and country boundaries, edge of map.
m.drawcoastlines()
m.drawstates()
m.drawcountries()
# draw parallels.
delat = 10.0
parallels = pylab.arange(0.,90,delat)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
delon = 10.
meridians = pylab.arange(180.,360.,delon)
m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
ny = data.shape[0]; nx = data.shape[1]
lons, lats = m.makegrid(nx, ny) # get lat/lons of ny by nx evenly space grid.
x, y = m(lons, lats) # compute map proj coordinates.
# draw filled contours.
clevs = [0,1,2.5,5,7.5,10,15,20,30,40,50,70,100,150,200,250,300,400,500,600,750]
cs = m.contourf(x,y,data,clevs,cmap=cm.s3pcpn)
# new axis for colorbar.
l,b,w,h=ax.get_position()
cax = pylab.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
# draw colorbar.
pylab.colorbar(cs, cax, format='%g', ticks=clevs, drawedges=False)
pylab.axes(ax) # make the original axes current again
# plot title
pylab.title(plottitle+'- contourf',fontsize=10)
pylab.subplot(212)
ax = pylab.gca()