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


Python scipy.linspace函数代码示例

本文整理汇总了Python中scipy.linspace函数的典型用法代码示例。如果您正苦于以下问题:Python linspace函数的具体用法?Python linspace怎么用?Python linspace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_quasi_newton_broyden_bad

def test_quasi_newton_broyden_bad():
    op = p.OptimizationProblem(c.chebyquad)
    guess=linspace(0,1,4)
    cn  = p.QuasiNewtonBroydenBad(op)
    assert near(sol4,(cn.optimize(guess)))
    guess=linspace(0,1,8)
    assert near(sol8,(cn.optimize(guess)))
开发者ID:tapetersen,项目名称:FMNN25,代码行数:7,代码来源:testquasi.py

示例2: extract_seg_plot

def extract_seg_plot(data, output_filename_base):
    subclone_plot_file_name = output_filename_base + '.MixClone.segplot.png'
    
    subclone_prev_lst = []
    copynumber_lst = []
    seg_num = data.seg_num

    print "Extracting segments plot file..."
    sys.stdout.flush()

    for j in range(0, seg_num):
        if data.segments[j].baseline_label == True or data.segments[j].allele_type == 'PM':
            continue
        subclone_prev_lst.append(data.segments[j].subclone_prev)
        copynumber_lst.append(data.segments[j].copy_number)

    X = len(subclone_prev_lst)
    
    plt.figure(figsize=(8,8), dpi = 150)
    plt.plot(range(1, X+1), subclone_prev_lst, 'o')
    plt.xlim(0, X+1)
    plt.ylim(0, 1)
    plt.xlabel('Copy number')
    plt.ylabel('Subclonal cellular prevalence')
    plt.xticks(sp.linspace(1, X, X), copynumber_lst)
    plt.yticks(sp.linspace(0, 1, 11), ['0%', '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%'])
    plt.savefig(subclone_plot_file_name, bbox_inches='tight')
开发者ID:uros-sipetic,项目名称:MixClone,代码行数:27,代码来源:run_postprocess.py

示例3: split

    def split(self, sagi, meri):
        """ utilizes geometry.grid to change the rectangle into a generalized surface,
        it is specified with a single set of basis vectors to describe the meridonial,
        normal, and sagittal planes."""
        ins = float((sagi - 1))/sagi
        inm = float((meri - 1))/meri
        stemp = self.norm.s/sagi
        mtemp = self.meri.s/meri

        z,theta = scipy.meshgrid(scipy.linspace(-self.norm.s*ins,
                                                self.norm.s*ins,
                                                sagi),
                                 scipy.linspace(-self.meri.s*inm,
                                                self.meri.s*inm,
                                                meri))

        vecin =geometry.Vecr((self.sagi.s*scipy.ones(theta.shape),
                              theta+scipy.pi/2,
                              scipy.zeros(theta.shape))) #this produces an artificial
        # meri vector, which is in the 'y_hat' direction in the space of the cylinder
        # This is a definite patch over the larger problem, where norm is not normal
        # to the cylinder surface, but is instead the axis of rotation.  This was
        # done to match the Vecr input, which works better with norm in the z direction
               
        pt1 = geometry.Point(geometry.Vecr((scipy.zeros(theta.shape),
                                            theta,
                                            z)),
                             self)

        pt1.redefine(self._origin)

        vecin = vecin.split()

        x_hat = self + pt1 #creates a vector which includes all the centers of the subsurface

        out = []
        #this for loop makes me cringe super hard
        for i in xrange(meri):
            try:
                temp = []
                for j in xrange(sagi):
                    inp = self.rot(vecin[i][j])
                    temp += [Cyl(geometry.Vecx(x_hat.x()[:,i,j]),
                                 self._origin,
                                 [2*stemp,2*mtemp],
                                 self.sagi.s,
                                 vec=[inp, self.norm.copy()],
                                 flag=self.flag)]
                out += [temp]
            except IndexError:
                inp = self.rot(vecin[i])
                out += [Cyl(geometry.Vecx(x_hat.x()[:,i]),
                            self._origin,
                            [2*stemp,2*mtemp],
                            self.norm.s,
                            vec=[inp, self.norm.copy()],
                            flag=self.flag)]
                

        return out
