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


Python numpy.kaiser方法代码示例

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


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

示例1: smooth_curve

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def smooth_curve(x):
    """用于使损失函数的图形变圆滑
    参考:http://glowingpython.blogspot.jp/2012/02/convolution-with-numpy.html
    """
    window_len = 11
    s = np.r_[x[window_len-1:0:-1], x, x[-1:-window_len:-1]]
    w = np.kaiser(window_len, 2)
    y = np.convolve(w/w.sum(), s, mode='valid')
    return y[5:len(y)-5] 
开发者ID:wdxtub,项目名称:deep-learning-note,代码行数:11,代码来源:util.py

示例2: window_visu

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def window_visu(N=51, name='hamming', **kargs):
    """A Window visualisation tool

    :param N: length of the window
    :param name: name of the window
    :param NFFT: padding used by the FFT
    :param mindB: the minimum frequency power in dB
    :param maxdB: the maximum frequency power in dB
    :param kargs: optional arguments passed to :func:`create_window`

    This function plot the window shape and its equivalent in the Fourier domain.

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

        from spectrum import window_visu
        window_visu(64, 'kaiser', beta=8.)

    """
    # get the default parameters
    mindB = kargs.pop('mindB', -100)
    maxdB = kargs.pop('maxdB', None)
    norm = kargs.pop('norm', True)

    # create a window object
    w = Window(N, name, **kargs)

    # plot the time and frequency windows
    w.plot_time_freq(mindB=mindB, maxdB=maxdB, norm=norm) 
开发者ID:cokelaer,项目名称:spectrum,代码行数:32,代码来源:window.py

示例3: smooth_curve

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def smooth_curve(x):
    """損失関数のグラフを滑らかにするために用いる

    参考:http://glowingpython.blogspot.jp/2012/02/convolution-with-numpy.html
    """
    window_len = 11
    s = np.r_[x[window_len-1:0:-1], x, x[-1:-window_len:-1]]
    w = np.kaiser(window_len, 2)
    y = np.convolve(w/w.sum(), s, mode='valid')
    return y[5:len(y)-5] 
开发者ID:oreilly-japan,项目名称:deep-learning-from-scratch,代码行数:12,代码来源:util.py

示例4: kaiser

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def kaiser(M, beta):
    """Return the Kaiser window.
    The Kaiser window is a taper formed by using a Bessel function.

    .. math::  w(n) = I_0\\left( \\beta \\sqrt{1-\\frac{4n^2}{(M-1)^2}}
               \\right)/I_0(\\beta)

    with

    .. math:: \\quad -\\frac{M-1}{2} \\leq n \\leq \\frac{M-1}{2}

    where :math:`I_0` is the modified zeroth-order Bessel function.

     Args:
        M (int):
            Number of points in the output window. If zero or less, an empty
            array is returned.
        beta (float):
            Shape parameter for window

    Returns:
        ~cupy.ndarray:  The window, with the maximum value normalized to one
        (the value one appears only if the number of samples is odd).

    .. seealso:: :func:`numpy.kaiser`
    """
    if M == 1:
        return cupy.array([1.])
    if M <= 0:
        return cupy.array([])
    alpha = (M - 1) / 2.0
    out = cupy.empty(M, dtype=cupy.float64)
    return _kaiser_kernel(beta, alpha, out) 
开发者ID:cupy,项目名称:cupy,代码行数:35,代码来源:window.py

示例5: _kaiser

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def _kaiser(n, beta):
    """Independant Kaiser window

    For the definition of the Kaiser window, see A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".

    The continuous version of width n centered about x=0 is:

    .. note:: 2 times slower than scipy.kaiser
    """
    from scipy.special import iv as besselI
    m = n - 1
    k = arange(0, m)
    k = 2. * beta / m * sqrt (k * (m - k))
    w = besselI (0, k) / besselI (0, beta)
    return w 
开发者ID:cokelaer,项目名称:spectrum,代码行数:17,代码来源:window.py

