本文整理匯總了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 -> waverecn

rng = np.random.RandomState(1234)

x1 = rng.randn(35, 33)

for mode in pywt.Modes.modes:

for wave in ['haar', ]:

w = pywt.Wavelet(wave)

maxlevel = pywt.dwt_max_level(np.min(x1.shape), w.dec_len)

if maxlevel == 0:

continue

coeffs = pywt.wavedecn(x1, w, mode=mode)

coeff_arr, coeff_slices = pywt.coeffs_to_array(coeffs)

coeffs2 = pywt.array_to_coeffs(coeff_arr, coeff_slices)

x1r = pywt.waverecn(coeffs2, w, mode=mode)

# truncate reconstructed values to original shape

x1r = x1r[[slice(s) for s in x1.shape]]

assert_allclose(x1, x1r, rtol=1e-4, atol=1e-4)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:20,

示例7: test_swt_dtypes

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_swt_dtypes():

wavelet = pywt.Wavelet('haar')

for dt_in, dt_out in zip(dtypes_in, dtypes_out):

errmsg = "wrong dtype returned for {0} input".format(dt_in)

# swt

x = np.ones(8, dtype=dt_in)

(cA2, cD2), (cA1, cD1) = pywt.swt(x, wavelet, level=2)

assert_(cA2.dtype == cD2.dtype == cA1.dtype == cD1.dtype == dt_out,

"swt: " + errmsg)

# swt2

with warnings.catch_warnings():

warnings.simplefilter('ignore', FutureWarning)

x = np.ones((8, 8), dtype=dt_in)

cA, (cH, cV, cD) = pywt.swt2(x, wavelet, level=1)[0]

assert_(cA.dtype == cH.dtype == cV.dtype == cD.dtype == dt_out,

"swt2: " + errmsg)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:20,

示例8: test_swt2_axes

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_swt2_axes():

atol = 1e-14

current_wavelet = pywt.Wavelet('db2')

input_length_power = int(np.ceil(np.log2(max(

current_wavelet.dec_len,

current_wavelet.rec_len))))

input_length = 2**(input_length_power)

X = np.arange(input_length**2).reshape(input_length, input_length)

with warnings.catch_warnings():

warnings.simplefilter('ignore', FutureWarning)

(cA1, (cH1, cV1, cD1)) = pywt.swt2(X, current_wavelet, level=1)[0]

# opposite order

(cA2, (cH2, cV2, cD2)) = pywt.swt2(X, current_wavelet, level=1,

axes=(1, 0))[0]

assert_allclose(cA1, cA2, atol=atol)

assert_allclose(cH1, cV2, atol=atol)

assert_allclose(cV1, cH2, atol=atol)

assert_allclose(cD1, cD2, atol=atol)

# duplicate axes not allowed

assert_raises(ValueError, pywt.swt2, X, current_wavelet, 1,

axes=(0, 0))

# too few axes

assert_raises(ValueError, pywt.swt2, X, current_wavelet, 1, axes=(0, ))

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:26,

示例9: test_accuracy_pymatbridge

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_accuracy_pymatbridge():

rstate = np.random.RandomState(1234)

# max RMSE (was 1.0e-10, is reduced to 5.0e-5 due to different coefficents)

epsilon = 5.0e-5

epsilon_pywt_coeffs = 1.0e-10

mlab.start()

try:

for wavelet in wavelets:

w = pywt.Wavelet(wavelet)

mlab.set_variable('wavelet', wavelet)

for N in _get_data_sizes(w):

data = rstate.randn(N)

mlab.set_variable('data', data)

for pmode, mmode in modes:

ma, md = _compute_matlab_result(data, wavelet, mmode)

yield _check_accuracy, data, w, pmode, ma, md, wavelet, epsilon

ma, md = _load_matlab_result_pywt_coeffs(data, wavelet, mmode)

yield _check_accuracy, data, w, pmode, ma, md, wavelet, epsilon_pywt_coeffs

finally:

mlab.stop()

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:23,

示例10: _compute_matlab_result

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def _compute_matlab_result(data, wavelet, mmode):

""" Compute the result using MATLAB.

This function assumes that the Matlab variables `wavelet` and `data` have

already been set externally.

"""

if np.any((wavelet == np.array(['coif6', 'coif7', 'coif8', 'coif9', 'coif10', 'coif11', 'coif12', 'coif13', 'coif14', 'coif15', 'coif16', 'coif17'])),axis=0):

