예제 #1
0
    def test_vspht_vispht_one_added_args(self):
        """::Test vspht when only nmax is passed.
        """
        c = sp.random_coefs(100, 100, coef_type=sp.vector)
        p = sp.vispht(c)
        c2 = sp.vspht(p, 5)

        res = True
        if (sp.L2_coef(c[0:5, :] - c2) / sp.L2_coef(c[0:5, :])) > 1e-13:
            res = False

        self.assertTrue(res)
예제 #2
0
    def test_vspht_vispht_no_added_args(self):
        """::Test spht and ispht when nmax, mmax, nrows, ncols are not passed.
        """
        c = sp.random_coefs(100, 100, coef_type=sp.vector)
        p = sp.vispht(c)
        c2 = sp.vspht(p)

        res = True
        if (sp.L2_coef(c - c2) / sp.L2_coef(c)) > 1e-13:
            res = False

        self.assertTrue(res)
예제 #3
0
    def test_vspht_with_large_random(self):
        """::Generate 100 random modes and test both vspht and vispht.
        """

        c = sp.random_coefs(100, 100, coef_type=sp.vector)
        p = sp.vispht(c, 202, 202)

        c2 = sp.vspht(p, 100, 100)

        res = True
        if (sp.L2_coef(c - c2) / sp.L2_coef(c)) > 1e-13:
            res = False

        self.assertTrue(res)
예제 #4
0
def verify_vispht(pattf1, pattf2, scoeff1, scoeff2):

    vfpatt = fl.load_vpatt(pattf1, pattf2)

    fsc1 = fl.load_coef(scoeff1)
    fsc2 = fl.load_coef(scoeff2)

    vfsc = sp.VectorCoefs(fsc1._vec, fsc2._vec, fsc1.nmax, fsc1.mmax)

    vpatt = sp.vispht(vfsc, vfpatt.nrows, vfpatt.ncols)

    diff = vfpatt - vpatt

    return (sp.L2_patt(diff),
            sp.LInf_patt(diff), sp.L2_patt(diff) / sp.L2_patt(vfpatt),
            sp.LInf_patt(diff) / sp.LInf_patt(vfpatt))
예제 #5
0
    def test_vec_with_individual_coefficients_set(self):
        """::Testing vspht and vispht with single coefficients, first 5 modes.
        """
        res = True

        for n in xrange(1, 6):
            for m in xrange(-n, n + 1):
                rnd1 = np.random.normal(0, 10)
                rnd2 = np.random.normal(0, 10)
                vc = sp.zeros_coefs(15, 15, coef_type=sp.vector)
                vc[n, m] = (rnd1, rnd2)
                p = sp.vispht(vc, 50, 50)
                vc2 = sp.vspht(p, 15, 15)
                s = sp.L2_coef(vc - vc2) / sp.L2_coef(vc)

                if s > 1e-10:
                    res = False

        self.assertTrue(res)
예제 #6
0
 def test_vispht_size_error2(self):
     """::Test ispht error when ncols is too small.
     """
     c = sp.random_coefs(100, 100, coef_type=sp.vector)
     with self.assertRaises(ValueError):
         _ = sp.vispht(c, 104, 198)
예제 #7
0
FFT = 4

ctrl = SPHT

c = sp.random_coefs(Nmax, Nmax)
vc  = sp.random_coefs(Nmax, Nmax, coef_type = sp.vector)

if ctrl == ISPHT:
    profile.run('p = sp.ispht(c,Nrows,Nrows)',sort=1)

if ctrl == SPHT:
    p = sp.ispht(c, Nrows, Nrows)
    profile.run('c2 = sp.spht(p,Nmax,Nmax)',sort=1)

if ctrl == VISPHT:
    profile.run('p = sp.vispht(vc,Nrows,Nrows)',sort=1)

if ctrl == VSPHT:
    vp = sp.vispht(vc, Nrows, Nrows)
    profile.run('vc2 = sp.vspht(vp,Nmax,Nmax)',sort=1)

if ctrl == FFT:
    """Interesting, fft2 calls cfft twice"""

    data = np.ones([Nrows,Nrows],dtype = np.complex128)

    profile.run('fdata = np.fft.fft2(data) / (Nrows * Nrows)',sort=1)