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


Python Basemap.warpimage方法代码示例

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


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

示例1: plot_brights

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
def plot_brights(ax, path, star, regionList, goal=False):
    '''
    Components of this routine:
        Projected brightness map
         
    Please note that this has been modified for use in diagnostic plots, 
    there should really be a way to specify a windowNumber for real data
    '''
    currentWindow = 0

    ###########################
    # Make the brightness map #
    ###########################
    img = make_bright_image(star, regionList, currentWindow, goal=goal)
    
    plt.imsave(path + "temp.jpg", img, cmap='hot', vmin=0.85, vmax=1.15)
    plt.imshow(img, cmap='hot')
    #Create the plot
    bmap = Basemap(projection='moll', lon_0 = 0, ax=ax)
    bmap.warpimage(path + "temp.jpg", ax=ax)
    
    if goal:
        ax.set_title("Desired Map")
    else:
        ax.set_title("Average Map")
开发者ID:rapidsnow,项目名称:Eclipse-Mapping,代码行数:27,代码来源:plots_scratch.py

示例2: proj_plot

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
    def proj_plot(self):
        '''
        Creates a Mollweide projection of Rectangle and saves it
        '''
        #ax = plt.axes([.15, .6, .32, .32])
        plt.imsave("/temp.png", self.matrix, cmap='hot', vmin=0.85, vmax=1.15)
        plt.imshow(self.matrix, cmap='hot')    
        plt.clim(0.85,1.15)
        plt.colorbar(shrink=0.5)

        #Create the plot
        bmap = Basemap(projection='robin', lon_0 = 0)
        bmap.warpimage("/temp.png")
        
        fig = plt.gcf()
        fig.set_size_inches(18.5,11.5)
        plt.savefig("spot_proj.png", dpi=120)
开发者ID:rapidsnow,项目名称:Eclipse-Mapping,代码行数:19,代码来源:random_spot_scratch.py

示例3: save_map

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
def save_map(routes, file_name):
    """
    Render flight routes to an image file.

    :param list routes: flight path lines
    :param str file_name: image output file name
    """
    fig = plt.figure(figsize=(7.195, 3.841), dpi=100)
    m = Basemap(projection='cyl', lon_0=0, resolution='c')
    ax = plt.Axes(fig, [0., 0., 1., 1.])
    ax.set_axis_off()
    fig.add_axes(ax)

    for (colour, alpha, linewidth, lat1, long1, lat2, long2) in sorted(routes):
        """
        Cannot handle situations in which the great circle intersects the 
        edge of the map projection domain, and then re-enters the domain.

        Fix from: http://stackoverflow.com/questions/13888566/
        """
        line, = m.drawgreatcircle(long1, lat1, long2, lat2,
                                  linewidth=linewidth,
                                  color=colour,
                                  alpha=alpha,
                                  solid_capstyle='round')

        p = line.get_path()

        # Find the index which crosses the dateline (the delta is large)
        cut_point = np.where(np.abs(np.diff(p.vertices[:, 0])) > 200)[0]

        if cut_point:
            cut_point = cut_point[0]

            # Create new vertices with a nan in between and set 
            # those as the path's vertices
            new_verts = np.concatenate([p.vertices[:cut_point, :], 
                                        [[np.nan, np.nan]], 
                                        p.vertices[cut_point+1:, :]])
            p.codes = None
            p.vertices = new_verts

    m.warpimage(image="earth_lights_lrg.jpg")
    plt.savefig(file_name, dpi=1000)
开发者ID:jurnlee,项目名称:airline-passenger-counts,代码行数:46,代码来源:plot.py

