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


Python Basemap.contour方法代码示例

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


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

示例1: generate_image

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def generate_image(year, month, xs=500, ys=500, elev=60, azim=-90, colormap=cm.seismic):
    m = Basemap(width=12000000,height=12000000,
                rsphere=(6378137.00,6356752.3142),\
                resolution='l',area_thresh=1000.,projection='lcc',\
                lat_0=45,lon_0=170)

    ssl_loc = '/home/guy/Data/cci-ssl/ESACCI-SEALEVEL-L4-MSLA-MERGED-%04d%02d15000000-fv01.nc' % (year, month)
    lons_proj, lats_proj, XX, YY, sla = reproject_data(ssl_loc,'sla', m, xsize=xs, ysize=ys, filter=0)
    sst_loc = '/mnt/surft/data/SST_CCI_L4_monthly_mean_anomalies/%04d%02d--ESACCI-L4_GHRSST-SSTdepth-OSTIA-GLOB_LT-v02.0-fv01.0_anomalies.nc' %(year, month)
    lons_proj, lats_proj, XX, YY, sst = reproject_data(sst_loc,'sst_anomaly', m, xsize=xs, ysize=ys, filter=None)
    
    min_sst = -4
    max_sst = 4
    
    colors = np.empty(sst.shape, dtype=np.dtype((float, (4))))
    for y in range(sst.shape[1]):
        for x in range(sst.shape[0]):
            val = sst[x, y]
            if(np.ma.getmask(sst[x,y]) == True):
                colors[x,y] = (1,0,0,0)
            else:
                zero_to_one = (val - min_sst) / (max_sst - min_sst)
                colors[x, y] = colormap(zero_to_one)
    
    fig = plt.figure(figsize=(19.2,9.6))
    
    ax = plt.subplot(121, projection='3d')
       
    # ax = fig.gca(projection='3d')
    ax.view_init(elev=elev, azim=azim)
    ax.set_axis_off()
     
    surf = ax.plot_surface(XX, YY, sla, rstride=1, cstride=1, facecolors=colors,#cmap=cm.coolwarm,
                           linewidth=0, antialiased=False)
    ax.set_zlim(-3, 3)
    ax.set_xlim((0.22 * xs, 0.78 * xs))
    ax.set_ylim((0.18 * ys, 0.82 * ys))
    
    ax2d = plt.subplot(122, aspect=1)
    m.bluemarble(ax=ax2d, scale=0.2)
    #m.imshow(sst, ax=ax, cmap=cm.coolwarm)
    x, y = m(lons_proj, lats_proj)
    m.pcolor(x,y, sst, ax=ax2d, cmap=colormap, vmin=min_sst, vmax=max_sst)
    
    #matplotlib.rcParams['contour.negative_linestyle'] = 'dashed'
    m.contour(x,y, sla, np.linspace(-1,1,11), colors='k', ax=ax2d)
    # m.pcolor(XX, YY, sla, ax=ax)
    #ax.pcolormesh(XX,YY,sst, vmin=min_sst, vmax=max_sst, cmap=cm.coolwarm)
    
    
    # ax = fig.gca()
    # surf = ax.pcolormesh(XX,YY,sla, vmin=-limit, vmax=limit)
    # fig.colorbar(surf, shrink=0.5, aspect=5)
    
    fig.tight_layout()
    return fig
开发者ID:guygriffiths,项目名称:cci-visualisations,代码行数:58,代码来源:cci-ssl.py

