當前位置: 首頁>>代碼示例>>Python>>正文


Python pylab.linspace方法代碼示例

本文整理匯總了Python中pylab.linspace方法的典型用法代碼示例。如果您正苦於以下問題:Python pylab.linspace方法的具體用法?Python pylab.linspace怎麽用?Python pylab.linspace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pylab的用法示例。


在下文中一共展示了pylab.linspace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: plot_wt_layout

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def plot_wt_layout(wt_layout, borders=None, depth=None):
    fig = plt.figure(figsize=(6,6), dpi=2000)
    fs = 14
    ax = plt.subplot(111)

    if depth is not None:
        N = 100
        X, Y = plt.meshgrid(plt.linspace(depth[:,0].min(), depth[:,0].max(), N), 
                            plt.linspace(depth[:,1].min(), depth[:,1].max(), N))
        Z = plt.griddata(depth[:,0],depth[:,1],depth[:,2],X,Y, interp='linear')
        plt.contourf(X,Y,Z, label='depth [m]')
        plt.colorbar().set_label('water depth [m]')
    #ax.plot(wt_layout.wt_positions[:,0], wt_layout.wt_positions[:,1], 'or', label='baseline position')
    
    ax.scatter(wt_layout.wt_positions[:,0], wt_layout.wt_positions[:,1], wt_layout._wt_list('rotor_diameter'), label='baseline position')

    if borders is not None:
        ax.plot(borders[:,0], borders[:,1], 'r--', label='border')
        
    ax.set_xlabel('x [m]'); 
    ax.set_ylabel('y [m]')
    ax.axis('equal');
    ax.legend(loc='lower left') 
開發者ID:DTUWindEnergy,項目名稱:TOPFARM,代碼行數:25,代碼來源:plot.py

示例2: plot_wind_rose

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def plot_wind_rose(wind_rose):
    fig = plt.figure(figsize=(12,5), dpi=1000)

    # Plotting the wind statistics
    ax1 = plt.subplot(121, polar=True)
    w = 2.*np.pi/len(wind_rose.frequency)
    b = ax1.bar(np.pi/2.0-np.array(wind_rose.wind_directions)/180.*np.pi - w/2.0, 
                np.array(wind_rose.frequency)*100, width=w)

    # Trick to set the right axes (by default it's not oriented as we are used to in the WE community)
    mirror = lambda d: 90.0 - d if d < 90.0 else 360.0 + (90.0 - d)
    ax1.set_xticklabels([u'%d\xb0'%(mirror(d)) for d in linspace(0.0, 360.0,9)[:-1]]);
    ax1.set_title('Wind direction frequency');

    # Plotting the Weibull A parameter
    ax2 = plt.subplot(122, polar=True)
    b = ax2.bar(np.pi/2.0-np.array(wind_rose.wind_directions)/180.*np.pi - w/2.0, 
                np.array(wind_rose.A), width=w)
    ax2.set_xticklabels([u'%d\xb0'%(mirror(d)) for d in linspace(0.0, 360.0,9)[:-1]]);
    ax2.set_title('Weibull A parameter per wind direction sectors'); 
開發者ID:DTUWindEnergy,項目名稱:TOPFARM,代碼行數:22,代碼來源:plot.py

示例3: plot_window

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def plot_window(self):
        """Plot the window in the time domain

        .. plot::
            :width: 80%
            :include-source:

            from spectrum.window import Window
            w = Window(64, name='hamming')
            w.plot_window()

        """
        from pylab import plot, xlim, grid, title, ylabel, axis
        x = linspace(0, 1, self.N)
        xlim(0, 1)
        plot(x, self.data)
        grid(True)
        title('%s Window (%s points)' % (self.name.capitalize(), self.N))
        ylabel('Amplitude')
        axis([0, 1, 0, 1.1]) 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:22,代碼來源:window.py

