This function should be used in dwt() and uwt() to extend the length of data to power of two. cwt() use it as internal function.
Extend the 1D numpy array x beyond its original length.
Parameters: |
|
---|---|
Returns: |
|
Example:
>>> import numpy as np
>>> import mlpy
>>> a = np.array([1,2,3,4,5])
>>> mlpy.extend(a, method='periodic', length='powerof2')
array([1, 2, 3, 4, 5, 1, 2, 3])
New in version 2.0.6.
Discrete Wavelet Transform based on the GSL DWT [Gsldwt].
Discrete Wavelet Tranform
Parameters: |
|
---|---|
Returns: |
|
Example:
>>> import numpy as np
>>> import mlpy
>>> x = np.array([1,2,3,4,3,2,1,0])
>>> mlpy.dwt(x=x, wf='d', k=6)
array([ 5.65685425, 3.41458985, 0.29185347, -0.29185347, -0.28310081,
-0.07045258, 0.28310081, 0.07045258])
Inverse Discrete Wavelet Tranform
Parameters: |
|
---|---|
Returns: |
|
Example:
>>> import numpy as np
>>> import mlpy
>>> X = np.array([ 5.65685425, 3.41458985, 0.29185347, -0.29185347, -0.28310081,
... -0.07045258, 0.28310081, 0.07045258])
>>> mlpy.idwt(X=X, wf='d', k=6)
array([ 1.00000000e+00, 2.00000000e+00, 3.00000000e+00,
4.00000000e+00, 3.00000000e+00, 2.00000000e+00,
1.00000000e+00, -3.53954610e-09])
Undecimated Wavelet Transform based on the “wavelets” R package.
Undecimated Wavelet Tranform
Parameters: |
|
---|---|
Returns: |
|
Example:
>>> import numpy as np
>>> import mlpy
>>> x = np.array([1,2,3,4,3,2,1,0])
>>> mlpy.uwt(x=x, wf='d', k=6, levels=0)
array([[ 0.0498175 , 0.22046721, 0.2001825 , -0.47046721, -0.0498175 ,
-0.22046721, -0.2001825 , 0.47046721],
[ 0.28786838, 0.8994525 , 2.16140162, 3.23241633, 3.71213162,
3.1005475 , 1.83859838, 0.76758367]])
Inverse Undecimated Wavelet Tranform
Parameters: |
|
---|---|
Returns: |
|
Example:
>>> import numpy as np
>>> import mlpy
>>> X = np.array([[ 0.0498175 , 0.22046721, 0.2001825 , -0.47046721, -0.0498175,
... -0.22046721, -0.2001825 , 0.47046721],
... [ 0.28786838, 0.8994525 , 2.16140162, 3.23241633, 3.71213162,
... 3.1005475 , 1.83859838, 0.76758367]])
>>> mlpy.iuwt(X=X, wf='d', k=6)
array([ 1.00000000e+00, 2.00000000e+00, 3.00000000e+00,
4.00000000e+00, 3.00000000e+00, 2.00000000e+00,
1.00000000e+00, 2.29246158e-09])
New in version 2.0.2.
Continuous Wavelet Transform based on [Torrence98].
Continuous Wavelet Tranform.
Parameters: |
|
---|---|
Returns: |
|
Example:
>>> import numpy as np
>>> import mlpy
>>> x = np.array([1,2,3,4,3,2,1,0])
>>> mlpy.cwt(x=x, dt=1, dj=2, wf='dog', p=2)
(array([[ -4.66713159e-02 -6.66133815e-16j,
-3.05311332e-16 +2.77555756e-16j,
4.66713159e-02 +1.38777878e-16j,
6.94959463e-01 -8.60422844e-16j,
4.66713159e-02 +6.66133815e-16j,
3.05311332e-16 -2.77555756e-16j,
-4.66713159e-02 -1.38777878e-16j,
-6.94959463e-01 +8.60422844e-16j],
[ -2.66685280e+00 +2.44249065e-15j,
-1.77635684e-15 -4.44089210e-16j,
2.66685280e+00 -3.10862447e-15j,
3.77202823e+00 -8.88178420e-16j,
2.66685280e+00 -2.44249065e-15j,
1.77635684e-15 +4.44089210e-16j,
-2.66685280e+00 +3.10862447e-15j,
-3.77202823e+00 +8.88178420e-16j]]), array([ 0.50329212, 2.01316848]))
Inverse Continuous Wavelet Tranform.
Parameters: |
|
---|---|
Returns: |
|
Example:
>>> import numpy as np
>>> import mlpy
>>> X = np.array([[ -4.66713159e-02 -6.66133815e-16j,
... -3.05311332e-16 +2.77555756e-16j,
... 4.66713159e-02 +1.38777878e-16j,
... 6.94959463e-01 -8.60422844e-16j,
... 4.66713159e-02 +6.66133815e-16j,
... 3.05311332e-16 -2.77555756e-16j,
... -4.66713159e-02 -1.38777878e-16j,
... -6.94959463e-01 +8.60422844e-16j],
... [ -2.66685280e+00 +2.44249065e-15j,
... -1.77635684e-15 -4.44089210e-16j,
... 2.66685280e+00 -3.10862447e-15j,
... 3.77202823e+00 -8.88178420e-16j,
... 2.66685280e+00 -2.44249065e-15j,
... 1.77635684e-15 +4.44089210e-16j,
... -2.66685280e+00 +3.10862447e-15j,
... -3.77202823e+00 +8.88178420e-16j]])
>>> mlpy.icwt(X=X, dt=1, dj=2, wf='dog', p=2)
array([ -1.24078928e+00, -1.07301771e-15, 1.24078928e+00,
2.32044753e+00, 1.24078928e+00, 1.07301771e-15,
-1.24078928e+00, -2.32044753e+00])
See [Torrence98].
Compute angular frequencies.
Input
- N - [integer] number of data samples
- dt - [float] time step
Output
- angular frequencies - [1D numpy array float]
Compute scales.
Input
- N - [integer] number of data samples
- dj - [float] scale resolution
- dt - [float] time step
Output
- scales - [1D numpy array float]
Compute s0.
Input
- dt - [float] time step
- p - [float] omega0 (‘morlet’) or order (‘paul’, ‘dog’)
- wf - [string] wavelet function (‘morlet’, ‘paul’, ‘dog’)
Output
- s0 - [float]
[Torrence98] | (1, 2) C Torrence and G P Compo. Practical Guide to Wavelet Analysis |
[Gsldwt] | Gnu Scientific Library, http://www.gnu.org/software/gsl/ |