w = pywt.Wavelet(wavelet)

mlab.set_variable('Lo_D', w.dec_lo)

mlab.set_variable('Hi_D', w.dec_hi)

mlab_code = ("[ma, md] = dwt(data, Lo_D, Hi_D, 'mode', '%s');" % mmode)

else:

mlab_code = "[ma, md] = dwt(data, wavelet, 'mode', '%s');" % mmode

res = mlab.run_code(mlab_code)

if not res['success']:

raise RuntimeError("Matlab failed to execute the provided code. "

"Check that the wavelet toolbox is installed.")

# need np.asarray because sometimes the output is a single float64

ma = np.asarray(mlab.get_variable('ma'))

md = np.asarray(mlab.get_variable('md'))

return ma, md

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:23,

示例11: test_3D_reconstruct

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_3D_reconstruct():

data = np.array([

[[0, 4, 1, 5, 1, 4],

[0, 5, 26, 3, 2, 1],

[5, 8, 2, 33, 4, 9],

[2, 5, 19, 4, 19, 1]],

[[1, 5, 1, 2, 3, 4],

[7, 12, 6, 52, 7, 8],

[2, 12, 3, 52, 6, 8],

[5, 2, 6, 78, 12, 2]]])

wavelet = pywt.Wavelet('haar')

for mode in pywt.Modes.modes:

d = pywt.dwtn(data, wavelet, mode=mode)

assert_allclose(data, pywt.idwtn(d, wavelet, mode=mode),

rtol=1e-13, atol=1e-13)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:18,

示例12: test_stride

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_stride():

wavelet = pywt.Wavelet('haar')

for dtype in ('float32', 'float64'):

data = np.array([[0, 4, 1, 5, 1, 4],

[0, 5, 6, 3, 2, 1],

[2, 5, 19, 4, 19, 1]],

dtype=dtype)

for mode in pywt.Modes.modes:

expected = pywt.dwtn(data, wavelet)

strided = np.ones((3, 12), dtype=data.dtype)

strided[::-1, ::2] = data

strided_dwtn = pywt.dwtn(strided[::-1, ::2], wavelet)

for key in expected.keys():

assert_allclose(strided_dwtn[key], expected[key])

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:18,

示例13: test_3D_reconstruct_complex

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_3D_reconstruct_complex():

# All dimensions even length so `take` does not need to be specified

data = np.array([

[[0, 4, 1, 5, 1, 4],

[0, 5, 26, 3, 2, 1],

[5, 8, 2, 33, 4, 9],

[2, 5, 19, 4, 19, 1]],

[[1, 5, 1, 2, 3, 4],

[7, 12, 6, 52, 7, 8],

[2, 12, 3, 52, 6, 8],

[5, 2, 6, 78, 12, 2]]])

data = data + 1j

wavelet = pywt.Wavelet('haar')

d = pywt.dwtn(data, wavelet)

# idwtn creates even-length shapes (2x dwtn size)

original_shape = [slice(None, s) for s in data.shape]

assert_allclose(data, pywt.idwtn(d, wavelet)[original_shape],

rtol=1e-13, atol=1e-13)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:21,

示例14: test_idwtn_missing

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_idwtn_missing():

# Test to confirm missing data behave as zeroes

data = np.array([

[0, 4, 1, 5, 1, 4],

[0, 5, 6, 3, 2, 1],

[2, 5, 19, 4, 19, 1]])

wavelet = pywt.Wavelet('haar')

coefs = pywt.dwtn(data, wavelet)

# No point removing zero, or all

for num_missing in range(1, len(coefs)):

for missing in combinations(coefs.keys(), num_missing):

missing_coefs = coefs.copy()

for key in missing:

del missing_coefs[key]

LL = missing_coefs.get('aa', None)

HL = missing_coefs.get('da', None)

LH = missing_coefs.get('ad', None)

HH = missing_coefs.get('dd', None)

assert_allclose(pywt.idwt2((LL, (HL, LH, HH)), wavelet),

pywt.idwtn(missing_coefs, 'haar'), atol=1e-15)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:26,

示例15: test_error_on_invalid_keys

​點讚 6

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_error_on_invalid_keys():

data = np.array([

[0, 4, 1, 5, 1, 4],

[0, 5, 6, 3, 2, 1],

[2, 5, 19, 4, 19, 1]])

wavelet = pywt.Wavelet('haar')

LL, (HL, LH, HH) = pywt.dwt2(data, wavelet)

