本文整理汇总了Python中matplotlib.toolkits.basemap.Basemap.drawcoastlines方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.drawcoastlines方法的具体用法?Python Basemap.drawcoastlines怎么用?Python Basemap.drawcoastlines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.drawcoastlines方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InvokeMap
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
def InvokeMap(coastfile='/media/sda4/map-data/aust-coast-noaa-2000000-1.dat',
lllon=80,
urlon=166,
lllat=-47,
urlat=-9,
draw_map=True):
global PYLIB_PATH
map = Basemap(projection='cyl',
llcrnrlon=lllon,
urcrnrlon=urlon,
llcrnrlat=lllat,
urcrnrlat=urlat,
#lat_ts=-35,
lat_0=-35,
lon_0=120,
resolution='l',
area_thresh=1000.)
try:
coast = p.load(coastfile)
coast = p.load(coastfile)
coast_x,coast_y = map(coast[:,0],coast[:,1])
p.plot(coast_x,coast_y,color='black')
except IOError:
map.drawcoastlines()
map.drawmapboundary()
map.drawmeridians(p.arange(0,360,10),labels=[0,0,1,0])
map.drawparallels(p.arange(-90,0,10),labels=[1,0,0,0])
return map
示例2: draw_client_density
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
def draw_client_density():
m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\
resolution='c',projection='cyl')
# plot them as filled circles on the map.
# first, create a figure.
dpi=100
dimx=800/dpi
dimy=400/dpi
fig=figure(figsize=(dimx,dimy), dpi=dpi, frameon=False, facecolor='blue')
# ax=fig.add_axes([0.1,0.1,0.7,0.7],axisbg='g')
ax=fig.add_axes([0.0,0.0,1.0,1.0],axisbg='g')
canvas = FigureCanvas(fig)
results = lookup_client_locations()
X,Y,Z = find_client_density(m,results)
# s = random.sample(results, 40000)
# for t in s:
# lat=t[2]
# lon=t[3]
# # draw a red dot at the center.
# xpt, ypt = m(lon, lat)
# m.plot([xpt],[ypt],'ro', zorder=10)
# draw coasts and fill continents.
m.drawcoastlines(linewidth=0.5)
m.drawcountries(linewidth=0.5)
m.drawlsmask([100,100,100,0],[0,0,255,255])
# m.fillcontinents(color='green')
palette = cm.YlOrRd
m.imshow(Z,palette,extent=(m.xmin,m.xmax,m.ymin,m.ymax),interpolation='gaussian',zorder=0)
# l,b,w,h = ax.get_position()
# cax = axes([l+w+0.075, b, 0.05, h])
# colorbar(cax=cax) # draw colorbar
canvas.print_figure(outdir+'/clientmap.png', dpi=100)
示例3: doit
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
def doit():
map = Basemap(projection='lcc',
llcrnrlon=80,
urcrnrlon=160,
llcrnrlat=-50,
urcrnrlat=-8,
#lat_ts=-35,
lat_0=-35,
lon_0=120,
resolution='c',
area_thresh=1000.)
p.clf()
map.drawcoastlines()
# map.drawcountries()
# map.drawrivers()
map.drawmeridians(p.arange(0,360,10),labels=[0,0,1,0])
map.drawparallels(p.arange(-90,0,10),labels=[1,0,0,0])
traj=p.load('example_traj.dat')
coast=p.load('/media/sda4/map-data/aust-coast-noaa-2000000-1.dat')
traj_x,traj_y = map(traj[:,1],traj[:,0])
# coast_x,coast_y = map(coast[:,0],coast[:,1])
p.plot(traj_x,traj_y)
p.plot(coast_x,coast_y,color='black')
map.drawmapboundary()
p.show()
return map
示例4: load
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
etopo = load('etopo20data.gz')
lons = load('etopo20lons.gz')
lats = load('etopo20lats.gz')
# create figure.
fig = Figure()
canvas = FigureCanvas(fig)
# create axes instance, leaving room for colorbar at bottom.
ax = fig.add_axes([0.125,0.175,0.75,0.75])
# create Basemap instance for Robinson projection.
# set 'ax' keyword so pylab won't be imported.
m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]),ax=ax)
# make filled contour plot.
x, y = m(*meshgrid(lons, lats))
cs = m.contourf(x,y,etopo,30,cmap=cm.jet)
# draw coastlines.
m.drawcoastlines()
# draw a line around the map region.
m.drawmapboundary()
# draw parallels and meridians.
m.drawparallels(nx.arange(-60.,90.,30.),labels=[1,0,0,0],fontsize=10)
m.drawmeridians(nx.arange(0.,420.,60.),labels=[0,0,0,1],fontsize=10)
# add a title.
ax.set_title('Robinson Projection')
# add a colorbar.
l,b,w,h = ax.get_position()
cax = fig.add_axes([l, b-0.1, w, 0.03],frameon=False) # setup colorbar axes
fig.colorbar(cs, cax=cax, orientation='horizontal',ticks=cs.levels[::3])
# save image (width 800 pixels with dpi=100 and fig width 8 inches).
canvas.print_figure('simpletest',dpi=100)
# done.
print 'image saved in simpletest.png'
示例5: spans
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
rgba = rgba.astype(P.Float32)/255. # convert to normalized floats.
# define lat/lon grid that image spans (projection='cyl').
nlons = rgba.shape[1]; nlats = rgba.shape[0]
delta = 360./float(nlons)
lons = P.arange(-180.+0.5*delta,180.,delta)
lats = P.arange(-90.+0.5*delta,90.,delta)
# create new figure
fig=P.figure()
# define cylindrical equidistant projection.
m = Basemap(projection='cyl',llcrnrlon=-180,llcrnrlat=-90,urcrnrlon=180,urcrnrlat=90,resolution='l')
# plot (unwarped) rgba image.
im = m.imshow(rgba)
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines.
m.drawmeridians(P.arange(-180,180,60),labels=[0,0,0,1],color='0.5')
m.drawparallels(P.arange(-90,90,30),labels=[1,0,0,0],color='0.5')
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)
示例6: Basemap
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
import matplotlib
from matplotlib.toolkits.basemap import Basemap
from pylab import *
# setup a mercator projection.
m = Basemap(-90.,30.,30.,60.,\
resolution='c',area_thresh=10000.,projection='merc',\
lat_ts=20.)
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
fig.add_axes([0.1,0.1,0.8,0.8])
ax = gca() # get current axis instance
ax.update_datalim(((m.llcrnrx, m.llcrnry),(m.urcrnrx,m.urcrnry)))
ax.set_xlim((m.llcrnrx, m.urcrnrx))
ax.set_ylim((m.llcrnry, m.urcrnry))
m.drawcoastlines(ax)
m.fillcontinents(ax)
# draw parallels
circles = [35,45,55]
m.drawparallels(ax,circles,labels=[1,1,0,1])
# draw meridians
meridians = [-90,-60,-30,0,30]
m.drawmeridians(ax,meridians,labels=[1,1,0,1])
# nylat, nylon are lat/lon of New York
nylat = 40.78
nylon = -73.98
# lonlat, lonlon are lat/lon of London.
lonlat = 51.53
lonlon = 0.08
# draw the great circle.
m.drawgreatcircle(ax,nylon,nylat,lonlon,lonlat,linewidth=2,color='b')
示例7: Basemap
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
from pyroms.focus import Focus
m = Basemap(projection='lcc',
resolution='i',
llcrnrlon=5.0,
llcrnrlat= 52.,
urcrnrlon=35.5,
urcrnrlat=68.0,
lat_0=15.00,
lon_0=0.0,
suppress_ticks=False)
fig=pl.figure()
# background color will be used for 'wet' areas.
fig.add_axes([0.1,0.1,0.8,0.8],axisbg='azure')
m.drawcoastlines(linewidth=0.25)
m.fillcontinents(color='beige')
x, y, beta = zip(*[(241782.65384467551, 1019981.3539730886, 1.0),
(263546.12512432877, 686274.79435173667, 0),
(452162.87621465814, 207478.42619936226, 1.0),
(1431519.0837990609, 432367.62942244718, 1.0),
(1409755.6125194072, 816855.62202965701, -1.0),
(1612881.344462839, 816855.62202965701, 1.0),
(1620135.83488939, 1194089.1242103155, -1.0),
(2048150.7700559068, 1302906.4806085825, 1.0),
(1982860.3562169466, 1520541.1934051164, 1.0),
(1358974.1795335496, 1447996.2891396051, -1.0),
(1344465.1986804469, 1716412.4349219969, 0),
(1620135.83488939, 2318535.1403257404, 1.0),
(1199375.3901494243, 2383825.5541647007, 1.0),
示例8: Basemap
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
res = 'i'
map = Basemap(projection=prj,
llcrnrlon=lonmin,
llcrnrlat=latmin,
urcrnrlon=lonmax,
urcrnrlat=latmax,
resolution=res)
map.plot(lon, lat, 'r-')
map.plot(lon, lat, 'k+')
fs = 10
pylab.text(115.9,-31.9, "Perth", fontsize=fs, ha='left', va='top')
pylab.text(114.1,-21.9, "Exmouth", fontsize=fs, ha='left', va='top')
pylab.text(118.5,-20.4, "Port Hedland", fontsize=fs, ha='left', va='top')
pylab.text(130.8,-12.6, "Darwin", fontsize=fs, ha='left', va='top')
pylab.text(145.75,-16.9, "Cairns", fontsize=fs, ha='right', va='top')
pylab.text(149.2,-21.2, "Mackay", fontsize=fs, ha='right', va='top')
pylab.text(153.0,-27.5, "Brisbane", fontsize=fs, ha='right', va='top')
pylab.text(153.1,-30.25, "Coffs Harbour", fontsize=fs, ha='right', va='top')
pylab.text(151.1,-33.9, "Sydney", fontsize=fs, ha='right', va='top')
pylab.text(150.5,-35.3, "Ulladulla", fontsize=fs, ha='right', va='top')
map.fillcontinents(color='0.9')
map.drawcoastlines()
map.drawparallels(parallel, label=[1,0,0,1], fontsize=8)
map.drawmeridians(meridian, label=[1,0,0,1], fontsize=8)
pylab.show()
pylab.savefig("N:\\cyclone\\sandpits\\carthur\\landfall\\gates.v0.2.png")
示例9: zip
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
#Do the necessary processing for each analysis
contours = N.arange(5300., 6000., 60.0)
parallels = N.arange(25., 60.0, 10.0)
meridians = N.arange(-120., -60.0, 10.0)
fields = (cress1, cress2, cress3, cress_187, barnes_analyses[0],
barnes_analyses[1], barnes_analyses[2], barnes_3pass)
names = ('Cressman 1st Pass', 'Cressman 2nd Pass', 'Cressman 3rd Pass',
'Cressman R=1.87d', r'$\rm{Barnes} \gamma=1.0$',r'$\rm{Barnes} \gamma=0.4$',
r'$\rm{Barnes} \gamma=0.2$', r'$\rm{Barnes 3-pass} \gamma=1.0$')
filenames = ('cress1', 'cress2', 'cress3', 'cress187', 'barnes1', 'barnes2',
'barnes3', 'barnes3pass')
for field,name,filename in zip(fields, names, filenames):
f = P.figure()
bm_ps.drawstates()
bm_ps.drawcountries()
bm_ps.drawcoastlines()
bm_ps.drawparallels(parallels, labels = [1,1,0,0])
bm_ps.drawmeridians(meridians, labels = [0,0,1,1])
cp = bm_ps.contour(x_bm, y_bm, field, contours, cmap=colormap)
P.clabel(cp, fontsize=fontsize, fmt='%.1f')
f.text(0.5,0.95,name,horizontalalignment='center',fontsize=16)
if save_work:
P.savefig(filename + '.png', dpi = 300)
else:
P.show()
filename = 'cress12diff'
f = P.figure()
bm_ps.drawstates()
bm_ps.drawcountries()
bm_ps.drawcoastlines()
示例10: grid
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
#urot,vrot = m.rotate_vector(u[nt,:,:],v[nt,:,:],lons,lats)
# plot wind vectors over map.
#Q = m.quiver(x,y,urot,vrot,scale=500)
# plot wind vectors on projection grid (looks better).
# first, shift grid so it goes from -180 to 180 (instead of 0 to 360
# in longitude). Otherwise, interpolation is messed up.
ugrid,newlons = shiftgrid(180.,u[nt,:,:],longitudes,start=False)
vgrid,newlons = shiftgrid(180.,v[nt,:,:],longitudes,start=False)
# transform vectors to projection grid.
urot,vrot,xx,yy = m.transform_vector(ugrid,vgrid,newlons,latitudes,51,51,returnxy=True,masked=True)
# plot wind vectors over map.
Q = m.quiver(xx,yy,urot,vrot,scale=500)
# make quiver key.
qk = p.quiverkey(Q, 0.1, 0.1, 20, '20 m/s', labelpos='W')
# draw coastlines, parallels, meridians, title.
m.drawcoastlines(linewidth=1.5)
m.drawparallels(parallels)
m.drawmeridians(meridians)
p.title('SLP and Wind Vectors '+date)
if nt == 0: # plot colorbar on a separate axes (only for first frame)
cax = p.axes([l+w-0.05, b, 0.03, h]) # setup colorbar axes
fig.colorbar(CS,drawedges=True, cax=cax) # draw colorbar
cax.text(0.0,-0.05,'mb')
p.axes(ax) # reset current axes
p.draw() # draw the plot
# save first and last frame n1 times
# (so gif animation pauses at beginning and end)
if nframe == 0 or nt == slp.shape[0]-1:
for n in range(n1):
p.savefig('anim%03i'%nframe+'.png')
nframe = nframe + 1
示例11: arange
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
circles = arange(0.,90.+delat,delat).tolist()+\
arange(-delat,-90.-delat,-delat).tolist()
delon = 30.
meridians = arange(10.,360.,delon)
npanel = 0
# plots of the US.
projs = ['lcc','aeqd','aea','laea','eqdc','stere']
fig = figure(figsize=(8,12))
for proj in projs:
m = Basemap(width=width,height=height,
resolution='c',projection=proj,\
lat_0=lat_0,lon_0=lon_0)
npanel = npanel + 1
subplot(3,2,npanel)
# setup figure with same aspect ratio as map.
m.drawcoastlines()
m.drawcountries()
m.fillcontinents()
m.drawstates()
m.drawparallels(circles)
m.drawmeridians(meridians)
title('proj = '+proj+' centered on %sW, %sN' % (lon_0,lat_0),fontsize=10)
show()
proj = 'omerc'
delat = 10.
circles = arange(0.,90.+delat,delat).tolist()+\
arange(-delat,-90.-delat,-delat).tolist()
delon = 10.
meridians = arange(10.,360.,delon)
lat_1 = 40; lat_2 = 55
示例12: plot_ncdf_output
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
#.........这里部分代码省略.........
elif N.size(rngs_idxs['lon']) == 1:
zgrid = num.MLab.squeeze(data[ ritim[0]:ritim[-1]+1,
rilat[0]:rilat[-1]+1,
rilon[0] ])
else:
raise ValueError, 'unrecognized configuration'
#* Change zgrid for special case of a lat. vs. time contour
# plot. Calculate xgrid and ygrid:
if keys_rngs_sizes_gt_1.count('time') and \
keys_rngs_sizes_gt_1.count('lat'):
zgrid = N.transpose(zgrid)
xgrid, ygrid = pylab.meshgrid(x, y)
#* Set contour levels:
if plotkwds['levels'] == None:
levels = nice_levels(zgrid)
else:
levels = plotkwds['levels']
#- Plot (creating continents first if is a lat vs. lon plot)
# and write contour levels/color bar as appropriate:
if keys_rngs_sizes_gt_1.count('lon') and \
keys_rngs_sizes_gt_1.count('lat'):
mapplot = Basemap(projection='cyl', resolution='l',
llcrnrlon=N.min(xgrid), llcrnrlat=N.min(ygrid),
urcrnrlon=N.max(xgrid), urcrnrlat=N.max(ygrid))
mapplot.drawcoastlines()
mapplot.drawmeridians(nice_levels(rngs['lon'],
approx_nlev=plotkwds['nlatlon']),
labels=[1,0,0,1])
mapplot.drawparallels(nice_levels(rngs['lat'],
approx_nlev=plotkwds['nlatlon']),
labels=[1,0,0,1])
if plotkwds['filled']:
plot = mapplot.contourf(xgrid, ygrid, zgrid, levels)
pylab.colorbar(plot, orientation='horizontal', format='%g')
else:
plot = mapplot.contour(xgrid, ygrid, zgrid, levels)
pylab.clabel(plot, inline=1, fontsize=10, fmt='%g')
else:
if plotkwds['filled']:
plot = pylab.contourf(xgrid, ygrid, zgrid, levels)
pylab.colorbar(plot, orientation='horizontal', format='%g')
else:
plot = pylab.contour(xgrid, ygrid, zgrid, levels)
pylab.clabel(plot, inline=1, fontsize=10, fmt='%g')
else:
raise ValueError, 'unrecognized plottype'
#- Add titling. Lat vs. lon plots do not have axis labels because
# the map labels already make it clear, and for those plots the
# title also includes the time value:
if keys_rngs_sizes_gt_1.count('lon') and \
keys_rngs_sizes_gt_1.count('lat'):
titlename = titlename + ' at ' \
+ dimname['time'] + ' ' \
+ str(rngs['time'][0]) + ' ' \
+ dimunits['time']
titlename = mpl_latex_script1(titlename)
pylab.title(titlename)
else:
titlename = mpl_latex_script1(titlename)
xname = mpl_latex_script1(xname)
yname = mpl_latex_script1(yname)
pylab.xlabel(xname)
pylab.ylabel(yname)
pylab.title(titlename)
#- Output plot to PNG file or screen. The show command seems to
# have a problem on my Mac OS X, so save to a temporary file
# and use preview to view for fn == None and tmppreview set to
# True. Note that the temporary file is not deleted by this
# method:
if plotkwds['fn'] == None: #+ Screen display
if plotkwds['tmppreview'] and sys.platform == 'darwin':
outputfn = tempfile.mkstemp('.png','qtcm_')
pylab.savefig(outputfn[-1])
os.system('open -a /Applications/Preview.app '+outputfn[-1])
else:
pylab.show()
elif type(plotkwds['fn']) == type('a'): #+ Write to file
pylab.savefig(plotkwds['fn'])
pylab.close(1)
else:
raise ValueError, 'cannot write to this type of file'
示例13:
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
x_bm,y_bm = ps2.to_basemap_xy(m2, x_grid / cm_per_m, y_grid / cm_per_m)
#Radius factor used in all of the analyses
R = 4.32
heights_cress = oban.analyze_grid(data.heights, x_grid, y_grid, data.x, data.y,
oban.cressman_weights, R)
contours = N.arange(5300., 6000., 60.0)
parallels = N.arange(25., 60.0, 10.0)
meridians = N.arange(-120., -60.0, 10.0)
##m2.drawstates()
##m2.drawcountries()
##m2.drawcoastlines()
##m2.drawparallels(parallels, labels = [1,1,0,0])
##m2.drawmeridians(meridians, labels = [0,0,1,1])
ob_x, ob_y = ps2.to_basemap_xy(m2, data.x / cm_per_m, data.y / cm_per_m)
#m2.plot(ob_x, ob_y, 'bx')
#m2.plot(x_bm, y_bm, 'g.')
for name in M.cm.cmapnames:
f = P.figure()
m2.drawstates()
m2.drawcountries()
m2.drawcoastlines()
m2.drawparallels(parallels, labels = [1,1,0,0])
m2.drawmeridians(meridians, labels = [0,0,1,1])
c = m2.contour(x_bm, y_bm, heights_cress, contours, cmap=M.cm.get_cmap(name))
P.title(name)
#P.clabel(c)
P.show()
示例14: figure
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
ll_lat = -35.55
ur_lon = 48.45
ur_lat = 0.2
lon_0 = 0.0
satellite_height = 35785831.0
fig = figure(figsize=(7,7))
ax = fig.add_axes((0.1,0.1,0.8,0.8))
# create Basemap instance for a Geostationary projection.
m = Basemap(projection='geos', lon_0=lon_0, satellite_height=satellite_height,
resolution='l', llcrnrlon=ll_lon, llcrnrlat=ll_lat, urcrnrlon=ur_lon, urcrnrlat=ur_lat)
# add data
m.imshow(data, cmap=cm.gray, interpolation='nearest')
clim(0, 255)
# draw coastlines.
m.drawcoastlines(linewidth=0.5, color=overlay_color)
m.drawcountries(linewidth=0.5, color=overlay_color)
# can't label meridians on bottom, because labels would
# be outside map projection region.
m.drawmeridians(arange(10,76,5), labels=[0,0,1,0], color=overlay_color)
m.drawparallels(arange(-90,90,5), labels=[1,0,0,0], color=overlay_color)
# add a colobar
#colorbar()
# add timestamp and save
fig = gcf()
fig.text(x=0.275, y=0.025, s=u'Meteosat-9 VIS 0.6 channel - 12:00 UTC 04/06/2007\n \N{COPYRIGHT SIGN} EUMETSAT 2007',
horizontalalignment='left',
verticalalignment='bottom',
fontsize=10,
fontweight='bold',
bbox=dict(facecolor='gray', alpha=0.25, pad=15))
示例15: wrf_grid
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import drawcoastlines [as 别名]
def wrf_grid(
# WPS -> map_proj
projection,
# WPS -> truelat1
lat_1,
# WPS -> truelat2
lat_2,
# WPS -> stand_lon
lon_0,
# WPS -> ref_lat
grid_centre_lat,
# WPS -> ref_lon
grid_centre_lon,
delta_x,
delta_y,
# WPS -> e_we
nx,
# WPS -> e_sn
ny,
show_mass_grid = False,
show_stag_grids = False,
):
if lon_0 != grid_centre_lon:
print 'not implemented yet -> see the source'
print "\tbut let's try it anyways..."
#return
width = nx * delta_x
height = ny * delta_y
frame_x = 10 * delta_x
frame_y = 10 * delta_y
m = Basemap(
lat_0 = grid_centre_lat,
# this could be a bad assumption... because lon_0 and grid_centre_lon
# need not be aligned, but at the same time I need to give this to
# basemap for the grid to be centred... I could probably fix it
# assigning lon_0 and then imposing a grid shift in native coordinates
# if ref_lon and lon_0 were not the same
lon_0 = lon_0,
lat_1 = lat_1,
lat_2 = lat_2,
width = width + 2*frame_x,
height = height + 2*frame_y,
resolution = 'l',
area_thresh=1000.
)
grid_centre_x, grid_centre_y = m(grid_centre_lon, grid_centre_lat)
min_x = grid_centre_x - width/2.
min_y = grid_centre_y - height/2.
max_x = min_x + width
max_y = min_y + height
x = n.arange(min_x, max_x + a_small_number, delta_x)
y = n.arange(min_y, max_y + a_small_number, delta_y)
x = x[1:-1]
y = y[1:-1]
x_u = n.arange(min_x, max_x + delta_x + a_small_number, delta_x)
x_u -= delta_x/2.
x_u = x_u[1:-1]
y_v = n.arange(min_y, max_y + delta_y + a_small_number, delta_y)
y_v -= delta_y/2.
y_v = y_v[1:-1]
X, Y = p.meshgrid(x,y)
lon, lat = m(X, Y, inverse=True)
X_u, Y_u = p.meshgrid(x_u,y)
lon_u, lat_u = m(X_u, Y_u, inverse=True)
X_v, Y_v = p.meshgrid(x,y_v)
lon_v, lat_v = m(X_v, Y_v, inverse=True)
if show_mass_grid:
m.plot(X, Y, 'b+')
m.plot([grid_centre_x], [grid_centre_y], 'r+')
if show_stag_grids:
m.plot(X_u, Y_u, 'g+')
m.plot(X_v, Y_v, 'r+')
m.drawcoastlines()
p.show()
output = {
'map' : m,
'mass_stag': {
'lon_2d' : lon,
'lat_2d' : lat,
'x' : x,
'y' : y,
'x_2d' : X,
'y_2d' : Y,
},
'u_stag': {
'lon_2d' : lon_u,
'lat_2d' : lat_u,
'x' : x_u,
'y' : y,
'x_2d' : X_u,
'y_2d' : Y_u,
},
'v_stag': {
'lon_2d' : lon_v,
'lat_2d' : lat_v,
'x' : x,
'y' : y_v,
'x_2d' : X_v,
'y_2d' : Y_v,
#.........这里部分代码省略.........