开发者ID:icfaust,项目名称:TRIPPy,代码行数:60,代码来源:surface.py

示例4: loadImageAsGreyScale

 def loadImageAsGreyScale(self, subscriber=0):
     im = Image.open(self.paramFilename.value)
     if im.mode == "I;16":
         im = im.convert("I")
         data = scipy.misc.fromimage(im).astype("int16")
     else:
         data = scipy.misc.fromimage(im, flatten=True)
     Ny, Nx = data.shape
     xUnit = Quantity(self.paramXScale.value.encode("utf-8"))
     xAxis = DataContainer.FieldContainer(
         scipy.linspace(0.0, xUnit.value, Nx, True), xUnit / xUnit.value, longname="x-coordinate", shortname="x"
     )
     if self.paramYScale.value == "link2X":
         yUnit = xUnit * float(Ny) / Nx
     else:
         yUnit = Quantity(self.paramYScale.value.encode("utf-8"))
     yAxis = DataContainer.FieldContainer(
         scipy.linspace(0.0, yUnit.value, Ny, True), yUnit / yUnit.value, longname="y-coordinate", shortname="y"
     )
     try:
         FieldUnit = Quantity(self.paramFieldUnit.value.encode("utf-8"))
     except AttributeError:
         FieldUnit = self.paramFieldUnit.value
     result = DataContainer.FieldContainer(
         data, FieldUnit, longname="Image", shortname="I", dimensions=[yAxis, xAxis]
     )
     result.seal()
     return result
开发者ID:gclos,项目名称:pyphant1,代码行数:28,代码来源:ImageLoaderWorker.py

示例5: uvToELz_grid

def uvToELz_grid(ulinspace,vlinspace,R=1.,t=-4.,pot='bar',beta=0.,
            potparams=(0.9,0.01,25.*_degtorad,.8,None)):
    """
    NAME:
       uvToELz_grid
    PURPOSE:
       calculate uvToLz on a grid in (u,v)
    INPUT:
       ulinspace, vlinspace - build the grid using scipy's linspace with
                              these arguments
       R - Galactocentric Radius
       t - time to integrate backwards for 
           (interpretation depends on potential)
       pot - type of non-axisymmetric, time-dependent potential
       beta - power-law index of rotation curve
       potparams - parameters for this potential
    OUTPUT:
       final (E,Lz) on grid [nus,nvs,2]
       E=E/vo^2; Lz= Lz/Ro/vo
    HISTORY:
       2010-03-01 - Written - Bovy (NYU)
    """
    us= sc.linspace(*ulinspace)
    vs= sc.linspace(*vlinspace)
    nus= len(us)
    nvs= len(vs)
    out= sc.zeros((nus,nvs,2))
    for ii in range(nus):
        for jj in range(nvs):
            tmp_out= uvToELz(UV=(us[ii],vs[jj]),R=R,t=t,pot=pot,beta=beta,potparams=potparams)
            out[ii,jj,0]= tmp_out[0]
            out[ii,jj,1]= tmp_out[1]
    return out
开发者ID:jobovy,项目名称:hercules-simulation,代码行数:33,代码来源:integrate_orbits.py

示例6: volweight