示例4: plot_clusters

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
def plot_clusters(pts,filename,markerscale,background_img=None):
	rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
	rc('text', usetex=True)
	m = Basemap(projection='moll',lon_0=0,resolution='c')
	if background_img: m.warpimage(background_img)
	else: m.drawmapboundary(fill_color='black')
	m.drawparallels(np.arange(-90.,180.,15.),color='white',linewidth=.5)
	m.drawmeridians(np.arange(0.,420.,15.),color='white',linewidth=.5)
	for px,py,sz,name,alpha in pts:
		x,y = m(r2d(px),r2d(py))
		plt.plot(x,y,'*',color='yellow',markersize=markerscale*log(sz,markerscale), alpha=alpha)
		plt.text(x,y,name.replace("_","-").replace("#","No. "),color='red',size=2)
	# Plot the zone of avoidance
	m.drawparallels([ZONE_OF_AVOIDANCE,-ZONE_OF_AVOIDANCE], color='yellow', linewidth=1)
	x,y=m(0,-(ZONE_OF_AVOIDANCE-2))
	plt.text(x,y,r'$b = %i^{\circ}$' % (-(ZONE_OF_AVOIDANCE)),color='yellow',size=7, ha='center', va='bottom')
	x_,y_=m(0,(ZONE_OF_AVOIDANCE-2))                      
	plt.text(x_,y_,r'$b = %i^{\circ}$' % (ZONE_OF_AVOIDANCE),color='yellow',size=7,ha='center', va='top')
	#plt.title("Galaxy Clusters")
	plt.savefig(filename,dpi=300)
开发者ID:dooog,项目名称:Galaxy-Clusters,代码行数:22,代码来源:plot_clusters.py

示例5: plot_brights_stripes_only

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
def plot_brights_stripes_only(path, bright_file, nstripes, output):
    '''
    Take in a set of brightness values and output a brightness map.
    This snippet of code is adapted from Leslie's IDL code
    '''
    
    #Read in file
    temp = []
    for line in open(bright_file):                           
        temp.append(float(line))
    brights = np.array(temp)
    
    #Set up arrays for brightnesses and positions
    nx = nstripes * 50
    ny = nstripes * 50
    bright_stripe = np.array(brights)
    img = np.zeros((nx,ny))
    idx1_stripe = np.arange(0, nstripes, 1.)/nstripes * nx
    idx2_stripe = (np.arange(0, nstripes, 1.) + 1)/nstripes * nx - 1

    #Populate the pixel values
    for jj in range(nstripes):
        idx1 = idx1_stripe[jj]
        idx2 = idx2_stripe[jj]
        idy1 = 0
        idy2 = ny-1
        img[idy1:idy2, idx1:idx2] = bright_stripe[jj]
    
    plt.imsave(path + "/" + output, img, cmap='hot')
    plt.imshow(img, cmap='hot')
    plt.clim(.9,1.25)
    plt.title("Surface Brightness Map")
    #Create the plot
    bmap = Basemap(projection='moll', lon_0 = 0)
    #plt.savefig(path + "/" + output)
    bmap.warpimage(path + "/" + output)
    #Place the plot in the appropriate place
    plt.savefig(path + "/" + output)
    plt.close()
开发者ID:rapidsnow,项目名称:Eclipse-Mapping,代码行数:41,代码来源:data_plots.py

示例6: make

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

