本文整理匯總了Python中pywt.Wavelet方法的典型用法代碼示例。如果您正苦於以下問題:Python pywt.Wavelet方法的具體用法?Python pywt.Wavelet怎麽用?Python pywt.Wavelet使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊pywt的用法示例。
在下文中一共展示了pywt.Wavelet方法的30個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: _wavelet_coefs
點讚 6
# 需要導入模塊: import pywt [as 別名]
# 或者: from pywt import Wavelet [as 別名]
def _wavelet_coefs(data, wavelet_name='db4'):
"""Compute Discrete Wavelet Transform coefficients.
Parameters
----------
data : ndarray, shape (n_channels, n_times)
wavelet_name : str (default: db4)
Wavelet name (to be used with ``pywt.Wavelet``). The full list of
Wavelet names are given by: ``[name for family in pywt.families() for
name in pywt.wavelist(family)]``.
Returns
-------
coefs : list of ndarray
Coefficients of a DWT (Discrete Wavelet Transform). ``coefs[0]`` is
the array of approximation coefficient and ``coefs[1:]`` is the list
of detail coefficients.
"""
wavelet = pywt.Wavelet(wavelet_name)
levdec = min(pywt.dwt_max_level(data.shape[-1], wavelet.dec_len), 6)
coefs = pywt.wavedec(data, wavelet=wavelet, level=levdec)
return coefs
開發者ID:mne-tools,項目名稱:mne-features,代碼行數:25,
示例2: compute_wavelet_feature_vector
點讚 6
# 需要導入模塊: import pywt [as 別名]
# 或者: from pywt import Wavelet [as 別名]
def compute_wavelet_feature_vector(image, wavelet='db6'):
image_np = np.array(image)
rgb = [image_np[:, :, i] for i in (0, 1, 2)]
if isinstance(wavelet, basestring):
wavelet = pywt.Wavelet(wavelet)
feature_vector = []
for c in rgb:
level = pywt.dwt_max_level(min(c.shape[0], c.shape[1]), wavelet.dec_len)
levels = pywt.wavedec2(c, wavelet, mode='sym', level=level)
for coeffs in levels:
if not isinstance(coeffs, tuple):
coeffs = (coeffs,)
for w in coeffs:
w_flat = w.flatten()
feature_vector += [float(np.mean(w_flat)), float(np.std(w_flat))]
return feature_vector
開發者ID:seanbell,項目名稱:opensurfaces,代碼行數:21,
示例3: check_coefficients
點讚 6
# 需要導入模塊: import pywt [as 別名]
# 或者: from pywt import Wavelet [as 別名]
def check_coefficients(wavelet):
epsilon = 5e-11
level = 10
w = pywt.Wavelet(wavelet)
# Lowpass filter coefficients sum to sqrt2
res = np.sum(w.dec_lo)-np.sqrt(2)
msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))
assert_(res < epsilon, msg=msg)
# sum even coef = sum odd coef = 1 / sqrt(2)
res = np.sum(w.dec_lo[::2])-1./np.sqrt(2)
msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))
assert_(res < epsilon, msg=msg)
res = np.sum(w.dec_lo[1::2])-1./np.sqrt(2)
msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))
assert_(res < epsilon, msg=msg)
# Highpass filter coefficients sum to zero
res = np.sum(w.dec_hi)
msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))
assert_(res < epsilon, msg=msg)
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:22,
示例4: test_custom_wavelet
點讚 6
# 需要導入模塊: import pywt [as 別名]
# 或者: from pywt import Wavelet [as 別名]
def test_custom_wavelet():
haar_custom1 = pywt.Wavelet('Custom Haar Wavelet',
filter_bank=_CustomHaarFilterBank())
haar_custom1.orthogonal = True
haar_custom1.biorthogonal = True
val = np.sqrt(2) / 2
filter_bank = ([val]*2, [-val, val], [val]*2, [val, -val])
haar_custom2 = pywt.Wavelet('Custom Haar Wavelet',
filter_bank=filter_bank)
# check expected default wavelet properties
assert_(~haar_custom2.orthogonal)
assert_(~haar_custom2.biorthogonal)
assert_(haar_custom2.symmetry == 'unknown')
assert_(haar_custom2.family_name == '')
assert_(haar_custom2.short_family_name == '')
assert_(haar_custom2.vanishing_moments_phi == 0)
assert_(haar_custom2.vanishing_moments_psi == 0)
# Some properties can be set by the user
haar_custom2.orthogonal = True
haar_custom2.biorthogonal = True
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:25,
示例5: test_wavedecn_coeff_reshape_even
點讚 6
# 需要導入模塊: import pywt [as 別名]
# 或者: from pywt import Wavelet [as 別名]
def test_wavedecn_coeff_reshape_even():
# verify round trip is correct:
# wavedecn - >coeffs_to_array-> array_to_coeffs -> waverecn
# This is done for wavedec{1, 2, n}
rng = np.random.RandomState(1234)
params = {'wavedec': {'d': 1, 'dec': pywt.wavedec, 'rec': pywt.waverec},
'wavedec2': {'d': 2, 'dec': pywt.wavedec2, 'rec': pywt.waverec2},
'wavedecn': {'d': 3, 'dec': pywt.wavedecn, 'rec': pywt.waverecn}}
N = 28
for f in params:
x1 = rng.randn(*([N] * params[f]['d']))
for mode in pywt.Modes.modes:
for wave in wavelist:
w = pywt.Wavelet(wave)
maxlevel = pywt.dwt_max_level(np.min(x1.shape), w.dec_len)
if maxlevel == 0:
continue
coeffs = params[f]['dec'](x1, w, mode=mode)
coeff_arr, coeff_slices = pywt.coeffs_to_array(coeffs)
coeffs2 = pywt.array_to_coeffs(coeff_arr, coeff_slices,
output_format=f)
x1r = params[f]['rec'](coeffs2, w, mode=mode)
assert_allclose(x1, x1r, rtol=1e-4, atol=1e-4)
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:27,
示例6: test_waverecn_coeff_reshape_odd
點讚 6
# 需要導入模塊: import pywt [as 別名]
# 或者: from pywt import Wavelet [as 別名]
def test_waverecn_coeff_reshape_odd():
# verify round trip is correct:
# wavedecn - >coeffs_to_array-> array_to_coeffs -> waverec