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


Python Basemap.drawlsmask方法代码示例

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


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

示例1: lambert_conformal

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def lambert_conformal(request):
    import matplotlib
    from mpl_toolkits.basemap import Basemap
    import numpy as np
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    
    width = float(request.GET.get('width', 6000000))
    height = float(request.GET.get('height', 4500000))
    lat = float(request.GET.get('lat',-7))
    lon = float(request.GET.get('lon',107))
    true_lat1 = float(request.GET.get('true_lat1',5))
    true_lat2 = float(request.GET.get('true_lat2',5))
    
    m = Basemap(width=width,height=height,
            rsphere=(6378137.00,6356752.3142),\
            resolution=None,projection='lcc',\
            lat_1=true_lat1,lat_2=true_lat2,lat_0=lat,lon_0=lon)
    
    fig = Figure()
    canvas = FigureCanvas(fig)
    m.ax = fig.add_axes([0, 0, 1, 1])
    
    m.drawlsmask(land_color='gray',ocean_color='white',lakes=True)
    m.drawparallels(np.arange(-90.,91.,30.), color='black')
    m.drawmeridians(np.arange(-180.,181.,60.), color='black')
    
    x, y = m(lon, lat)
    m.plot(x, y, 'ro')
    
    response = HttpResponse(content_type='image/png')
    canvas.print_figure(response, dpi=100)
    return response
开发者ID:arifwn,项目名称:AQMWEB,代码行数:35,代码来源:plot.py

示例2: mapper

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

	fig = plt.figure()
	
	cmap = mpc.ListedColormap(palettable.colorbrewer.diverging.PiYG_5.mpl_colors)
	# cmap.set_bad('grey',1.)

	# ax = fig.add_subplot(1)
	plt.plot()
	plt.title("a. ((maxNDVI/mm AcuPrecip)/year)", loc= 'left')

	#set the spatial cordinates of the grid, mask the ocean and draw coastlines
	map = Basemap(llcrnrlon=112.0,llcrnrlat=-44.5,urcrnrlon=156.25,urcrnrlat=-10, resolution = 'h', epsg=4326)
	map.drawmapboundary(fill_color='grey')
	map.fillcontinents(color= 'none', lake_color='white')
	map.drawlsmask(land_color='none', )
	map.drawcoastlines()

	map.imshow(np.flipud(image), cmap=cmap, vmin=-0.006, vmax=0.009,)
	# cb = plt.colorbar()

	#Tweaking the colorbar so the the ticks allign with the grid.  
	cb = map.colorbar()#ticks= [-0.01, -0.0075, -0.0050, -0.00250, 0.0000, 0.0025, 0.0050, 0.0075, 0.010, 0.0125])
	tick_locator = ticker.MaxNLocator(nbins=5)
	cb.locator = tick_locator
	cb.update_ticks()

	#add in the grid
	map.drawparallels(np.arange(-50, -10, 10),labels=[1,0,0,0], dashes=[1,2])#color= 'none')
	map.drawmeridians(np.arange(110, 156.25, 10),labels=[0,0,0,1], dashes=[1,2])

	plt.show()
开发者ID:ArdenB,项目名称:RESTREND,代码行数:34,代码来源:R3a_Sort_display.py

示例3: sub_plot_pcolor

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def sub_plot_pcolor(lons, lats, data, title=None, cmap=cm.jet,
                    vmin=None, vmax=None, cbar=True, cbar_location='bottom',
                    units=None, ncolors=5):

    if vmin is None:
        vmin = data.min()
    if vmax is None:
        vmax = data.max()

    m = Basemap(**projection)
    m.drawlsmask(land_color='grey', lakes=False)
    xi, yi = m(np.squeeze(lons), np.squeeze(lats))
    sp = m.pcolormesh(xi, yi, np.squeeze(data), vmin=vmin, vmax=vmax,
                      cmap=cmap)
    m.drawparallels(np.arange(-80., 81., 20.))
    m.drawmeridians(np.arange(-180., 181., 20.))
    m.drawcoastlines(color='k', linewidth=0.25)
    if title:
        plt.title(title, size=13)
    if cbar:
        cmap = cmap_discretize(cmap, ncolors)
        mappable = cm.ScalarMappable(cmap=cmap)
        mappable.set_array([])
        mappable.set_clim(-0.5, ncolors+0.5)
        colorbar = m.colorbar(mappable, location=cbar_location)
        colorbar.set_ticks(np.linspace(0, ncolors, ncolors))
        colorbar.set_ticklabels(np.linspace(vmin, vmax, ncolors))
        colorbar.set_label(units)
    return sp
