Beispiel #1
0
    def test_coif(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        for N in np.arange(1,6):
            wname = "coif" + str(N)
            [cA,cD] = pyyawt.dwt(x1,wname)
            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)
Beispiel #2
0
    def test_type2(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "bior3.9"
        [cA,cD] = pyyawt.dwt(x1,wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x2,wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(s1,wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)
Beispiel #3
0
    def test_coif(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        for N in np.arange(1, 6):
            wname = "coif" + str(N)
            [cA, cD] = pyyawt.dwt(x1, wname)
            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)
Beispiel #4
0
    def test_type2(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "bior3.9"
        [cA, cD] = pyyawt.dwt(x1, wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x2, wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(s1, wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)
Beispiel #5
0
    def test_haar(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = 'haar'
        [cA, cD] = pyyawt.dwt(x1, wname)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, wname)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x1, wname)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, wname)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x1, wname)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, wname)
        np.testing.assert_almost_equal(r, x0)
Beispiel #6
0
    def test_bior(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wnames = [
            'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
            'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
            'bior4.4', 'bior5.5', 'bior6.8'
        ]
        for N in np.arange(1, 13):
            wname = wnames[N]
            [cA, cD] = pyyawt.dwt(x1, wname)
            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)
Beispiel #7
0
    def test_haar(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = 'haar'
        [cA,cD] = pyyawt.dwt(x1,wname)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,wname)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x1,wname)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,wname)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x1,wname)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,wname)
        np.testing.assert_almost_equal(r, x0)
Beispiel #8
0
    def test_bior(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wnames = ['bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
                  'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
                  'bior4.4', 'bior5.5', 'bior6.8']
        for N in np.arange(1,13):
            wname = wnames[N]
            [cA,cD] = pyyawt.dwt(x1,wname)
            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)
