本文整理汇总了Python中matplotlib.toolkits.basemap.Basemap.transform_scalar方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.transform_scalar方法的具体用法?Python Basemap.transform_scalar怎么用?Python Basemap.transform_scalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.transform_scalar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: map
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import transform_scalar [as 别名]
P.title("Blue Marble image - native 'cyl' projection",fontsize=12)
print 'plot cylindrical map (no warping needed) ...'
# create new figure
fig=P.figure()
# define orthographic projection centered on North America.
m = Basemap(projection='ortho',lat_0=40,lon_0=40,resolution='l')
# transform to nx x ny regularly spaced native projection grid
# nx and ny chosen to have roughly the same horizontal res as original image.
dx = 2.*P.pi*m.rmajor/float(nlons)
nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
rgba_warped = ma.zeros((ny,nx,4),P.Float64)
# interpolate rgba values from proj='cyl' (geographic coords) to 'lcc'
# values outside of projection limb will be masked.
for k in range(4):
rgba_warped[:,:,k] = m.transform_scalar(rgba[:,:,k],lons,lats,nx,ny,masked=True)
# make points outside projection limb transparent.
rgba_warped = rgba_warped.filled(0.)
# plot warped rgba image.
im = m.imshow(rgba_warped)
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines every 30 degrees.
m.drawmeridians(P.arange(0,360,30),color='0.5')
m.drawparallels(P.arange(-90,90,30),color='0.5')
P.title("Blue Marble image warped from 'cyl' to 'ortho' projection",fontsize=12)
print 'warp to orthographic map ...'
# create new figure
fig=P.figure()
# define Lambert Conformal basemap for North America.
示例2: arange
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import transform_scalar [as 别名]
arange(-delat,-90.-delat,-delat).tolist()
m.drawparallels(circles,labels=[1,0,0,1])
# draw meridians
delon = 60.
meridians = arange(-180,180,delon)
m.drawmeridians(meridians,labels=[1,0,0,1])
title('Cylindrical Equidistant')
print 'plotting Cylindrical Equidistant example, close plot window to proceed ...'
show()
# setup miller cylindrical map projection.
m = Basemap(-180.,-90.,180.,90.,\
resolution='c',area_thresh=10000.,projection='mill')
# transform to nx x ny regularly spaced native projection grid
nx = len(lons); ny = len(lats)
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# setup figure with same aspect ratio as map.
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
fig.add_axes([0.1,0.1,0.75,0.75])
# plot image over map.
im = m.imshow(topodat,cm.jet)
m.drawcoastlines()
# draw parallels
m.drawparallels(circles,labels=[1,1,1,1])
# draw meridians
m.drawmeridians(meridians,labels=[1,1,1,1])
title('Miller Cylindrical',y=1.1)
print 'plotting Miller Cylindrical example, close plot window to proceed ...'
show()
示例3: array
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import transform_scalar [as 别名]
# longitudes go from 20 to 380.
topoin = array(load('etopo20data.gz'),'d')
lons = array(load('etopo20lons.gz'),'d')
lats = array(load('etopo20lats.gz'),'d')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
# setup of basemap ('lcc' = lambert conformal conic).
# use major and minor sphere radii from WGS84 ellipsoid.
m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
rsphere=(6378137.00,6356752.3142),\
resolution='l',area_thresh=1000.,projection='lcc',\
lat_1=50.,lon_0=-107.)
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat,x,y = m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True)
# create the figure.
fig=figure(figsize=(8,8))
# add an axes, leaving room for colorbar on the right.
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map with imshow.
im = m.imshow(topodat,cm.jet)
# setup colorbar axes instance.
l,b,w,h = ax.get_position()
cax = axes([l+w+0.075, b, 0.05, h])
colorbar(tickfmt='%d', cax=cax) # draw colorbar
axes(ax) # make the original axes current again
# plot blue dot on boulder, colorado and label it as such.
xpt,ypt = m(-104.237,40.125)
m.plot([xpt],[ypt],'bo')
text(xpt+100000,ypt+100000,'Boulder')
示例4: shiftgrid
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import transform_scalar [as 别名]
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']
# shift data so lons go from -180 to 180 instead of 0 to 360.
hgt,lons = shiftgrid(180.,hgt,lons,start=False)
# set up map projection (lambert azimuthal equal area).
m = Basemap(-135.,-20.,45.,-20.,
resolution='c',area_thresh=10000.,projection='laea',
lat_0=90.,lon_0=-90.)
# transform to map projection coordinates.
nx = 101; ny = 101
hgt,x,y = m.transform_scalar(hgt,lons,lats,nx,ny,returnxy=True)
fig = figure(figsize=(8,8))
plots = ['contour','pcolor']
#plots = ['contour','imshow']
for np,plot in enumerate(plots):
fig.add_subplot(1,2,np+1)
ax = gca()
# plot data.
print plot+' plot ...'
if plot == 'pcolor':
m.pcolor(x,y,hgt,shading='flat')