开发者ID:orianac,项目名称:tonic,代码行数:31,代码来源:compare_soil_params.py

示例4: plotMap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def plotMap(llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, 
            lons, lats, color, title):
        m = Basemap(projection='merc',
                    resolution='i', 
                    llcrnrlon = llcrnrlon,
                    llcrnrlat = llcrnrlat,
                    urcrnrlon = urcrnrlon,
                    urcrnrlat = urcrnrlat)

        m.drawcountries(linewidth=1)
        m.drawcoastlines(linewidth=1)
        m.drawlsmask()
        m.drawstates()
        m.drawrivers(linewidth=.1)

        plt.title((str(len(lats)))+ \
            title,
            fontsize=12)

        x,y = m(lons, lats)
        if color == 'r':
            plt.hexbin(x, y, gridsize=40, cmap=plt.cm.Reds)
        if color == 'b':
            plt.hexbin(x, y, gridsize=40, cmap=plt.cm.Blues)        
        if color == 'g':
            plt.hexbin(x, y, gridsize=40, cmap=plt.cm.Greens)
        m.scatter(lons, lats, 1, marker='o',color=color, latlon=True)
        plt.show()
开发者ID:JRMeyer,项目名称:twitter,代码行数:30,代码来源:geoPlotting.py

示例5: worldplot

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
 def worldplot(self,kmeans=None,proj='merc'):
     """
     plots customer GPS location on a map with state and national boundaries.
     IN
         kmeans (int) number of means for k-means clustering, default=None
         proj (string) the map projection to use, use 'robin' to plot the whole earth, default='merc'
     """
     # create a matplotlib Basemap object
     if proj == 'robin':
         my_map = Basemap(projection=proj,lat_0=0,lon_0=0,resolution='l',area_thresh=1000)
     else:
         my_map = Basemap(projection=proj,lat_0=33.,lon_0=-125.,resolution='l',area_thresh=1000.,
                 llcrnrlon=-130.,llcrnrlat=25,urcrnrlon=-65., urcrnrlat=50)
     my_map.drawcoastlines(color='grey')
     my_map.drawcountries(color='grey')
     my_map.drawstates(color='grey')
     my_map.drawlsmask(land_color='white',ocean_color='white')
     my_map.drawmapboundary() #my_map.fillcontinents(color='black')
     x,y = my_map(np.array(self.data['lon']),np.array(self.data['lat']))
     my_map.plot(x,y,'ro',markersize=3,alpha=.4,linewidth=0)
     if kmeans:
         # k-means clustering algorithm---see wikipedia for details
         data_in = self.data.drop(['id','clv','level'],axis=1)
         # vq is scipy's vector quantization module
         output,distortion = vq.kmeans(data_in,kmeans)
         x1,y1 = my_map(output[:,1],output[:,0])
         my_map.plot(x1,y1,'ko',markersize=20,alpha=.4,linewidth=0)
     plt.show()
     return output
开发者ID:dgmiller,项目名称:portfolio,代码行数:31,代码来源:tools.py