示例6: iFFT

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def iFFT(Y, output_length=None, window=False):
    """ Inverse real-valued Fourier Transform

    Parameters
    ----------
    Y : array_like
       Frequency domain data [Nsignals x Nbins]
    output_length : int, optional
       Length of returned time-domain signal (Default: 2 x len(Y) + 1)
    window : boolean, optional
       Window applied to the resulting time-domain signal

    Returns
    -------
    y : array_like
       Reconstructed time-domain signal
    """
    Y = _np.atleast_2d(Y)
    y = _np.fft.irfft(Y, n=output_length)

    if window:
        no_of_samples = y.shape[-1]

        if window == 'hann':
            window_array = _np.hanning(no_of_samples)
        elif window == 'hamming':
            window_array = _np.hamming(no_of_samples)
        elif window == 'blackman':
            window_array = _np.blackman(no_of_samples)
        elif window == 'kaiser':
            window_array = _np.kaiser(no_of_samples, 3)
        else:
            raise ValueError('Selected window must be one of hann, hamming, blackman or kaiser')

        y *= window_array

    return y


# noinspection PyUnusedLocal 
开发者ID:AppliedAcousticsChalmers,项目名称:sound_field_analysis-py,代码行数:42,代码来源:process.py

示例7: smooth_curve

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def smooth_curve(x):
    """用于使损失函数的图形变圆滑

    参考:http://glowingpython.blogspot.jp/2012/02/convolution-with-numpy.html
    """
    window_len = 11
    s = np.r_[x[window_len-1:0:-1], x, x[-1:-window_len:-1]]
    w = np.kaiser(window_len, 2)
    y = np.convolve(w/w.sum(), s, mode='valid')
    return y[5:len(y)-5] 
开发者ID:hguomin,项目名称:deep-learning-from-scratch,代码行数:12,代码来源:util.py

示例8: _resample_window_oct

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def _resample_window_oct(p, q):
    """Port of Octave code to Python"""

    gcd = np.gcd(p, q)
    if gcd > 1:
        p /= gcd
        q /= gcd

    # Properties of the antialiasing filter
    log10_rejection = -3.0
    stopband_cutoff_f = 1. / (2 * max(p, q))
    roll_off_width = stopband_cutoff_f / 10

    # Determine filter length
    rejection_dB = -20 * log10_rejection
    L = np.ceil((rejection_dB - 8) / (28.714 * roll_off_width))

    # Ideal sinc filter
    t = np.arange(-L, L + 1)
    ideal_filter = 2 * p * stopband_cutoff_f \
        * np.sinc(2 * stopband_cutoff_f * t)

    # Determine parameter of Kaiser window
    if (rejection_dB >= 21) and (rejection_dB <= 50):
        beta = 0.5842 * (rejection_dB - 21)**0.4 \
            + 0.07886 * (rejection_dB - 21)
    elif rejection_dB > 50:
        beta = 0.1102 * (rejection_dB - 8.7)
    else:
        beta = 0.0

    # Apodize ideal filter response
    h = np.kaiser(2 * L + 1, beta) * ideal_filter

    return h 
开发者ID:mpariente,项目名称:pystoi,代码行数:37,代码来源:utils.py

示例9: smooth_curve

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def smooth_curve(x):
    """ Used to smooth the graph of the loss function

    reference:http://glowingpython.blogspot.jp/2012/02/convolution-with-numpy.html
    """
    window_len = 11
    s = np.r_[x[window_len-1:0:-1], x, x[-1:-window_len:-1]]
    w = np.kaiser(window_len, 2)
    y = np.convolve(w/w.sum(), s, mode='valid')
    return y[5:len(y)-5] 
开发者ID:YeongHyeon,项目名称:R-CNN_LIGHT,代码行数:12,代码来源:util.py

示例10: kaiser

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def kaiser(active, *, beta):
    """Kaiser tapering window.

    This uses :func:`numpy.kaiser`.

    Parameters
    ----------
    active : array_like, dtype=bool
        A boolean array containing ``True`` for active loudspeakers.
    alpha : float
        Shape parameter of the Kaiser window, see :func:`numpy.kaiser`.

    Returns
    -------
    (len(active),) `numpy.ndarray`
        Tapering weights.

    Examples
    --------
    .. plot::
        :context: close-figs

        plt.plot(sfs.tapering.kaiser(active1, beta=0), label='beta = 0')
        plt.plot(sfs.tapering.kaiser(active1, beta=2), label='beta = 2')
        plt.plot(sfs.tapering.kaiser(active1, beta=6), label='beta = 6')
        plt.plot(sfs.tapering.kaiser(active1, beta=8.6), label='beta = 8.6')
        plt.plot(sfs.tapering.kaiser(active1, beta=14), label='beta = 14')
        plt.axis([-3, 103, -0.1, 1.1])
        plt.legend(loc='lower center')

    .. plot::
        :context: close-figs

        plt.plot(sfs.tapering.kaiser(active2, beta=7))
        plt.axis([-3, 103, -0.1, 1.1])

    """
    idx = _windowidx(active)
    window = _np.zeros(len(active))
    window[idx] = _np.kaiser(len(idx), beta)
    return window 
