本文整理汇总了Python中mpl_toolkits.basemap.Basemap.contourf方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.contourf方法的具体用法?Python Basemap.contourf怎么用?Python Basemap.contourf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.contourf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _vec_plot_on_earth
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def _vec_plot_on_earth(lons, lats, x_data, y_data, vmin=-4, vmax=12, loc=None, colorbar=False):
plot_lons, plot_x_data = _extend_data(lons, lats, x_data)
plot_lons, plot_y_data = _extend_data(lons, lats, y_data)
lons, lats = np.meshgrid(plot_lons, lats)
if not loc:
m = Basemap(projection='cyl', resolution='c',
llcrnrlat=-90, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180)
else:
m = Basemap(projection='cyl', resolution='c', **loc)
x, y = m(lons, lats)
mag = np.sqrt(plot_x_data**2 + plot_y_data**2)
vmin, vmax = mag.min(), mag.max()
m.contourf(x, y, mag)
# m.pcolormesh(x, y, mag, vmin=vmin, vmax=vmax)
# m.quiver(x, y, plot_x_data, plot_y_data)
skip = 1
m.quiver(x[::skip, ::skip], y[::skip, ::skip],
plot_x_data[::skip, ::skip], plot_y_data[::skip, ::skip], scale=500)
m.drawcoastlines()
m.drawparallels(np.arange(-90., 90., 45.), labels=[1, 0, 0, 0], fontsize=10)
m.drawmeridians(np.arange(-180., 180., 60.), labels=[0, 0, 0, 1], fontsize=10)
if colorbar:
m.colorbar(location='right', pad='7%')
return m
示例2: plot_robinson_rossby
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def plot_robinson_rossby(model,vec,val,m,l):
E = model.physical_constants['E']
Nk = model.Nk
Nl = model.Nl
th = model.th
## Plot Robinson vector field
#### Display waves on a Spherical Map Projection
projtype = 'robin'
## Create full vector grid in theta and phi
u_1D = model.getVariable(vec,'uph')[0][0]
v_1D = model.getVariable(vec,'uth')[0][0]
Nph = 2*Nl
ph = np.linspace(-180.,180.-360./Nph,Nph)
lon_grid, lat_grid = np.meshgrid(ph,th[1:-1]*180./np.pi-90.,)
v = (np.exp(1j*m*lon_grid*np.pi/180.).T*v_1D).T
u = (np.exp(1j*m*lon_grid*np.pi/180.).T*u_1D).T
absu=u**2 + v**2
Nvec = np.floor(Nl/20.)
### Plot Robinson Projection
plt.figure(figsize=(10,10))
## Set up map
bmap = Basemap(projection=projtype,lon_0=0.)
bmap.drawparallels(np.arange(-90.,90.,15.))
bmap.drawmeridians(np.arange(0.,360.,15.))
## Convert Coordinates to those used by basemap to plot
lon,lat = bmap(lon_grid,lat_grid)
bmap.contourf(lon,lat,absu,15,cmap=plt.cm.Reds,alpha=0.5)
bmap.quiver(lon[::Nvec,::Nvec],lat[::Nvec,::Nvec],u[::Nvec,::Nvec].real,v[::Nvec,::Nvec].real)
plt.title('{0} Projection Vector Field for m={1}, l={2}'.format('Robinson',m,l))
plt.savefig('./output/m={1}/{0}VectorField_m={1}_l={2}.png'.format('Robinson',m,l))
示例3: demo_north_pole
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def demo_north_pole():
r = RPN(path = "/home/huziy/skynet3_rech1/classOff_Andrey/era2/temp_3d")
t = r.get_first_record_for_name("I0")
lon, lat = r.get_longitudes_and_latitudes_for_the_last_read_rec()
r.close()
nx, ny = lon.shape
lon_0, lat_0 = lon[nx//2, ny//2], lat[nx//2, ny//2]
basemap = Basemap(projection = "omerc", lon_1=60, lat_1 = 89.999, lon_2=-30, lat_2=0, no_rot=True,
lon_0 = lon_0, lat_0 = lat_0,
llcrnrlon=lon[0, 0], llcrnrlat=lat[0,0],
urcrnrlon=lon[-1, -1], urcrnrlat=lat[-1, -1]
)
x, y = basemap(lon, lat)
basemap.contourf(x, y, t)
basemap.drawcoastlines()
basemap.colorbar()
#basemap.shadedrelief()
plt.show()
示例4: plot_eof
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def plot_eof(self,name,no_eofs=1):
m = Basemap(projection='ortho', lat_0=-60., lon_0=100.)#todo
world=[0,-90,360,0]
min_lat=self._lat[0]
max_lat=self._lat[-1]
min_lon=self._lon[0]
max_lon=self._lon[-1]
dif_lat=(max_lat-min_lat)
if max_lon%360==min_lon%360:
dif_lon=360
else:
dif_lon=(max_lon-min_lon)%360
lon_line=5
while dif_lon/lon_line>9:
lon_line+=5
lat_line=5
while dif_lat/lat_line>10:
lat_line+=5
for i in range(no_eofs):
plt.figure(i)
m=Basemap(projection='gall',llcrnrlat=min_lat,urcrnrlat=max_lat,\
llcrnrlon=min_lon,urcrnrlon=max_lon,resolution='c')
x, y = m(*np.meshgrid(self._lon, self._lat))
levels = np.linspace(-1,1,11)
m.contourf(x, y, self._eof[i].squeeze(),levels, cmap=plt.cm.RdBu_r)
m.drawcoastlines()
m.drawparallels(np.arange(-80.,86.,lat_line),labels=[True,False,False,False])
m.drawmeridians(np.arange(-180.,181.,lon_line),labels=[False,False,False,True])
plt.title("EOF ("+"%0.1f"%(self._fraction[i]*100)+"%)" , fontsize=16)
cb = plt.colorbar(orientation='horizontal')
cb.set_label('correlation coefficient', fontsize=12)
plt.savefig(name+'.pdf',figsize=(15, 6), dpi=300, facecolor='w', edgecolor='w')
plt.clf()
示例5: old_plot_cappi
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def old_plot_cappi(x,y,data,sweep_dict, **kwargs):
radar_loc=kwargs.get('radar_loc', [-12.2492, 131.0444])
parm=kwargs.get('parm','')
fig_name=kwargs.get('fig_name', 'cappi_'+parm+'_.png')
f=figure()
#gp_loc=[-12.2492, 131.0444]
Re=6371.0*1000.0
rad_at_radar=Re*sin(pi/2.0 -abs(radar_loc[0]*pi/180.0))#ax_radius(float(lat_cpol), units='degrees')
lons=radar_loc[1]+360.0*x/(rad_at_radar*2.0*pi)
lats=radar_loc[0] + 360.0*y/(Re*2.0*pi)
def_loc_dict={'lat_0':lats.mean(), 'lon_0':lons.mean(),'llcrnrlat':lats.min(), 'llcrnrlon':lons.min(), 'urcrnrlat':lats.max() , 'urcrnrlon':lons.max(), 'lat_ts':lats.mean()}
loc_dict=kwargs.get('loc_dict', def_loc_dict)
map= Basemap(projection='merc', resolution='l',area_thresh=1., **loc_dict)
longr, latgr=meshgrid(lons,lats)
xx, yy = map(longr, latgr)
#map.drawcoastlines()
#map.drawcountries()
map.drawmapboundary()
map.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
map.drawmeridians(array([129,130,131,132,133]), labels=[1,0,0,1])
map.drawparallels(array([-14,-13,-12,-11,-10]), labels=[1,0,0,1])
comp_levs=linspace(-1.,1., 30)
levs_dict={'VR':linspace(-15,15,31), 'CZ': linspace(-8,64,10), 'TEST':linspace(((abs(data)+data)/2.0).min(), data.max(), 200), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs}
titles_dict={'VR': 'Velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component'}
map.contourf(xx,yy,data, levels=levs_dict[parm])
p=sweep_dict['date']
dtstr='%(#1)02d-%(#2)02d-%(#3)04d %(#4)02d%(#5)02dZ ' %{"#1":p.day, "#2":p.month, "#3":p.year, "#4":p.hour, '#5':p.minute}
title(sweep_dict['radar_name']+' '+dtstr+titles_dict[parm])
colorbar()
savefig(getenv('HOME')+'/bom_mds/output/'+fig_name)
close(f)
示例6: interpolated_color_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def interpolated_color_map(station_lon, station_lat, station_val, grid_dim=(80,110), interp='nn', cmap=None):#cm.s3pcpn):
# map boundries
lat_0 = 51
lat_min = 47
lat_max = 55
lon_0 = 10
lon_min = 5
lon_max = 16
m = Basemap(projection='tmerc', lat_0=lat_0, lon_0=lon_0,
llcrnrlat=lat_min, llcrnrlon=lon_min, urcrnrlat=lat_max,
urcrnrlon=lon_max, resolution='i')
m.drawcoastlines()
m.drawcountries()
m.drawmapboundary()
# x = np.linspace(0, m.urcrnrx, station_val.shape[1])
# y = np.linspace(0, m.urcrnry, station_val.shape[0])
# xx, yy = np.meshgrid(x, y)
# m.contourf(xx, yy, station_val)
m.contourf(station_lon, station_lat, station_val[:,0], latlon='true')
plt.show()
示例7: preview
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def preview(self):
'''Preview map in window'''
theurl = self.FILENAME.get()
if empty(theurl):
messagebox.showinfo(message='No image selected')
return
self.ax1.clear()
print('Preview of ',theurl)
icdf = Dataset(theurl,'r')
lon = icdf.variables['lon'][:]
lat = icdf.variables['lat'][:]
sst = icdf.variables['mcsst'][0,:,:].squeeze()
xxT,yyT = np.meshgrid(lon,lat)
SOUTH = np.min(lat)
NORTH = np.max(lat)
WEST = np.min(lon)
EAST = np.max(lon)
m = Basemap(llcrnrlat=SOUTH,urcrnrlat=NORTH, \
llcrnrlon=WEST,urcrnrlon=EAST, \
ax=self.ax1)
m.fillcontinents(color='coral')
m.drawcoastlines(linewidth=1)
m.contourf(xxT,yyT,sst)
self.canvas.draw()
print('done')
示例8: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def plot(array,typep=None,clevel=None):
fig,ax = plt.subplots()
lats=array['lats']
lons=array['lons']
latm,lonm = np.meshgrid(lats,lons)
latn = np.min(lats)
latx = np.max(lats)
lonn = np.min(lons)
lonx = np.max(lons)
m = Basemap(projection='merc',
llcrnrlat=latn,
urcrnrlat=latx,
llcrnrlon=lonn,
urcrnrlon=lonx,
resolution='l',
ax=ax)
if typep == 'pcolor':
m.pcolormesh(lonm.T,latm.T,array['data'],latlon=True)
elif typep == 'contourf':
X,Y=m(lonm.T, latm.T)
m.contourf(X,Y,array['data'],clevel)
m.drawparallels(lats[1::10],labels=[1,0,0,0])
m.drawmeridians(lons[1::20],labels=[0,0,0,1])
m.drawcoastlines()
plt.show(block=False)
示例9: vec_plot_on_earth
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def vec_plot_on_earth(lons, lats, x_data, y_data, vmin=-4, vmax=12, ax=None):
if ax == None:
ax = plt.gca()
plot_lons, plot_x_data = extend_data(lons, lats, x_data)
plot_lons, plot_y_data = extend_data(lons, lats, y_data)
lons, lats = np.meshgrid(plot_lons, lats)
m = Basemap(ax=ax, projection='cyl', resolution='c', llcrnrlat=-90, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180)
x, y = m(lons, lats)
mag = np.sqrt(plot_x_data**2 + plot_y_data**2)
vmin, vmax = mag.min(), mag.max()
m.contourf(x[:-1,:], y[:-1,:], mag, ax=ax)
#m.pcolormesh(x, y, mag, vmin=vmin, vmax=vmax)
#m.quiver(x, y, plot_x_data, plot_y_data)
skip = 5
m.quiver(x[::skip, ::skip], y[::skip, ::skip], plot_x_data[::skip, ::skip], plot_y_data[::skip, ::skip], ax=ax)
m.drawcoastlines(ax=ax)
m.drawparallels(np.arange(-90.,90.,45.), labels=[1, 0, 0, 0], fontsize=10, ax=ax)
m.drawmeridians(np.arange(-180.,180.,60.), labels=[0, 0, 0, 1], fontsize=10, ax=ax)
m.colorbar(location='bottom', pad='7%', ax=ax)
plt.show()
示例10: plot_ppi
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def plot_ppi(sweep_dict, parm, **kwargs):
radar_loc=kwargs.get('radar_loc', [-12.2492, 131.0444])
fig_name=kwargs.get('fig_name', 'ppi_'+parm+'_.png')
fig_path=kwargs.get('fig_path', getenv('HOME')+'/bom_mds/output/')
f=figure()
#gp_loc=[-12.2492, 131.0444]
Re=6371.0*1000.0
rad_at_radar=Re*sin(pi/2.0 -abs(radar_loc[0]*pi/180.0))#ax_radius(float(lat_cpol), units='degrees')
lons=radar_loc[1]+360.0*sweep_dict['xar']/(rad_at_radar*2.0*pi)
lats=radar_loc[0] + 360.0*sweep_dict['yar']/(Re*2.0*pi)
def_loc_dict={'lat_0':lats.mean(), 'lon_0':lons.mean(),'llcrnrlat':lats.min(), 'llcrnrlon':lons.min(), 'urcrnrlat':lats.max() , 'urcrnrlon':lons.max(), 'lat_ts':lats.mean()}
loc_dict=kwargs.get('loc_dict', def_loc_dict)
map= Basemap(projection='merc', resolution='l',area_thresh=1., **loc_dict)
xx, yy = map(lons, lats)
#map.drawcoastlines()
#map.drawcountries()
map.drawmapboundary()
map.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
map.drawmeridians(array([129,130,131,132,133]), labels=[1,0,0,1])
map.drawparallels(array([-14,-13,-12,-11,-10]), labels=[1,0,0,1])
levs_dict={'VR':linspace(-15,15,31), 'CZ': linspace(-8,64,10), 'PH': linspace(0,185,255), "RH": linspace(0,1.5,16), "SW":linspace(0, 5, 11), "ZD":linspace(-10,10,21), 'VE':linspace(-30,30,31), 'TI':linspace(-30,30,31), 'KD':linspace(-1.0,6.0,30)}
titles_dict={'VR': 'Velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'PH': 'Differential Prop Phase (degrees)', 'RH':'Correlation Co-ef', 'SW':'Spectral Width (m/s)', 'ZD':'Differentail Reflectivity dBz', 'VE':'Edited Velocity (m/s)', 'TI':'Simualated winds,(m/s)', 'KD':'Specific differential Phase (Degrees/m)'}
map.contourf(xx,yy,sweep_dict[parm], levels=levs_dict[parm])
p=sweep_dict['date']
dtstr='%(#1)02d-%(#2)02d-%(#3)04d %(#4)02d%(#5)02dZ ' %{"#1":p.day, "#2":p.month, "#3":p.year, "#4":p.hour, '#5':p.minute}
title(sweep_dict['radar_name']+' '+dtstr+titles_dict[parm])
colorbar()
savefig(fig_path+fig_name)
close(f)
示例11: triangulation_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def triangulation_map(station_lon, station_lat, station_val, cmap=None, *args, **kwargs):
""" Using matplotlib.pyplot.tricontourf() function to plot contourplot on an irreguar grid by using triangulation. """
# map boundries
lat_0 = 51
lat_min = 47
lat_max = 55
lon_0 = 10
lon_min = 5
lon_max = 16
m = Basemap(projection='tmerc', lat_0=lat_0, lon_0=lon_0,
llcrnrlat=lat_min, llcrnrlon=lon_min, urcrnrlat=lat_max,
urcrnrlon=lon_max, resolution='i')
m.drawcoastlines()
m.drawcountries()
m.drawmapboundary()
m.contourf(station_lon, station_lat, station_val, cmap=cmap, latlon=True, tri=True, *args, **kwargs)
m.scatter(station_lon, station_lat, color='k', s=5, latlon=True)
# Set Triangulation manual?:
#station_x, station_y = m(station_lon, station_lat)
#triang = tri.Triangulation(station_x, station_y)
#plt.tricontour(station_x, station_y, station_val, 15, linewidths=0.5, colors='k')
#plt.tricontourf(x, y, z, 15, cmap=plt.cm.rainbow, norm=plt.Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max()))
plt.show()
示例12: plot_mollyweide_rossby
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def plot_mollyweide_rossby(model,vec,val,m,l):
E = model.E
Nk = model.Nk
Nl = model.Nl
th = model.th
## Calculate vector field and contour field for plotting with basemap
## Create full vector grid in theta and phi
u_1D = model.getVariable(vec,'uph')[0][0]
v_1D = model.getVariable(vec,'uth')[0][0]
Nph = 2*Nl
ph = np.linspace(-180.,180.-360./Nph,Nph)
lon_grid, lat_grid = np.meshgrid(ph,th[1:-1]*180./np.pi-90.,)
v = (np.exp(1j*m*lon_grid*np.pi/180.).T*v_1D).T
u = (np.exp(1j*m*lon_grid*np.pi/180.).T*u_1D).T
absu=u**2 + v**2
Nvec = np.floor(Nl/20.)
### Plot Mollweide Projection
plt.figure(figsize=(10,10))
## Set up map
bmap = Basemap(projection='moll',lon_0=0.)
bmap.drawparallels(np.arange(-90.,90.,15.))
bmap.drawmeridians(np.arange(0.,360.,15.))
## Convert Coordinates to those used by basemap to plot
lon,lat = bmap(lon_grid,lat_grid)
bmap.contourf(lon,lat,absu,15,cmap=plt.cm.Reds,alpha=0.5)
bmap.quiver(lon[::Nvec,::Nvec],lat[::Nvec,::Nvec],u[::Nvec,::Nvec].real,v[::Nvec,::Nvec].real)
plt.title('Mollweide Projection Vector Field for m={0}, l={1}'.format(m,l))
plt.savefig('./output/m={1}/MollweideVectorField_m={1}_l={2}.png'.format(val.imag,m,l))
示例13: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def plot(rec):
data = rec.values
lats, lons = rec.latlons()
fig = plt.figure(figsize=(8,8))
# create figure and axes instances
ax = fig.add_axes([0.1,0.1,0.8,0.8])
# create polar stereographic Basemap instance.
# m = Basemap(projection='stere',lon_0=lon_0,lat_0=90.,lat_ts=lat_0,\
# llcrnrlat=latcorners[0],urcrnrlat=latcorners[2],\
# llcrnrlon=loncorners[0],urcrnrlon=loncorners[2],\
# rsphere=6371200.,resolution='l',area_thresh=10000)
#
# Lambert Conformal Conic map.
m = Basemap(llcrnrlon=-100.,llcrnrlat=0.,urcrnrlon=-20.,urcrnrlat=57.,
projection='lcc',lat_1=20.,lat_2=40.,lon_0=-60.,
resolution ='l',area_thresh=1000.)
# draw coastlines, state and country boundaries, edge of map.
m.drawcoastlines()
m.drawstates()
m.drawcountries()
# draw parallels.
parallels = np.arange(0.,90,10.)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
meridians = np.arange(180.,360.,10.)
m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
ny = data.shape[0]; nx = data.shape[1]
x, y = m(lons, lats) # compute map proj coordinates.
m.contourf(x, y, data)
plt.title('{0} ({5}) for period ending {1}/{2}/{3} {4}:00'.format(rec.parameterName, rec.year, rec.month, rec.day, rec.hour, rec.parameterNumber))
plt.show()
示例14: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def plot(self,key='Re'):
"""
Create a plot of a variable over the ORACLES study area.
Parameters
----------
key : string
See names for available datasets to plot.
clf : boolean
If True, clear off pre-existing figure. If False, plot over pre-existing figure.
Modification history
--------------------
Written: Michael Diamond, 08/16/2016, Seattle, WA
Modified: Michael Diamond, 08/21/2016, Seattle, WA
-Added ORACLES routine flight plan, Walvis Bay (orange), and Ascension Island
Modified: Michael Diamond, 09/02/2016, Swakopmund, Namibia
-Updated flihgt track
"""
plt.clf()
size = 16
font = 'Arial'
m = Basemap(llcrnrlon=self.lon.min(),llcrnrlat=self.lat.min(),urcrnrlon=self.lon.max(),\
urcrnrlat=self.lat.max(),projection='merc',resolution='i')
m.drawparallels(np.arange(-180,180,5),labels=[1,0,0,0],fontsize=size,fontname=font)
m.drawmeridians(np.arange(0,360,5),labels=[1,1,0,1],fontsize=size,fontname=font)
m.drawmapboundary(linewidth=1.5)
m.drawcoastlines()
m.drawcountries()
if key == 'Pbot' or key == 'Ptop' or key == 'Nd' or key == 'DZ':
m.drawmapboundary(fill_color='steelblue')
m.fillcontinents(color='floralwhite',lake_color='steelblue',zorder=0)
else: m.fillcontinents('k',zorder=0)
if key == 'Nd':
m.pcolormesh(self.lon,self.lat,self.ds['%s' % key],cmap=self.colors['%s' % key],\
latlon=True,norm = LogNorm(vmin=self.v['%s' % key][0],vmax=self.v['%s' % key][1]))
elif key == 'Zbf' or key == 'Ztf':
levels = [0,250,500,750,1000,1250,1500,1750,2000,2500,3000,3500,4000,5000,6000,7000,8000,9000,10000]
m.contourf(self.lon,self.lat,self.ds['%s' % key],levels=levels,\
cmap=self.colors['%s' % key],latlon=True,extend='max')
elif key == 'DZ':
levels = [0,500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000]
m.contourf(self.lon,self.lat,self.ds['%s' % key],levels=levels,\
cmap=self.colors['%s' % key],latlon=True,extend='max')
else:
m.pcolormesh(self.lon,self.lat,self.ds['%s' % key],cmap=self.colors['%s' % key],\
latlon=True,vmin=self.v['%s' % key][0],vmax=self.v['%s' % key][1])
cbar = m.colorbar()
cbar.ax.tick_params(labelsize=size-2)
cbar.set_label('[%s]' % self.units['%s' % key],fontsize=size,fontname=font)
if key == 'Pbot' or key == 'Ptop': cbar.ax.invert_yaxis()
m.scatter(14.5247,-22.9390,s=250,c='orange',marker='D',latlon=True)
m.scatter(-14.3559,-7.9467,s=375,c='c',marker='*',latlon=True)
m.scatter(-5.7089,-15.9650,s=375,c='chartreuse',marker='*',latlon=True)
m.plot([14.5247,13,0],[-22.9390,-23,-10],c='w',linewidth=5,linestyle='dashed',latlon=True)
m.plot([14.5247,13,0],[-22.9390,-23,-10],c='k',linewidth=3,linestyle='dashed',latlon=True)
plt.title('%s from MSG SEVIRI on %s/%s/%s at %s UTC' % \
(self.names['%s' % key],self.month,self.day,self.year,self.time),fontsize=size+4,fontname=font)
plt.show()
示例15: vec_plot_south_america
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contourf [as 别名]
def vec_plot_south_america(lons, lats, sa_mask, data_x, data_y, ax=None):
if ax == None:
ax = plt.gca()
#print(sa_mask.shape)
#print(data_x.shape)
#print(data_y.shape)
#data_x_masked = np.ma.array(data_x, mask=sa_mask)
#data_y_masked = np.ma.array(data_y, mask=sa_mask)
plot_lons, plot_x_data = extend_data(lons, lats, data_x)
plot_lons, plot_y_data = extend_data(lons, lats, data_y)
lons, lats = np.meshgrid(plot_lons, lats)
m = Basemap(ax=ax, projection='cyl', resolution='c', llcrnrlat=-60, urcrnrlat=15, llcrnrlon=-85, urcrnrlon=-32)
x, y = m(lons, lats)
mag = np.sqrt(plot_x_data**2 + plot_y_data**2)
vmin, vmax = mag.min(), mag.max()
m.contourf(x[:-1,:], y[:-1,:], mag, ax=ax)
#m.pcolormesh(x, y, mag, vmin=vmin, vmax=vmax, ax=ax)
m.quiver(x, y, plot_x_data, plot_y_data, scale=40, ax=ax)
m.drawcoastlines(ax=ax)
m.drawparallels(np.arange(-60.,15.,10.), labels=[1, 0, 0, 0], fontsize=10, ax=ax)
m.drawmeridians(np.arange(-90.,-30.,10.), labels=[0, 0, 0, 1], fontsize=10, ax=ax)
m.colorbar(location='right', pad='5%', ax=ax)
plt.show()