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


Python Basemap.transform_vector方法代码示例

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


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

示例1: m

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
clevs = np.arange(960,1061,5)
# compute native x,y coordinates of grid.
x, y = m(lons, lats)
# define parallels and meridians to draw.
parallels = np.arange(-80.,90,20.)
meridians = np.arange(0.,360.,20.)
# plot SLP contours.
CS1 = m.contour(x,y,slp,clevs,linewidths=0.5,colors='k',animated=True)
CS2 = m.contourf(x,y,slp,clevs,cmap=plt.cm.RdBu_r,animated=True)
# plot wind vectors on projection grid.
# 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,longitudes,start=False)
vgrid,newlons = shiftgrid(180.,v,longitudes,start=False)
# transform vectors to projection grid.
uproj,vproj,xx,yy = \
m.transform_vector(ugrid,vgrid,newlons,latitudes,31,31,returnxy=True,masked=True)
# now plot.
Q = m.quiver(xx,yy,uproj,vproj,scale=700)
# make quiver key.
qk = plt.quiverkey(Q, 0.1, 0.1, 20, '20 m/s', labelpos='W')
# draw coastlines, parallels, meridians.
m.drawcoastlines(linewidth=1.5)
m.drawparallels(parallels)
m.drawmeridians(meridians)
# add colorbar
cb = m.colorbar(CS2,"bottom", size="5%", pad="2%")
cb.set_label('hPa')
# set plot title
ax.set_title('SLP and Wind Vectors '+str(date))
plt.show()
开发者ID:chiluf,项目名称:Environmental-Data-Exploration-Visualization,代码行数:33,代码来源:Plotting+wind+vectors+and+wind+barbs.py

示例2: Pressure

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
delon = 45.
meridians = np.arange(-180,180,delon)
m.drawmeridians(meridians,labels=[1,1,1,1])
plt.title('Surface Winds Winds and Pressure (lat-lon grid)',y=1.075)
 
# plot vectors in map projection coordinates.

# north polar projection.
m = Basemap(lon_0=-135,boundinglat=25,round=True,
            resolution='c',area_thresh=10000.,projection='npstere')
# transform from spherical to map projection coordinates (rotation
# and interpolation).
nxv = 41; nyv = 41
nxp = 101; nyp = 101
spd = np.sqrt(u**2+v**2)
udat, vdat, xv, yv = m.transform_vector(u,v,lons1,lats1,nxv,nyv,returnxy=True)
pdat, xp, yp = m.transform_scalar(p,lons1,lats1,nxp,nyp,returnxy=True)
# create a figure, add an axes.
fig=plt.figure(figsize=(8,8))
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map
im = m.imshow(pdat,plt.cm.jet)
# plot wind vectors over map.
Q = m.quiver(xv,yv,udat,vdat) #or specify, e.g., width=0.003, scale=400)
qk = plt.quiverkey(Q, 0.95, 1.05, 25, '25 m/s', labelpos='W')
m.colorbar(pad='12%') # draw colorbar
m.drawcoastlines()
m.drawcountries()
# draw parallels
delat = 20.
circles = np.arange(0.,90.+delat,delat).tolist()+\
开发者ID:matplotlib,项目名称:basemap,代码行数:33,代码来源:quiver_demo.py

示例3: enumerate

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
# parallels, meridians and title.
for nt, date in enumerate(dates):
    CS = m.contour(x, y, slp[nt, :, :], clevs, linewidths=0.5, colors="k", animated=True)
    CS = m.contourf(x, y, slp[nt, :, :], clevs, cmap=plt.cm.RdBu_r, animated=True)
    # plot wind vectors on lat/lon grid.
    # rotate wind vectors to map projection coordinates.
    # 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.0, u[nt, :, :], longitudes, start=False)
    vgrid, newlons = shiftgrid(180.0, 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 = plt.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)
    plt.title("SLP and Wind Vectors " + str(date))
    if nt == 0:  # plot colorbar on a separate axes (only for first frame)
        cax = plt.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")
        plt.axes(ax)  # reset current axes
    plt.draw()  # draw the plot
开发者ID:nlhepler,项目名称:basemap,代码行数:33,代码来源:pnganim.py