示例6: ResearchRegion_surface

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def ResearchRegion_surface():
    """
    在地图上画出柱表面混合比图
    :return:
    """

    fig = plt.figure(figsize=(11, 8), facecolor="white")
    # data = np.loadtxt('seasonAvr_data/SurfaceMixingRatio/1_seasonAvr.txt')
    data = np.loadtxt("allYearAvr_data/SurfaceMixingRatio/allYearAvr.txt")
    arr = np.zeros((180, 360))
    for i in range(180):
        arr[i, :] = data[179 - i, :]

    longitude = np.loadtxt("lonlat_data/longitude.txt")
    latitude = np.loadtxt("lonlat_data/latitude.txt")

    m = Basemap(llcrnrlon=70, llcrnrlat=15, urcrnrlon=138, urcrnrlat=55, projection="mill", resolution="h")
    m.drawparallels(np.arange(5.5, 90.5, 1.0), color="w", linewidth=0.5, dashes=[1, 1], labels=[0, 0, 0, 0])
    m.drawmeridians(np.arange(60.5, 181.5, 1.0), color="w", linewidth=0.5, dashes=[1, 1], labels=[0, 0, 0, 0])
    m.drawmapboundary(fill_color="0.3")
    m.readshapefile("shp/CHINA", "CHINA", drawbounds=1, color="black")

    topo = maskoceans(longitude, latitude, arr)
    im = m.pcolormesh(longitude, latitude, topo, shading="flat", cmap=plt.cm.jet, latlon=True, vmin=0, vmax=500)
    m.drawlsmask(ocean_color="w", lsmask=0)

    cbar = m.colorbar()
    cbar.ax.set_ylabel("SurfaceMixingRatio", color="black", fontsize="14", rotation=90)
    plt.show()
开发者ID:wuliangradi,项目名称:RemoteSensing,代码行数:31,代码来源:plotImg.py

示例7: mapfig

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def mapfig(ax=plt.gca()):
    m = Basemap(projection='merc',llcrnrlat=-25,urcrnrlat=8,llcrnrlon=-15,urcrnrlon=18,resolution='l',ax=ax)
    m.drawcoastlines()
    #m.drawmeridians(np.linspace(-17,11,8),labels=[0,0,0,1],linewidth=0.1)
    #m.drawparallels(np.linspace(-18,4,12),labels=[1,0,0,0],linewidth=0.1)
    m.drawlsmask(land_color='lightgrey',ocean_color='None',lakes=True)
    #m.shadedrelief(alpha=0.4)
    return m
开发者ID:samuelleblanc,项目名称:python_codes,代码行数:10,代码来源:ORACLES_AOD_summary_allyears.py

示例8: n_pac_sect_2_w

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

    map = Basemap(width=16000000,height=9000000,rsphere=(6378137.00,6356752.3142),projection='lcc',lat_1=0.,lat_2=65,lat_0=30,lon_0=-190.,area_thresh=50000.)
    map.drawcoastlines()
    map.drawmeridians([120,150,210,240,270],dashes=[3,4])
    map.drawmeridians([180],dashes=[6,4])
    map.drawparallels(np.arange(-180,180,30),dashes=[3,4])
    map.drawlsmask(land_color='0.8', ocean_color='w', lsmask=None, lsmask_lons=None, lsmask_lats=None, lakes=False, resolution='c', grid=10)
    return map
开发者ID:albamesp,项目名称:Bristol_Geography_Python,代码行数:11,代码来源:maps.py

示例9: make_map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def make_map():
	from mpl_toolkits.basemap import Basemap 
        m=Basemap(llcrnrlon=-125,llcrnrlat=31,urcrnrlon = -102.5,urcrnrlat=50,projection='cyl',lat_1=33,lat_2=42,lon_0=-110,
                resolution='c')
        m.drawcoastlines()
        m.drawstates()
        m.drawcountries()
        m.drawlsmask(land_color='grey',ocean_color='lightblue',lakes=True)
        return(m)
开发者ID:mbaptiste,项目名称:IS_snowfire,代码行数:11,代码来源:snowpack_functions.py

