当前位置: 首页>>代码示例>>Python>>正文


Python Basemap.quiver方法代码示例

本文整理汇总了Python中mpl_toolkits.basemap.Basemap.quiver方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.quiver方法的具体用法?Python Basemap.quiver怎么用?Python Basemap.quiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpl_toolkits.basemap.Basemap的用法示例。


在下文中一共展示了Basemap.quiver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: vec_plot_south_america

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [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()
开发者ID:markmuetz,项目名称:geogg134_project,代码行数:30,代码来源:plotting.py

示例2: displayWindMapPlot

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def displayWindMapPlot(vdata,udata, lons, lats,):
    """ TODO add a docstring! """
    #plt.clf()
    #pc = plt.contourf(lons, lats, data, 20)
    #plt.colorbar(pc, orientation='horizontal')
    #plt.title(title)
    #plt.xlabel("longitude (degrees east)")
    #plt.ylabel("latitude (degrees north)")
    #plt.show()
    fig, ax = plt.subplots()
    # Do the plot code
    # make orthographic basemap.
    m = Basemap(projection='cyl',llcrnrlat=-40,urcrnrlat=0,\
            llcrnrlon=-20,urcrnrlon=60,resolution='l')

    X,Y=np.meshgrid(lons, lats)
    x,y=m(X,Y) #Convert to map coordinates
    #m.barbs(x,y,vdata,udata,20)
    m.quiver(x,y,vdata,udata,10)
    plt.streamplot(x,y,vdata,udata,10)
    #plt.colorbar(pc,orientation='horizontal')
    m.drawmapboundary()
    m.drawcountries()
    
    m.drawcoastlines(linewidth=1.5)
    
    fig.savefig('myimage.svg', format='svg', dpi=1200)
    plt.show()
    #m.drawparallels(parallels)
    #m.drawmeridians(meridians)
    
    
    """ Contains code for displaying data """
开发者ID:chiluf,项目名称:Environmental-Data-Exploration-Visualization,代码行数:35,代码来源:plotting.py

示例3: plot_robinson_rossby

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [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))
开发者ID:nknezek,项目名称:rossby_waves,代码行数:35,代码来源:rossby_plotting.py

示例4: _vec_plot_on_earth

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [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
开发者ID:markmuetz,项目名称:stormtracks,代码行数:31,代码来源:figure_plotting.py

示例5: plot_mollyweide_rossby

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [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))
开发者ID:nknezek,项目名称:rossby_waves,代码行数:32,代码来源:rossby_plotting.py

示例6: contourMap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def contourMap(grdROMS, tlon, tlat, mydata1, mydata2, mydata3, var, mytype, currentdate):

    plt.figure(figsize=(10,10), frameon=False)
    
    map = Basemap(lon_0=25,boundinglat=50,
                      resolution='l',area_thresh=100.,projection='npstere')
    
    x, y = list(map(tlon,tlat))

    map.drawcoastlines()
    map.fillcontinents(color='grey')
    map.drawcountries()

    if var=='wind':
        levels = np.arange(np.min(mydata3),np.max(mydata3),0.1)
   
        CS1 = map.contourf(x, y, mydata3, levels, cmap=cm.get_cmap('RdYlBu_r',len(levels)-1) )#,alpha=0.5)
        plt.colorbar(CS1, orientation='vertical', extend='both', shrink=0.5)
            
        if mytype=="REGSCEN":
          step=8
        else:
          step=1
        map.quiver(x[0:-1:step,0:-1:step],y[0:-1:step,0:-1:step],
            mydata1[0:-1:step,0:-1:step],mydata2[0:-1:step,0:-1:step],
            scale=400)
   
  #  plt.title('Var:%s - depth:%s - time:%s'%(var,grdROMS.time))
    plotfile='figures/'+str(var)+'_'+str(mytype)+'_time_'+str(currentdate)+'.png'
    if not os.path.exists('figures'):
        os.makedirs('figure')
    plt.savefig(plotfile)
    print("Saved figure: %s"%(plotfile))