示例4: m

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
        lat_ts=20,
        resolution="f",
    )

    # Draw a think border around the whole map
    m.drawmapboundary(linewidth=3)

    # Plot Data
    xi, yi = m(lon2, lat2)
    cs = m.pcolormesh(xi, yi, umag, cmap=cm.gist_ncar_r, vmin=0.01, vmax=1)
    xi, yi = m(lon, lat)
    cM = m.contour(xi, yi, scope2, [1, 1], colors="k", linewidth=2.0)

    # transform vectors to projection grid.
    uproj, vproj, xx, yy = m.transform_vector(
        u[::3, ::3], v[::3, ::3], lonu[0, ::3].squeeze(), latu[::3, 0].squeeze(), 60, 60, returnxy=True, masked=True
    )
    # now plot.
    Q = m.quiver(xx, yy, uproj, vproj, scale=15)

    # Add Grid Lines
    m.drawparallels(np.arange(0.0, 90.0, 10.0), labels=[1, 0, 0, 0], fontsize=10, linewidth=0.75, color=".5")
    m.drawmeridians(np.arange(-105.0, -35.0, 10.0), labels=[0, 0, 0, 1], fontsize=10, linewidth=0.75, color=".5")

    # Add Coastlines, States, and Country Boundaries
    m.drawcoastlines()
    m.drawstates()
    m.drawcountries()
    m.fillcontinents(color="grey")

    # Add Colorbar
开发者ID:austinctodd,项目名称:USEast,代码行数:33,代码来源:plot_surface_vels.py