#.........这里部分代码省略.........
            # ... unsupported projections
            else:
                print "!! ERROR !! unsupported projection. supported: "+\
                      "cyl, npstere, spstere, ortho, moll, robin, lcc, laea, merc"
            # finally define projection
	    try:
	      from mpl_toolkits.basemap import Basemap
	    except:
              print "!! ERROR !! basemap is not available."
	      print "... either install it or use another plot type."
	      exit()
            m = Basemap(projection=self.proj,\
                        lat_0=lat_0,lon_0=lon_0,\
                        boundinglat=self.blat,\
                        llcrnrlat=wlat[0],urcrnrlat=wlat[1],\
                        llcrnrlon=wlon[0],urcrnrlon=wlon[1])
            # in some case need to translated to the left for colorbar + labels
            # TBD: break stuff. a better solution should be found.
            if self.leftcorrect:
                ax = mpl.gca()
                pos = ax.get_position().bounds
                newpos = [0.,pos[1],pos[2],pos[3]]
                ax.set_position(newpos)
            # draw meridians and parallels
            ft = int(mpl.rcParams['font.size']*3./4.)
            zelatmax = 85.
            m.drawmeridians(mertab,labels=merlab,color='grey',linewidth=0.75,fontsize=ft,fmt=format,latmax=zelatmax)
            m.drawparallels(partab,labels=parlab,color='grey',linewidth=0.75,fontsize=ft,fmt=format,latmax=zelatmax)
            # define background (see set_back.txt)
            if self.back is not None:
              if self.back in back.keys():
                 print "**** info: loading a background, please wait.",self.back
                 if self.back not in ["coast","sea"]:
                    try: m.warpimage(back[self.back],scale=0.75)
                    except: print "!! ERROR !! no background image could be loaded. probably not connected to the internet?"
                 elif self.back == "coast":
                    m.drawcoastlines()
                 elif self.back == "sea":
                    m.drawlsmask(land_color='white',ocean_color='aqua')
              else:
                 print "!! ERROR !! requested background not defined. change name or fill in set_back.txt" ; exit()
            # define x and y given the projection
            x, y = m(self.x, self.y)
            # contour field. first line contour then shaded contour.
            if self.c is not None: 
                #zelevelsc = np.arange(900.,1100.,5.)
                objC2 = m.contour(x, y, what_I_contour, \
                            self.clev, colors = self.ccol, linewidths = cline)
                #mpl.clabel(objC2, inline=1, fontsize=10,manual=True,fmt='-%2.0f$^{\circ}$C',colors='r')
                #mpl.clabel(objC2, inline=0, fontsize=8, fmt='%.0f',colors='r', inline_spacing=0) 
            m.contourf(x, y, what_I_plot, zelevels, cmap = palette, alpha = self.trans, antialiased=True)
        ############################################################################################
        ### COLORBAR
        ############################################################################################
        if self.trans > 0. and self.showcb:
            ## draw colorbar. settings are different with projections. or if not mapmode.
            #if not self.mapmode: orientation=zeorientation ; frac = 0.075 ; pad = 0.03 ; lu = 0.5
            if not self.mapmode: orientation=zeorientation ; frac = 0.15 ; pad = 0.04 ; lu = 0.5
            elif self.proj in ['moll']: orientation="horizontal" ; frac = 0.08 ; pad = 0.03 ; lu = 1.0
            elif self.proj in ['robin']: orientation="horizontal" ; frac = 0.07 ; pad = 0.1 ; lu = 1.0
            elif self.proj in ['cyl']: orientation="vertical" ; frac = 0.023 ; pad = 0.03 ; lu = 0.5
            else: orientation = zeorientation ; frac = zefrac ; pad = 0.03 ; lu = 0.5
            if self.cbticks is None:
                self.cbticks = min([ticks/2+1,21])
            zelevpal = np.linspace(zevmin,zevmax,num=self.cbticks)
            zecb = mpl.colorbar(fraction=frac,pad=pad,\
开发者ID:olivierfarges,项目名称:planetoplot,代码行数:70,代码来源:ppplot.py

示例7: Basemap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import Image

map = Basemap(projection="ortho", lat_0=0, lon_0=0)


tmpdir = "/tmp"

size = [600, 300]
im = Image.open("../sample_files/by.png")

im2 = im.resize(size, Image.ANTIALIAS)
im2.save(tmpdir + "/resized.png", "PNG")

map.warpimage(tmpdir + "/resized.png")

map.drawcoastlines()

plt.show()
开发者ID:paulvija,项目名称:BasemapTutorial,代码行数:22,代码来源:warpimage.py

示例8: mapSubject

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
def mapSubject(dataset,subject,box='tight',level='auto',
               longest=20,call='default',highlight=False,
               heatmap=True, mark = 'r', cmap='YlOrRd',
               show = True, offset = 0, subtitle = '', geobox = 'null',
	       important = 'null',background = 'none'):

    if call == 'animate':
        plt.clf()
    else:
        fig = plt.figure(figsize=(9,9))
    
    if geobox == 'null' or (type(box) is str and type(geobox) is str):
    	box = fixBox(dataset,box)
    else:
        box = geobox
    	
    lats, lons, times = getData(dataset,offset)
    
    mapped = Basemap(projection='mill', 
                     llcrnrlon=box['lon1'],
                     llcrnrlat=box['lat1'],
                     urcrnrlon=box['lon2'],
                     urcrnrlat=box['lat2'])

    mapOpacity = 0.75
    if background == 'etopo':
	mapped.etopo(zorder=0, alpha=mapOpacity)
    elif background == 'shaded relief':
	mapped.shadedrelief(zorder=0, alpha=mapOpacity)
    elif background == 'blue marble':
        mapped.bluemarble(zorder=0, alpha=mapOpacity)
    elif '/' in background or '.' in background:
        try:
            mapped.warpimage(image='maps/'+background, scale=None, zorder=0, alpha=mapOpacity)
        except:
            mapped.warpimage(image=background, scale=None, zorder=0, alpha=mapOpacity)
    else:
	background = 'null'
	
    smallest = min(box['lat2']-box['lat1'],box['lon2']-box['lon1'])

    mapped.drawcoastlines(zorder=3)
    
    if smallest < 5:
        mapped.drawcountries(zorder=3,linewidth = 3)
        mapped.drawstates(zorder=3, linewidth = 2)
        mapped.drawcounties(zorder=3,linewidth = 1)
    else:
        mapped.drawcountries(zorder=3,linewidth = 2)
        mapped.drawstates(zorder=3, linewidth = 1)
    
    if heatmap:
        # ######################################################################
        # http://stackoverflow.com/questions/11507575/basemap-and-density-plots)
        density, lon_bins, lat_bins = getDensity(box,lats,lons,longest)
        lon_bins_2d, lat_bins_2d = np.meshgrid(lon_bins, lat_bins)
        xs, ys = mapped(lon_bins_2d, lat_bins_2d) # will be plotted using pcolormesh
        # ######################################################################
        
        if level == 'auto':
            level = np.amax(density)

	density = fixDensity(density,xs,ys)
	
  	if background == 'null':
        	plt.pcolormesh(xs, ys, density, cmap = cmap,zorder=2, alpha = 1, vmin =1)
	else:
		extent = (xs[0][0],xs[0][-1],ys[0][0],ys[-1][0]) 
		colorized = mapColors(density,level,cmap)
		colorized = mapTransparency(density,colorized,level)
		plt.imshow(colorized, extent=extent,cmap=cmap,origin='lower',interpolation='nearest',zorder=2)


    smallest = min(box['lat2']-box['lat1'],box['lon2']-box['lon1'])
    
    if smallest < 1.0:
        gridIncrement = 0.1
    if smallest < 2.5:
	gridIncrement = 0.5
    elif smallest < 5:
	gridIncrement = 1.0
    elif smallest < 10:
	gridIncrement = 2.5
    else:
	gridIncrement = 5.0

    parallels = np.arange(-90.,90.,gridIncrement)
    mapped.drawparallels(parallels,labels=[1,0,0,0],fontsize=10, alpha = .75)
    meridians = np.arange(-180.,180.,gridIncrement)
    mapped.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10, alpha = .75)

    if important != 'null':
	xI,yI = mapped(important[0],important[1])
	xM,yM = mapped(np.mean(lons),np.mean(lats))
	mapped.plot(xI,yI,'o',markersize=15, zorder=6, markerfacecolor = "white", markeredgecolor=mark, alpha = 1.0)
	mapped.plot(xM,yM,'x',markersize=15, zorder=6, markerfacecolor = "white", markeredgecolor=mark, alpha = 1.0)

    x, y = mapped(lons, lats) # compute map proj coordinates.
    mapped.plot(x, y, 'o', markersize=4,zorder=6, markerfacecolor=mark,markeredgecolor="none", alpha=0.30)
    if highlight != False:
#.........这里部分代码省略.........
开发者ID:jschlitt84,项目名称:visualization,代码行数:103,代码来源:CGVis.py

示例9: rc

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
from mpl_toolkits.basemap import Basemap
from master_variables import ZONE_OF_AVOIDANCE
import numpy as np
import matplotlib.pyplot as plt
import sys

if __name__ == "__main__":
	rc('text', usetex=True)
	rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
	# lon_0 is central longitude of projection.
	# resolution = 'c' means use crude resolution coastlines.
	m = Basemap(projection='moll',lat_0=0,lon_0=0,resolution='h')
	# draw parallels and meridians.
	m.drawparallels(np.arange(-90.,180.,15.),color='white',linewidth=.5)
	m.drawmeridians(np.arange(0.,420.,15.),color='white',linewidth=.5)
	# Draw a line of longitude
	m.drawparallels([ZONE_OF_AVOIDANCE,-ZONE_OF_AVOIDANCE],color='yellow',linewidth=1)
	m.warpimage(sys.argv[1],scale=1.0)
	#m.drawgreatcircle(0,0,4*15,0,color='r',linewidth=1)
	x,y=m(0,-(ZONE_OF_AVOIDANCE+2))
	plt.text(x,y,r'$b = %i^{\circ}$' % (-(ZONE_OF_AVOIDANCE)),color='yellow',size=7, ha='center', va='top')
	x_,y_=m(0,(ZONE_OF_AVOIDANCE+2))
	plt.text(x_,y_,r'$b = %i^{\circ}$' % (ZONE_OF_AVOIDANCE),color='yellow',size=7,ha='center', va='bottom')
	x__,y__=m(0,0)
	plt.text(x__,y__,r'Zone of Avoidance',color='yellow',size=16,ha='center', va='center')
	# Draw a line of latitude
	#m.drawgreatcircle(4*15,0,4*15,4*15,color='r',linewidth=1)
	#x_,y_=m(4*15+4,2*15)
	#plt.text(x_,y_,r'$b$',color='r',size=16)
	plt.savefig(sys.argv[2],dpi=300,transparent=True)