开发者ID:trondkr,项目名称:model2roms,代码行数:35,代码来源:plotAtmos.py

示例7: vec_plot_on_earth

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [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()
开发者ID:markmuetz,项目名称:geogg134_project,代码行数:28,代码来源:plotting.py

示例8: vec_plot_polar

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def vec_plot_polar(lons, lats, data_x, data_y, pole, ax=None):
    if ax == None:
	ax = plt.gca()
    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)

    if pole == 'N':
	m = Basemap(ax=ax, resolution='c',projection='stere',lat_0=90.,lon_0=0, width=12000000,height=8000000)
    elif pole == 'S':
	m = Basemap(ax=ax, resolution='c',projection='stere',lat_0=-90.,lon_0=0, width=12000000,height=8000000)
    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)
    skip = 5
    m.quiver(x[::5, ::5], y[::5, ::5], plot_x_data[::5, ::5], plot_y_data[::5, ::5], scale=50, 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(-180.,180.,10.), fontsize=10, ax=ax)

    m.colorbar(location='right', pad='5%', ax=ax)
    plt.show()
开发者ID:markmuetz,项目名称:geogg134_project,代码行数:29,代码来源:plotting.py

示例9: plot_grid

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def plot_grid(EIC_grid,sat_track,sat_krig,title):
    '''
    This function plots a scatter map of the EICS grid and its horizontal components, and the krigged value for the
    satellite.

    :param EIC_grid: The EICS grid
    :param satPos: The position of the satellite
    :param ptz_u: The krigged u component of the satellite
    :param ptz_v: The krigged v component of the satllite
    :param title: Timestamp of the satellite
    :return: The figure
    '''

    # Define the size of the figure in inches
    plt.figure(figsize=(18,18))

    # The horizontal components of the Ionospheric current from the EICS grid
    u = EIC_grid[:,2]
    v = EIC_grid[:,3]

    '''
    The m variable defines the basemap of area that is going to be displayed.
    1) width and height is the area in pixels of the area to be displayed.
    2) resolution is the resolution of the boundary dataset being used 'c' for crude and 'l' for low
    3) projection is type of projection of the basemape, in this case it is a Lambert Azimuthal Equal Area projection
    4) lat_ts is the latitude of true scale,
    5) lat_0 and lon_0 is the latitude and longitude of the central point of the basemap
    '''
    m = Basemap(width=8000000, height=8000000, resolution='l', projection='lcc',\
             lat_0=60,lon_0=-100.)

    m.drawcoastlines() #draw the coastlines on the basemap

    # draw parallels and meridians and label them
    m.drawparallels(np.arange(-80.,81.,20.),labels=[1,0,0,0],fontsize=10)
    m.drawmeridians(np.arange(-180.,181.,20.),labels=[0,0,0,1],fontsize=10)

    # Project the inputted grid into x,y values defined of the projected basemap parameters
    x,y =m(EIC_grid[:,1],EIC_grid[:,0])
    satx,saty = m(sat_track[::10,7],sat_track[::10,6])
    satkrigx,satkrigy = m(sat_krig[1],sat_krig[0])


    '''
    Plot the inputted grid as a quiver plot on the basemap,
    1) x,y are the projected latitude and longitude coordinates of the grid
    2) u and v are the horizontal components of the current
    3) the EICS grid values are plotted in blue color where as the satellite krigged values are in red
    '''
    eic = m.quiver(x,y,u,v,width = 0.004, scale=10000,color='#0000FF')
    satkrig = m.quiver(satkrigx,satkrigy,sat_krig[2],sat_krig[3],color='#FF0000',width=0.004, scale = 10000)
    satpos = m.scatter(satx,saty,s=100,marker='.',c='#009933',edgecolors='none',label='Satellite Track')
    sat_halo = m.scatter(satkrigx,satkrigy,s=400,facecolors='none',edgecolors='#66FF66',linewidth='5')

    plt.title(title)
    plt.legend([satpos],['Satellite Track'],loc='upper right',scatterpoints=1)
    plt.quiverkey(satkrig,0.891,0.948,520,u'\u00B1' +'520 mA/m',labelpos='E')

    plt.savefig('EICS_20110311_002400.png',bbox_inches='tight',pad_inches=0.2)