示例2: plotmap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def plotmap(variable, mode='multi', tstep=0, proj='merc', style='pcolormesh', clevs=20):

	latitudes = variable.coords['latitude'][:]
	longitudes = variable.coords['longitude'][:]

	lats, lons = makegrid(latitudes, longitudes, variable.shape[-2:])

	vmin, vmax = variable[:].min(), variable[:].max()

	llcrnrlat, urcrnrlat = lats.min(), lats.max()
	llcrnrlon, urcrnrlon = lons.min(), lons.max()
	lat_ts = lats.mean()
	lon_0 = lons.mean()

	fig = plt.figure(figsize=(10,14))

	cols, rows = 1, 1

	if mode == 'tstep':
		data = variable[:][tstep]
	elif mode == 'mean':
		data = variable[:].mean(axis=0)
	elif mode == 'multi':
		nplots = variable.shape[0]
		cols = int(np.floor(np.sqrt(nplots)))
		rows = int(np.ceil(np.sqrt(nplots)))

		print nplots, cols, rows

	fig, axes = plt.subplots(rows, cols, squeeze=False)

	for col in range(cols):
		for row in range(rows):
			print col, row, col+cols*row
			if proj == 'merc':
				m = Basemap(projection='merc',llcrnrlat=llcrnrlat,urcrnrlat=urcrnrlat,llcrnrlon=llcrnrlon,urcrnrlon=urcrnrlon,lat_ts=lat_ts,resolution='l', ax=axes[row][col])
			elif proj == 'lcc':
				m = Basemap(projection='lcc',llcrnrlat=llcrnrlat,urcrnrlat=urcrnrlat,llcrnrlon=llcrnrlon,urcrnrlon=urcrnrlon,lat_0=lat_ts,lon_0=lon_0,resolution='l', ax=axes[row][col])

			x, y = m(lons, lats)

			if mode == 'multi':
				data = variable[col+cols*row]

			if style == 'pcolormesh':
				m.pcolormesh(x, y, data, vmin=vmin, vmax=vmax, cmap='Blues')
			elif style == 'contour':
				m.contourf(x, y, data, clevs)
				m.contour(x, y, data, clevs, colors='black')

			m.fillcontinents(color='white',lake_color='aqua',zorder=0)
			m.drawcoastlines(linewidth=1.0)

			plt.tight_layout()

	return plt
开发者ID:csag-uct,项目名称:climstats,代码行数:58,代码来源:plotting.py

示例3: main

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def main(file_name='Greenland1km.nc'):
    '''Description'''

    # Set up the file and projection
    data = os.path.dirname(os.path.abspath(__file__)) + os.sep + '..' + os.sep \
            + 'data' + os.sep + file_name
    proj_file = pyproj.Proj('+proj=stere +ellps=WGS84 +datum=WGS84 +lat_ts=71.0 +lat_0=90 ' \
            + '+lon_0=321.0 +k_0=1.0')
    proj_lat_long = pyproj.Proj('+proj=latlong +ellps=WGS84 +datum=WGS84')
    fig, ax = plt.subplots(1,2)

    # Open up the file and grab the data we want out of it
    greenland = Dataset(data)
    x = greenland.variables['x'][:]
    y = greenland.variables['y'][:]
    nx = x.shape[0]
    ny = y.shape[0]
    y_grid, x_grid = scipy.meshgrid(y[:], x[:], indexing='ij')
    thk = greenland.variables['thk'][0]
    bheatflx = greenland.variables['bheatflx'][0]

    # Now transform the coordinates to the correct lats and lons
    lon, lat = pyproj.transform(proj_file, proj_lat_long, x_grid.flatten(), y_grid.flatten())
    lat = lat.reshape(ny,nx)
    lon = lon.reshape(ny,nx)

    # Put thickness in a basemap
    mapThk = Basemap(projection='stere',lat_0=65, lon_0=-25,\
                llcrnrlat=55,urcrnrlat=85,\
                llcrnrlon=-50,urcrnrlon=0,\
                rsphere=6371200.,resolution='l',area_thresh=10000, ax=ax[0])
    mapThk.drawcoastlines(linewidth=0.25)
    mapThk.fillcontinents(color='grey')
    mapThk.drawmeridians(np.arange(0,360,30))
    mapThk.drawparallels(np.arange(-90,90,30))
    x, y = mapThk(lon,lat)
    cs = mapThk.contour(x, y, thk, 3)

    # Put basal heat flux in a basemap
    mapFlx = Basemap(projection='stere',lat_0=65, lon_0=-25,\
                llcrnrlat=55,urcrnrlat=85,\
                llcrnrlon=-50,urcrnrlon=0,\
                rsphere=6371200.,resolution='l',area_thresh=10000, ax=ax[1])
    mapFlx.drawcoastlines(linewidth=0.25)
    mapFlx.fillcontinents(color='grey')
    mapFlx.drawmeridians(np.arange(0,360,30))
    mapFlx.drawparallels(np.arange(-90,90,30))
    x, y = mapFlx(lon,lat)
    cs = mapFlx.contour(x, y, bheatflx, 3)

    plugins.connect(fig, ClickInfo(cs))
    mpld3.show()
开发者ID:arbennett,项目名称:Greenland_Interacts,代码行数:54,代码来源:greenland_interacts.py