开发者ID:sfstoolbox,项目名称:sfs-python,代码行数:43,代码来源:tapering.py

示例11: window_design

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def window_design(self, window_length, beta):
        """Kaiser window design

        Args:
            window_length: Length of the window in number of samples
            beta: Beta value for Kaiser window design

        Returns:
            window: Window designed using the beta and length provided as inputs

        """

        self.window = np.kaiser(window_length, beta)

        return self.window 
开发者ID:HDI-Project,项目名称:MLPrimitives,代码行数:17,代码来源:dsp.py

示例12: enbw

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def enbw(data):
    r"""Computes the equivalent noise bandwidth

    .. math:: ENBW = N \frac{\sum_{n=1}^{N} w_n^2}{\left(\sum_{n=1}^{N} w_n \right)^2}

    .. doctest::

        >>> from spectrum import create_window, enbw
        >>> w = create_window(64, 'rectangular')
        >>> enbw(w)
        1.0

    The following table contains the ENBW values for some of the
    implemented windows in this module (with N=16384). They have been
    double checked against litterature (Source: [Harris]_, [Marple]_).

    If not present, it means that it has not been checked.

    =================== ============ =============
    name                 ENBW        litterature
    =================== ============ =============
    rectangular         1.           1.
    triangle            1.3334       1.33
    Hann                1.5001       1.5
    Hamming             1.3629       1.36
    blackman            1.7268       1.73
    kaiser              1.7
    blackmanharris,4    2.004        2.
    riesz               1.2000       1.2
    riemann             1.32         1.3
    parzen              1.917        1.92
    tukey 0.25          1.102        1.1
    bohman              1.7858       1.79
    poisson 2           1.3130       1.3
    hanningpoisson 0.5  1.609        1.61
    cauchy              1.489        1.48
    lanczos             1.3
    =================== ============ =============


    """
    N = len(data)
    return N * np.sum(data**2) / np.sum(data)**2 
开发者ID:cokelaer,项目名称:spectrum,代码行数:45,代码来源:window.py

示例13: define_weight_function

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import kaiser [as 别名]
def define_weight_function(self, weight_size=DEFAULT_WEIGHT_SIZE):
        """
        Try to derive WgtFunct from WgtType, if necessary. This should likely be called from the `GridType` parent.

        Parameters
        ----------
        weight_size : int
            the size of the `WgtFunct` to generate.

        Returns
        -------
        None
        """

        if self.WgtType is None or self.WgtType.WindowName is None:
            return  # nothing to be done

        window_name = self.WgtType.WindowName.upper()
        if window_name == 'HAMMING':
            # A Hamming window is defined in many places as a raised cosine of weight .54, so this is the default.
            # Some data use a generalized raised cosine and call it HAMMING, so we allow for both uses.
            try:
                # noinspection PyTypeChecker
                coef = float(self.WgtType.get_parameter_value(None, 0.54))  # just get first parameter - name?
            except ValueError:
                coef = 0.54
            self.WgtFunct = _raised_cos(weight_size, coef)
        elif window_name == 'HANNING':
            self.WgtFunct = _raised_cos(weight_size, 0.5)
        elif window_name == 'KAISER':
            try:
                # noinspection PyTypeChecker
                beta = float(self.WgtType.get_parameter_value(None, 14))  # just get first parameter - name?
            except ValueError:
                beta = 14.0  # default suggested in numpy.kaiser
            self.WgtFunct = numpy.kaiser(weight_size, beta)
        elif window_name == 'TAYLOR':
            # noinspection PyTypeChecker
            sidelobes = int(self.WgtType.get_parameter_value('NBAR', 4))  # apparently the matlab argument name
            # noinspection PyTypeChecker
            max_sidelobe_level = float(self.WgtType.get_parameter_value('SLL', -30))  # same
            if max_sidelobe_level > 0:
                max_sidelobe_level *= -1
            self.WgtFunct = _taylor_win(weight_size,
                                        sidelobes=sidelobes,
                                        max_sidelobe_level=max_sidelobe_level,
                                        normalize=True) 
开发者ID:ngageoint,项目名称:sarpy,代码行数:49,代码来源:Grid.py


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