# unexpected key

d = {'aa': LL, 'da': HL, 'ad': LH, 'dd': HH, 'ff': LH}

assert_raises(ValueError, pywt.idwtn, d, wavelet)

# mismatched key lengths

d = {'a': LL, 'da': HL, 'ad': LH, 'dd': HH}

assert_raises(ValueError, pywt.idwtn, d, wavelet)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:19,

示例16: __init__

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def __init__(self,nrow=256,ncol=256,wavelet='db4',level=3,fwd_mode='recon',\

dtype=np.float64,name=None):

# Save parameters

self.wavelet = wavelet

self.level = level

shape0 = (nrow,ncol)

shape1 = (nrow,ncol)

dtype0 = dtype

dtype1 = dtype

if pywt.Wavelet(wavelet).orthogonal:

svd_avail = True #SVD calculation assumes an orthogonal wavelet

else:

svd_avail = False

BaseLinTrans.__init__(self, shape0, shape1, dtype0, dtype1,\

svd_avail=svd_avail,name=name)

# Set the mode to periodic to make the wavelet orthogonal

self.mode = 'periodization'

# Send a zero image to get the coefficient slices

im = np.zeros((nrow,ncol))

coeffs = pywt.wavedec2(im, wavelet=self.wavelet, level=self.level, \

mode=self.mode)

_, self.coeff_slices = pywt.coeffs_to_array(coeffs)

# Confirm that fwd_mode is valid

if (fwd_mode != 'recon') and (fwd_mode != 'analysis'):

raise common.VpException('fwd_mode must be recon or analysis')

self.fwd_mode = fwd_mode

開發者ID:GAMPTeam,項目名稱:vampyre,代碼行數:35,

示例17: recon

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def recon(self,z1):

"""

Wavelet reconstruction: coefficients -> image

"""

coeffs = pywt.array_to_coeffs(z1, self.coeff_slices, \

output_format='wavedec2')

z0 = pywt.waverec2(coeffs, wavelet=self.wavelet, mode=self.mode)

return z0

開發者ID:GAMPTeam,項目名稱:vampyre,代碼行數:10,

示例18: compute_wavelet_descriptor

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def compute_wavelet_descriptor(beat, family, level):

wave_family = pywt.Wavelet(family)

coeffs = pywt.wavedec(beat, wave_family, level=level)

return coeffs[0]

# Compute my descriptor based on amplitudes of several intervals

開發者ID:mondejar,項目名稱:ecg-classification,代碼行數:8,

示例19: plot_signal_decomp

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def plot_signal_decomp(data, w, title):

"""Decompose and plot a signal S.

S = An + Dn + Dn-1 + ... + D1

"""

w = pywt.Wavelet(w)

a = data

ca = []

cd = []

for i in range(5):

(a, d) = pywt.dwt(a, w, mode)

ca.append(a)

cd.append(d)

rec_a = []

rec_d = []

for i, coeff in enumerate(ca):

coeff_list = [coeff, None] + [None] * i

rec_a.append(pywt.waverec(coeff_list, w))

for i, coeff in enumerate(cd):

coeff_list = [None, coeff] + [None] * i

rec_d.append(pywt.waverec(coeff_list, w))

fig = plt.figure()

ax_main = fig.add_subplot(len(rec_a) + 1, 1, 1)

ax_main.set_title(title)

ax_main.plot(data)

ax_main.set_xlim(0, len(data) - 1)

for i, y in enumerate(rec_a):

ax = fig.add_subplot(len(rec_a) + 1, 2, 3 + i * 2)

ax.plot(y, 'r')

ax.set_xlim(0, len(y) - 1)

ax.set_ylabel("A%d" % (i + 1))

for i, y in enumerate(rec_d):

ax = fig.add_subplot(len(rec_d) + 1, 2, 4 + i * 2)

ax.plot(y, 'g')

ax.set_xlim(0, len(y) - 1)

ax.set_ylabel("D%d" % (i + 1))

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:43,

示例20: test_intwave_deprecation

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_intwave_deprecation():

wavelet = pywt.Wavelet('db3')

assert_warns(DeprecationWarning, pywt.intwave, wavelet)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:5,

示例21: test_centrfrq_deprecation

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_centrfrq_deprecation():

wavelet = pywt.Wavelet('db3')

assert_warns(DeprecationWarning, pywt.centrfrq, wavelet)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:5,

示例22: test_scal2frq_deprecation

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_scal2frq_deprecation():