开发者ID:sonalranjit,项目名称:GOCE_SECS-EICS,代码行数:61,代码来源:eics_single_plot.py

示例10: test

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def test():
    plt.figure()
    b = Basemap()
    u = np.array([1, ])
    v = np.array([1, ])
    lon, lat = np.array([-90, ]), np.array([45, ])
    xx, yy = b(lon, lat)
    print(xx.shape)
    b.quiver(xx, yy, u, v, color="r")

    urot, vrot = b.rotate_vector(u, v, lon, lat)
    b.quiver(xx, yy, urot, vrot, color="g")

    b.drawcoastlines()



    # Plot the same in rotpole projection

    HL_LABEL = "CRCM5_HL"
    NEMO_LABEL = "CRCM5_NEMO"

    sim_label_to_path = OrderedDict(
        [(HL_LABEL, "/RESCUE/skynet3_rech1/huziy/CNRCWP/C5/2016/2-year-runs/coupled-GL+stfl_oneway/Samples"),
         (NEMO_LABEL, "/HOME/huziy/skynet3_rech1/CNRCWP/C5/2016/2-year-runs/coupled-GL+stfl/Samples")]
    )

    # get a coord file ...
    coord_file = ""
    found_coord_file = False
    for mdir in os.listdir(sim_label_to_path[HL_LABEL]):

        mdir_path = os.path.join(sim_label_to_path[HL_LABEL], mdir)
        if not os.path.isdir(mdir_path):
            continue

        for fn in os.listdir(mdir_path):
            print(fn)
            if fn[:2] not in ["pm", "dm", "pp", "dp"]:
                continue

            coord_file = os.path.join(mdir_path, fn)
            found_coord_file = True

        if found_coord_file:
            break

    bmp, lons, lats = nemo_hl_util.get_basemap_obj_and_coords_from_rpn_file(path=coord_file)


    plt.figure()
    urot, vrot = bmp.rotate_vector(u, v, lon, lat)
    xx, yy = bmp(lon, lat)

    bmp.quiver(xx, yy, urot, vrot, color="b")
    bmp.drawcoastlines()
    plt.show()
开发者ID:guziy,项目名称:RPN,代码行数:59,代码来源:rotate_wind_vectors.py

示例11: plot_grid

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def plot_grid(EIC_grid,sat_latlon,ptz_u,ptz_v,title):
    '''
    This function plots a scatter map of the EICS grid and its horizontal components, and the krigged value for the
    satellite.

    :param EIC_grid: The EICS grid
    :param satPos: The position of the satellite
    :param ptz_u: The krigged u component of the satellite
    :param ptz_v: The krigged v component of the satllite
    :param title: Timestamp of the satellite
    :return: The figure
    '''

    # Define the size of the figure in inches
    plt.figure(figsize=(18,18))

    # The horizontal components of the Ionospheric current from the EICS grid
    u = EIC_grid[:,2]
    v = EIC_grid[:,3]

    '''
    The m variable defines the basemap of area that is going to be displayed.
    1) width and height is the area in pixels of the area to be displayed.
    2) resolution is the resolution of the boundary dataset being used 'c' for crude and 'l' for low
    3) projection is type of projection of the basemape, in this case it is a Lambert Azimuthal Equal Area projection
    4) lat_ts is the latitude of true scale,
    5) lat_0 and lon_0 is the latitude and longitude of the central point of the basemap
    '''
    m = Basemap(width=8000000, height=8000000, resolution='l', projection='laea',\
                lat_ts=min(EIC_grid[:,0]), lat_0=np.median(EIC_grid[:,0]),lon_0=-100.)

    m.drawcoastlines() #draw the coastlines on the basemap

    # draw parallels and meridians and label them
    m.drawparallels(np.arange(-80.,81.,20.),labels=[1,0,0,0],fontsize=10)
    m.drawmeridians(np.arange(-180.,181.,20.),labels=[0,0,0,1],fontsize=10)

    # Project the inputted grid into x,y values defined of the projected basemap parameters
    x,y =m(EIC_grid[:,1],EIC_grid[:,0])
    satx,saty = m(sat_latlon[0,1],sat_latlon[0,0])

    '''
    Plot the inputted grid as a quiver plot on the basemap,
    1) x,y are the projected latitude and longitude coordinates of the grid
    2) u and v are the horizontal components of the current
    3) the EICS grid values are plotted in blue color where as the satellite krigged values are in red
    '''
    m.quiver(x,y,u,v,width = 0.004, scale=10000,color='#0000FF')
    m.quiver(satx,saty,ptz_u[0],ptz_v[0],color='#FF0000',width=0.004, scale = 10000)
    m.scatter(satx,saty,s=400,facecolors='none',edgecolors='#66FF66',linewidth='5')

    plt.title(title)
    plt.savefig('/home/sonal/EICS_201104/figs/'+title+'.png',bbox_inches='tight',pad_inches=0.1)
    #plt.show()
    plt.clf()