示例5: plot_seasonal_winds

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
def plot_seasonal_winds(samples_folder, seasons=commons.default_seasons, level_hpa=850):
    long_name = "Wind at {}hPa".format(level_hpa)
    file_prefix = "dp"

    plot_units = "m/s"
    mult_coeff = 0.5144444444
    add_offset = 0

    out_dx = 0.5

    lons2d, lats2d, u_season_to_mean, v_season_to_mean = calculate_seasonal_mean_winds(seasons=seasons,
                                                                                       level_hpa=level_hpa,
                                                                                       samples_folder=samples_folder,
                                                                                       file_prefix=file_prefix)


    # Plotting ++++++++++++++++++
    plot_utils.apply_plot_params(width_cm=25, height_cm=15, font_size=18)
    fig = plt.figure()
    ncols = 2
    gs = GridSpec(len(u_season_to_mean) // ncols + int(not (len(u_season_to_mean) % ncols == 0)), ncols, wspace=0, hspace=0)
    xx, yy = None, None
    bmp = Basemap(projection="robin", lon_0=0)

    cmap = cm_basemap.GMT_no_green

    clevs = None


    for i, (sname, u_field) in enumerate(u_season_to_mean.items()):
        row = i // ncols
        col = i % ncols

        ax = fig.add_subplot(gs[row, col])

        lons, lats, u = commons.interpolate_to_uniform_global_grid(u_field, lons_in=lons2d, lats_in=lats2d, out_dx=out_dx)
        _, _, v = commons.interpolate_to_uniform_global_grid(v_season_to_mean[sname], lons_in=lons2d, lats_in=lats2d, out_dx=out_dx)

        if xx is None:
            xx, yy = bmp(lons, lats)


        cs = bmp.contourf(xx, yy, (u ** 2 + v ** 2) ** 0.5 * mult_coeff, 20 if clevs is None else clevs, cmap=cmap, extend="max")

        uproj, vproj, xx_uv, yy_uv = bmp.transform_vector(u.transpose(), v.transpose(),
                                                          lons[:, 0], lats[0, :], lons.shape[0],
                                                          lats.shape[1], returnxy=True)
        step = 15
        qkey = bmp.quiver(xx_uv[::step, ::step], yy_uv[::step, ::step], uproj[::step, ::step], vproj[::step, ::step], scale=700)

        # save color levels for next subplots
        clevs = cs.levels

        ax.set_title(sname)
        cb = plt.colorbar(cs, ax=ax)
        if not (row == 0 and col == ncols - 1):
            # cb.ax.set_title(plot_units)
            cb.ax.set_visible(False)
        bmp.drawcoastlines(ax=ax, linewidth=LINEWIDTH)

    fig.suptitle("{}, {}".format(long_name, plot_units))


    img_folder = samples_folder.joinpath("images/seasonal")
    if not img_folder.is_dir():
        img_folder.mkdir(parents=True)

    img_file = img_folder.joinpath("wind_vectors_{}hPa.eps".format(level_hpa))


    with img_file.open("wb") as f:
        fig.savefig(f, format="eps", bbox_inches="tight")

    plt.close(fig)
开发者ID:guziy,项目名称:RPN,代码行数:76,代码来源:plot_seasonal_means.py

示例6: shiftgrid

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
    plt.clabel(cs2,inline=1,fmt='%1.1f',fontsize=12) 
# plot wind vectors on projection grid.
# first, shift grid so it goes from -180 to 180 (instead of 0 to 360
# in longitude).  Otherwise, interpolation is messed up.
    print lat_uwd[0]
    lat_rev=lat_uwd[::-1] 
    print lat_rev[72]
    print uwds[iz,0,0]
    uwdsx=uwds[iz,::-1,:]
    print uwdsx[72,0]
    vwdsx=vwds[iz,::-1,:]
    ugrid,newlons = shiftgrid(180.,uwdsx,lon_uwd,start=False)
    vgrid,newlons = shiftgrid(180.,vwdsx,lon_uwd,start=False)
# transform vectors to projection grid.       
    uproj,vproj,xx,yy = \
    m.transform_vector(ugrid,vgrid,newlons,lat_rev,40,30,returnxy=True,masked=True)
# now plot.
    Q = m.quiver(xx,yy,uproj,vproj,color='w')
# make quiver key.
    qk = plt.quiverkey(Q, 0.1, 0.1, 10, '10 m/s') #, labelpos='W')
    if iz<5:
        clevs_ht=[3000.,12000] 
        color_ht=['lightgrey','lightgrey','lightgrey']                
        cs3 = m.contourf(x,y,height,clevs_ht, alpha=1.0,\
                     colors=color_ht,antialiased=True,animated=True)
    else:
        clevs_ht=[3000.]
        color_ht=['lightgrey']
        cs3 = m.contour(x,y,height,clevs_ht,linewidths=3.5,\
                     colors= color_ht,animated=True)
#    
开发者ID:cheenor,项目名称:PhD02,代码行数:33,代码来源:dynv3.py

示例7: m

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
        
            grid_lons, grid_lats = np.meshgrid(lon, lat)
            stereo_x, stereo_y = m(grid_lons, grid_lats)
            
            m.pcolor(stereo_x, stereo_y, np.squeeze(v10[count, :, :]))
            
            pl.savefig('/Users/jmh2g09/Documents/PhD/Data/Wind/Figures/'+ year + month + '_10m_v_wind.png', 
                format='png')
            pl.close()
            
            pl.figure()
            pl.clf()
            m = Basemap(projection='spstere', boundinglat=-50, lon_0=180, resolution='l')
            m.drawmapboundary()
            m.drawcoastlines(zorder=10)
            #m.fillcontinents(zorder=10)
            m.drawparallels(np.arange(-80., 81., 20.), labels=[1, 0, 0, 0])
            m.drawmeridians(np.arange(-180., 181., 20.), labels=[0, 0, 0, 1])

            ugrid, newlons = shiftgrid(180.,np.squeeze(np.flipud(u10[count, :, :])),lon,start=False)
            vgrid, newlons = shiftgrid(180.,np.squeeze(np.flipud(v10[count, :, :])),lon,start=False)
            
            uproj,vproj,xx,yy = m.transform_vector(ugrid,vgrid,newlons,np.flipud(lat),70, 70,returnxy=True,masked=True)

            m.quiver(xx, yy,  -uproj, -vproj)
            
            pl.savefig('/Users/jmh2g09/Documents/PhD/Data/Wind/Figures/'+ year + month + '_wind_quiver.png', 
                format='png')
            pl.close()
            
            count += 1
开发者ID:jhooley16,项目名称:PhD,代码行数:33,代码来源:wind_extract.py

示例8: m

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
  plt.clf()
  m=Basemap(projection='merc',llcrnrlat=lat[0,0],urcrnrlat=27.5,\
          llcrnrlon=-89,urcrnrlon=lon[481,376],lat_ts=20,resolution='f')

  # Draw a think border around the whole map
  m.drawmapboundary(linewidth=3)

  # Plot Data
  xi, yi = m(lon2,lat2)
  cs = m.pcolormesh(xi,yi,umag2,cmap=cm.gist_ncar_r,vmin=0.005, vmax = 0.5)
  xi, yi = m(lon,lat)
  cM = m.contour(   xi,yi,scope2,[1,1],colors='k',linewidth=2.0)
  
  # transform vectors to projection grid.
  uproj,vproj,xx,yy = m.transform_vector(u2[::3,::3]*12,v2[::3,::3]*12,\
                                        lonu[0,::3].squeeze(),latu[::3,0].squeeze(),\
                                         60,60,returnxy=True,masked=True)
  # now plot.
  Q  = m.quiver(xx,yy,uproj,vproj)#,scale=20)

  # Add Grid Lines
  m.drawparallels(np.arange(0.,90.,10.), labels=[1,0,0,0],\
                  fontsize=10, linewidth=0.75, color='.5')
  m.drawmeridians(np.arange(-105.,-35.,10.), labels=[0,0,0,1],\
                  fontsize=10, linewidth=0.75, color='.5')

  # Add Coastlines, States, and Country Boundaries
  m.drawcoastlines()
  m.drawstates()
  m.drawcountries()
  m.fillcontinents(color='grey')
开发者ID:austinctodd,项目名称:USEast,代码行数:33,代码来源:plot_depav_vels.py

示例9: plot_gridded_ensemble

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]

