示例#1
0
    def __init__(self,
                 order = 20,
                 size  = 1024):
        self.size = size
        self.half = A.nblock2(size)
        self.wlen = self.half*2

        self.wvlt_i = wvlt.daubechies(order)
        self.wwrk_i = wvlt.workspace(self.wlen)
        self.tail_i = N.zeros(self.half)

        self.wvlt_q = wvlt.daubechies(order)
        self.wwrk_q = wvlt.workspace(self.wlen)
        self.tail_q = N.zeros(self.half)
示例#2
0
def transform(data):
    w = wavelet.daubechies(4)
    # If no workspace is given, the wrapper will allocate one itself for the
    # transform. I am not sure how much of an performance impact that is.    
    result = w.transform_forward(data);

    # If you perfer you could have the workspace and the transform stored
    # somewhere, and then perhaps your code is faster
    # work = wavelet.wavelet_workspace(n)
    # result = w.transform_forward(data, work)
    return result
示例#3
0
def run(array):
    # Initalise the wavelet and the workspace
    w = wavelet.daubechies(4)
    ws = wavelet.workspace(len(array))
    
    # Transform forward
    result = w.transform_forward(array, ws)

    # Select the largest 20 coefficients
    abscoeff = numx.absolute(result)
    indices  = numx.argsort(abscoeff) # ascending order

    tmp = numx.zeros(result.shape, numx.float_)
    for i in indices[-20:]:
        tmp[i] = result[i] # Set all others to zero

    # And back
    result2 = w.transform_inverse(tmp, ws)