wavelet = pywt.Wavelet('db3')

assert_warns(DeprecationWarning, pywt.scal2frq, wavelet, 1)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:5,

示例23: test_wavelet_properties

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_wavelet_properties():

w = pywt.Wavelet('db3')

# Name

assert_(w.name == 'db3')

assert_(w.short_family_name == 'db')

assert_(w.family_name, 'Daubechies')

# String representation

fields = ('Family name', 'Short name', 'Filters length', 'Orthogonal',

'Biorthogonal', 'Symmetry')

for field in fields:

assert_(field in str(w))

# Filter coefficients

dec_lo = [0.03522629188210, -0.08544127388224, -0.13501102001039,

0.45987750211933, 0.80689150931334, 0.33267055295096]

dec_hi = [-0.33267055295096, 0.80689150931334, -0.45987750211933,

-0.13501102001039, 0.08544127388224, 0.03522629188210]

rec_lo = [0.33267055295096, 0.80689150931334, 0.45987750211933,

-0.13501102001039, -0.08544127388224, 0.03522629188210]

rec_hi = [0.03522629188210, 0.08544127388224, -0.13501102001039,

-0.45987750211933, 0.80689150931334, -0.33267055295096]

assert_allclose(w.dec_lo, dec_lo)

assert_allclose(w.dec_hi, dec_hi)

assert_allclose(w.rec_lo, rec_lo)

assert_allclose(w.rec_hi, rec_hi)

assert_(len(w.filter_bank) == 4)

# Orthogonality

assert_(w.orthogonal)

assert_(w.biorthogonal)

# Symmetry

assert_(w.symmetry)

# Vanishing moments

assert_(w.vanishing_moments_phi == 0)

assert_(w.vanishing_moments_psi == 3)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:42,

示例24: check_coefficients_orthogonal

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def check_coefficients_orthogonal(wavelet):

epsilon = 5e-11

level = 5

w = pywt.Wavelet(wavelet)

phi, psi, x = w.wavefun(level=level)

# 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)

# Scaling function integrates to unity

res = np.sum(phi) - 2**level

msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))

assert_(res < epsilon, msg=msg)

# Wavelet function is orthogonal to the scaling function at the same scale

res = np.sum(phi*psi)

msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))

assert_(res < epsilon, msg=msg)

# The lowpass and highpass filter coefficients are orthogonal

res = np.sum(np.array(w.dec_lo)*np.array(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,代碼行數:38,

示例25: check_coefficients_biorthogonal

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def check_coefficients_biorthogonal(wavelet):

epsilon = 5e-11

level = 5

w = pywt.Wavelet(wavelet)

phi_d, psi_d, phi_r, psi_r, x = w.wavefun(level=level)

# 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)

# Scaling function integrates to unity

res = np.sum(phi_d) - 2**level

msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))

assert_(res < epsilon, msg=msg)

res = np.sum(phi_r) - 2**level

msg = ('[RMS_REC > EPSILON] for Wavelet: %s, rms=%.3g' % (wavelet, res))

assert_(res < epsilon, msg=msg)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:31,

示例26: test_wavefun_sym3

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_wavefun_sym3():

w = pywt.Wavelet('sym3')

# sym3 is an orthogonal wavelet, so 3 outputs from wavefun

phi, psi, x = w.wavefun(level=3)

assert_(phi.size == 41)

assert_(psi.size == 41)

assert_(x.size == 41)

assert_allclose(x, np.linspace(0, 5, num=x.size))

phi_expect = np.array([0.00000000e+00, 1.04132926e-01, 2.52574126e-01,

3.96525521e-01, 5.70356539e-01, 7.18934305e-01,

8.70293448e-01, 1.05363620e+00, 1.24921722e+00,

1.15296888e+00, 9.41669683e-01, 7.55875887e-01,

4.96118565e-01, 3.28293151e-01, 1.67624969e-01,

-7.33690312e-02, -3.35452855e-01, -3.31221131e-01,

-2.32061503e-01, -1.66854239e-01, -4.34091324e-02,

-2.86152390e-02, -3.63563035e-02, 2.06034491e-02,

8.30280254e-02, 7.17779073e-02, 3.85914311e-02,

1.47527100e-02, -2.31896077e-02, -1.86122172e-02,

-1.56211329e-03, -8.70615088e-04, 3.20760857e-03,

2.34142153e-03, -7.73737194e-04, -2.99879354e-04,

1.23636238e-04, 0.00000000e+00, 0.00000000e+00,

0.00000000e+00, 0.00000000e+00])