开发者ID:dooog,项目名称:Galaxy-Clusters,代码行数:32,代码来源:zone-of-avoidance.py

示例10: Basemap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
        m = Basemap(projection='laea', width= 4300000,height=4000000, resolution='i', lat_ts=55.00,lat_0=55.00,lon_0=15.00)
        m.drawparallels(np.arange(-90.,91.,10.), labels=[0,0,0,0],linewidth=0.5)
        m.drawmeridians(np.arange(-180.,181.,10.), labels=[0,0,0,0],linewidth=0.5)
        m.drawmapboundary(fill_color='white')
    elif options.show_domain.lower()=='world':
        m = Basemap(projection='moll',resolution='c',lon_0=0.)
        m.drawparallels(np.arange(-90.,91.,10.), labels=[0,0,0,0],linewidth=0.5)
        m.drawmeridians(np.arange(-180.,181.,10.), labels=[0,0,0,0],linewidth=0.5)
        m.drawmapboundary(fill_color='white')
    else:
        grdis = gridfh.grid_size_in_meters

        m = Basemap(width=(len(gridfh.dimensions['x'])-bufferzone*2-2)*grdis, height=(len(gridfh.dimensions['y'])-bufferzone*2-2)*grdis, resolution='i', projection='lcc', lat_0=gridfh.latitude_of_projection_origin, lon_0=gridfh.longitude_of_projection_origin, lat_1=gridfh.standard_parallel[0], lat_2=gridfh.standard_parallel[1], ax=plt.gca())

    if isfile(options.bgimage):
        m.warpimage(image=options.bgimage)

    if options.normalize:
        vardatanorm = colors.Normalize(vmin=options.norm_minimum,vmax=options.norm_maximum)
    elif options.lognormalize:
        vardatanorm = colors.SymLogNorm(linthresh=20.,linscale=1.0,vmin=options.norm_minimum,vmax=options.norm_maximum)
    else:
        vardatanorm = None

    x,y = m(lon,lat)
    if options.deaccumulate>0 and t>time1 and counter%options.deaccumulate>0:
        print "*** Deaccumulating time %d " % t
        data = vardata[t]-vardata[t-1]
    else:
        data = vardata[t]
开发者ID:micval,项目名称:regcmutils,代码行数:32,代码来源:draw-maps.py

示例11: range

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
for j in range(0,nelements):
    verts = [(xnode[i1[j]],ynode[i1[j]]),\
         (xnode[i2[j]],ynode[i2[j]]),\
         (xnode[i3[j]],ynode[i3[j]]),\
         (xnode[i1[j]],ynode[i1[j]]) ]
    path = Path(verts)
    patch = patches.PathPatch(path, facecolor='none',edgecolor='grey',lw=0.5)
    m.ax.add_patch(patch)

m.ax.set_xlim(lonmin,lonmax)
m.ax.set_ylim(latmin,latmax)
#m.drawcoastlines(ax=ax,color='black')
##m.drawparallels(np.arange(latmin,latmax,dlat), linewidth=0,
##                    labels=[1, 0, 0, 0], fontname='Times New Roman',fontsize=16)
##m.drawmeridians(np.arange(lonmin,lonmax,dlon), linewidth=0,
##                    labels=[0, 0, 1, 0], fontname='Times New Roman',fontsize=16)
##