示例4: window_lanczos

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def window_lanczos(N):
    r"""Lanczos window also known as sinc window.

    :param N: window length

    .. math:: w(n) = sinc \left(  \frac{2n}{N-1} - 1 \right)

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'lanczos')

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    if N ==1:
        return ones(1)

    n = linspace(-N/2., N/2., N)
    win = sinc(2*n/(N-1.))
    return win 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:24,代碼來源:window.py

示例5: window_riesz

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def window_riesz(N):
    r"""Riesz tapering window

    :param N: window length

    .. math:: w(n) = 1 - \left| \frac{n}{N/2}  \right|^2

    with :math:`-N/2 \leq n \leq N/2`.

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'riesz')

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    n = linspace(-N/2., (N)/2., N)

    w = 1 - abs(n/(N/2.))**2.
    return w 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:24,代碼來源:window.py

示例6: window_riemann

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def window_riemann(N):
    r"""Riemann tapering window

    :param int N: window length

    .. math:: w(n) = 1 - \left| \frac{n}{N/2}  \right|^2

    with :math:`-N/2 \leq n \leq N/2`.

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'riesz')

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    n = linspace(-N/2., (N)/2., N)
    w = sin(n/float(N)*2.*pi) / (n / float(N)*2.*pi)
    return w 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:23,代碼來源:window.py

示例7: window_poisson

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def window_poisson(N, alpha=2):
    r"""Poisson tapering window

    :param int N: window length

    .. math:: w(n) = \exp^{-\alpha \frac{|n|}{N/2} }

    with :math:`-N/2 \leq n \leq N/2`.

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'poisson')
        window_visu(64, 'poisson', alpha=3)
        window_visu(64, 'poisson', alpha=4)

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    n = linspace(-N/2., (N)/2., N)
    w = exp(-alpha * abs(n)/(N/2.))
    return w 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:25,代碼來源:window.py

示例8: meyeraux

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def meyeraux(x):
    r"""Compute the Meyer auxiliary function

    The Meyer function is

    .. math:: y = 35 x^4-84 x^5+70 x^6-20 x^7

    :param array x:
    :return: the waveform

    .. plot::
        :include-source:
        :width: 80%

        from spectrum import meyeraux
        from pylab import linspace, plot
        t = linspace(0, 1, 1000)
        plot(t, meyeraux(t))

    """

    return  35*x**4-84.*x**5+70.*x**6-20.*x**7 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:24,代碼來源:waveform.py

示例9: plot_CDR_correlation

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def plot_CDR_correlation(self, doplot=True):
        """
        Displays correlation between sampling time points and CDR. It returns the two
        parameters of the linear fit, Pearson's r, p-value and standard error. If optional argument 'doplot' is
        False, the plot is not displayed.
        """
        pel2, tol = self.get_gene(self.rootlane, ignore_log=True)
        pel = numpy.array([pel2[m] for m in self.pl])*tol
        dr2 = self.get_gene('_CDR')[0]
        dr = numpy.array([dr2[m] for m in self.pl])
        po = scipy.stats.linregress(pel, dr)
        if doplot:
            pylab.scatter(pel, dr, s=9.0, alpha=0.7, c='r')
            pylab.xlim(min(pel), max(pel))
            pylab.ylim(0, max(dr)*1.1)
            pylab.xlabel(self.rootlane)
            pylab.ylabel('CDR')
            xk = pylab.linspace(min(pel), max(pel), 50)
            pylab.plot(xk, po[1]+po[0]*xk, 'k--', linewidth=2.0)
            pylab.show()
        return po 
開發者ID:CamaraLab,項目名稱:scTDA,代碼行數:23,代碼來源:main.py

示例10: contour_plot

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def contour_plot(func):
    rose = func()
    XS, YS = plt.meshgrid(np.linspace(-2, 2, 20), np.linspace(-2,2, 20));
    ZS = np.array([rose(x1=x, x2=y).f_xy for x,y in zip(XS.flatten(),YS.flatten())]).reshape(XS.shape);
    plt.contourf(XS, YS, ZS, 50);
    plt.colorbar() 