def volweight(numsplit=(3,3), factor=1, fact2=None, eq='/home/ian/python/g1120824019.01400'):

    b =  TRIPPy.Tokamak(eqtools.EqdskReader(gfile=eq))
    
    rgrid = b.eq.getRGrid()
    zgrid = b.eq.getZGrid()
    rgrid = scipy.linspace(rgrid[0],rgrid[-1],len(rgrid)*factor)
    zgrid = scipy.linspace(zgrid[0],zgrid[-1],len(zgrid)*factor)
    
    twopi2 = twopi(b)
    
    surfs = twopi2[0].split(numsplit[0],numsplit[1])

    out = scipy.zeros((len(rgrid)-1,len(zgrid)-1))

    for i in surfs:
        for j in i:
            surf2 = j
            if fact2 is None:
                surf2 = j
            else:
                surf2 = j.split(fact2,fact2)

            beam = TRIPPy.beam.multiBeam(surf2,twopi2[1])
            b.trace(beam)
            #TRIPPy.plot.mayaplot.plotLine(beam)
            out += TRIPPy.beam.volWeightBeam(beam,rgrid,zgrid)

    
    return out
开发者ID:icfaust,项目名称:TRIPPy,代码行数:30,代码来源:twopi.py

示例7: getImageDescriptor

def getImageDescriptor(model, im, conf):
	im = standardizeImage(im)
	height, width = im.shape[:2]
	numWords = model.vocab.shape[1]
	frames, descrs = getPhowFeatures(im, conf.phowOpts)
	# quantize appearance
	if model.quantizer == 'vq':
		binsa, _ = vq(descrs.T, model.vocab.T)
	elif model.quantizer == 'kdtree':
		raise ValueError('quantizer kdtree not implemented')
	else:
		raise ValueError('quantizer {0} not known or understood'.format(model.quantizer))
	hist = []
	for n_spatial_bins_x, n_spatial_bins_y in zip(model.numSpatialX, model.numSpatialX):
		binsx, distsx = vq(frames[0, :], linspace(0, width, n_spatial_bins_x))
		binsy, distsy = vq(frames[1, :], linspace(0, height, n_spatial_bins_y))
		# binsx and binsy list to what spatial bin each feature point belongs to
		if (numpy.any(distsx < 0)) | (numpy.any(distsx > (width/n_spatial_bins_x+0.5))):
			print ("something went wrong")
			import pdb; pdb.set_trace()
		if (numpy.any(distsy < 0)) | (numpy.any(distsy > (height/n_spatial_bins_y+0.5))):
			print ("something went wrong")
			import pdb; pdb.set_trace()
		# combined quantization
		number_of_bins = n_spatial_bins_x * n_spatial_bins_y * numWords
		temp = arange(number_of_bins)
		# update using this: http://stackoverflow.com/questions/15230179/how-to-get-the-linear-index-for-a-numpy-array-sub2ind
		temp = temp.reshape([n_spatial_bins_x, n_spatial_bins_y, numWords])
		bin_comb = temp[binsx, binsy, binsa]
		hist_temp, _ = histogram(bin_comb, bins=range(number_of_bins+1), density=True)
		hist.append(hist_temp)
	
	hist = hstack(hist)
	hist = array(hist, 'float32') / sum(hist)
	return hist
开发者ID:esokullu,项目名称:birdid_classifier,代码行数:35,代码来源:birdid_utils.py

示例8: test_interpolateArray

def test_interpolateArray():
	grid_x = scipy.linspace(1, 5, 20)
	grid_y = scipy.linspace(-1, 1, 10)
	def fn(x):
		return scipy.sin(x[0] + x[1])
	((xlist, ylist), f) = applyGrid([grid_x, grid_y], fn)
	fig = plt.figure()
	ax = Axes3D(fig)	
	ax.scatter(xlist, ylist, f.ravel())
	
	grid2_x = scipy.linspace(1, 5, 40)
	grid2_y = scipy.linspace(-1, 1, 20)
	f2 = interpolateArray([grid_x, grid_y], [grid2_x, grid2_y], f)
	xy_list = itertools.product(grid2_x, grid2_y)
	(xlist2, ylist2) = zip(*xy_list)	
	fig = plt.figure()	
	ax = Axes3D(fig)
	ax.scatter(xlist2, ylist2, f2.ravel())
	
	grid3_x = grid_x
	grid3_y = grid_y
	f3 = interpolateArray([grid2_x, grid2_y], [grid3_x, grid3_y], f2)
	xy_list = itertools.product(grid3_x, grid3_y)
	(xlist3, ylist3) = zip(*xy_list)	
	fig = plt.figure()	
	ax = Axes3D(fig)	
	ax.scatter(xlist3, ylist3, f3.ravel())	
	
	
	
	
	
	
	