m.warpimage(image='/home/ctroupin/Software/Python/backgrounds/land_ocean_ice_cloud_2048.jpg')
#m.etopo()
m.drawcountries()
#m.drawrivers()
#m.nightshade(date)  

plt.savefig(figdir+figname+figtype, dpi=300, facecolor='w', edgecolor='w',
         transparent=False, bbox_inches='tight', pad_inches=0.1)
#plt.show()
plt.close()
开发者ID:ctroupin,项目名称:SOCIB_plots,代码行数:31,代码来源:diva_global_mesh_warpimage.py

示例12: Window

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

#.........这里部分代码省略.........

    def plot_cmt_sliprate(self):
        fig = self.ui.cmt_sliprate.fig
        fig.clf()
        fig.set_facecolor('white')
        ax = fig.add_axes([0.05, 0.2, 0.9, 0.8], frameon=False)
        ax.get_xaxis().tick_bottom()
        ax.axes.get_yaxis().set_visible(False)

        nsamp = len(self.finite_source.CMT.sliprate)
        time = np.linspace(0, self.finite_source.CMT.dt * nsamp, nsamp,
                           endpoint=False)

        ax.plot(time, self.finite_source.CMT.sliprate)
        ax.set_xlim(0., self.finite_source.rupture_duration * 2.)
        fig.canvas.draw()

    def plot_map(self):
        self.mpl_map_figure = self.ui.map_fig.fig

        # if hasattr(self, 'mpl_map_ax'):
        #     self.mpl_map_ax.clear()

        self.mpl_map_ax = self.mpl_map_figure.add_axes([0.01, 0.01, .98, .98])
        self.mpl_map_ax.set_title("Left click: Set Receiver; Right click: Set "
                                  "Source")

        self.map = Basemap(projection='moll', lon_0=0, resolution="c",
                           ax=self.mpl_map_ax)

        self.map.drawmapboundary(fill_color='#cccccc')
        if self.instaseis_db and self.instaseis_db.info.planet_radius < 5e6:
            imfile = os.path.join(DATA, 'mola_texture_shifted_800.jpg')
            self.map.warpimage(image=imfile, zorder=0)
        else:
            self.map.fillcontinents(color='white', lake_color='#cccccc',
                                    zorder=0)

        self.mpl_map_figure.patch.set_alpha(0.0)

        self.mpl_map_figure.canvas.mpl_connect(
            'button_press_event', self._on_map_mouse_click_event)
        self.mpl_map_figure.canvas.draw()

    def _on_map_mouse_click_event(self, event):
        if None in (event.xdata, event.ydata):
            return
        # Get map coordinates by the inverse transform.
        lng, lat = self.map(event.xdata, event.ydata, inverse=True)
        # Left click: set receiver
        if event.button == 1:
            self.ui.receiver_longitude.setValue(lng)
            self.ui.receiver_latitude.setValue(lat)
        # Right click: set event
        elif (event.button == 3 and self.ui.finsource_tab.currentIndex() == 0):
            self.ui.source_longitude.setValue(lng)
            self.ui.source_latitude.setValue(lat)

    def _plot_event(self):
        if self.ui.finsource_tab.currentIndex() == 0:
            s = self.source
            lng, lat = s.longitude, s.latitude
        elif self.ui.finsource_tab.currentIndex() == 1:
            s = self.finite_source
            s.find_hypocenter()
            lng, lat = s.hypocenter_longitude, s.hypocenter_latitude
开发者ID:MMesch,项目名称:instaseis,代码行数:70,代码来源:instaseis_gui.py