Beispiel #9
0
 def test_haar(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     [c, l] = pyyawt.wavedec(s1, 3, 'haar')
     [cA1, cD1] = pyyawt.dwt(s1, 'haar')
     [cA2, cD2] = pyyawt.dwt(cA1, 'haar')
     [cA3, cD3] = pyyawt.dwt(cA2, 'haar')
     ca2 = pyyawt.idwt(cA3, cD3, 'haar', np.size(cA2))
     ca1 = pyyawt.idwt(ca2, cD2, 'haar', np.size(cA1))
     a0 = pyyawt.idwt(ca1, cD1, 'haar', np.size(s1))
     s0 = pyyawt.waverec(c, l, 'haar')
     np.testing.assert_almost_equal(a0, s0)
Beispiel #10
0
 def test_haar(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     [c,l] = pyyawt.wavedec(s1,3,'haar')
     [cA1,cD1] = pyyawt.dwt(s1,'haar')
     [cA2,cD2] = pyyawt.dwt(cA1,'haar')
     [cA3,cD3] = pyyawt.dwt(cA2,'haar')
     ca2 = pyyawt.idwt(cA3,cD3,'haar',np.size(cA2))
     ca1 = pyyawt.idwt(ca2,cD2,'haar',np.size(cA1))
     a0 = pyyawt.idwt(ca1,cD1,'haar',np.size(s1))
     s0 = pyyawt.waverec(c,l,'haar')
     np.testing.assert_almost_equal(a0, s0)
Beispiel #11
0
 def test_sym(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     for N in np.arange(2,21):
         wname = "sym" + str(N)
         [c,l] = pyyawt.wavedec(s1,3,wname)
         [cA1,cD1] = pyyawt.dwt(s1,wname)
         [cA2,cD2] = pyyawt.dwt(cA1,wname)
         [cA3,cD3] = pyyawt.dwt(cA2,wname)
         ca2 = pyyawt.idwt(cA3,cD3,wname,np.size(cA2))
         ca1 = pyyawt.idwt(ca2,cD2,wname,np.size(cA1))
         a0 = pyyawt.idwt(ca1,cD1,wname,np.size(s1))
         s0 = pyyawt.waverec(c,l,wname)
         np.testing.assert_almost_equal(a0, s0)
Beispiel #12
0
 def test_sym(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     for N in np.arange(2, 21):
         wname = "sym" + str(N)
         [c, l] = pyyawt.wavedec(s1, 3, wname)
         [cA1, cD1] = pyyawt.dwt(s1, wname)
         [cA2, cD2] = pyyawt.dwt(cA1, wname)
         [cA3, cD3] = pyyawt.dwt(cA2, wname)
         ca2 = pyyawt.idwt(cA3, cD3, wname, np.size(cA2))
         ca1 = pyyawt.idwt(ca2, cD2, wname, np.size(cA1))
         a0 = pyyawt.idwt(ca1, cD1, wname, np.size(s1))
         s0 = pyyawt.waverec(c, l, wname)
         np.testing.assert_almost_equal(a0, s0)
def check_reconstruction(pmode, wavelet, dtype, epsilon=None):
    data_size = [500, 1000, 2000, 10000, 50000, 100000]
    np.random.seed(12345)
    # TODO: smoke testing - more failures for different seeds
    if epsilon is None:
        if dtype == np.float32:
            epsilon = 3e-7
        else:
            # FIXME: limit was 5e-11, but gave failures.  Investigate
            epsilon = 5e-11

    for N in data_size:
        data = np.asarray(np.random.random(N), dtype)

        # compute dwt coefficients
        pa, pd = pyyawt.dwt(data, wavelet, 'mode', pmode)

        # compute reconstruction
        rec = pyyawt.idwt(pa, pd, wavelet,'mode', pmode)

        if len(data) % 2:
            rec = rec[:len(data)]

        rms_rec = np.sqrt(np.mean((data-rec)**2))
        msg = ('[RMS_REC > EPSILON] for Mode: %s, Wavelet: %s, '
               'Length: %d, rms=%.3g' % (pmode, wavelet, len(data), rms_rec))
        np.testing.assert_equal(rms_rec < epsilon,True, err_msg=msg)
Beispiel #14
0
 def test_bior(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wnames = ['bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
               'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
               'bior4.4', 'bior5.5', 'bior6.8']
     for N in np.arange(len(wnames)):
         wname = wnames[N]
         [c,l] = pyyawt.wavedec(s1,3,wname)
         [cA1,cD1] = pyyawt.dwt(s1,wname)
         [cA2,cD2] = pyyawt.dwt(cA1,wname)
         [cA3,cD3] = pyyawt.dwt(cA2,wname)
         ca2 = pyyawt.idwt(cA3,cD3,wname,np.size(cA2))
         ca1 = pyyawt.idwt(ca2,cD2,wname,np.size(cA1))
         a0 = pyyawt.idwt(ca1,cD1,wname,np.size(s1))
         s0 = pyyawt.waverec(c,l,wname)
         np.testing.assert_almost_equal(a0, s0)
Beispiel #15
0
 def test_type5(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = ['symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1',
                 'ppd','per']
     [cA,cD] = pyyawt.dwt(x1,wname)
     [Lo_R,Hi_R] = pyyawt.wfilters(wname,'r')
     a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
     d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
     x0 = pyyawt.wkeep(a0+d0,50)
     for N in np.arange(len(dwtModes)-1):
         r = pyyawt.idwt(cA,cD,wname,50,'mode',dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA,cD,wname,50,'mode','per')
     x0 = pyyawt.wkeep(a0+d0,50)
     np.testing.assert_almost_equal(r, x0)
Beispiel #16
0
 def test_type5(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = [
         'symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1', 'ppd', 'per'
     ]
     [cA, cD] = pyyawt.dwt(x1, wname)
     [Lo_R, Hi_R] = pyyawt.wfilters(wname, 'r')
     a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
     d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
     x0 = pyyawt.wkeep(a0 + d0, 50)
     for N in np.arange(len(dwtModes) - 1):
         r = pyyawt.idwt(cA, cD, wname, 50, 'mode', dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA, cD, wname, 50, 'mode', 'per')
     x0 = pyyawt.wkeep(a0 + d0, 50)
     np.testing.assert_almost_equal(r, x0)
Beispiel #17
0
 def test_type6(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = ['symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1',
                 'ppd','per']
     [cA,cD] = pyyawt.dwt(x1,wname)
     Lo_R = np.random.rand(14)
     Hi_R = np.random.rand(14)
     a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R.flatten())
     d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R.flatten())
     x0 = pyyawt.wkeep(a0+d0,50)
     for N in np.arange(len(dwtModes)-1):
         r = pyyawt.idwt(cA,cD,Lo_R,Hi_R,50,'mode',dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA,cD,Lo_R,Hi_R,50,'mode','per')
     x0 = pyyawt.wkeep(a0+d0,50)
     np.testing.assert_almost_equal(r, x0)
Beispiel #18
0
 def test_bior(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wnames = [
         'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
         'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
         'bior4.4', 'bior5.5', 'bior6.8'
     ]
     for N in np.arange(len(wnames)):
         wname = wnames[N]
         [c, l] = pyyawt.wavedec(s1, 3, wname)
         [cA1, cD1] = pyyawt.dwt(s1, wname)
         [cA2, cD2] = pyyawt.dwt(cA1, wname)
         [cA3, cD3] = pyyawt.dwt(cA2, wname)
         ca2 = pyyawt.idwt(cA3, cD3, wname, np.size(cA2))
         ca1 = pyyawt.idwt(ca2, cD2, wname, np.size(cA1))
         a0 = pyyawt.idwt(ca1, cD1, wname, np.size(s1))
         s0 = pyyawt.waverec(c, l, wname)
         np.testing.assert_almost_equal(a0, s0)
Beispiel #19
0
 def test_type6(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = [
         'symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1', 'ppd', 'per'
     ]
     [cA, cD] = pyyawt.dwt(x1, wname)
     Lo_R = np.random.rand(14)
     Hi_R = np.random.rand(14)
     a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R.flatten())
     d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R.flatten())
     x0 = pyyawt.wkeep(a0 + d0, 50)
     for N in np.arange(len(dwtModes) - 1):
         r = pyyawt.idwt(cA, cD, Lo_R, Hi_R, 50, 'mode', dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA, cD, Lo_R, Hi_R, 50, 'mode', 'per')
     x0 = pyyawt.wkeep(a0 + d0, 50)
     np.testing.assert_almost_equal(r, x0)
Beispiel #20
0
    def test_bior2(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        ST = pyyawt.dwtmode("status", "nodisp")
        wnames = [
            'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
            'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
            'bior4.4', 'bior5.5', 'bior6.8'
        ]
        for N in np.arange(len(wnames)):
            wname = wnames[N]
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            [c, l] = pyyawt.wavedec(s1, 3, wname)
            s0 = pyyawt.waverec(c, l, wname)
            [cA1, cD1] = pyyawt.dwt(s1, wname)
            [cA2, cD2] = pyyawt.dwt(cA1, wname)
            [cA3, cD3] = pyyawt.dwt(cA2, wname)
            ca2 = pyyawt.idwt(cA3, cD3, wname, np.size(cA2))
            ca1 = pyyawt.idwt(ca2, cD2, wname, np.size(cA1))
            a0 = pyyawt.idwt(ca1, cD1, wname, np.size(s1))
            np.testing.assert_almost_equal(a0, s0)

            Lo_D = np.random.randn(np.size(Lo_D))
            Hi_D = np.random.randn(np.size(Lo_D))
            ca2 = pyyawt.idwt(cA3, cD3, Lo_R, Hi_R, np.size(cA2))
            ca1 = pyyawt.idwt(ca2, cD2, Lo_R, Hi_R, np.size(cA1))
            a0 = pyyawt.idwt(ca1, cD1, Lo_R, Hi_R, np.size(s1))
            s0 = pyyawt.waverec(c, l, Lo_R, Hi_R)
            np.testing.assert_almost_equal(a0, s0)
Beispiel #21
0
    def test_bior2(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        ST = pyyawt.dwtmode("status","nodisp")
        wnames = ['bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
                  'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
                  'bior4.4', 'bior5.5', 'bior6.8']
        for N in np.arange(len(wnames)):
            wname = wnames[N]
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            [c,l] = pyyawt.wavedec(s1,3,wname)
            s0 = pyyawt.waverec(c,l,wname)
            [cA1,cD1] = pyyawt.dwt(s1,wname)
            [cA2,cD2] = pyyawt.dwt(cA1,wname)
            [cA3,cD3] = pyyawt.dwt(cA2,wname)
            ca2 = pyyawt.idwt(cA3,cD3,wname,np.size(cA2))
            ca1 = pyyawt.idwt(ca2,cD2,wname,np.size(cA1))
            a0 = pyyawt.idwt(ca1,cD1,wname,np.size(s1))
            np.testing.assert_almost_equal(a0, s0)

            Lo_D = np.random.randn(np.size(Lo_D))
            Hi_D = np.random.randn(np.size(Lo_D))
            ca2 = pyyawt.idwt(cA3,cD3,Lo_R,Hi_R,np.size(cA2))
            ca1 = pyyawt.idwt(ca2,cD2,Lo_R,Hi_R,np.size(cA1))
            a0 = pyyawt.idwt(ca1,cD1,Lo_R,Hi_R,np.size(s1))
            s0 = pyyawt.waverec(c,l,Lo_R,Hi_R)
            np.testing.assert_almost_equal(a0, s0)
Beispiel #22
0
    def test_type3(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "sym8"
        [cA, cD] = pyyawt.dwt(x1, wname)
        r = pyyawt.idwt(cA, cD, wname, 50)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x2, wname)
        r = pyyawt.idwt(cA, cD, wname, 50)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(s1, wname)
        r = pyyawt.idwt(cA, cD, wname, 50)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        np.testing.assert_almost_equal(r, x0)

        Lo_R = np.random.randn(50)
        Hi_R = np.random.randn(50)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten(), 50)
        np.testing.assert_almost_equal(r, x0)
Beispiel #23
0
    def test_type3(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "sym8"
        [cA,cD] = pyyawt.dwt(x1,wname)
        r = pyyawt.idwt(cA,cD,wname,50)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x2,wname)
        r = pyyawt.idwt(cA,cD,wname,50)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(s1,wname)
        r = pyyawt.idwt(cA,cD,wname,50)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        np.testing.assert_almost_equal(r, x0)

        Lo_R = np.random.randn(50)
        Hi_R = np.random.randn(50)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten(),50)
        np.testing.assert_almost_equal(r, x0)