示例10: plotDifference

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def plotDifference(lats,lons,years,thk_diff,directory):
    """
    Makes large subplot of difference in all the SIT data between
    PIOMAS and the satellites [satellite - PIOMAS]
    """
        
    ### Call parameters
    plt.rcParams['text.usetex']=True
    plt.rcParams['font.family'] = 'sans-serif'
    plt.rcParams['font.sans-serif'] = 'Avant Garde'
    
    ### Define figure
    fig = plt.figure()
    
    for i in xrange(len(thk_diff)):
        ax = plt.subplot(3,4,i+1)    
        m = Basemap(projection='npstere',boundinglat=60,lon_0=-90,
                    round=True,resolution='l')
        m.drawmapboundary(fill_color = 'white')
        m.drawlsmask(land_color='darkgrey',ocean_color='snow')
        parallels = np.arange(50,90,10)
        meridians = np.arange(-180,180,30)
        m.drawparallels(parallels,labels=[False,False,False,False],
                        linewidth=0.25)
        m.drawmeridians(meridians,labels=[False,False,False,False],
                        linewidth=0.25)

        thk_diff[np.where(thk_diff >= 3.)] = 3
        thk_diff[np.where(thk_diff <= -3.)] = -3
        
        cs = m.contourf(lons,lats,thk_diff[i,:,:],np.arange(-3,3.1,0.1),
                        latlon=True,extend='both')
        cs.set_cmap('seismic_r')
        ax.text(0.89,0.95,r'\textbf{%s}' % (years[i]),size='8',
                horizontalalignment='center',backgroundcolor='w',
                verticalalignment='center',bbox=dict(facecolor='w',
                edgecolor='k',alpha=0.9),transform=ax.transAxes)
                
    cbar_ax = fig.add_axes([0.30,0.1,0.4,0.03])                
    cbar = fig.colorbar(cs,cax=cbar_ax,orientation='horizontal',
                        extend='both',extendfrac=0.07)

    cbar.set_label(r'Thickness (m)')
    cbar.set_ticks(np.arange(-3,4,1))
    cbar.set_ticklabels(map(str,np.arange(-3,4,1)))   
    
    fig.suptitle(r'\textbf{SIT Difference [Satellite - PIOMAS]}',fontsize=16)
    plt.tight_layout() 
    fig.subplots_adjust(bottom=0.14)
    fig.subplots_adjust(top=0.92)
    fig.subplots_adjust(wspace=-.56)
    fig.subplots_adjust(hspace=-0.0)         
                
    plt.savefig(directory +'cs2piomas_diff.png',
                dpi=500)
    print 'Completed: Difference subplot finished!'
开发者ID:zmlabe,项目名称:SeaIceThickness,代码行数:58,代码来源:calc_cs2icesatpiomas_differ.py

示例11: n_am_ortho

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

    map = Basemap(projection='ortho',lon_0=-115,lat_0=90,area_thresh=50000.)
    map.drawcoastlines(linewidth=1,color=[.3,.9,.3])
#    map.fillcontinents(color='.9') #[.91,.91,.95]
    map.drawmeridians(np.arange(0,360,90))
    map.drawparallels(np.arange(-180,180,30))
#    map.drawmapboundary(fill_color='w')
    map.drawlsmask(land_color='0.8', ocean_color='w', lsmask=None, lsmask_lons=None, lsmask_lats=None, lakes=False, resolution='c', grid=10)

    return map
开发者ID:albamesp,项目名称:Bristol_Geography_Python,代码行数:13,代码来源:maps.py

示例12: preload_map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def preload_map():
    if not os.path.isfile(pickle_file):
        ip_map = Basemap(projection='robin', lon_0=0, resolution='c')
        ip_map.drawlsmask(ocean_color="#99ccff", land_color="#009900")
        ip_map.drawcountries(linewidth=0.25, color='#ffff00')
        ip_map.drawcoastlines(linewidth=0.25)
        pickle.dump(ip_map, open(pickle_file, 'wb'), -1)
    else:
        ip_map = pickle.load(open(pickle_file, 'rb'))

    global pickle_bytes
    pickle_bytes = pickle.dumps(ip_map, -1)
开发者ID:RECCE7,项目名称:recce7,代码行数:14,代码来源:WorldmapServiceHandler.py

