/usr/share/pyshared/mlpy/_uwt.py is in python-mlpy 2.2.0~dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | ## This file is part of mlpy.
## DWT
## This code is written by Davide Albanese, <albanese@fbk.eu>.
## (C) 2009 Fondazione Bruno Kessler - Via Santa Croce 77, 38100 Trento, ITALY.
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
import uwtcore
__all__ = ['uwt', 'iuwt']
def uwt(x, wf, k, levels=0):
"""
Undecimated Wavelet Tranform
:Parameters:
x : 1d ndarray float (the length is restricted to powers of two)
data
wf : string ('d': daubechies, 'h': haar, 'b': bspline)
wavelet type
k : integer
member of the wavelet family
* daubechies : k = 4, 6, ..., 20 with k even
* haar : the only valid choice of k is k = 2
* bspline : k = 103, 105, 202, 204, 206, 208, 301, 303, 305 307, 309
levels : integer
level of the decomposition (J).
If levels = 0 this is the value J such that the length of X
is at least as great as the length of the level J wavelet filter,
but less than the length of the level J+1 wavelet filter.
Thus, j <= log_2((n-1)/(l-1)+1), where n is the length of x.
:Returns:
X : 2d ndarray float (2J x len(x))
undecimated wavelet transformed data
Data::
[[wavelet coefficients W_1]
[wavelet coefficients W_2]
:
[wavelet coefficients W_J]
[scaling coefficients V_1]
[scaling coefficients V_2]
:
[scaling coefficients V_J]]
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]])
"""
return uwtcore.uwt(x, wf, k)
def iuwt(X, wf, k):
"""
Inverse Undecimated Wavelet Tranform
:Parameters:
X : 2d ndarray float
undecimated wavelet transformed data
wf : string ('d': daubechies, 'h': haar, 'b': bspline)
wavelet type
k : integer
member of the wavelet family
* daubechies : k = 4, 6, ..., 20 with k even
* haar : the only valid choice of k is k = 2
* bspline : k = 103, 105, 202, 204, 206, 208, 301, 303, 305 307, 309
:Returns:
x : 1d ndarray float
data
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])
"""
return uwtcore.iuwt(X, wf, k)
|