#.........这里部分代码省略.........
        lats = lats[lat_inds]
    if NautAngle(lons[0]).is_east_of(NautAngle(lons[-1])):
        lon_inds.reverse()
        lons = lons[lon_inds]

    # determine layout:
    fig_width_inches = 10
    plot_aspect_ratio = (abs(lons[-1] - lons[0]) /
                         float(abs(lats[-1] - lats[0])))
    rows = int(np.ceil(gfsx.dimensions[conv.TIME] / float(cols)))
    fig_height_inches = (fig_width_inches / (float(cols) * plot_aspect_ratio)
                         * rows + 2)
    fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))
    fig.suptitle("GFS wind forecast in %s and "
                 "ensemble wind speed deviation" % barb_units,
                 fontsize=12)
    grid = AxesGrid(fig, [0.01, 0.01, 0.95, 0.93],
                    nrows_ncols=(rows, cols),
                    axes_pad=0.8,
                    cbar_mode='single',
                    cbar_pad=0.0,
                    cbar_size=0.2,
                    cbar_location='bottom',
                    share_all=True,)

    # size for lat/lon labels, timestamp:
    label_fontsize = 'medium' if cols <= 2 else 'small'
    # format string for colorbar labels:
    decimals = max(0, int(2 - np.floor(np.log10(max_level))))
    cb_label_fmt = '%.' + '%d' % decimals + 'f'

    # heatmap color scaling and levels
    spread_levels = np.linspace(0., max_level, 50)

    m = Basemap(projection='merc', llcrnrlon=lons[0], llcrnrlat=lats[0],
            urcrnrlon=lons[-1], urcrnrlat=lats[-1], resolution='l')

    for t_step, t in enumerate(f_times):

        ax = grid[t_step]
        m.drawcoastlines(ax=ax)
        m.drawparallels(lats,labels=[1,0,0,0], ax=ax,
                fontsize=label_fontsize)
        m.drawmeridians(lons,labels=[0,0,0,1], ax=ax,
                fontsize=label_fontsize, rotation='vertical')

        # ensemble spread heatmap:
        x, y = m(*np.meshgrid(lons, lats))
        data = gfsx[conv.ENS_SPREAD_WS]
        data = data.indexed(**{conv.TIME: t_step})
        data = data.indexed(**{conv.LAT: lat_inds})
        data = data.indexed(**{conv.LON: lon_inds}).values
        cs = m.contourf(x, y, data, spread_levels, ax=ax, extend='max',
                cmap=cm.jet)

        # wind barbs:
        u = gfsx[conv.UWND].indexed(**{conv.TIME: t_step})
        u = u.indexed(**{conv.LAT: lat_inds})
        u = u.indexed(**{conv.LON: lon_inds}).values
        v = gfsx[conv.VWND].indexed(**{conv.TIME: t_step})
        v = v.indexed(**{conv.LAT: lat_inds})
        v = v.indexed(**{conv.LON: lon_inds}).values
        # transform from spherical to map projection coordinates (rotation
        # and interpolation).
        nxv = len(lons)
        nyv = len(lats)
        barb_length = 8 - cols
        barb_width = 1.2 - (cols / 10.)
        udat, vdat, xv, yv = m.transform_vector(
                u, v, lons, lats, nxv, nyv, returnxy=True)
        # plot barbs.
        m.barbs(xv, yv, udat, vdat, ax=ax, length=barb_length, barbcolor='w',
                flagcolor='r', linewidth=barb_width)

        ax.set_title(t.astype('M8[h]').item().strftime('%Y-%m-%dT%H:%MZ'),
                fontsize=label_fontsize)

    cbar = fig.colorbar(cs, cax=grid.cbar_axes[0], orientation='horizontal',
            format=cb_label_fmt)
    attr = gfsx[conv.ENS_SPREAD_WS].attrs
    cb_label = attr.get('long_name',
            'Average (normalized) wind speed delta (ens - gfs)')
    s = ["%s = %s" % (k, attr[k]) for k in attr if k != 'long_name']
    if s:
        cb_label = "%s (%s)" % (cb_label, ', '.join(s))
    cbar.set_label(cb_label)

    if save_path:
        t0_str = f_times[0].astype('M8[h]').item().strftime('%Y%m%dT%H%MZ')
        file_name = "ens_%s%s-%s%s_%s.%s" % (
                NautAngle(lats[0]).named_str(conv.LAT),
                NautAngle(lons[0]).named_str(conv.LON),
                NautAngle(lats[-1]).named_str(conv.LAT),
                NautAngle(lons[-1]).named_str(conv.LON),
                t0_str, save_fmt)
        plt.savefig(os.path.join(save_path, file_name), bbox_inches='tight')
    else:
        plt.show()

    plt.close()
