Beispiel #1
0
    def test_003_abs_integrate(self):
        print 'abs_integrate test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(
            K, cp_len, preamble, 4000)

        signal, preamble = generate_test_sync_samples(M, K, L, alpha, cp_len,
                                                      ramp_len, snr_dB,
                                                      test_cfo)
        ac = auto_correlate_signal(signal, K)
        ic = abs_integrate(np.abs(ac), cp_len)
        window_size = 1024
        kic = np.array([], dtype=np.complex)
        for i in range(0, len(signal), window_size):
            w = ac[i:i + window_size]
            kic = np.concatenate((kic, kernel.abs_integrate_preamble(w)))
        # kic = np.array(kernel.abs_integrate_preamble(ac))
        self.assertFloatTuplesAlmostEqual(ic[cp_len:], kic[cp_len:], 6)
Beispiel #2
0
    def test_004_find_auto_correlation_peak(self):
        print 'find auto correlation peak test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(
            K, cp_len, preamble, 4000)

        signal, preamble = generate_test_sync_samples(M, K, L, alpha, cp_len,
                                                      ramp_len, snr_dB,
                                                      test_cfo)
        ac = auto_correlate_signal(signal, K)
        ic = abs_integrate(np.abs(ac), cp_len)

        nm = np.argmax(ic)
        knm = kernel.find_peak_preamble(ic)
        self.assertEqual(nm, knm)

        cfo = np.angle(ac[nm]) / np.pi
        kcfo = kernel.calculate_normalized_cfo_preamble(ac[knm])
        self.assertAlmostEqual(cfo, kcfo)
Beispiel #3
0
    def test_005_remove_cfo(self):
        print 'remove CFO test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(
            K, cp_len, preamble, 4000)

        signal, preamble = generate_test_sync_samples(M, K, L, alpha, cp_len,
                                                      ramp_len, snr_dB,
                                                      test_cfo)
        ac = auto_correlate_signal(signal, K)
        ic = abs_integrate(np.abs(ac), cp_len)
        nm = np.argmax(ic)
        cfo = np.angle(ac[nm]) / np.pi

        s = correct_frequency_offset(signal, cfo / (2. * K))
        ks = kernel.remove_cfo_preamble(signal, cfo)
        self.assertComplexTuplesAlmostEqual(
            s, ks, 3)  # VOLK rotator is inaccurate. Thus, accuracy == 3
Beispiel #4
0
    def test_003_abs_integrate(self):
        print 'abs_integrate test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(K, cp_len, preamble, 4000)

        signal, preamble, pn_symbols = generate_test_sync_samples(M, K, L, alpha, cp_len, ramp_len, snr_dB, test_cfo)
        ac = auto_correlate_signal(signal, K)
        ic = abs_integrate(np.abs(ac), cp_len)
        window_size = 1024
        kic = np.array([], dtype=np.complex)
        for i in range(0, len(signal), window_size):
            w = ac[i:i + window_size]
            kic = np.concatenate((kic, kernel.abs_integrate_preamble(w)))
        # kic = np.array(kernel.abs_integrate_preamble(ac))
        self.assertFloatTuplesAlmostEqual(ic[cp_len:], kic[cp_len:], 6)
Beispiel #5
0
    def test_004_find_auto_correlation_peak(self):
        print 'find auto correlation peak test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(K, cp_len, preamble, 4000)

        signal, preamble, pn_symbols = generate_test_sync_samples(M, K, L, alpha, cp_len, ramp_len, snr_dB, test_cfo)
        ac = auto_correlate_signal(signal, K)
        ic = abs_integrate(np.abs(ac), cp_len)

        nm = np.argmax(ic)
        knm = kernel.find_peak_preamble(ic)
        self.assertEqual(nm, knm)

        cfo = np.angle(ac[nm]) / np.pi
        kcfo = kernel.calculate_normalized_cfo_preamble(ac[knm])
        self.assertAlmostEqual(cfo, kcfo)
Beispiel #6
0
    def test_001_norm_preamble(self):
        alpha = .5
        K = 32
        cp_len = K

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())

        kernel = gfdm.improved_sync_algorithm_kernel_cc(K, cp_len, preamble, 4000)
        kernel_preamble = np.array(kernel.preamble())

        # normalize preamble
        preamble /= np.sqrt(np.abs(calculate_signal_energy(preamble)))
        print 'norm_preamble energy:', calculate_signal_energy(preamble)

        self.assertComplexTuplesAlmostEqual(kernel_preamble, preamble)
Beispiel #7
0
    def test_001_norm_preamble(self):
        alpha = .5
        K = 32
        cp_len = K

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())

        kernel = gfdm.improved_sync_algorithm_kernel_cc(
            K, cp_len, preamble, 4000)
        kernel_preamble = np.array(kernel.preamble())

        # normalize preamble
        preamble /= np.sqrt(np.abs(calculate_signal_energy(preamble)))
        print 'norm_preamble energy:', calculate_signal_energy(preamble)

        self.assertComplexTuplesAlmostEqual(kernel_preamble, preamble)
Beispiel #8
0
    def test_002_auto_correlate(self):
        print 'auto correlation test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(K, cp_len, preamble, 4000)

        signal, preamble, pn_symbols = generate_test_sync_samples(M, K, L, alpha, cp_len, ramp_len, snr_dB, test_cfo)
        ac = auto_correlate_signal(signal, K)
        kac = np.array(kernel.auto_correlate_preamble(signal))
        self.assertComplexTuplesAlmostEqual(ac, kac, 6)
Beispiel #9
0
    def test_002_auto_correlate(self):
        print 'auto correlation test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(
            K, cp_len, preamble, 4000)

        signal, preamble = generate_test_sync_samples(M, K, L, alpha, cp_len,
                                                      ramp_len, snr_dB,
                                                      test_cfo)
        ac = auto_correlate_signal(signal, K)
        kac = np.array(kernel.auto_correlate_preamble(signal))
        self.assertComplexTuplesAlmostEqual(ac, kac, 6)
Beispiel #10
0
    def test_005_remove_cfo(self):
        print 'remove CFO test'
        alpha = .5
        M = 33
        K = 32
        L = 2
        cp_len = K
        ramp_len = cp_len / 2

        test_cfo = -.1
        snr_dB = 15.0

        pre_gen = gfdm.preamble_generator(K, alpha, K * 2)
        preamble = np.array(pre_gen.get_preamble())
        kernel = gfdm.improved_sync_algorithm_kernel_cc(K, cp_len, preamble, 4000)

        signal, preamble, pn_symbols = generate_test_sync_samples(M, K, L, alpha, cp_len, ramp_len, snr_dB, test_cfo)
        ac = auto_correlate_signal(signal, K)
        ic = abs_integrate(np.abs(ac), cp_len)
        nm = np.argmax(ic)
        cfo = np.angle(ac[nm]) / np.pi

        s = correct_frequency_offset(signal, cfo, 2 * K)
        ks = kernel.remove_cfo_preamble(signal, cfo)