开发者ID:Twizanex,项目名称:bellman,代码行数:27,代码来源:lininterp2.py

示例9: subdivide

def subdivide(g, rmin, rmax, m):
    """
    Subdivide the given interval by equal integrals of g.

    **example**
     >>> g = lambda r : r**2
     >>> rmin = 0.0
     >>> rmax = 1.0
     >>> m = 2
     >>> r = subdivide(g, rmin, rmax, m)
     >>> abs(r - array([0.0, .5**(1./3.), 1.0])).sum() <= 1e-4
     True
    """
    r = sp.linspace(rmin, rmax, m+1)

    # total integral value
    tot = quad(g, rmin, rmax)[0]
    cuts = sp.linspace(0.0, tot, m+1)[1:-1]
    
    # define intervals r_n to r_n+1 to give equal area under g(r)
    r[1:-1] = [brentq((lambda r_: quad(g, rmin, r_)[0]-cut), rmin, rmax,
                      xtol=1.0e-4)
                for cut in cuts]
    # return the sequence of subinterval boundaries
    return r
开发者ID:wgm2111,项目名称:wgm-mie-scattering,代码行数:25,代码来源:size_average.py

示例10: draw_plot

	def draw_plot(self):
		self.axes.clear()
		self.histax.clear()
		global mode
		if mode == 'hsv':
			self.axes.set_xlabel('Hue')
			self.axes.set_ylabel('Saturation')
			self.axes.set_zlabel('Value')
			tubepixels = np.array(list(self.hsv[greenloc[0], greenloc[1]] for greenloc in coloredpixels(self.mask, (0,255,0))))
			nontubepixels = np.array(list(self.hsv[redloc[0], redloc[1]] for redloc in coloredpixels(self.mask, (0,0,255))))
		else:
			self.axes.set_xlabel('Blue')
			self.axes.set_ylabel('Green')
			self.axes.set_zlabel('Red')
			tubepixels = np.array(list(self.smallimg[greenloc[0], greenloc[1]] for greenloc in coloredpixels(self.mask, (0,255,0))))
			nontubepixels = np.array(list(self.smallimg[redloc[0], redloc[1]] for redloc in coloredpixels(self.mask, (0,0,255))))
		onehundredtube = [int(x) for x in scipy.linspace(0,len(tubepixels)-1, 500)]
		onehundrednon = [int(x) for x in scipy.linspace(0,len(nontubepixels)-1, 500)]
		if len(tubepixels):
			self.axes.scatter(tubepixels[onehundredtube,0], tubepixels[onehundredtube,1], tubepixels[onehundredtube,2], c='g')
			self.histax.hist(tubepixels[onehundredtube, 1], 100, normed=1, facecolor='green')
		if len(nontubepixels):
			self.axes.scatter(nontubepixels[onehundrednon,0], nontubepixels[onehundrednon,1], nontubepixels[onehundrednon,2], c='r')
			self.histax.hist(nontubepixels[onehundrednon, 1], 100, normed=1, facecolor='red')
		self.figure.canvas.draw()
		self.histfig.canvas.draw()
开发者ID:keegano,项目名称:labrobot,代码行数:26,代码来源:segmenttest.py