開發者ID:DTUWindEnergy,項目名稱:TOPFARM,代碼行數:8,代碼來源:tutorial.py

示例11: plot_range_fixed_x

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def plot_range_fixed_x(self, xmin="auto", xmax="auto", xsteps=21, ymin="auto", ymax="auto", ysteps=200, clear=True, x_derivative=0):
        if xmin=="auto": xmin=self.xmin
        if xmax=="auto": xmax=self.xmax
        
        self.plot_fixed_x(_pylab.linspace(xmin, xmax, xsteps), x_derivative, ysteps, ymin, ymax, False, clear)
        _s.format_figure() 
開發者ID:Spinmob,項目名稱:spinmob,代碼行數:8,代碼來源:_spline.py

示例12: plot_range_fixed_y

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def plot_range_fixed_y(self, ymin="auto", ymax="auto", ysteps=21, xmin="auto", xmax="auto", xsteps=200, clear=True, x_derivative=0):
        if ymin=="auto": ymin=self.ymin
        if ymax=="auto": ymax=self.ymax
        
        self.plot_fixed_y(_pylab.linspace(ymin, ymax, ysteps), x_derivative, xsteps, xmin, xmax, False, clear)
        _s.format_figure() 
開發者ID:Spinmob,項目名稱:spinmob,代碼行數:8,代碼來源:_spline.py

示例13: _getF

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def _getF(self):
        if self.__response is None:
            self.compute_response()
        self.__frequencies = linspace(-0.5, 0.5, len(self.__response))
        return self.__frequencies 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:7,代碼來源:window.py

示例14: window_gaussian

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def window_gaussian(N, alpha=2.5):
    r"""Gaussian window

    :param N: window length

    .. math:: \exp^{-0.5 \left( \sigma\frac{n}{N/2} \right)^2}

    with :math:`\frac{N-1}{2}\leq n \leq \frac{N-1}{2}`.

    .. note:: N-1 is used to be in agreement with octave convention. The ENBW of
         1.4 is also in agreement with [Harris]_

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'gaussian', alpha=2.5)



    .. seealso:: scipy.signal.gaussian, :func:`create_window`
    """
    t = linspace(-(N-1)/2., (N-1)/2., N)
    #t = linspace(-(N)/2., (N)/2., N)
    w = exp(-0.5*(alpha * t/(N/2.))**2.)
    return w 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:29,代碼來源:window.py

示例15: window_parzen

# 需要導入模塊: import pylab [as 別名]
# 或者: from pylab import linspace [as 別名]
def window_parzen(N):
    r"""Parsen tapering window (also known as de la Valle-Poussin)

    :param N: window length

    Parzen windows are piecewise cubic approximations
    of Gaussian windows. Parzen window sidelobes fall off as :math:`1/\omega^4`.

    if :math:`0\leq|x|\leq (N-1)/4`:

    .. math:: w(n) = 1-6 \left( \frac{|n|}{N/2} \right)^2 +6 \left( \frac{|n|}{N/2}\right)^3

    if :math:`(N-1)/4\leq|x|\leq (N-1)/2`

    .. math:: w(n) = 2 \left(1- \frac{|n|}{N/2}\right)^3


    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'parzen')


    .. seealso:: :func:`create_window`, :class:`Window`
    """
    from numpy import  where, concatenate

    n = linspace(-(N-1)/2., (N-1)/2., N)
    n1 = n[where(abs(n)<=(N-1)/4.)[0]]
    n2 = n[where(n>(N-1)/4.)[0]]
    n3 = n[where(n<-(N-1)/4.)[0]]


    w1 = 1. -6.*(abs(n1)/(N/2.))**2 + 6*(abs(n1)/(N/2.))**3
    w2 = 2.*(1-abs(n2)/(N/2.))**3
    w3 = 2.*(1-abs(n3)/(N/2.))**3

    w = concatenate((w3, w1, w2))
    return w 
開發者ID:cokelaer,項目名稱:spectrum,代碼行數:43,代碼來源:window.py


注:本文中的pylab.linspace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。