示例13: map_template

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def map_template():
    """Return template figure for the given title and date."""
    fig = plt.figure(figsize=(11.69, 8.27), dpi=300)
    plt.text(62, -47, "wenfo.org/apwm/", ha="left", fontsize=10)
    plt.text(208, -47, 'Created ' + TODAY.isoformat(), ha="right", fontsize=10)
    m = Basemap(projection='cyl', resolution='l', llcrnrlat=-50, urcrnrlat=40,
                llcrnrlon=60, urcrnrlon=210)
    m.drawcoastlines(linewidth=0.75)
    m.drawcountries()
    m.drawlsmask(land_color=(0, 0, 0, 0), ocean_color='white', lakes=True)
    m.drawparallels(np.arange(-23, 24, 23), labels=[1, 0, 0, 1],
                    linewidth=0.6, color=(0.2, 0.2, 0.2))
    m.drawmeridians(np.arange(-180, 181, 30), labels=[1, 0, 0, 1],
                    linewidth=0.6, color=(0.2, 0.2, 0.2))
    return fig, m
开发者ID:ANU-WALD,项目名称:job-scheduler,代码行数:17,代码来源:plotmap.py

示例14: render_map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def render_map(grb_file, llclat, llclon, urclat, urclon, altitude_layer):
    """Given a grb file, renders a jpg map on disk."""
    print('processing file %s ' % grb_file)
    grbs = pygrib.open(grb_file)
    data = grbs.select(name='Temperature')[altitude_layer]['values']
    plt.figure(figsize=(12, 12))

    # We don't like the way noaa aligns things. We like monotonic variations.
    data = realign_noaa_data(data)
    lonlat2temp = interpolate.interp2d(ALL_LONS, ALL_LATS, data, kind='linear')
    lats_interp = np.arange(llclat, urclat, 0.01)
    lons_interp = np.arange(llclon, urclon, 0.01)
    data_interp = lonlat2temp(lons_interp, lats_interp)
    # Size of the img to render in meters.
    width, height = width_height_from_bbox(llclat, llclon, urclat, urclon)
    m = Basemap(
        projection='cass',
        lat_ts=10,
        lat_0=(urclat + llclat) / 2,
        lon_0=(llclon + urclon) / 2,
        resolution='i',
        width=width,
        height=height)
    x, y = m(*np.meshgrid(lons_interp, lats_interp))

    # Draw plenty of fancy stuff
    m.drawstates()
    m.drawcountries()
    m.drawlsmask()
    m.drawrivers()
    m.drawcoastlines()
    m.shadedrelief()
    m.drawparallels(np.arange(-90., 120., 30.), labels=[1, 0, 0, 0])
    m.drawmeridians(np.arange(-180., 180., 60.), labels=[0, 0, 0, 1])
    m.pcolormesh(
        x,
        y,
        data_interp,
        shading='flat',
        cmap=plt.cm.jet,
        alpha=0.05,
        vmin=260,
        vmax=305)
    m.colorbar(location='right')
    plt.title('Temperature')
    image = '%s.jpg' % grb_file
    plt.savefig(image)
    plt.close()
开发者ID:johmathe,项目名称:baroque_octopus,代码行数:50,代码来源:plot_temperatures.py

示例15: define_map_projection

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawlsmask [as 别名]
def define_map_projection(projection='gall', llcrnrlat=-80, urcrnrlat=80, llcrnrlon=-180, urcrnrlon=180, resolution='i', land_color='grey', ocean_color='lightblue', lakes=True):
    '''Define projected map

    Return: the projection
    '''

    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt

    m = Basemap(projection=projection, llcrnrlat=llcrnrlat, urcrnrlat=urcrnrlat, llcrnrlon=llcrnrlon, urcrnrlon=urcrnrlon, resolution=resolution)
    m.drawlsmask(land_color=land_color, ocean_color=ocean_color, lakes=lakes)
    m.drawcoastlines(linewidth=0.75)
    m.drawstates(linewidth=0.5)
    m.drawcountries(linewidth=0.5)

    return m
开发者ID:YifanCheng,项目名称:simple_reservoir_model,代码行数:18,代码来源:my_functions.py


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