开发者ID:ms8r,项目名称:slocum,代码行数:104,代码来源:enslib.py

示例10: m

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
x, y = m(X, Y)
if diagnostic == 1:
   # Plot temperature and wind at either the upper or lower level
   putstuffhere = 1
   
else:
   # Plot geostrophic vorticity and wind at either the upper or lower level
   CS1 = m.contourf(x,y,var_upper,cmap=plt.cm.hot_r,levels=cflevs_upper, extend='both',zorder=1)
   cbar = plt.colorbar(CS1, shrink=0.95, orientation='horizontal',extend='both')
   CS2 = m.contour(x, y, var_upper, cflevs_upper, colors='k', linewidths=0.5)
   cbar.set_ticks(cflevs_upper_ticks)
   clabs = ['%i K' % f for f in cflevs_upper_ticks]
   cbar.ax.set_yticklabels(clabs, size=10)      
if plot_barbs == "true":
   # Rotate and interpolate wind from lat/lon grid to map projection grid.
   uproj_lower,vproj_lower, xx_lower, yy_lower = m.transform_vector(ugrid_lower,vgrid_lower,newlons,lats,41,41,returnxy=True)
   uproj_upper,vproj_upper, xx_upper, yy_upper = m.transform_vector(ugrid_upper,vgrid_upper,newlons,lats,41,41,returnxy=True)  
   uproj_mid,vproj_mid, xx_mid, yy_mid = m.transform_vector(ugrid_mid,vgrid_mid,newlons,lats,41,41,returnxy=True)     
   barbs = m.barbs(xx_upper,yy_upper,uproj_upper,vproj_upper,length=5,barbcolor='k',flagcolor='r',linewidth=1.0)
ax1.set_title(titletext1)
save_name = figname + "_01.png"
plt.savefig(save_name, bbox_inches='tight')

# Figure 2
fig = plt.figure(figsize=(8., 16./golden), dpi=128)   # New figure
ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8])
if map_projection == 'ortho':
   m = Basemap(projection='ortho', lat_0 = 50, lon_0 = 260,
          resolution = 'l', area_thresh = 1000.,ax=ax1)
elif map_projection == 'lcc':
   #   m = Basemap(llcrnrlon=-125.5,llcrnrlat=15.,urcrnrlon=-30.,urcrnrlat=50.352,\
