1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
.. module:: mlpy.wavelet
:py:mod:`mlpy.wavelet` - Wavelet Transform
==========================================
Padding
-------
.. autofunction:: pad
Discrete Wavelet Transform
--------------------------
Discrete Wavelet Transform based on the GSL DWT [Gsldwt]_.
For the forward transform, the output is the discrete wavelet transform
:math:`f_i \rightarrow w_{j,k}` in a packed triangular storage layout, where :math:`j`
is the index of the level :math:`j = 0 \dots J-1` and :math:`k` is the index
of the coefficient within each level, :math:`k = 0 \dots (2^j)-1`.
The total number of levels is :math:`J = \log_2(n)`. The output data
has the following form,
.. math::
(s_{-1,0}, d_{0,0}, d_{1,0}, d_{1,1}, d_{2,0}, \dots, d_{j,k}, ..., d_{J-1,2^{J-1}-1})
where the first element is the smoothing coefficient :math:`s_{-1,0}`,
followed by the detail coefficients :math:`d_{j,k}` for each level :math:`j`.
The backward transform inverts these coefficients to obtain the original data.
.. note::
from GSL online manual (http://www.gnu.org/software/gsl/manual/)
.. autofunction:: dwt(x, wf, k, centered=False)
.. autofunction:: idwt(X, wf, k, centered=False)
Undecimated Wavelet Transform
-----------------------------
Undecimated Wavelet Transform (also known as stationary wavelet transform,
redundant wavelet transform, translation invariant wavelet transform,
shift invariant wavelet transform or Maximal overlap wavelet transform)
based on the "wavelets" R package.
.. autofunction:: uwt(x, wf, k, levels=0)
.. autofunction:: iuwt(X, wf, k)
.. autofunction:: uwt_align_h2
.. autofunction:: uwt_align_d4
Continuous Wavelet Transform
----------------------------
Continuous Wavelet Transform based on [Torrence98]_.
.. autofunction:: cwt
.. autofunction:: icwt
.. autofunction:: autoscales
.. autofunction:: fourier_from_scales
.. autofunction:: scales_from_fourier
.. [Torrence98] C Torrence and G P Compo. Practical Guide to Wavelet Analysis
.. [Gsldwt] Gnu Scientific Library, http://www.gnu.org/software/gsl/
Example (requires matplotlib)
.. code-block:: python
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import mlpy.wavelet as wave
>>> x = np.random.sample(512)
>>> scales = wave.autoscales(N=x.shape[0], dt=1, dj=0.25, wf='dog', p=2)
>>> X = wave.cwt(x=x, dt=1, scales=scales, wf='dog', p=2)
>>> fig = plt.figure(1)
>>> ax1 = plt.subplot(2,1,1)
>>> p1 = ax1.plot(x)
>>> ax1.autoscale_view(tight=True)
>>> ax2 = plt.subplot(2,1,2)
>>> p2 = ax2.imshow(np.abs(X), interpolation='nearest')
>>> plt.show()
.. image:: images/cwt.png
|