开发者ID:sonalranjit,项目名称:SECS,代码行数:57,代码来源:EICS_krig.py

示例12: plot_flow_directions

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def plot_flow_directions():
    data = read_binary(BASE_PATH + os.path.sep + "5minfdr.img")

    print data[:, 0]

    return
    data = data[::100, ::100]

    print data.shape

    #    plot_flow_directions(data)
    lons, lats = get_graham_grid(the_shape=data.shape, lower_left_point=GeoPoint(-80, 45)).get_lons_lats_2d()
    #    plt.contourf(lons, lats, data)

    m = Basemap(llcrnrlon=-80.0, llcrnrlat=45, urcrnrlon=0, urcrnrlat=90)
    lons, lats = m(lons, lats)

    scale = 1.0

    get_u_coord_vec = np.vectorize(get_u_coordinate, otypes=["float"])
    get_v_coord_vec = np.vectorize(get_v_coordinate, otypes=["float"])

    flat_data = data.ravel()

    u = get_u_coord_vec(flat_data, scale)
    v = get_v_coord_vec(flat_data, scale)

    u, v = u.reshape(data.shape), v.reshape(data.shape)

    inches_per_pt = 1.0 / 72.27  # Convert pt to inch
    golden_mean = (sqrt(5) - 1.0) / 2.0  # Aesthetic ratio
    fig_width = 700 * inches_per_pt  # width in inches
    fig_height = fig_width * golden_mean  # height in inches
    fig_size = [fig_width, fig_height]

    params = {
        "axes.labelsize": 14,
        "text.fontsize": 14,
        "legend.fontsize": 14,
        "xtick.labelsize": 16,
        "ytick.labelsize": 16,
        "figure.figsize": fig_size,
    }

    pylab.rcParams.update(params)

    m.quiver(lons, lats, u, v, width=0.002, scale=50)
    m.drawcoastlines()

    plt.savefig("fdr5min.png")
开发者ID:guziy,项目名称:PlotWatrouteData,代码行数:52,代码来源:read_graham_binary.py

示例13: plot_gini_grid_vectors

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def plot_gini_grid_vectors(gini_grid, box = [-110, -70, 20, 52], resolution = 'l',
                   parallels = None,
                   meridians = None,
                   vmin = None, vmax = None,
                   fld = 'IR', title = None,
                   degrade = 5, u='u', v='v', scale = 200):
    m = Basemap(llcrnrlon = box[0] ,llcrnrlat = box[2] , urcrnrlon = box[1],
                   urcrnrlat = box[3] , projection = 'mill', area_thresh =1000 ,
                   resolution = resolution)
    
    x, y = m(gini_grid.fields['lon']['data'], gini_grid.fields['lat']['data'])
    # create figure.
    if parallels == None:
        parallels = np.linspace(10,50, 9)
    if meridians == None:
        meridians = np.linspace(-110, -80,7)
    m.drawparallels(parallels, labels=[1,1,0,0])
    m.drawmeridians(meridians,labels=[0,0,0,1]) 
    pc = m.pcolormesh(x, y , gini_grid.fields[fld]['data'][0,:], cmap=plt.get_cmap('gray'),
                      vmin = vmin, vmax = vmax)
    qq = m.quiver(x[::degrade,::degrade], y[::degrade,::degrade], 
                  gini_grid.fields[u]['data'][0,::degrade,::degrade], 
                  gini_grid.fields[v]['data'][0,::degrade,::degrade], scale=scale)

    plt.title(title)
    m.drawcoastlines(linewidth=1.25)
    m.drawstates()
    plt.colorbar(mappable=pc, label = 'Counts')