示例13: plot_lc_and_brights

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
def plot_lc_and_brights(path, bright_file, model_curve, data_curve, bb, Rp, nstripes, outfile, number):
    #Read in the values for model and data light curves
    model_time = []
    model_flux = []
    data_time_on = []
    data_flux_on = []
    data_time_off = []
    data_flux_off = []
    
    #Read in file
    temp = []
    for line in open(bright_file):                           
        temp.append(float(line))
    brights = np.array(temp)
   
    #Define latitudes of boxes
    lat1 = bb - Rp
    lat2 = bb + Rp

    for line in open(model_curve):                            
        new_array = line.split(' ')
        model_time.append(float(new_array[0]))
        model_flux.append(float(new_array[1]))
        
    for line in open(data_curve):                            
        new_array = line.split(' ')
        if float(new_array[0]) >= model_time[0] and float(new_array[0]) <= model_time[len(model_time) - 1]:
            data_time_on.append(float(new_array[0]))
            data_flux_on.append(float(new_array[1]))
        else:
            data_time_off.append(float(new_array[0]))
            data_flux_off.append(float(new_array[1]))
    
    #Create the plot and label it
    plt.plot(model_time, model_flux, c='black', label="Model")
    plt.scatter(data_time_on, data_flux_on, c='red', marker='+', label="Brightness Map Region")
    plt.scatter(data_time_off, data_flux_off, c='green', marker = '+', label="Data")
    minimum = min(data_flux_on + data_flux_off)
    maximum = max(data_flux_on + data_flux_off)
    diff = maximum - minimum
    plt.ylim(ymax=maximum + (diff * .85))
    plt.ylim(ymin=minimum - (diff * .1))
    plt.xlabel("Orbital Phase")
    plt.ylabel("Relative Flux")
    plt.title("Model Light Curve Vs. Data - Window %d" % number)

       #Set up arrays for brightnesses and positions
    nx = nstripes * 50
    ny = nstripes * 50
    bright_stripe = np.array(brights)
    img = np.zeros((nx,ny))
    idx1_stripe = np.arange(0, nstripes, 1.)/nstripes * nx
    idx2_stripe = (np.arange(0, nstripes, 1.) + 1)/nstripes * nx - 1

    #Populate the pixel values
    for jj in range(nstripes):
        idx1 = idx1_stripe[jj]
        idx2 = idx2_stripe[jj]
        idy1 = 0
        idy2 = ny-1
        img[idy1:idy2, idx1:idx2] = bright_stripe[jj]

    ax = plt.axes([.15, .6, .32, .32])
    plt.imsave(path + "/temp.png", img, cmap='hot', vmin=0.95, vmax=1.05)
    plt.imshow(img, cmap='hot')    
    plt.clim(0.95,1.05)
    plt.colorbar(shrink=0.5)    

    #Create the plot
    bmap = Basemap(projection='moll', lon_0 = 0)
    bmap.warpimage(path + "/temp.png")

    #Create the plots of the transits
    fig = plt.gcf()
    fig.set_size_inches(18.5,11.5)
    plt.savefig(path + "/" + outfile + ".png", dpi=120)
    plt.close()
开发者ID:rapidsnow,项目名称:Eclipse-Mapping,代码行数:79,代码来源:jim_plots.py

示例14: Basemap

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
	m.drawmapboundary(color='#787878', linewidth=0.4)

if(mproj == 'CE'):
	# define projection
	m = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,area_thresh=10000,\
	llcrnrlon=30,urcrnrlon=390,resolution='l')

if(mproj == 'RB'):
	m = Basemap(projection='robin',lon_0=-150,resolution='l')

if(yyyy != '0000'):
	orig = Image.open(infile)
	bg = Image.new("RGB", orig.size, (211,211,211))
	bg.paste(orig,orig)
	bg.save("./tmp.png")
	im = m.warpimage("./tmp.png")

#orig = np.array(orig).astype(np.float) / 255
#fig.figimage(orig, logo_x, logo_y, zorder=10)

if(yyyy == '0000'):
	# draw coastlines and boundaries
	m.drawcoastlines(color='#787878',linewidth=mlw)
	m.drawcountries(color='#787878',linewidth=mlw)


#Add the NOAA logo (except for DIY)
if(imgsize != 'DIY'):
	logo_im = Image.open(logo_image)
	height = logo_im.size[1]
	# We need a float array between 0-1, rather than
开发者ID:LarryBelcher,项目名称:OISSTA_Python,代码行数:33,代码来源:oissta_yearly_map.py

示例15: plot_lc_and_brights

# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import warpimage [as 别名]
def plot_lc_and_brights(path, bright_file, chi_file, model_curve, data_curve, bb, Rp, nstripes, nboxes, outfile, number, trans_info):
    #Read in the values for model and data light curves
    model_time = []
    model_flux = []
    data_time_on = []
    data_flux_on = []
    data_time_off = []
    data_flux_off = []
    
    #Read in file
    temp = []
    for line in open(bright_file):                           
        temp.append(float(line))
    brights = np.array(temp)
   
    #Define latitudes of boxes
    lat1 = bb - Rp
    lat2 = bb + Rp

    for line in open(model_curve):                            
        new_array = line.split(' ')
        model_time.append(float(new_array[0]))
        model_flux.append(float(new_array[1]))
        
    for line in open(data_curve):                            
        new_array = line.split(' ')
        if float(new_array[0]) >= model_time[0] and float(new_array[0]) <= model_time[len(model_time) - 1]:
            data_time_on.append(float(new_array[0]))
            data_flux_on.append(float(new_array[1]))
        else:
            data_time_off.append(float(new_array[0]))
            data_flux_off.append(float(new_array[1]))

    try:
        information = csv.reader(open(trans_info))
    except:
        information = []
    transit_count = 1
    
    for row in information:
        trans_time = []
        trans_flux = []
        #Create the plot and label it
        plt.plot(model_time, model_flux, c='black', label="Model")
        plt.scatter(data_time_on, data_flux_on, c='red', marker='+', label="Brightness Map Region")
        plt.scatter(data_time_off, data_flux_off, c='green', marker = '+', label="Data")
        minimum = min(data_flux_on + data_flux_off)
        maximum = max(data_flux_on + data_flux_off)
        diff = maximum - minimum
        plt.ylim(ymax=maximum + (diff * .85))
        plt.ylim(ymin=minimum - (diff * .1))
        plt.xlabel("Orbital Phase")
        plt.ylabel("Relative Flux")
        plt.title("Model Light Curve Vs. Data - Window %d" % number)
    
           #Set up arrays for brightnesses and positions
        nx = nboxes * 50
        ny = nboxes * 50
        bright_stripe = np.array(brights[nboxes:nboxes+nstripes])
        bright_box = np.array(brights[0:nboxes])
        img = np.zeros((nx,ny))
        idx1_stripe = np.arange(0, nstripes, 1.)/nstripes * nx
        idx2_stripe = (np.arange(0, nstripes, 1.) + 1)/nstripes * nx - 1
        idx1_box = np.arange(0, nboxes, 1.)/nboxes * nx
        idx2_box = (np.arange(0, nboxes, 1.) + 1)/nboxes * nx - 1
        idy1_lat = int(lat1 * ny/2 + ny/2 + 0.5)
        idy2_lat = int(lat2 * ny/2 + ny/2 + 0.5) - 1
    
        #Populate the pixel values
        for jj in range(nstripes):
            idx1 = idx1_stripe[jj]
            idx2 = idx2_stripe[jj]
            idy1 = 0
            idy2 = idy1_lat-1
            img[idy1:idy2, idx1:idx2] = bright_stripe[jj]
            idy1 = idy2_lat+1
            idy2 = ny-1
            img[idy1:idy2, idx1:idx2] = bright_stripe[jj]
        for jj in range(nboxes):
            idx1 = idx1_box[jj]
            idx2 = idx2_box[jj]
            idy1 = idy1_lat
            idy2 = idy2_lat
            img[idy1:idy2, idx1:idx2] = bright_box[jj]
    
        ax = plt.axes([.15, .6, .32, .32])
        plt.imsave(path + "/temp.png", img, cmap='hot', vmin=0.85, vmax=1.15)
        plt.imshow(img, cmap='hot')    
        plt.clim(0.85,1.15)
        plt.colorbar(shrink=0.5)    

        #Create the plot
        bmap = Basemap(projection='moll', lon_0 = 0)
        bmap.warpimage(path + "/temp.png")

        #Create the plots of the transits
        for line in open(path + "/" + "input_files/binned_%d.out" % number):
            new_array = line.split(' ')
            trans_time.append(float(new_array[0]))
            trans_flux.append(float(new_array[1]))
#.........这里部分代码省略.........
开发者ID:rapidsnow,项目名称:Eclipse-Mapping,代码行数:103,代码来源:data_plots.py


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