示例11: testSnrFuncs

    def testSnrFuncs(self):
        """test for signal to noise ratio functions"""

        # trivial
        data_triv = sp.ones((3, 10))
        snr_triv_test = sp.ones(3)
        assert_equal(
            snr_peak(data_triv, 1.0),
            snr_triv_test)
        assert_equal(
            snr_power(data_triv, 1.0),
            snr_triv_test)
        assert_equal(
            snr_maha(data_triv, sp.eye(data_triv.shape[1])),
            snr_triv_test)

        # application
        data = sp.array([
            sp.sin(sp.linspace(0.0, 2 * sp.pi, 100)),
            sp.sin(sp.linspace(0.0, 2 * sp.pi, 100)) * 2,
            sp.sin(sp.linspace(0.0, 2 * sp.pi, 100)) * 5,
        ])
        assert_equal(
            snr_peak(data, 1.0),
            sp.absolute(data).max(axis=1))
        assert_equal(
            snr_power(data, 1.0),
            sp.sqrt((data * data).sum(axis=1) / data.shape[1]))
        assert_almost_equal(
            snr_maha(data, sp.eye(data.shape[1])),
            sp.sqrt((data * data).sum(axis=1) / data.shape[1]))
开发者ID:christiando,项目名称:BOTMpy,代码行数:31,代码来源:test_common.py

示例12: test_newton_exact_line_search

def test_newton_exact_line_search():
    op = p.OptimizationProblem(c.chebyquad)
    guess=linspace(0,1,4)
    cn  = p.NewtonExactLine(op)
    assert near(sol4,(cn.optimize(guess)))
    guess=linspace(0,1,8)
    assert near(sol8,(cn.optimize(guess)))
开发者ID:tapetersen,项目名称:FMNN25,代码行数:7,代码来源:testnewton.py

示例13: test_classic_newton

def test_classic_newton():
    op = p.OptimizationProblem(c.chebyquad)
    guess=linspace(0,1,4)
    cn  = p.ClassicNewton(op)
    assert near(sol4,(cn.optimize(guess)))
    guess=linspace(0,1,8)
    assert near(sol8,(cn.optimize(guess)))
开发者ID:tapetersen,项目名称:FMNN25,代码行数:7,代码来源:testnewton.py

示例14: get_znodes

 def get_znodes(self):
     " Compute a nodes for a log-lower and linear-upper grid. "
     zlower = sp.exp(sp.linspace(sp.log(self.zmin), sp.log(self.zmid), self.Nlo))
     zupper = sp.linspace(self.zmid, self.zmax, self.Nhi)
     znodes = sp.concatenate([zlower, 
                              zupper[1:]])
     return znodes
开发者ID:wgm2111,项目名称:wgm-mie-scattering,代码行数:7,代码来源:z_scale_mie.py

示例15: add_intron_patch2

def add_intron_patch2(ax, start, stop, cnt, color='green'):
    ### compute a quadratic function through the three points

    ### we set the first root to 0 and shift only the plotting ...
    x2 = ((stop - start) / 2.0)
    x3 = float(stop - start)

    ### compute coefficients
    #z = float((x1*x1*x2 + x1*x3*x3 + x2*x2*x3) - (x3*x3*x2 + x2*x2*x1 + x1*x1*x3))
    z = float((x2*x2*x3) - (x3*x3*x2))
    if z == 0:
        return

    #a = float(cnt) * (x3 - x1) / z
    #b = float(cnt) * ((x1*x1) - (x3*x3)) / z
    #c = float(cnt) * ((x1*x3*x3) - (x1*x1*x3)) / z
    a = float(cnt) * x3 / z
    b = float(cnt) * (-1*(x3*x3)) / z

    ### get points
    #x = sp.linspace(start, stop, 100)
    x = sp.linspace(0, stop-start, 100)
    #y = (a*x*x) + (b*x) + c
    y = (a*x*x) + (b*x)
    ax.plot(sp.linspace(start, stop, 100), y, '-', color=color)
开发者ID:ccwang12,项目名称:spladder,代码行数:25,代码来源:coverage.py


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