开发者ID:scollis,项目名称:gini_tools,代码行数:30,代码来源:cloud_motion.py

示例14: plot

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
 def plot (self, basemap = None, alpha=1, color='red') :
     if basemap == None :
         from mpl_toolkits.basemap import Basemap
         basemap = Basemap(
                 projection = 'nplaea',
                 boundinglat = 30,
                 lon_0 = 0,
                 round = True)
         basemap.drawcoastlines()
     """
     basemap.plot(*basemap(self.lons, self.lats),
             linewidth=2, color=color, alpha=0.3)
     """
     x, y = basemap(self.lons, self.lats)
     basemap.quiver(x[:-1], y[:-1], x[1:]-x[:-1], y[1:]-y[:-1],
         scale_units='xy', angles='xy', scale=1, width=3e-3, color=color, alpha=alpha)
开发者ID:Biroise,项目名称:aa,代码行数:18,代码来源:tracker.py

示例15: main

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import quiver [as 别名]
def main():

    plot_utils.apply_plot_params(width_cm=20, height_cm=20, font_size=10)

    high_hles_years = [1993, 1995, 1998]
    low_hles_years = [1997, 2001, 2006]
    data_path = "/BIG1/skynet1_rech1/diro/sample_obsdata/eraint/eraint_uvslp_years_198111_201102_NDJmean_ts.nc"





    with xr.open_dataset(data_path) as ds:
        print(ds)


        u = get_composit_for_name(ds, "u10", high_years_list=high_hles_years, low_years_list=low_hles_years)
        v = get_composit_for_name(ds, "v10", high_years_list=high_hles_years, low_years_list=low_hles_years)
        msl = get_composit_for_name(ds, "msl", high_years_list=high_hles_years, low_years_list=low_hles_years)

        lons = ds["longitude"].values
        lats = ds["latitude"].values

        print(lats)
        print(msl.shape)
        print(lons.shape, lats.shape)


        lons2d, lats2d = np.meshgrid(lons, lats)


    fig = plt.figure()

    map = Basemap(llcrnrlon=-130, llcrnrlat=22, urcrnrlon=-28,
                  urcrnrlat=65, projection='lcc', lat_1=33, lat_2=45,
                  lon_0=-95, resolution='i', area_thresh=10000)


    clevs = np.arange(-11.5, 12, 1)
    cmap = cm.get_cmap("bwr", len(clevs) - 1)
    bn = BoundaryNorm(clevs, len(clevs) - 1)

    x, y = map(lons2d, lats2d)
    im = map.contourf(x, y, msl / 100, levels=clevs, norm=bn, cmap=cmap) # convert to mb (i.e hpa)
    map.colorbar(im)


    stride = 2
    ux, vy = map.rotate_vector(u, v, lons2d, lats2d)
    qk = map.quiver(x[::stride, ::stride], y[::stride, ::stride], ux[::stride, ::stride], vy[::stride, ::stride],
               scale=10, width=0.01, units="inches")
    plt.quiverkey(qk, 0.5, -0.1, 2, "2 m/s", coordinates="axes")


    map.drawcoastlines(linewidth=0.5)
    map.drawcountries()
    map.drawstates()
    #plt.show()

    fig.savefig("hles_wind_compoosits.png", bbox_inches="tight", dpi=300)
开发者ID:guziy,项目名称:RPN,代码行数:62,代码来源:plot_slp_and_circulation.py


注:本文中的mpl_toolkits.basemap.Basemap.quiver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。