psi_expect = np.array([0.00000000e+00, 1.10265752e-02, 2.67449277e-02,

4.19878574e-02, 6.03947231e-02, 7.61275365e-02,

9.21548684e-02, 1.11568926e-01, 1.32278887e-01,

6.45829680e-02, -3.97635130e-02, -1.38929884e-01,

-2.62428322e-01, -3.62246804e-01, -4.62843343e-01,

-5.89607507e-01, -7.25363076e-01, -3.36865858e-01,

2.67715108e-01, 8.40176767e-01, 1.55574430e+00,

1.18688954e+00, 4.20276324e-01, -1.51697311e-01,

-9.42076108e-01, -7.93172332e-01, -3.26343710e-01,

-1.24552779e-01, 2.12909254e-01, 1.75770320e-01,

1.47523075e-02, 8.22192707e-03, -3.02920592e-02,

-2.21119497e-02, 7.30703025e-03, 2.83200488e-03,

-1.16759765e-03, 0.00000000e+00, 0.00000000e+00,

0.00000000e+00, 0.00000000e+00])

assert_allclose(phi, phi_expect)

assert_allclose(psi, psi_expect)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:43,

示例27: test_wavedec

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_wavedec():

x = [3, 7, 1, 1, -2, 5, 4, 6]

db1 = pywt.Wavelet('db1')

cA3, cD3, cD2, cD1 = pywt.wavedec(x, db1)

assert_almost_equal(cA3, [8.83883476])

assert_almost_equal(cD3, [-0.35355339])

assert_allclose(cD2, [4., -3.5])

assert_allclose(cD1, [-2.82842712, 0, -4.94974747, -1.41421356])

assert_(pywt.dwt_max_level(len(x), db1) == 3)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:11,

示例28: test_multilevel_dtypes_1d

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_multilevel_dtypes_1d():

# only checks that the result is of the expected type

wavelet = pywt.Wavelet('haar')

for dt_in, dt_out in zip(dtypes_in, dtypes_out):

# wavedec, waverec

x = np.ones(8, dtype=dt_in)

errmsg = "wrong dtype returned for {0} input".format(dt_in)

coeffs = pywt.wavedec(x, wavelet, level=2)

for c in coeffs:

assert_(c.dtype == dt_out, "wavedec: " + errmsg)

x_roundtrip = pywt.waverec(coeffs, wavelet)

assert_(x_roundtrip.dtype == dt_out, "waverec: " + errmsg)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:15,

示例29: test_multilevel_dtypes_2d

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_multilevel_dtypes_2d():

wavelet = pywt.Wavelet('haar')

for dt_in, dt_out in zip(dtypes_in, dtypes_out):

# wavedec2, waverec2

x = np.ones((8, 8), dtype=dt_in)

errmsg = "wrong dtype returned for {0} input".format(dt_in)

cA, coeffsD2, coeffsD1 = pywt.wavedec2(x, wavelet, level=2)

assert_(cA.dtype == dt_out, "wavedec2: " + errmsg)

for c in coeffsD1:

assert_(c.dtype == dt_out, "wavedec2: " + errmsg)

for c in coeffsD2:

assert_(c.dtype == dt_out, "wavedec2: " + errmsg)

x_roundtrip = pywt.waverec2([cA, coeffsD2, coeffsD1], wavelet)

assert_(x_roundtrip.dtype == dt_out, "waverec2: " + errmsg)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:16,

示例30: test_multilevel_dtypes_nd

​點讚 5

# 需要導入模塊: import pywt [as 別名]

# 或者: from pywt import Wavelet [as 別名]

def test_multilevel_dtypes_nd():

wavelet = pywt.Wavelet('haar')

for dt_in, dt_out in zip(dtypes_in, dtypes_out):

# wavedecn, waverecn

x = np.ones((8, 8), dtype=dt_in)

errmsg = "wrong dtype returned for {0} input".format(dt_in)

cA, coeffsD2, coeffsD1 = pywt.wavedecn(x, wavelet, level=2)

assert_(cA.dtype == dt_out, "wavedecn: " + errmsg)

for key, c in coeffsD1.items():

assert_(c.dtype == dt_out, "wavedecn: " + errmsg)

for key, c in coeffsD2.items():

assert_(c.dtype == dt_out, "wavedecn: " + errmsg)

