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


Python pywt.cwt方法代码示例

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


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

示例1: MyPywtCWT

# 需要导入模块: import pywt [as 别名]
# 或者: from pywt import cwt [as 别名]
def MyPywtCWT(data):
    pass
    ''' --原始数据信息初始化--'''

    # Fs = 500000 #采样频率:500 000 Hz ; 采样周期:2 us
    ''' --尺度计算-- '''
    wavename = 'gaus1'
    totalscal = 256          #尺度序列的长度
    
    #Fc = 2000;             #小波中心频率(Hz)(“主波峰之间的差值”=2000Hz)
    #Fc = pywt.central_frequency(wavename, precision=8) 
    Fc = pywt.central_frequency(wavename)               
                   
    C = 2*Fc*totalscal      # C为常数,用于计算尺度序列. C = 2*Fc/totalscal
    scal= C/np.arange(1,totalscal+1)    #尺度序列,范围(2*Fc,inf)

    #--连续小波变换--
    coef,freqs = pywt.cwt(data, scal, wavename)
    coef = np.abs(coef)
    return coef,freqs 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:22,代码来源:Algorithm_CWT.py

示例2: MyScipyCwt

# 需要导入模块: import pywt [as 别名]
# 或者: from pywt import cwt [as 别名]
def MyScipyCwt(data,MyWidths):
    ''' 将int型data转为float型sig '''
    sig = np.ones(len(data),np.float)  #产生空的float型sig
    for i in range(0,len(data)): 
        sig[i] = float(data[i])

    # widths = np.arange(1, 31)
    widths = np.arange(1, MyWidths+1)
    ''' 
    signal.cwt(sig, signal.ricker, widths) 
        - CWT: Continuous wavelet transform 连续小波变换
        - signal.ricker返回一个Ricker小波,也被称为“墨西哥帽子小波”   
    '''
    cwtmatr =  signal.cwt(sig, signal.ricker, widths) 
    # cwtmatr = np.abs(cwtmatr)
    # plt.imshow(cwtmatr, extent=[-1, 1, 31, 1], cmap='PRGn', aspect='auto', vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
    return cwtmatr 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:19,代码来源:Algorithm_CWT.py

示例3: child_wav

# 需要导入模块: import pywt [as 别名]
# 或者: from pywt import cwt [as 别名]
def child_wav(wavelet, scale):
    """Returns an array of complex values with the child wavelet used at the
    given ``scale``.

    The ``wavelet`` argument can be either a string like 'cmor1-1.5' or
    a ``pywt.ContinuousWavelet`` instance
    """

    wavelet = _wavelet_instance(wavelet)

    # the following code has been extracted from pywt.cwt() 1.0.2
    precision = 10
    int_psi, x = pywt.integrate_wavelet(wavelet, precision=precision)
    step = x[1] - x[0]
    j = np.floor(
            np.arange(scale * (x[-1] - x[0]) + 1) / (scale * step))
    if np.max(j) >= np.size(int_psi):
                j = np.delete(j, np.where((j >= np.size(int_psi)))[0])

    return int_psi[j.astype(np.int)] 
开发者ID:alsauve,项目名称:scaleogram,代码行数:22,代码来源:wfun.py

示例4: _peaks_delineator

# 需要导入模块: import pywt [as 别名]
# 或者: from pywt import cwt [as 别名]
def _peaks_delineator(ecg, rpeaks, sampling_rate=1000):
    # Try loading pywt
    try:
        import pywt
    except ImportError:
        raise ImportError(
            "NeuroKit error: ecg_delineator(): the 'PyWavelets' module is required for this method to run. ",
            "Please install it first (`pip install PyWavelets`).",
        )
    # first derivative of the Gaissian signal
    scales = np.array([1, 2, 4, 8, 16])
    cwtmatr, __ = pywt.cwt(ecg, scales, "gaus1", sampling_period=1.0 / sampling_rate)

    qrs_duration = 0.1

    search_boundary = int(0.9 * qrs_duration * sampling_rate / 2)
    significant_peaks_groups = []
    for i in range(len(rpeaks) - 1):
        # search for T peaks and P peaks from R peaks
        start = rpeaks[i] + search_boundary
        end = rpeaks[i + 1] - search_boundary
        search_window = cwtmatr[4, start:end]
        height = 0.25 * np.sqrt(np.mean(np.square(search_window)))
        peaks_tp, heights_tp = scipy.signal.find_peaks(np.abs(search_window), height=height)
        peaks_tp = peaks_tp + rpeaks[i] + search_boundary
        # set threshold for heights of peaks to find significant peaks in wavelet
        threshold = 0.125 * max(search_window)
        significant_index = []
        significant_index = [j for j in range(len(peaks_tp)) if heights_tp["peak_heights"][j] > threshold]

        significant_peaks_tp = []
        for index in significant_index:
            significant_peaks_tp.append(peaks_tp[index])
        significant_peaks_groups.append(_find_tppeaks(ecg, significant_peaks_tp, sampling_rate=sampling_rate))

    tpeaks, ppeaks = zip(*[(g[0], g[-1]) for g in significant_peaks_groups])

    tpeaks = np.array(tpeaks, dtype="int")
    ppeaks = np.array(ppeaks, dtype="int")
    return tpeaks, ppeaks 
开发者ID:neuropsychology,项目名称:NeuroKit,代码行数:42,代码来源:ecg_delineate.py

示例5: _find_tppeaks

# 需要导入模块: import pywt [as 别名]
# 或者: from pywt import cwt [as 别名]
def _find_tppeaks(ecg, keep_tp, sampling_rate=1000):
    # Try loading pywt
    try:
        import pywt
    except ImportError:
        raise ImportError(
            "NeuroKit error: ecg_delineator(): the 'PyWavelets' module is required for this method to run. ",
            "Please install it first (`pip install PyWavelets`).",
        )
    # first derivative of the Gaissian signal
    scales = np.array([1, 2, 4, 8, 16])
    cwtmatr, __ = pywt.cwt(ecg, scales, "gaus1", sampling_period=1.0 / sampling_rate)
    max_search_duration = 0.05
    tppeaks = []
    for index_cur, index_next in zip(keep_tp[:-1], keep_tp[1:]):
        # limit 1
        correct_sign = cwtmatr[4, :][index_cur] < 0 and cwtmatr[4, :][index_next] > 0  # pylint: disable=R1716
        #    near = (index_next - index_cur) < max_wv_peak_dist #limit 2
        #    if near and correct_sign:
        if correct_sign:
            index_zero_cr = signal_zerocrossings(cwtmatr[4, :][index_cur:index_next])[0] + index_cur
            nb_idx = int(max_search_duration * sampling_rate)
            index_max = np.argmax(ecg[index_zero_cr - nb_idx : index_zero_cr + nb_idx]) + (index_zero_cr - nb_idx)
            tppeaks.append(index_max)
    return tppeaks


# =============================================================================
#                              PEAK METHOD
# ============================================================================= 
开发者ID:neuropsychology,项目名称:NeuroKit,代码行数:32,代码来源:ecg_delineate.py


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