コード例 #1
0
 def test_001_init(self):
     # check if prefixer is properly ctor'ed / dtor'ed
     prefixer = gfdm.cyclic_prefixer_cc(16 * 8, 4, 0, 4, np.arange(4 * 2))
     prefixer = gfdm.cyclic_prefixer_cc(16 * 8, 4, 0, 4, np.arange(16 * 8 + 4))
     try:
         prefixer = gfdm.cyclic_prefixer_cc(16 * 8, 4, 0, 4, np.arange(16 * 8))
         raise ValueError('invalid parameter set, but passed anyway!')
     except:
         # expected behavior!
         pass
コード例 #2
0
    def test_003_block_pinching(self):
        n_reps = 1
        n_subcarriers = 8
        n_timeslots = 8
        block_len = n_subcarriers * n_timeslots
        cp_len = 8
        ramp_len = 4
        cs_len = ramp_len * 2
        window_len = get_window_len(cp_len, n_timeslots, n_subcarriers, cs_len)
        window_taps = get_raised_cosine_ramp(ramp_len, window_len)
        data = np.arange(block_len, dtype=np.complex) + 1
        ref = add_cyclic_starfix(data, cp_len, cs_len)
        ref = pinch_block(ref, window_taps)
        data = np.tile(data, n_reps)
        ref = np.tile(ref, n_reps)
        print("input is: ", len(data), " -> " , len(ref))
        # short_window = np.concatenate((window_taps[0:ramp_len], window_taps[-ramp_len:]))
        prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, cs_len, ramp_len,
                                           window_taps)
        src = blocks.vector_source_c(data)
        dst = blocks.vector_sink_c()
        self.tb.connect(src, prefixer, dst)
        self.tb.run()

        res = np.array(dst.data())
        print(ref[-10:])
        print(res[-10:])

        self.assertComplexTuplesAlmostEqual(res, ref, 4)
コード例 #3
0
    def test_001_t(self):
        np.set_printoptions(precision=2)
        n_frames = 3
        alpha = .5
        active = 8
        M = 8
        K = 16
        L = 2
        cp_len = 8
        cs_len = 4
        ramp_len = 4
        block_len = M * K
        window_len = get_window_len(cp_len, M, K, cs_len)
        taps = get_frequency_domain_filter('rrc', alpha, M, K, L)
        taps /= np.sqrt(calculate_signal_energy(taps) / M)
        window_taps = get_raised_cosine_ramp(ramp_len, window_len)
        pn_symbols = get_random_qpsk(K)
        H_preamble = get_frequency_domain_filter('rrc', alpha, 2, K, L)
        preamble = get_sync_symbol(pn_symbols, H_preamble, K, L, cp_len,
                                   ramp_len)[0]
        smap = get_subcarrier_map(K, active, dc_free=True)

        ref = np.array([], dtype=complex)
        data = np.array([], dtype=complex)
        frame_len = window_len + len(preamble)
        frame_gap = np.zeros(frame_len)
        for i in range(n_frames):
            d = get_random_qpsk(active * M)
            dd = map_to_waveform_resources(d, active, K, smap)
            D = get_data_matrix(dd, K, group_by_subcarrier=False)
            b = gfdm_modulate_block(D, taps, M, K, L, False)
            b = add_cyclic_starfix(b, cp_len, cs_len)
            b = pinch_block(b, window_taps)
            ref = np.concatenate((ref, frame_gap, preamble, b))
            data = np.concatenate((data, d))

        src = blocks.vector_source_c(data)
        mapper = gfdm.resource_mapper_cc(active, K, M, smap, True)
        mod = gfdm.simple_modulator_cc(M, K, L, taps)
        prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, cs_len, ramp_len,
                                           window_taps)
        preambler = blocks.vector_insert_c(preamble,
                                           window_len + len(preamble), 0)
        gapper = blocks.vector_insert_c(frame_gap, frame_len + len(frame_gap),
                                        0)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, mapper, mod, prefixer, preambler, gapper, dst)
        # self.tb.connect(src, mapper, dst)
        self.tb.run()
        res = np.array(dst.data())[0:len(ref)]

        self.assertComplexTuplesAlmostEqual(ref, res, 5)
コード例 #4
0
    def test_002_simple_cp(self):
        print('simple_cp test')
        block_len = 48
        cp_len = 8
        data = np.arange(block_len, dtype=np.complex) + 1
        ref = add_cyclic_prefix(data, cp_len)

        prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, 0, 0,
                                           np.ones(block_len + cp_len))
        src = blocks.vector_source_c(data)
        dst = blocks.vector_sink_c()
        self.tb.connect(src, prefixer, dst)
        self.tb.run()
        res = np.array(dst.data())
        self.assertComplexTuplesAlmostEqual(res, ref)