x_roundtrip = pywt.waverecn([cA, coeffsD2, coeffsD1], wavelet)

assert_(x_roundtrip.dtype == dt_out, "waverecn: " + errmsg)

開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:16,

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

matlab wavefun怎么用,Python pywt.Wavelet方法代碼示例相关推荐

  1. python datetime datetime_Python datetime.tzinfo方法代碼示例

    本文整理匯總了Python中datetime.datetime.tzinfo方法的典型用法代碼示例.如果您正苦於以下問題:Python datetime.tzinfo方法的具體用法?Python da ...

  2. python terminator_Python turtle.Terminator方法代碼示例

    本文整理匯總了Python中turtle.Terminator方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.Terminator方法的具體用法?Python turtle. ...

  3. python execute_command err_Python management.execute_from_command_line方法代碼示例

    本文整理匯總了Python中django.core.management.execute_from_command_line方法的典型用法代碼示例.如果您正苦於以下問題:Python manageme ...

  4. python template languages_Python template.TemplateSyntaxError方法代碼示例

    本文整理匯總了Python中django.template.TemplateSyntaxError方法的典型用法代碼示例.如果您正苦於以下問題:Python template.TemplateSynt ...

  5. python里turtle.circle什么意思_Python turtle.circle方法代碼示例

    本文整理匯總了Python中turtle.circle方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.circle方法的具體用法?Python turtle.circle怎麽 ...

  6. python的from_bytes属性_Python parse.quote_from_bytes方法代碼示例

    本文整理匯總了Python中urllib.parse.quote_from_bytes方法的典型用法代碼示例.如果您正苦於以下問題:Python parse.quote_from_bytes方法的具體 ...

  7. python中startout是什么意思_Python socket.timeout方法代碼示例

    本文整理匯總了Python中gevent.socket.timeout方法的典型用法代碼示例.如果您正苦於以下問題:Python socket.timeout方法的具體用法?Python socket ...

  8. python time strptime_Python time.strptime方法代碼示例

    本文整理匯總了Python中time.strptime方法的典型用法代碼示例.如果您正苦於以下問題:Python time.strptime方法的具體用法?Python time.strptime怎麽 ...

  9. python markdown2 样式_Python markdown2.markdown方法代碼示例

    本文整理匯總了Python中markdown2.markdown方法的典型用法代碼示例.如果您正苦於以下問題:Python markdown2.markdown方法的具體用法?Python markd ...

最新文章

  1. 搞科研不如当老师香?南科大助理教授“跳槽”深圳中学当老师
  2. js new Date()不带时分秒时,时间变了 问题解决
  3. 十五个常用的 Laravel 集合(Collection)
  4. 【Android 逆向】Linux 文件分类 ( 普通文件 | 目录文件 | 链接文件 | 字符设备文件 | 管道文件 | 块设备文件 )
  5. CSS垂直翻转/水平翻转提高web页面资源重用性
  6. Android Device Monitor 文件管理的常见问题 - z
  7. Linux学习:静态库和动态库
  8. 机器学习 | 回归评估指标
  9. 图片标注尺寸_AutoCAD图纸与测量尺寸不一样怎么办
  10. 使用DBUnit集成Spring简化测试
  11. 23种设计模式(0)——概述
  12. 基于台达PLC的步进电机控制<续一>
  13. 独立游戏如何对接STEAM SDK
  14. 【python爬虫】反反爬之破解js加密--入门篇:谷歌学术镜像搜索(scmor.com)
  15. 【渝粤教育】电大中专计算机职业素养 (11)作业 题库
  16. Excel的最大行数
  17. 卸载Google Drive 硬盘-必须退出程序才能卸载
  18. 走近棒球运动·全国青年棒球锦标赛·MLB棒球创造营
  19. 打开桌面计算机投屏到扩展屏,将Win10电脑屏幕内容投屏到小米电视的操作方法...
  20. Java后端程序员未来职业规划路线,超用心整理,建议收藏

热门文章

  1. 概率论与数量统计(二)_第2章随机变量及其概率分布__贝努利试验
  2. C语言: 字符串 -2
  3. 启动远程桌面连接的方法
  4. PS污点修复画笔工具及其附属工具的用法
  5. web容器的加载过程
  6. promethesu普罗米修斯安装
  7. 用Castor处理XML文档
  8. jmeter随机参数化
  9. 【转】配置Symbian模拟器支持模拟MMC存储卡
  10. GB18030文件下载链接