开发者ID:metr4424,项目名称:classcode,代码行数:33,代码来源:plot_qg_diagnostics_forlab8.py

示例11: map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
map.drawcoastlines(linewidth=2, color="#444444", zorder=6)
map.drawcountries(linewidth=1, color="#444444", zorder=5)
map.drawstates(linewidth=0.66, color="#444444", zorder=4)
map.drawmapboundary

x, y = map(X, Y)
cf = map.contour(x, y, temperature_plot, levels=clevs, extend="both", zorder=1, linewidths=2)
plt.clabel(cf, inline=1, fontsize=10)

# plot wind vectors on projection grid.
# 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.0, u_plot, lons, start=False)
vgrid, newlons = shiftgrid(180.0, v_plot, lons, start=False)
# transform vectors to projection grid and plot windbarbs.
uproj, vproj, xx, yy = map.transform_vector(ugrid, vgrid, newlons, lats, 41, 41, returnxy=True)
barbs = map.barbs(xx, yy, uproj, vproj, length=5, barbcolor="k", flagcolor="r", linewidth=0.5)
# Title
ax1.set_title(str(levelh) + " hPa temperature and wind barbs")

# <codecell>

# Temperature advection plot
cbar_min = -0.0001
cbar_max = 0.0001
cfint = 0.00001
cflevs = np.arange(cbar_min, cbar_max + cfint - (cfint / 2), cfint)
ncolors = np.size(cflevs) - 1
cmap = cm.get_cmap("jet")
djet = cmap_whitezero(cmap, ncolors, 1, -1)
开发者ID:metr4424,项目名称:classcode,代码行数:32,代码来源:plot_temperature_advection.py

示例12: Basemap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
#-- create map
map = Basemap(projection='cyl',llcrnrlat= -90.,urcrnrlat= 90.,\
              resolution='c',  llcrnrlon=-180.,urcrnrlon=180.)

#-- draw coastlines, state and country boundaries, edge of map
map.drawcoastlines()
map.drawstates()
map.drawcountries()

#-- create and draw meridians and parallels grid lines
map.drawparallels(np.arange( -90., 90.,30.),labels=[1,0,0,0],fontsize=10)
map.drawmeridians(np.arange(-180.,180.,30.),labels=[0,0,0,1],fontsize=10)

#-- convert latitude/longitude values to plot x/y values
x, y = map(*np.meshgrid(lon,lat))

#-- transform vector and coordinate data
veclon = u10.shape[1]/2                    #-- only every 2nd vector
veclat = u10.shape[0]/2                    #-- only every 2nd vector
uproj,vproj,xx,yy = map.transform_vector(u,v,lonsout,lat,veclon,veclat,returnxy=True,masked=True)

#-- create vector plot on map
vecplot = map.quiver(xx,yy,uproj,vproj,scale=600)
qk = plt.quiverkey(vecplot, 0.2, -0.2, 20, '20 m/s', labelpos='W')  #-- position and reference label

#-- add plot title
plt.title('Wind velocity')

plt.show()
#plt.savefig('plot_vector_matplotlib.png')
开发者ID:KMFleischer,项目名称:PyEarthScience,代码行数:32,代码来源:vectors_simple_matplotlib.py

示例13: Basemap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
from osgeo import gdal
import numpy as np

map = Basemap(projection='sinu', 
              lat_0=0, lon_0=0)

lons = np.linspace(-180, 180, 8)
lats = np.linspace(-90, 90, 8)

v10 = np.ones((lons.shape)) * 15
u10 = np.zeros((lons.shape))

u10, v10 = np.meshgrid(u10, v10)

u10_rot, v10_rot, x_rot, y_rot = map.transform_vector(u10, v10, 
                                                      lons, lats, 
                                                      15, 15, 
                                                      returnxy=True)

map.drawmapboundary(fill_color='#9999FF')
map.fillcontinents(color='#ddaa66', lake_color='#9999FF', zorder = 0)
map.drawcoastlines(color = '0.15')

#Drawing the original points
lons, lats = np.meshgrid(lons, lats)
x, y = map(lons, lats)
map.barbs(x, y, u10, v10, 
    pivot='middle', barbcolor='#333333')

