Python pywt.cwt() Examples
The following are 30
code examples of pywt.cwt().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pywt
, or try the search function
.
Example #1
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #2
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #3
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #4
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #5
Source File: Algorithm.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #6
Source File: Algorithm.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #7
Source File: wfun.py From scaleogram with MIT License | 6 votes |
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)]
Example #8
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #9
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #10
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #11
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #12
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #13
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #14
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #15
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #16
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #17
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #18
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #19
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #20
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #21
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #22
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #23
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #24
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #25
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #26
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #27
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #28
Source File: Algorithm_CWT.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
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
Example #29
Source File: unittests.py From scaleogram with MIT License | 5 votes |
def test_fastcwt(self): signal = np.zeros(1000, dtype=np.float64) signal[1] = 1 scales = np.asarray([1, 10, 50, 100, 200, 400]) for wavelet in [ l.split()[0] for l in WAVLIST]: coef1, freq1 = pywt.cwt(signal, scales, wavelet) coef2, freq2 = fastcwt( signal, scales, wavelet) self.assertLess(np.std(np.abs(coef1-coef2)), 1e-12) # check dtype conservation [on hold to be consistent with pywt-1.0.2] for check_dtype in [np.float16, np.float32, np.float64, np.float128]: for scales in [ [10], [400]]: sig = np.ones(1000, dtype=check_dtype) c,f = fastcwt(sig, scales, 'mexh') self.assertEqual(c.dtype, np.float64)
Example #30
Source File: ecg_delineate.py From NeuroKit with MIT License | 5 votes |
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