示例4: plot_cappi

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def plot_cappi(data,parm,lnum, **kwargs):
	x=data['xar']
	y=data['yar']
	radar_loc=data['radar_loc']
	radar_name=kwargs.get('radar_name', data['radar_name'])
	fig_name=kwargs.get('fig_name', 'cappi_'+parm+'_.png')
	f=figure()
	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-data['displacement'][0])/(rad_at_radar*2.0*pi)
	lats=radar_loc[0] + 360.0*(y-data['displacement'][1])/(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)
	#print 'Here'
	map= Basemap(projection='merc', resolution='l',area_thresh=1., **loc_dict)
	longr, latgr=meshgrid(lons,lats)
	xx, yy = map(longr, latgr)
	#print 'there'
	map.drawmapboundary()
	darwin_loc=[-12.5, 130.85]
	disp_from_darwin=mathematics.corner_to_point(darwin_loc, radar_loc)
	dist_from_darwin=sqrt(disp_from_darwin[0]**2+disp_from_darwin[1]**2)
	if dist_from_darwin < 500.*1000.: 
		map.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	else:
		map.drawcoastlines()
	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)
	#print 'everywhere'
	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)}
	#print 'or here?'
	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)'}
	#print parm
	if 'mask' in kwargs.keys():
		mask=kwargs['mask'][:,:,lnum]
		mdata=M.masked_where(M.array(mask) < 0.5, M.array(data[parm][:,:,lnum]))
		map.contourf(xx,yy,mdata, levels=levs_dict[parm])
	else:
		map.contourf(xx,yy,data[parm][:,:,lnum], levels=levs_dict[parm])
	colorbar()
	if 'angs' in kwargs.keys():
		map.contour(xx,yy,kwargs['angs'], levels=[30.0, 150.0],colors=['r']) 
	p=data['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(radar_name+' '+dtstr+titles_dict[parm])
	savefig(getenv('HOME')+'/bom_mds/output/'+fig_name)
	close(f)
开发者ID:scollis,项目名称:bom_mds,代码行数:50,代码来源:pres.py

示例5: bp

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def bp(lon, lat, data, yescbar, region = 'Arctic', ptype = 'contourf', **kwargs):
    
    '''Basic Basemap plot function. Use coordinates (1d or 2d), data and name of the region
     as an input and plot data. Region defines in the "regbase" function.

     You can also provide any argument for matplotlib plotting functions.

     Usage:
         bp(lon, lat, data, region = 'Arctic', ptype = 'contourf', **kwargs)
     
     Input:
        lon         - 2D or 1D array of longitudes
        lat         - 2D or 1D array of latitudes
        data        - 2D array of scalar data.
        region      - one of the predefined regions (for list of regions see the "regbase" function)
        ptype       - plot type (contour, contourf, pcolor, pcolormesh)
        **kwargs    - arguments for plotting functions

     Output:
        Basemap instance.
    '''
    
    mapDict = regbase(region)

    # Create Basemap instance
    if mapDict['projection'] == 'npstere':
        m = Basemap(projection=mapDict['projection'],boundinglat=mapDict['boundinglat'],\
                    lon_0=mapDict['lon_0'],resolution=mapDict['resolution'])
    
    # Check if we have proper number of dimensions for lon (and hopefully lat as well)
    if lon.shape.__len__() == 1:
        lon, lat = np.meshgrid(lon, lat)
    elif lon.shape.__len__() > 2:
        raise Exception("Coordinate variables (lon) has too many dimensions")
    
    # Convert lat/lon to map coordinates
    x, y = m(lon, lat)

    # Make the map look better
    m.fillcontinents(color='gray',lake_color='gray')
    m.drawparallels(np.arange(-80.,81.,20.))
    m.drawmeridians(np.arange(-180.,181.,20.))
    m.drawmapboundary(fill_color='white')
    
    # Draw values on the map
    if ptype == 'contourf':
        cs = m.contourf(x,y,data,**kwargs)
        if yescbar == True:
            cbar3 = plt.colorbar(cs)
        return m
    elif ptype == 'pcolormesh':
        cs = m.pcolormesh(x,y,data,**kwargs)
    elif ptype == 'contour':
        cs = m.contour(x,y,data,**kwargs)
    elif ptype == 'pcolor':
        cs = m.pcolor(x,y,data,**kwargs)
    else:
        raise Exception("Plot type not supported. Valid plot types are: contour, contourf, pcolor, pcolormesh ")
    
    return m
开发者ID:AlessandroMozzato,项目名称:python_functions,代码行数:62,代码来源:plottransect.py

示例6: grid_plot

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def grid_plot(lon,lat, topoin, etlats, etlons, llimx=-180.,\
                    ulimx=-130.,llimy=50.,ulimy=75.):
    """"
    Parameters
    ----------
            lat: array_like
                0->360 Prime to Prime or -180 -> 180 IDL -> IDL
    
    Returns
    -------
            figure and plot instances
              
    """
    
    fig1 = plt.figure(1)
    #Custom adjust of the subplots
    ax = plt.subplot(1,1,1)
    #Let's create a basemap of Alaska
    x1 = llimx
    x2 = ulimx
    y1 = llimy
    y2 = ulimy
 
    m = Basemap(resolution='i',projection='merc', llcrnrlat=y1,urcrnrlat=y2,llcrnrlon=x1,urcrnrlon=x2,lat_ts=((y1+y2)/2))
    x, y = m(lon,lat)
    ex, ey = m(etlons, etlats)
    #lonpt, latpt = m(x,y,inverse=True)

    m.drawcountries(linewidth=0.5)
    m.drawcoastlines(linewidth=0.5)
    m.drawparallels(np.arange(y1,y2,5.),labels=[1,0,0,0],color='black',dashes=[1,1],labelstyle='+/-',linewidth=0.2) # draw parallels
    m.drawmeridians(np.arange(x1-20,x2,5.),labels=[0,0,0,1],color='black',dashes=[1,1],labelstyle='+/-',linewidth=0.2) # draw meridians
    m.fillcontinents(color='black')

    
    m.contour(ex,ey,topoin, levels=[ -70, -100, -200, -1000], linewidths=0.2)
    m.scatter(x,y,20,marker='+')

    
 
    f = plt.gcf()
    DefaultSize = f.get_size_inches()
    f.set_size_inches( (DefaultSize[0]*4, DefaultSize[1]*2) )

    return (fig1, plt)
开发者ID:shaunwbell,项目名称:AtSeaPrograms,代码行数:47,代码来源:isobath70m.py

示例7: plot_topo

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def plot_topo(filename,savename):
    """
    Reads in the topography/bathemetry text file and plots the data.
    """
    f = open(filename,'r')

    lon=[]
    lat=[]
    topo=[]
    for line in f.readlines():
        temp = line.split()
        if (float(temp[0]) == -180.0):
            lat.append(float(temp[1]))
        if (float(temp[1]) == -90.0):
            lon.append(float(temp[0]))
        topo.append(float(temp[2]))

    topo = np.array(topo).reshape((len(lat),len(lon)))

    lons,lats = np.meshgrid(lon,lat)

    m = Basemap(projection='cyl',
                llcrnrlon=-180,
                urcrnrlon=180,
                llcrnrlat=-90,
                urcrnrlat=90)

    x,y = m(lons,lats)

    fig = plt.figure(figsize=(10,5))
    m.drawmeridians(np.arange(-180,181,30),labels=[1,0,0,1])
    m.drawparallels(np.arange(-90,91,30), labels=[0,1,1,0])

    pcm = m.pcolormesh(x,y,topo,cmap='RdBu_r',vmin=-6000,vmax=6000)
    m.contour(x,y,topo,[-1000,0,1000],colors='k',linewidths=[.5, 1, .5])
    
    cax = fig.add_axes([0.68, 0.17, 0.14, 0.02])
    cb = plt.colorbar(pcm, cax=cax, orientation='horizontal',ticks=[-6000,-3000,0,3000,6000])
    cb.set_label('Topography/Bathymetry [m]',fontsize=6)
    xtl = cax.get_xticklabels()
    for foo in xtl:
        foo.set_fontsize(6)
    plt.savefig(savename,dpi=600)
开发者ID:mherr77m,项目名称:pg2014_herrera,代码行数:45,代码来源:HW2_q5.py

示例8: reconstruction_plot_pcolor

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def reconstruction_plot_pcolor(lats, lons, data_cube, lvl_num, parm, u, v,w, angs, mask, **kwargs):
	ber_loc=[-12.4, 130.85] #location of Berrimah radar
	gp_loc=[-12.2492,  131.0444]#location of CPOL at Gunn Point
	box=kwargs.get('box',[130.0, 132.0, -13.0, -11.5])#box for the plot
	bquiver=kwargs.get('bquiver', [0.1, 0.75])
	ksp=kwargs.get('ksp', 0.05)
	#Set up the map and projection
	mapobj= Basemap(projection='merc',lat_0=(box[2]+box[3])/2.0, lon_0=(box[0]+box[1])/2.0,llcrnrlat=box[2], llcrnrlon=box[0], urcrnrlat=box[3] , urcrnrlon=box[1], resolution='l',area_thresh=1., lat_ts=(box[2]+box[3])/2.0)
	#map.drawmapboundary()
	um=M.masked_where(M.array(mask) < 0.5, M.array(u))
	vm=M.masked_where(M.array(mask) < 0.5, M.array(v))
	mag=M.array(sqrt(u**2+v**2))
	magm=M.masked_where(M.array(mask)<0.5, mag)
	fig_name=kwargs.get('fig_name', 'recon_'+parm+'_.png')
	longr, latgr=meshgrid(lons,lats)
	xx, yy = mapobj(longr, latgr)
	mapobj.drawmapboundary()
	mapobj.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	mapobj.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstqldmd_r', 'qcoast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	#mapobj.drawmeridians(array([130,130.5, 131, 131.5, 132]), labels=[1,0,0,1])
	#mapobj.drawparallels(array([-13,-12.5,-12,-11.5,-11]), labels=[1,0,0,1])
	data=M.masked_where(M.array(mask) < 0.5, M.array(data_cube[parm][:,:,lvl_num]))
	if parm in ['diff']:
		data=M.masked_where(M.array(mask) < 0.5, M.array(data))
	comp_levs=linspace(-1.,1., 30)
	levs_dict={'VR':linspace(-25,25,51), 'CZ': linspace(-8,64,10), 'i_comp':comp_levs,'j_comp':comp_levs,'k_comp':comp_levs,'diff':linspace(-15,15,31), 'VE':linspace(-25,25,51)}
	titles_dict={'VR': 'Radial velocity m/s', 'CZ':'Corrected Reflectivity dBz', 'TEST':'TEST', 'i_comp':'i component','j_comp':'j component','k_comp':'k component', 'diff':'diff', 'VE':'Edited velocity'}
	mapobj.pcolor(xx,yy,data, vmin=levs_dict[parm].min(), vmax=levs_dict[parm].max())
	colorbar()
	#mapobj.quiver(xx,yy,u/sqrt(u**2+v**2),v/sqrt(u**2+v**2), scale=50)
	qq=mapobj.quiver(xx,yy,um,vm, scale=kwargs.get('qscale', 200))
	quiverkey(qq, bquiver[0], bquiver[1]+2.*ksp, 10, '10 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	print bquiver[0], bquiver[1]+2.*ksp
	quiverkey(qq, bquiver[0], bquiver[1]+ksp, 5, '5 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	quiverkey(qq, bquiver[0], bquiver[1], 2, '2 m/s', coordinates='figure',fontproperties={'size':rcParams['xtick.labelsize']})
	cobject=mapobj.contour(xx,yy,w, colors=['k'], levels=linspace(-10,10,6))
	fon = { 'fontname':'Tahoma', 'fontsize':5 }
	clabel(cobject, fmt="%1.1f", **fon)
	mapobj.contour(xx,yy,angs, levels=[30.0, 150.0],colors=['r']) 
	mapobj.readshapefile(getenv('HOME')+'/bom_mds/shapes/nt_coast','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	mapobj.drawmeridians(linspace(0,4,41)+130., labels=[1,0,0,1], fontsize=rcParams['xtick.labelsize'])
	mapobj.drawparallels(linspace(0,4,41)-15.0, labels=[1,0,0,1], fontsize=rcParams['ytick.labelsize'])
	return mapobj
开发者ID:scollis,项目名称:bom_mds,代码行数:45,代码来源:pres.py

示例9: plot_topBL

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
    def plot_topBL(self,datagrid,ugrid,vgrid,filename):
      
        module = (np.sqrt(ugrid*ugrid+vgrid*vgrid))*3.6
        
        fig = plt.figure(figsize=(figsize,figsize),dpi=self.cfg.map_dpi)
        
        Lon,Lat = np.meshgrid(self.lon, self.lat)
        
        map = Basemap(llcrnrlon=self.BB['lon'][0],llcrnrlat=self.BB['lat'][0],urcrnrlon=self.BB['lon'][1],urcrnrlat=self.BB['lat'][1],
                      rsphere=(6378137.00,6356752.3142), resolution='l',projection='merc')
    
        x, y = map(Lon, Lat)
        cs2 = map.contourf(x,y,datagrid,512)
        
        levels = np.arange(0, 5000, 100)
        CS = map.contour(x,y,datagrid, levels, linewidths=0.01,colors = 'k')
        plt.clabel(CS,inline=1,fmt='%d')

        lw = 1 + 4*module/50
        map.streamplot(x,y,ugrid,vgrid, density=3, color='k', linewidth=lw , arrowsize=2 )

        for ix in np.arange(0,module.shape[1],2):
            for iy in np.arange(0,module.shape[0],2):
                #print ix,iy
                ilon = self.lon[ix]
                ilat = self.lat[iy]      
                a,b = map(ilon,  ilat)
                plt.text(a,b  ,int(module[iy,ix]),fontsize=fontsize,fontweight='bold', ha='center',va='center',color='r')

        plt.subplots_adjust(left=0.0, right=figsize, top=figsize, bottom=0.0)
        
        self.saveplot(plt,filename)
        plt.close()
        
        
        # Legend
        fig1 = plt.figure(figsize=(11,11),dpi=100)
        cb = map.colorbar(cs2,"bottom", size="5%", pad="100%")
        
        
        name = filename + '_legend.jpg' 
        plt.savefig("maps/"+name, dpi=100,bbox_inches='tight',transparent=False)
        plt.close()
        list_of_maps_to_send.append("maps/"+name)

        
        img1 = Image.open("maps/"+name)
        w, h = img1.size
        box = (20, h-70, w-10, h-10)
        area = img1.crop(box)
        area.save("maps/"+name, 'jpeg')
        plt.close()
开发者ID:ToninoTarsi,项目名称:OpenMeteoData-PI,代码行数:54,代码来源:omdpi.py

示例10: plot_map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def plot_map(data_grid, grid_spacing, orientation, title, file_name, topo=None):
    pylab.clf()
    nx, ny = data_grid.shape
    grid_x, grid_y = grid_spacing

    map = Basemap(projection='lcc', resolution=None, width=(nx * grid_x), height=(ny * grid_y),
        lat_0=40.61998, lon_0=-107.344, lat_1=30., lat_2=60.) 

    ctr_x, ctr_y = map(-104.344, 41.61998)
    move_x = ctr_x - nx * grid_x / 2
    move_y = ctr_y - ny * grid_y / 2

    llcrnrlon, llcrnrlat = map(move_x, move_y, inverse=True)
    urcrnrlon, urcrnrlat = map(nx * grid_x + move_x, ny * grid_y + move_y, inverse=True)

    map = Basemap(projection='lcc', resolution='l',
        llcrnrlat=llcrnrlat, llcrnrlon=llcrnrlon, urcrnrlat=urcrnrlat, urcrnrlon=urcrnrlon,
        lat_0=40.61998, lon_0=-107.344, lat_1=30., lat_2=60.) 

    x, y = np.meshgrid(grid_x * np.arange(nx), grid_y * np.arange(ny))
    interval = (data_grid.max() - data_grid.min()) / 100.
    pylab.contourf(x, y, data_grid, levels=np.arange(data_grid.min(), data_grid.max() + interval, interval))

    if topo is not None:
        topo_data, topo_lats, topo_lons = topo

        topo_lats, topo_lons = np.meshgrid(topo_lats, topo_lons)
        topo_x, topo_y = map(topo_lons, topo_lats)

        map.contour(topo_x, topo_y, topo_data, colors='#808080')

    map.drawstates()
    map.drawcountries()
    map.drawcoastlines()

    pylab.colorbar()
    pylab.title(title)
    pylab.savefig(file_name)
    return
开发者ID:tsupinie,项目名称:research,代码行数:41,代码来源:balance.py

示例11: plot_ppi_lobes_qld

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def plot_ppi_lobes_qld(sweep_dict, parm, **kwargs):
	#[-27.669166564941406, 152.8619384765625]
	radar_loc=kwargs.get('radar_loc', [-12.2492,  131.0444])
	radar_loc2=kwargs.get('radar_loc2', [-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)
	alats=linspace(radar_loc[0]-2.0, radar_loc[0]+2.0, 100.0)
	alons=linspace(radar_loc[1]-2.0, radar_loc[1]+2.0, 100.0)
	angs=array(propigation.make_lobe_grid(radar_loc, radar_loc2, alats,alons))
	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)
	galons, galats=meshgrid(alons, alats)
	xxl, yyl=map(galons, galats)
	#map.drawcoastlines()
	#map.drawcountries()
	map.drawmapboundary()
	map.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstqldmd_r', 'qcoast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	map.readshapefile(getenv('HOME')+'/bom_mds/shapes/cstntcd_r','coast',drawbounds=True, linewidth=0.5,color='k',antialiased=1,ax=None)
	map.drawmeridians(array([152,152.5,153,153.5,154]), labels=[1,0,0,1])
	map.drawparallels(array([-29,-28.5,-28,-27.5,-27]), 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])
	colorbar()
	map.contour(xxl,yyl,angs, levels=[30.0, 150.0],colors=['r']) 
	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])
	savefig(fig_path+fig_name)
	close(f)
开发者ID:scollis,项目名称:bom_mds,代码行数:40,代码来源:pres.py

示例12: polar_quiver_wind

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
    def polar_quiver_wind(self, ax, ns='N'):
        # Wind vector in lat-long coordinates.
        # For different map projections, the arithmetics to calculate xywind
        # are different
        if self.empty:
            return
        from mpl_toolkits.basemap import Basemap
        from apexpy import Apex
        # Creat polar coordinates
        projection,fc = ('npstere',1) if ns=='N' else ('spstere',-1)
        m = Basemap(projection=projection,boundinglat=fc*40,lon_0=0,resolution='l')
        m.drawcoastlines(color='gray',zorder=1)
        m.fillcontinents(color='lightgray',zorder=0)
        dt = self.index.min() + (self.index.max()-self.index.min())/2
        m.nightshade(dt,zorder=2)
        #m.drawparallels(np.arange(-80,81,20))
        #m.drawmeridians(np.arange(-180,181,60),labels=[1,1,1,1])

        # Calculate mlat and mlon
        lat_grid = np.arange(-90,91,10)
        lon_grid = np.arange(-180,181,10)
        lon_grid, lat_grid = np.meshgrid(lon_grid, lat_grid)
        gm = Apex(date=2005)
        mlat,mlon = gm.convert(lat_grid,lon_grid,'geo','apex')
        hc1 = m.contour(lon_grid,lat_grid,mlat,levels=np.arange(-90,91,10),
                        colors='k', zorder=3, linestyles='dashed',
                        linewidths=1, latlon=True)
        # hc2 = m.contour(lon_grid,lat_grid,mlon,levels=np.arange(-180,181,45),
        #                 colors='k', zorder=3, linestyles='dashed', latlon=True)
        plt.clabel(hc1,inline=True,colors='k',fmt='%d')
        # plt.clabel(hc2,inline=True,colors='k',fmt='%d')

        # Calculate and plot x and y winds
        lat = self.lat
        lon = self.long
        wind = self.wind
        winde1 = self.winde
        winde = winde1*wind
        windn1 = self.windn
        windn = windn1*wind
        # only appropriate for the npstere and spstere
        xwind = fc*winde*np.cos(lon/180*np.pi)-windn*np.sin(lon/180*np.pi)
        ywind = winde*np.sin(lon/180*np.pi)+fc*windn*np.cos(lon/180*np.pi)
        hq = m.quiver(np.array(lon),np.array(lat),xwind,ywind,color='blue',
                      scale=300, scale_units='inches',zorder=3, latlon=True)
        #plt.quiverkey(hq,1.05,1.05,100,'100 m/s',coordinates='axes',labelpos='E')
        #m.scatter(np.array(lon),np.array(lat),
        #          s=50, c=self.index.to_julian_date(),linewidths=0, zorder=4,latlon=True)
        return m
开发者ID:guodj,项目名称:work,代码行数:51,代码来源:champ_grace.py

示例13: gera_contour

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def gera_contour (msg,tipo):   

    lat,lon = msg.latlons()
    data=msg.values  


    #Plotagem do campo usando o Basemap. Inicia a projeção do mapa usando os limites min e max dos proprios dados

    m=Basemap(projection='mill',lat_ts=10,llcrnrlon=lon.min(), \
    urcrnrlon=lon.max(),llcrnrlat=lat.min(),urcrnrlat=lat.max(), \
    resolution='c')

    #Convertendo os valores de lat/lon para as projeções de x/y
    x, y = m(lon,lat)

        
    #Opção colors define a cor da linha. Nesse caso preto.
    #
    cs=m.contour (x,y ,data,linewidth=5,colors='k' )
    #inline estabele que os rotulos são desenhados através das linhas
    #fmt controla o formato do número
    plt.clabel(cs, fontsize=10, inline=1,fmt='%.1f') 

    #Adicionado a linha de costa e limites dos eixos

    m.drawcoastlines()
    #m.fillcontinents()
    #m.drawmapboundary()
    m.drawparallels(np.arange(-90.,120.,30.),labels=[1,0,0,0])
    m.drawmeridians(np.arange(-180.,180.,60.),labels=[0,0,0,1])
      
   
    plt.title('Altura do '+tipo+ ' em 500 hPa  em 1 jan 2016')
   
    
    fig_out='/home/eduardo/dado/fig1/'+'Altura do geopotencial '+tipo+' _janeiro_2016 v1' + '.png'
    
    plt.savefig(fig_out)   
    plt.show()
    plt.close()
开发者ID:eduardofhenty,项目名称:scripts-gerais,代码行数:42,代码来源:plot_geopotencial.py

示例14: plotmap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
def plotmap():
    # create figure
    fig = plt.figure(figsize=(8, 8))
    # set up orthographic map projection with
    # perspective of satellite looking down at 50N, 100W.
    # use low resolution coastlines.
    map = Basemap(projection='ortho', lat_0=50, lon_0=-100, resolution='l')
    # lat/lon coordinates of five cities.
    lats = [40.02, 32.73, 38.55, 48.25, 17.29]
    lons = [-105.16, -117.16, -77.00, -114.21, -88.10]
    cities = ['Boulder, CO', 'San Diego, CA',
              'Washington, DC', 'Whitefish, MT', 'Belize City, Belize']
    # compute the native map projection coordinates for cities.
    xc, yc = map(lons, lats)
    # make up some data on a regular lat/lon grid.
    nlats = 73
    nlons = 145
    delta = 2.*np.pi/(nlons-1)
    lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0, :, :])
    lons = (delta*np.indices((nlats, nlons))[1, :, :])
    wave = 0.75*(np.sin(2.*lats)**8*np.cos(4.*lons))
    mean = 0.5*np.cos(2.*lats)*((np.sin(2.*lats))**2 + 2.)
    # compute native map projection coordinates of lat/lon grid.
    # (convert lons and lats to degrees first)
    x, y = map(lons*180./np.pi, lats*180./np.pi)
    # draw map boundary
    map.drawmapboundary(color="0.9")
    # draw graticule (latitude and longitude grid lines)
    map.drawmeridians(np.arange(0, 360, 30), color="0.9")
    map.drawparallels(np.arange(-90, 90, 30), color="0.9")
    # plot filled circles at the locations of the cities.
    map.plot(xc, yc, 'wo')
    # plot the names of five cities.
    for name, xpt, ypt in zip(cities, xc, yc):
        plt.text(xpt+100000, ypt+100000, name, fontsize=9, color='w')
    # contour data over the map.
    cs = map.contour(x, y, wave+mean, 15, linewidths=1.5)
    # draw blue marble image in background.
    # (downsample the image by 50% for speed)
    map.bluemarble(scale=0.5)
