예제 #1
0
    def test_002_big_data(self):
        print("big data test")
        reps = 5
        alpha = .5
        M = 127
        K = 16
        L = 4
        taps = get_frequency_domain_filter('rrc', alpha, M, K, L)
        taps /= np.sqrt(calculate_signal_energy(taps) / M)
        data = np.array([], dtype=complex)
        ref = np.array([], dtype=complex)
        for i in range(reps):
            d = get_random_qpsk(M * K)
            D = get_data_matrix(d, K, group_by_subcarrier=False)
            ref = np.append(ref, gfdm_modulate_block(D, taps, M, K, L, False))
            data = np.append(data, d)

        src = blocks.vector_source_c(data)
        mod = gfdm.simple_modulator_cc(M, K, L, taps)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, mod, dst)
        # set up fg
        self.tb.run()
        # check data
        res = np.array(dst.data())
        # res /= M * K

        self.assertComplexTuplesAlmostEqual(ref, res, 2)
예제 #2
0
    def test_001_t(self):
        alpha = .5
        M = 8
        K = 4
        L = 2
        taps = get_frequency_domain_filter('rrc', alpha, M, K, L)
        taps /= np.sqrt(calculate_signal_energy(taps) / M)
        # data = np.repeat(np.arange(1, K + 1), M)
        data = get_random_qpsk(M * K)
        D = get_data_matrix(data, K, group_by_subcarrier=False)

        src = blocks.vector_source_c(data)
        mod = gfdm.simple_modulator_cc(M, K, L, taps)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, mod, dst)
        # set up fg
        self.tb.run()
        # check data
        res = np.array(dst.data())
        # res /= M * K

        # F = gfdm_transform_subcarriers_to_fd(D, M)
        # F = gfdm_upsample_subcarriers_in_fd(F, K, L)
        # F = gfdm_filter_subcarriers_in_fd(F, taps, M, K, L)

        ref = gfdm_modulate_block(D, taps, M, K, L, False)

        self.assertComplexTuplesAlmostEqual(ref, res, 5)
예제 #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_t(self):
     n_frames = 1
     gfdm_var = struct({
         "subcarriers": 64,
         "timeslots": 9,
         "alpha": 0.5,
         "overlap": 2,
     })
     gfdm_constellation = digital.constellation_qpsk().base()
     self.f_taps = f_taps = filters.get_frequency_domain_filter(
         "rrc", 1.0, gfdm_var.timeslots, gfdm_var.subcarriers,
         gfdm_var.overlap)
     source_bits = np.random.randint(
         0,
         len(gfdm_constellation.points()),
         n_frames * gfdm_var.timeslots * gfdm_var.subcarriers,
     ).astype(np.uint8)
     self.random_bits = blocks.vector_source_b(source_bits, False)
     self.bits_to_symbols = digital.chunks_to_symbols_bc(
         (gfdm_constellation.points()), 1)
     self.mod = gfdm.simple_modulator_cc(gfdm_var.timeslots,
                                         gfdm_var.subcarriers,
                                         gfdm_var.overlap, f_taps)
     self.demod = gfdm.advanced_receiver_sb_cc(
         gfdm_var.timeslots,
         gfdm_var.subcarriers,
         gfdm_var.overlap,
         64,
         f_taps,
         gfdm_constellation,
         np.arange(gfdm_var.subcarriers),
         0,
     )
     self.tx_symbols = blocks.vector_sink_c()
     self.rx_symbols = blocks.vector_sink_c()
     self.tb.connect((self.random_bits, 0), (self.bits_to_symbols, 0))
     self.tb.connect((self.bits_to_symbols, 0), (self.tx_symbols, 0))
     self.tb.connect((self.bits_to_symbols, 0), (self.mod, 0))
     self.tb.connect((self.mod, 0), (self.demod, 0))
     self.tb.connect((self.demod, 0), (self.rx_symbols, 0))
     self.tb.run()
     ref = np.array(self.tx_symbols.data())
     res = np.array(self.rx_symbols.data())
     # more or less make sure all symbols have their correct sign.
     self.assertComplexTuplesAlmostEqual(ref, res, 2)
예제 #5
0
    def test_004_active_subcarriers(self):
        n_frames = 1
        timeslots = 9
        subcarriers = 32
        active_subcarriers = 20
        overlap = 2
        ic_iterations = 64
        f_taps = filters.get_frequency_domain_filter("rrc", 0.5, timeslots,
                                                     subcarriers, overlap)
        gfdm_constellation = digital.constellation_qpsk().base()
        print(gfdm_constellation.points())
        subcarrier_map = get_subcarrier_map(subcarriers, active_subcarriers)

        data = get_random_qpsk(n_frames * timeslots * active_subcarriers)
        data *= 2.0
        src = blocks.vector_source_c(data)
        mapper = gfdm.resource_mapper_cc(timeslots, subcarriers,
                                         active_subcarriers, subcarrier_map,
                                         True)
        mod = gfdm.simple_modulator_cc(timeslots, subcarriers, overlap, f_taps)
        demod = gfdm.advanced_receiver_sb_cc(
            timeslots,
            subcarriers,
            overlap,
            ic_iterations,
            f_taps,
            gfdm_constellation,
            subcarrier_map,
            0,
        )
        demod.set_ic(64)
        demapper = gfdm.resource_demapper_cc(timeslots, subcarriers,
                                             active_subcarriers,
                                             subcarrier_map, True)
        snk = blocks.vector_sink_c()
        self.tb.connect(src, mapper, mod, demod, demapper, snk)
        self.tb.run()

        res = np.array(snk.data())
        print(data[0:10])
        print(res[0:10])
        self.assertComplexTuplesAlmostEqual(data, res, 1)