#Drawing the rotated & interpolated points
map.barbs(x_rot, y_rot, u10_rot, v10_rot, 
    pivot='middle', barbcolor='#ff5555')
开发者ID:dansand,项目名称:vieps_mapping,代码行数:34,代码来源:transform_vector.py

示例14: m

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
m=Basemap(projection='merc',lat_ts=10, llcrnrlon=lons.min(),urcrnrlon=lons.max()-3, llcrnrlat=lats.min()+3,urcrnrlat=lats.max(), resolution='c')
fig1 = plt.figure(figsize=(8,10)) ; ax = fig1.add_axes([0.1,0.1,0.8,0.8])
x, y = m(lon, lat)

cmap = plt.cm.Reds
cmap = plt.cm.Spectral
cmap = plt.cm.RdBu_r

clevs = np.arange(990,1010,1)
cs1 = m.contour(x,y,p,clevs,linewidths=1.0,colors='k',animated=True)
cs2 = m.contourf(x,y,p,clevs,cmap=cmap,animated=True)

ugrid,newlons = shiftgrid(62.,uin,lons,start=True)
vgrid,newlons = shiftgrid(62.,vin,lons,start=True)

uproj,vproj,xx,yy = m.transform_vector(ugrid,vgrid,newlons,lats,51,51,returnxy=True,masked=True)
Q = m.quiver(xx,yy,uproj,vproj,scale=250,zorder=10,color='r')
qk = plt.quiverkey(Q, 0.1, 0.1, 20, '15 m/s', labelpos='W',coordinates='data',color='r')


m.readshapefile('subdiv/India_subdiv','ind',drawbounds=True, zorder=None, linewidth=1.0, color='k', antialiased=1, ax=None, default_encoding='utf-8')
m.drawmapboundary(fill_color='aqua') ; #m.fillcontinents(color='white',lake_color='white')
m.drawparallels(np.arange(0.,40.,10.), labels=[1,0,0,0])
m.drawmeridians(np.arange(60.,100.,10.), labels=[0,0,0,1])
cbar=m.colorbar(cs2,location='bottom', pad='5%') ; cbar.set_label('hpa') ; 
#plt.clabel(cs2, fontsize=9, inline=1)
m.bluemarble() ;
plt.title('Mean Sea Level Pressure(hpa) & Wind Vectors'); savefig('slp.png', dpi=100);
plt.show()

开发者ID:krnvi,项目名称:sample-plots,代码行数:31,代码来源:slpwindvectors.py

示例15: m

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import transform_vector [as 别名]
    plt.clf()
    m=Basemap(projection='merc',llcrnrlat=20,urcrnrlat=lat[481,401-26]+8,\
              llcrnrlon=-90.75,urcrnrlon=lon[481,401-26]+5,lat_ts=20,resolution='f')
      
    # Draw a thick border around the whole map
    m.drawmapboundary(linewidth=3)
              
    # Plot Data
    xi, yi = m(lon2,lat2)
    cs = m.pcolormesh(xi,yi,umag,cmap=cm.gist_ncar_r,vmin=0.005, vmax = 0.1)
    xi, yi = m(lon,lat)
    cM = m.contour(   xi,yi,scope2,[1,1],colors='k',linewidth=2.0)

    # transform vectors to projection grid.
    uproj,vproj,xx,yy = m.transform_vector(u[1::2,1::2]*10,v[1::2,1::2]*10,\
                                         lonu[0,1::2].squeeze(),latu[1::2,0].squeeze(),\
                                         60,60,returnxy=True,masked=True)
    # now plot.
    Q  = m.quiver(xx,yy,uproj,vproj,scale=15)

    # Add Coastlines, States, and Country Boundaries
    m.drawcoastlines()
    m.drawstates()
    m.drawcountries()
    m.fillcontinents(color='grey')
              
    # Add Colorbar
    clabels=np.array([0.005,0.025,0.05,0.075,0.1])
    cbar = m.colorbar(cs, location='right', pad="2%",ticks=clabels,extend='max')
    cbar.set_label('Current Speed (m/s)')
    cbar.ax.set_yticklabels([0.5,2.5,5,7.5,10])
开发者ID:austinctodd,项目名称:USEast,代码行数:33,代码来源:plot_bottom_vels_shelfmask.py


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