开发者ID:4over7,项目名称:matplotlib,代码行数:42,代码来源:plotmap.py

示例15: bmap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import contour [as 别名]
xc,yc = bmap(lons,lats)
# plot filled circles at the locations of the cities.
bmap.plot(xc,yc,'bo')
# plot the names of those five cities.
for name,xpt,ypt in zip(cities,xc,yc):
    plt.text(xpt+50000,ypt+50000,name,fontsize=9)
# make up some data on a regular lat/lon grid.
nlats = 73; nlons = 145; delta = 2.*np.pi/(nlons-1)
lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0,:,:])
lons = (delta*np.indices((nlats,nlons))[1,:,:])
wave = 0.75*(np.sin(2.*lats)**8*np.cos(4.*lons))
mean = 0.5*np.cos(2.*lats)*((np.sin(2.*lats))**2 + 2.)
# compute native map projection coordinates of lat/lon grid.
x, y = bmap(lons*180./np.pi, lats*180./np.pi)
# contour data over the map.
cs = bmap.contour(x,y,wave+mean,15,linewidths=1.5)
plt.title('filled continent background')

# as above, but use land-sea mask image as map background.
fig = plt.figure()
bmap.drawmapboundary()
bmap.drawmeridians(np.arange(0,360,30))
bmap.drawparallels(np.arange(-90,90,30))
# plot filled circles at the locations of the cities.
bmap.plot(xc,yc,'wo')
# plot the names of five cities.
for name,xpt,ypt in zip(cities,xc,yc):
    plt.text(xpt+50000,ypt+50000,name,fontsize=9,color='w')
# contour data over the map.
cs = bmap.contour(x,y,wave+mean,15,linewidths=1.5)
plt.title('land-sea mask background')
开发者ID:matplotlib,项目名称:basemap,代码行数:33,代码来源:wiki_example.py


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