本文整理汇总了Python中matplotlib.pyplot.barbs函数的典型用法代码示例。如果您正苦于以下问题:Python barbs函数的具体用法?Python barbs怎么用?Python barbs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了barbs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_sfwind
def plot_sfwind():
print(" 10M WIND")
# Set Figure Size (1000 x 800)
plt.figure(figsize=(width,height),frameon=False)
# Convert winds from m/s to kts and then draw barbs
u_wind_kts = u_wind_ms[time] * 1.94384449
v_wind_kts = v_wind_ms[time] * 1.94384449
windmag = np.power(np.power(u_wind_kts,2)+np.power(v_wind_kts,2), 0.5)
WIND_LEVS = range(10,46,2)
W=plt.contourf(x,y,windmag,WIND_LEVS,extend='max')
plt.barbs(x_th,y_th,u_wind_kts[::thin,::thin],\
v_wind_kts[::thin,::thin], length=5,\
sizes={'spacing':0.2},pivot='middle')
# Convert Surface Pressure to Mean Sea Level Pressure
stemps = temps[time]+6.5*nc.variables['HGT'][time]/1000.
mslp = nc.variables['PSFC'][time]*np.exp(9.81/(287.0*stemps)*nc.variables['HGT'][time])*0.01 + (6.7 * nc.variables['HGT'][time] / 1000)
# Contour the pressure
#PLEVS = range(900,1050,5)
#P=plt.contour(x,y,mslp,PLEVS,V=2,colors='k',linewidths=1.5)
#plt.clabel(P,inline=1,fontsize=8,fmt='%1.0f',inline_spacing=1)
title = 'Sfc MSLP (mb), 10m Wind (kts)'
prodid = 'wind'
units = "kts"
drawmap(W, title, prodid, units)
示例2: mapWind
def mapWind(nest, time):
"""Creates a map of the domain, showing
wind barbs for the given time
"""
nc = openWRF(nest)
nc1 = openWRF(nest + 1)
Nx, Ny, _Nz, longitude, latitude, _dx, _dy, _x, _y = getDimensions(nc)
m = _getMapForNC(nc, False, _getDL(nest), 100)
_makeDots(m)
u10 = nc.variables["U10"][time, :, :]
v10 = nc.variables["V10"][time, :, :]
# Use data from every 10th grid point
windx = 1 + Nx / 10
windy = 1 + Ny / 10
lat10 = np.zeros((windy, windx))
lon10 = np.zeros((windy, windx))
uwind = np.zeros((windy, windx))
vwind = np.zeros((windy, windx))
for j in range(windy):
for i in range(windx):
uwind[j, i] = 0.5 * (u10[j * 10, i * 10] + u10[j * 10, i * 10 + 1])
# print 'u: ' + str(uwind[j,i])
vwind[j, i] = 0.5 * (v10[j * 10, i * 10] + v10[j * 10 + 1, i * 10])
# print 'v: ' + str(vwind[j,i])
lat10[j, i] = latitude[j * 10, i * 10]
lon10[j, i] = longitude[j * 10, i * 10]
x10, y10 = m(lon10, lat10)
plt.barbs(x10, y10, uwind, vwind, barb_increments=barb_increments, linewidth=1.0, color="green")
if nc1 is not None:
_plotBorder(nc1, m, "black")
plt.show()
plt.close()
示例3: plot_srhel
def plot_srhel():
print(" SR Helicity")
# Set Figure Size (1000 x 800)
plt.figure(figsize=(width,height),frameon=False)
P = nc.variables['P']
PB = nc.variables['PB']
UU = nc.variables['U']
VV = nc.variables['V']
PH = nc.variables['PH']
PHB = nc.variables['PHB']
# Need pressures, temps and mixing ratios
PR = P[time] + PB[time]
PHT = np.add(PH[time],PHB[time])
ZH = np.divide(PHT, 9.81)
U = UU[time]
V = VV[time]
for j in range(len(U[1,:,1])):
curcol_c = []
curcol_Umo = []
curcol_Vmo = []
for i in range(len(V[1,1,:])):
sparms = severe.SRHEL_CALC(U[:,j,i], V[:,j,i], ZH[:,j,i], PR[:,j,i])
curcol_c.append(sparms[0])
curcol_Umo.append(sparms[1])
curcol_Vmo.append(sparms[2])
np_curcol_c = np.array(curcol_c)
np_curcol_Umo = np.array(curcol_Umo)
np_curcol_Vmo = np.array(curcol_Vmo)
if j == 0:
srhel = np_curcol_c
U_srm = np_curcol_Umo
V_srm = np_curcol_Vmo
else:
srhel = np.row_stack((srhel, np_curcol_c))
U_srm = np.row_stack((U_srm, np_curcol_Umo))
V_srm = np.row_stack((V_srm, np_curcol_Vmo))
#print " SRHEL: ", np.shape(srhel)
# Now plot
SRHEL_LEVS = range(50,800,50)
srhel = np.nan_to_num(srhel)
SRHEL=plt.contourf(x,y,srhel,SRHEL_LEVS)
u_mo_kts = U_srm * 1.94384449
v_mo_kts = V_srm * 1.94384449
plt.barbs(x_th,y_th,u_mo_kts[::thin,::thin],\
v_mo_kts[::thin,::thin], length=5,\
sizes={'spacing':0.2},pivot='middle')
title = '0-3 km SRHelicity, Storm Motion (kt)'
prodid = 'hlcy'
units = "m" + u'\u00B2' + '/s' + u'\u00B2'
drawmap(SRHEL, title, prodid, units)
示例4: windbarbs
def windbarbs(self,nc,time,y,x,P,thin_locs,n=45.0,color='black'):
uwind = 0.5*(nc.variables['U'][time,:,y,x]+nc.variables['U'][time,:,y,x+1])
vwind = 0.5*(nc.variables['V'][time,:,y,x]+nc.variables['V'][time,:,y+1,x])
zmax = len(uwind[thin_locs])
delta = 1
baraxis = [n for _j in range(0,zmax,delta)]
# pdb.set_trace()
plt.barbs(baraxis,P[thin_locs],uwind[thin_locs],vwind[thin_locs],
barb_increments=self.barb_increments, linewidth = .75,color=color)
示例5: plot_vector_barbs
def plot_vector_barbs(velocity_radial_f, azimuth, ranges, r, e, u, v):
ran, theta = np.meshgrid(ranges[r], azimuth[e,:])
plt.figure()
plt.subplot(111, polar=True)
plt.barbs(u[e,:,r], v[e,:,r], ran, theta)
plt.show()
#plt.savefig('Radar_Qxb_Band_S - Barbs ({:.2f} km Range) ME.png'.format((r*1498)/1000.), format='png')
plt.close()
示例6: windbarbs_real
def windbarbs_real(self,uwind,vwind,P,delta=3,color='red',n=37.5):
# Is wind in kt or m/s? .... uwind*
those = N.where(uwind==-9999) # Find nonsense values
uwind = N.delete(uwind,those)
vwind = N.delete(vwind,those)
P = N.delete(P,those)
zmax = len(uwind)
# n is x-ax position on skewT for barbs.
baraxis = [n for _j in range(0,zmax,delta)]
plt.barbs(baraxis,P[0:zmax:delta],uwind[0:zmax:delta],vwind[0:zmax:delta],
barb_increments=self.barb_increments, linewidth = .75, barbcolor = color, flagcolor = color)
示例7: test_barb_limits
def test_barb_limits():
ax = plt.axes()
x = np.linspace(-5, 10, 20)
y = np.linspace(-2, 4, 10)
y, x = np.meshgrid(y, x)
trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
# The calculated bounds are approximately the bounds of the original data,
# this is because the entire path is taken into account when updating the
# datalim.
assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6), decimal=1)
示例8: plot_vector_barbs
def plot_vector_barbs(radar, r, u, v):
azimuth = radar.azimuth['data'].reshape(10,360)
rang = radar.range['data']
velocity_radial = radar.fields['velocity']['data'].reshape(10,360,253)
theta, ran = np.meshgrid(azimuth[3,:], rang[r])
plt.figure()
plt.subplot(111, polar=True)
plt.barbs(theta, ran, u[3,:,r], v[3,:,r], velocity_radial[3,:,r])
plt.show()
#plt.savefig('Radar_Qxb_Band_S - Barbs ({:.2f} km Range).png'.format((r*1490)/1000.), format='png')
plt.close()
示例9: _windbarbs
def _windbarbs(nc, time, y, x, P, thin_locs, n=45.0, color="black"):
uwind = 0.5 * (nc.variables["U"][time, :, y, x] + nc.variables["U"][time, :, y, x + 1])
vwind = 0.5 * (nc.variables["V"][time, :, y, x] + nc.variables["V"][time, :, y + 1, x])
zmax = len(uwind[thin_locs])
delta = 1
baraxis = [n for _j in range(0, zmax, delta)]
plt.barbs(
baraxis,
P[thin_locs],
uwind[thin_locs],
vwind[thin_locs],
barb_increments=barb_increments,
linewidth=0.75,
color=color,
)
示例10: _make_barb
def _make_barb(self, temperature, theta, speed, angle):
"""Add the barb to the plot at the specified location."""
u, v = self._uv(speed, angle)
if 0 < speed < _BARB_BINS[0]:
# Plot the missing barbless 1-2 knots line.
length = self._kwargs['length']
pivot_points = dict(tip=0.0, middle=-length / 2.)
pivot = self._kwargs.get('pivot', 'tip')
offset = pivot_points[pivot]
verts = [(0.0, offset), (0.0, length + offset)]
rangle = math.radians(-angle)
verts = mtransforms.Affine2D().rotate(rangle).transform(verts)
codes = [Path.MOVETO, Path.LINETO]
path = Path(verts, codes)
size = length ** 2 / 4
xy = np.array([[temperature, theta]])
barb = PathCollection([path], (size,), offsets=xy,
transOffset=self._transform,
**self._custom_kwargs)
barb.set_transform(mtransforms.IdentityTransform())
self.axes.add_collection(barb)
else:
barb = plt.barbs(temperature, theta, u, v,
transform=self._transform, **self._kwargs)
return barb
示例11: plot_dwp
def plot_dwp():
print " DEWPOINT"
# Set Figure Size (1000 x 800)
plt.figure(figsize=(width,height),frameon=False)
qhum = nc.variables['Q2']
# Convert Surface Pressure to Mean Sea Level Pressure
stemps = temps[time]+6.5*nc.variables['HGT'][time]/1000.
mslp = psfc[time]*np.exp(9.81/(287.0*stemps)*nc.variables['HGT'][time])*0.01
# Find saturation vapor pressure
es = 6.112 * np.exp(17.67 * temps[time]/(temps[time] + 243.5))
w = qhum[time]/(1-qhum[time])
e = (w * psfc[time] / (.622 + w)) / 100
Td_C = (243.5 * np.log(e/6.112))/(17.67-np.log(e/6.112))
Td_F = (Td_C * 9 / 5) + 32
DP_LEVS = range(-10,85,1)
DP_CLEVS = range(40,90,10)
# Contour and fill the dewpoint temperature
Td=plt.contourf(x,y,Td_F,DP_LEVS,cmap=coltbls.dewpoint1(),extend='min')
Td_lev = plt.contour(x,y,Td_F,DP_CLEVS,colors='k',linewidths=.5)
plt.clabel(Td_lev,inline=1,fontsize=7,fmt='%1.0f',inline_spacing=1)
# Contour the pressure
# P=plt.contour(x,y,mslp,V=2,colors='k',linewidths=1.5)
# plt.clabel(P,inline=1,fontsize=8,fmt='%1.0f',inline_spacing=1)
#plt.clabel(T,inline=1,fontsize=10)
# Convert winds from m/s to kts and then draw barbs
u_wind_kts = u_wind_ms[time] * 1.94384449
v_wind_kts = v_wind_ms[time] * 1.94384449
plt.barbs(x_th,y_th,u_wind_kts[::thin,::thin],\
v_wind_kts[::thin,::thin], length=5,\
sizes={'spacing':0.2},pivot='middle')
title = 'Surface Dwp, 10m Wind (kts)'
prodid = 'dewp'
units = u"\u00B0" + "F"
drawmap(Td, title, prodid, units)
示例12: plot_thte
def plot_thte():
"""Plot surface theta-e map"""
print " THETA-E"
plt.figure(figsize=(width,height),frameon=False)
qhum = nc.variables['Q2']
thte = (temps[time] + qhum[time] * 2500000.0/1004.0) * (100000/psfc[time]) ** (287.0/1004.0)
THTE_LEVS = range(270,360,5)
THTE = plt.contourf(x,y,thte,THTE_LEVS,cmap=coltbls.thetae(),extend='max')
u_wind_kts = u_wind_ms[time] * 1.94384449
v_wind_kts = v_wind_ms[time] * 1.94384449
plt.barbs(x_th,y_th,u_wind_kts[::thin,::thin],\
v_wind_kts[::thin,::thin], length=5,\
sizes={'spacing':0.2},pivot='middle')
title = 'Theta-e, 10 m Wind (kt)'
prodid = 'thte'
units = 'K'
drawmap(THTE, title, prodid, units)
示例13: plot_surface
def plot_surface():
print(" SURFACE")
# Set Figure Size (1000 x 800)
plt.figure(figsize=(width,height),frameon=False)
# Convert Surface Pressure to Mean Sea Level Pressure
stemps = temps[time]+6.5*nc.variables['HGT'][time]/1000.
mslp = nc.variables['PSFC'][time]*np.exp(9.81/(287.0*stemps)*nc.variables['HGT'][time])*0.01 + (6.7 * nc.variables['HGT'][time] / 1000)
# Convert Celsius Temps to Fahrenheit
ftemps = (9./5.)*(temps[time]-273) + 32
T_LEVS = range(-10,125,5)
# Contour and fill the temperature
T=plt.contourf(x,y,ftemps,T_LEVS,cmap=coltbls.sftemp())
# Contour the pressure
P=plt.contour(x,y,mslp,V=2,colors='k',linewidths=1.5)
plt.clabel(P,inline=1,fontsize=8,fmt='%1.0f',inline_spacing=1)
#plt.clabel(T,inline=1,fontsize=10)
# Convert winds from m/s to kts and then draw barbs
u_wind_kts = u_wind_ms[time] * 1.94384449
v_wind_kts = v_wind_ms[time] * 1.94384449
plt.barbs(x_th,y_th,u_wind_kts[::thin,::thin],\
v_wind_kts[::thin,::thin], length=5,\
sizes={'spacing':0.2},pivot='middle')
title = 'Sfc Temp, MSLP (mb), 10m Wind (kts)'
prodid = 'pmsl'
units = u"\u00B0" + "F"
drawmap(T, title, prodid, units)
示例14: Fill
## W-Component vertical Wind Contour Fill (colored)
plt.contourf(x,y,masked_W,cmap='bwr',levels=np.arange(-5,5.1,.5),extend='both')
cbar_loc = plt.colorbar(shrink=.8,ticks= np.arange(-5,5.1,1))
cbar_loc.ax.set_ylabel('Vertical Velocity Wind on model level 7 (m/s)\n Approx. '+str(int(center_valley_height))+' meters',fontsize=20)
cbar_loc.ax.tick_params(labelsize=20)
## Contour Lake Outline
plt.contour(x,y,landmask, [0,1], linewidths=3, colors="b")
#plt.contour(x,y,HGT)
#plt.contourf(x,y,HGT,cmap=cmapgrey) # transparent greay if plotted on top
## Wind Barbs surface
plt.barbs(x[::3,::3],y[::3,::3],masked_U10[::3,::3],masked_V10[::3,::3],
length=6,
barb_increments=dict(half=1, full=2, flag=10),
sizes=dict(emptybarb=.1),
zorder=40)
plt.title('Surface wind barbs with \n vertical velocity on model level 7 (~2300 m)')
else:
## W-Component vertical Wind Contour Fill (colored)
plt.contourf(x,y,masked_W,cmap='bwr',levels=np.arange(-5,5.1,.5),extend='both')
cbar_loc = plt.colorbar(shrink=.8,ticks= np.arange(-5,5.1,1))
cbar_loc.ax.set_ylabel('Vertical Velocity Wind on model level '+str(model_level)+' (m/s)\n Approx. '+str(int(center_valley_height))+' meters',fontsize=20)
cbar_loc.ax.tick_params(labelsize=20)
## Contour Lake Outline
plt.contour(x,y,landmask, [0,1], linewidths=3, colors="b")
#plt.contour(x,y,HGT)
示例15: Temperature
# Total Irradiance
dataTi=dataKis+dataKil
#====== Plot Temperature
plt.subplot(2,2,1)
plt.title('Surface Temperature (K)')
# contour land
CL1=plt.contour(lons,lats,dataLand,levels=[0],colors = 'k')
# contour Temperature
CT1=plt.contourf(lons,lats,dataT2m,cmap=get_cmap('BuRd'))# filed contour
plt.colorbar(CT1)
# wind barbs
Cwind1=plt.barbs(X,Y,U,V,length=Lbarbs, barbcolor=['k'],pivot='middle',sizes=dict(emptybarb=0))
#====== Plot Humidity
plt.subplot(2,2,2)
plt.title('Relative Humidity (%)')
# contour land
CL2=plt.contour(lons,lats,dataLand,levels=[0],colors = 'k')
# contour humidity
CH2=plt.contourf(lons,lats,dataH2m,cmap=get_cmap('Blues'))# contour line
plt.colorbar(CH2)
# wind barbs
Cwind2=plt.barbs(X,Y,U,V,length=Lbarbs, barbcolor=['k'],pivot='middle',sizes=dict(emptybarb=0))
#====== Plot Precipitation