示例#1
0
    def test_005_python_gen(self):
        # check results against Python implementation
        print "\n\n\n\nlegacy"
        multiple = 10
        overlap = 4
        L = 4
        self.cfg = fbmc.fbmc_config(num_used_subcarriers=20,
                                    num_payload_sym=16,
                                    num_overlap_sym=overlap,
                                    modulation="QPSK",
                                    preamble="IAM")
        L = self.cfg.num_total_subcarriers()
        taps = np.array(self.cfg.prototype_taps_float(), dtype=np.float)
        print "config: overlap =  ", overlap, ", L = ", L

        # generate data and set it for source.
        d = np.arange(1, multiple * L // 2 + 1 + 1, dtype=np.complex)
        self.src = blocks.vector_source_c(d, vlen=1)
        self.smt = fbmc.rx_polyphase_cvc(taps, L)
        self.snk0 = blocks.vector_sink_c(vlen=L)
        self.tb.connect(self.src, self.smt, self.snk0)
        self.tb.run()

        # same way to generate data in python as in every test!
        ref = ft.rx(d[:-L // 2], taps, L)

        res0 = self.snk0.data()
        resultMatrix = np.array(res0).reshape((-1, L)).T
        print resultMatrix[:, 0:5]
        print np.shape(resultMatrix[:, 0:5])
        print L * resultMatrix[0]
        print "ref", ref[0]
示例#2
0
    def test_005_python_gen(self):
        # check results against Python implementation
        print "\n\n\n\nlegacy"
        multiple = 10
        overlap = 4
        L = 4
        self.cfg = fbmc.fbmc_config(num_used_subcarriers=20, num_payload_sym=16, num_overlap_sym=overlap,
                                    modulation="QPSK", preamble="IAM")
        L = self.cfg.num_total_subcarriers()
        taps = np.array(self.cfg.prototype_taps_float(), dtype=np.float)
        print "config: overlap =  ", overlap, ", L = ", L

        # generate data and set it for source.
        d = np.arange(1, multiple * L // 2 + 1 + 1, dtype=np.complex)
        self.src = blocks.vector_source_c(d, vlen=1)
        self.smt = fbmc.rx_polyphase_cvc(taps, L)
        self.snk0 = blocks.vector_sink_c(vlen=L)
        self.tb.connect(self.src, self.smt, self.snk0)
        self.tb.run()

        # same way to generate data in python as in every test!
        ref = ft.rx(d[: -L // 2], taps, L)

        res0 = self.snk0.data()
        resultMatrix = np.array(res0).reshape((-1, L)).T
        print resultMatrix[:, 0:5]
        print np.shape(resultMatrix[:, 0:5])
        print L * resultMatrix[0]
        print "ref", ref[0]
 def test_001_t(self):  # very basic test
     self.cfg = fbmc.fbmc_config(num_used_subcarriers=8,
                                 num_payload_sym=18,
                                 num_overlap_sym=4,
                                 modulation="QPSK",
                                 preamble="IAM")
     num_items = 3
     self.src = blocks.vector_source_c(
         [
             complex(i, i)
             for i in range(1,
                            self.cfg.num_total_subcarriers() + 1)
         ],
         vlen=self.cfg.num_total_subcarriers(),
         repeat=True)
     self.head = blocks.head(
         gr.sizeof_gr_complex * self.cfg.num_total_subcarriers(), num_items)
     self.ppfb = fbmc.polyphase_filterbank_vcvc(
         L=self.cfg.num_total_subcarriers(),
         prototype_taps=self.cfg.prototype_taps())
     self.snk = blocks.vector_sink_c(vlen=self.cfg.num_total_subcarriers())
     self.tb.connect(self.src, self.head, self.ppfb, self.snk)
     self.tb.run()
     # check data
     data = self.snk.data()
     self.assertEqual(len(data),
                      self.cfg.num_total_subcarriers() * num_items)
示例#4
0
 def setUp(self):
     self.tb = gr.top_block()
     self.cfg = fbmc.fbmc_config(num_used_subcarriers=8,
                                 num_payload_sym=2,
                                 num_overlap_sym=4,
                                 modulation="QPSK",
                                 preamble="IAM")
 def test_001_t (self): # very basic test
     self.cfg = fbmc.fbmc_config(num_used_subcarriers=8, num_payload_sym=18, num_overlap_sym=4, modulation="QPSK", preamble="IAM")
 	num_items = 3;
 	self.src = blocks.vector_source_c([complex(i,i) for i in range(1,self.cfg.num_total_subcarriers()+1)], vlen=self.cfg.num_total_subcarriers(), repeat=True)
 	self.head = blocks.head(gr.sizeof_gr_complex*self.cfg.num_total_subcarriers(),num_items)
 	self.ppfb = fbmc.polyphase_filterbank_vcvc(L=self.cfg.num_total_subcarriers(), prototype_taps=self.cfg.prototype_taps())
 	self.snk = blocks.vector_sink_c(vlen=self.cfg.num_total_subcarriers())
 	self.tb.connect(self.src, self.head, self.ppfb, self.snk)
     self.tb.run ()
     # check data
     data = self.snk.data()
     self.assertEqual(len(data), self.cfg.num_total_subcarriers()*num_items)
示例#6
0
    def test_004_config_frame_mod(self):
        num_frames = 10
        cfg = fbmc.fbmc_config(num_used_subcarriers=20, num_payload_sym=16, num_overlap_sym=4, modulation="QPSK",
                                    preamble="IAM", samp_rate=250000)
        total_subcarriers = cfg.num_total_subcarriers()  # 8
        used_subcarriers = cfg.num_used_subcarriers()  # 4
        channel_map = cfg.channel_map()  # ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = cfg.num_payload_sym()  # 8
        overlap = cfg.num_overlap_sym()  # 4
        taps = cfg.phydyas_impulse_taps(cfg.num_total_subcarriers(), cfg.num_overlap_sym())  # ft.generate_phydyas_filter(total_subcarriers, overlap)

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()

        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers, payload_symbols, overlap, channel_map, preamble)
        snk_frame = blocks.vector_sink_c(total_subcarriers)  # a debug output

        mod = fbmc.tx_sdft_vcc(taps, total_subcarriers)
        demod = fbmc.rx_sdft_cvc(taps, total_subcarriers)
        skipper = blocks.skiphead(8 * total_subcarriers, 4)

        snk_rx = blocks.vector_sink_c(total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers, num_preamble_symbols, payload_symbols, overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, mod, demod, skipper, deframer, snk)
        self.tb.connect(framer, snk_frame)
        self.tb.connect(skipper, snk_rx)
        self.tb.run()

        res = np.array(snk.data())
        print res
        print payload

        moddata = np.array(snk_frame.data())
        print "len(moddata) = ", len(moddata)
        rxdata = np.array(snk_rx.data())
        print "len(rxdata) = ", len(rxdata)

        # plt.plot(rxdata.real * 0.03)
        # for i in range(len(moddata)):
        #     if (i + 1) % total_subcarriers == 0:
        #         plt.axvline(i)
        # plt.plot(moddata.real)
        # plt.grid()
        # plt.show()

        print "len(payload) = ", len(payload)
        print "len(result)  = ", len(res)

        self.assertTupleEqual(tuple(payload[:len(res)]), tuple(res))
 def test_002_t (self): # again, just checking the length of the output
     self.cfg = fbmc.fbmc_config(num_used_subcarriers=64, num_payload_sym=18, num_overlap_sym=4, modulation="QPSK", preamble="IAM")
 	num_items = 10000
 	n = self.cfg.num_used_subcarriers()*num_items
 	input_data = range(n)
 	self.src = blocks.vector_source_c(input_data, vlen=self.cfg.num_total_subcarriers(), repeat=False)
 	self.ppfb = fbmc.polyphase_filterbank_vcvc(L=self.cfg.num_total_subcarriers(), prototype_taps=self.cfg.prototype_taps())
 	self.snk = blocks.vector_sink_c(vlen=self.cfg.num_total_subcarriers())
 	self.tb.connect(self.src, self.ppfb, self.snk)
     self.tb.run ()
     # check data
     data = self.snk.data()
     self.assertEqual(len(data), n)       
示例#8
0
    def test_004_legacy_big(self):
        np.set_printoptions(linewidth=150, precision=4)
        multiple = 4
        overlap = 4
        self.cfg = fbmc.fbmc_config(num_used_subcarriers=20,
                                    num_payload_sym=16,
                                    num_overlap_sym=overlap,
                                    modulation="QPSK",
                                    preamble="IAM")
        L = self.cfg.num_total_subcarriers()
        taps = np.array(self.cfg.prototype_taps_float(), dtype=np.float)

        # test data!
        d = np.arange(1, multiple * L // 2 + 1 + 1, dtype=np.complex)

        # initialize fg
        smt = fbmc.rx_polyphase_cvc(taps, L)
        self.src = blocks.vector_source_c(d, vlen=1)
        self.snk = blocks.vector_sink_c(vlen=L)

        # old chain
        self.com = fbmc.input_commutator_cvc(L)
        self.pfb = fbmc.polyphase_filterbank_vcvc(L, taps)
        self.fft = fft.fft_vcc(L, False, (), False, 1)
        self.snkold = blocks.vector_sink_c(vlen=L)
        self.tb.connect(self.src, self.com, self.pfb, self.fft, self.snkold)
        self.tb.connect(self.src, smt, self.snk)
        self.tb.run()

        # check data
        res = self.snk.data()
        resmatrix = np.array(res).reshape((-1, L)).T
        old = self.snkold.data()
        oldmatrix = np.array(old).reshape((-1, L)).T

        print np.array(smt.filterbank_taps())
        print "\nresult"
        print resmatrix
        print "\nold fg"
        print oldmatrix

        self.assertComplexTuplesAlmostEqual(oldmatrix.flatten(),
                                            resmatrix.flatten())
 def test_002_t(self):  # again, just checking the length of the output
     self.cfg = fbmc.fbmc_config(num_used_subcarriers=64,
                                 num_payload_sym=18,
                                 num_overlap_sym=4,
                                 modulation="QPSK",
                                 preamble="IAM")
     num_items = 10000
     n = self.cfg.num_used_subcarriers() * num_items
     input_data = range(n)
     self.src = blocks.vector_source_c(
         input_data, vlen=self.cfg.num_total_subcarriers(), repeat=False)
     self.ppfb = fbmc.polyphase_filterbank_vcvc(
         L=self.cfg.num_total_subcarriers(),
         prototype_taps=self.cfg.prototype_taps())
     self.snk = blocks.vector_sink_c(vlen=self.cfg.num_total_subcarriers())
     self.tb.connect(self.src, self.ppfb, self.snk)
     self.tb.run()
     # check data
     data = self.snk.data()
     self.assertEqual(len(data), n)
示例#10
0
    def test_003_go_big(self):
        print "\n\n\ntest_003"
        multiple = 2000
        overlap = 4

        # get test data, taps, config, etc.
        self.cfg = fbmc.fbmc_config(num_used_subcarriers=20,
                                    num_payload_sym=16,
                                    num_overlap_sym=overlap,
                                    modulation="QPSK",
                                    preamble="IAM")
        L = self.cfg.num_total_subcarriers()
        taps = np.array(self.cfg.prototype_taps_float(), dtype=np.float)
        taps[-1] = 0

        data = np.arange(1, L + 1, dtype=np.complex)
        data = np.repeat(data, multiple)

        # set up fg
        tx_sdft = fbmc.tx_sdft_vcc(taps, L)
        src = blocks.vector_source_c(data, vlen=L)
        snk0 = blocks.vector_sink_c(vlen=1)
        self.tb.connect(src, tx_sdft, snk0)

        ft = fft.fft_vcc(L, False, (), False, 1)
        pfb = fbmc.polyphase_filterbank_vcvc(L, taps)
        comm = fbmc.output_commutator_vcc(L=L)
        snk1 = blocks.vector_sink_c(vlen=1)
        self.tb.connect(src, ft, pfb, comm, snk1)

        self.tb.run()
        r0 = np.array(snk0.data()[L:])
        r1 = np.array(snk1.data()[:-L])

        print "\ntx_sdft"
        print r0.reshape((-1, L)).T

        print "\npolyphase"
        print r1.reshape((-1, L)).T

        self.assertComplexTuplesAlmostEqual(r0, r1, 4)
示例#11
0
    def test_004_legacy_big(self):
        np.set_printoptions(linewidth=150, precision=4)
        multiple = 4
        overlap = 4
        self.cfg = fbmc.fbmc_config(num_used_subcarriers=20, num_payload_sym=16, num_overlap_sym=overlap,
                                    modulation="QPSK", preamble="IAM")
        L = self.cfg.num_total_subcarriers()
        taps = np.array(self.cfg.prototype_taps_float(), dtype=np.float)

        # test data!
        d = np.arange(1, multiple * L // 2 + 1 + 1, dtype=np.complex)

        # initialize fg
        smt = fbmc.rx_polyphase_cvc(taps, L)
        self.src = blocks.vector_source_c(d, vlen=1)
        self.snk = blocks.vector_sink_c(vlen=L)

        # old chain
        self.com = fbmc.input_commutator_cvc(L)
        self.pfb = fbmc.polyphase_filterbank_vcvc(L, taps)
        self.fft = fft.fft_vcc(L, False, (), False, 1)
        self.snkold = blocks.vector_sink_c(vlen=L)
        self.tb.connect(self.src, self.com, self.pfb, self.fft, self.snkold)
        self.tb.connect(self.src, smt, self.snk)
        self.tb.run()

        # check data
        res = self.snk.data()
        resmatrix = np.array(res).reshape((-1, L)).T
        old = self.snkold.data()
        oldmatrix = np.array(old).reshape((-1, L)).T

        print np.array(smt.filterbank_taps())
        print "\nresult"
        print resmatrix
        print "\nold fg"
        print oldmatrix

        self.assertComplexTuplesAlmostEqual(oldmatrix.flatten(), resmatrix.flatten())
示例#12
0
    def test_003_go_big(self):
        print "\n\n\ntest_003"
        multiple = 2000
        overlap = 4

        # get test data, taps, config, etc.
        self.cfg = fbmc.fbmc_config(num_used_subcarriers=20, num_payload_sym=16, num_overlap_sym=overlap,
                                    modulation="QPSK", preamble="IAM")
        L = self.cfg.num_total_subcarriers()
        taps = np.array(self.cfg.prototype_taps_float(), dtype=np.float)
        taps[-1] = 0

        data = np.arange(1, L + 1, dtype=np.complex)
        data = np.repeat(data, multiple)

        # set up fg
        tx_sdft = fbmc.tx_sdft_vcc(taps, L)
        src = blocks.vector_source_c(data, vlen=L)
        snk0 = blocks.vector_sink_c(vlen=1)
        self.tb.connect(src, tx_sdft, snk0)

        ft = fft.fft_vcc(L, False, (), False, 1)
        pfb = fbmc.polyphase_filterbank_vcvc(L, taps)
        comm = fbmc.output_commutator_vcc(L=L)
        snk1 = blocks.vector_sink_c(vlen=1)
        self.tb.connect(src, ft, pfb, comm, snk1)

        self.tb.run()
        r0 = np.array(snk0.data()[L:])
        r1 = np.array(snk1.data()[:-L])

        print "\ntx_sdft"
        print r0.reshape((-1, L)).T

        print "\npolyphase"
        print r1.reshape((-1, L)).T

        self.assertComplexTuplesAlmostEqual(r0, r1, 4)
示例#13
0
 def setUp (self):
 	self.cfg = fbmc.fbmc_config(num_used_subcarriers=8, num_payload_sym=18, num_overlap_sym=4, modulation="QPSK", preamble="IAM")
     self.tb = gr.top_block ()
     self.cfo = fbmc.coarse_cfo_correction(self.cfg.channel_map())
示例#14
0
    def test_004_config_frame_mod(self):
        num_frames = 10
        cfg = fbmc.fbmc_config(num_used_subcarriers=20,
                               num_payload_sym=16,
                               num_overlap_sym=4,
                               modulation="QPSK",
                               preamble="IAM",
                               samp_rate=250000)
        total_subcarriers = cfg.num_total_subcarriers()  # 8
        used_subcarriers = cfg.num_used_subcarriers()  # 4
        channel_map = cfg.channel_map(
        )  # ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = cfg.num_payload_sym()  # 8
        overlap = cfg.num_overlap_sym()  # 4
        taps = cfg.phydyas_impulse_taps(
            cfg.num_total_subcarriers(), cfg.num_overlap_sym(
            ))  # ft.generate_phydyas_filter(total_subcarriers, overlap)

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()

        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers,
                                          payload_symbols, overlap,
                                          channel_map, preamble)
        snk_frame = blocks.vector_sink_c(total_subcarriers)  # a debug output

        mod = fbmc.tx_sdft_vcc(taps, total_subcarriers)
        demod = fbmc.rx_sdft_cvc(taps, total_subcarriers)
        skipper = blocks.skiphead(8 * total_subcarriers, 4)

        snk_rx = blocks.vector_sink_c(total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers,
                                     num_preamble_symbols, payload_symbols,
                                     overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, mod, demod, skipper, deframer, snk)
        self.tb.connect(framer, snk_frame)
        self.tb.connect(skipper, snk_rx)
        self.tb.run()

        res = np.array(snk.data())
        print res
        print payload

        moddata = np.array(snk_frame.data())
        print "len(moddata) = ", len(moddata)
        rxdata = np.array(snk_rx.data())
        print "len(rxdata) = ", len(rxdata)

        # plt.plot(rxdata.real * 0.03)
        # for i in range(len(moddata)):
        #     if (i + 1) % total_subcarriers == 0:
        #         plt.axvline(i)
        # plt.plot(moddata.real)
        # plt.grid()
        # plt.show()

        print "len(payload) = ", len(payload)
        print "len(result)  = ", len(res)

        self.assertTupleEqual(tuple(payload[:len(res)]), tuple(res))
示例#15
0
 def setUp (self):
     self.tb = gr.top_block ()
     self.cfg = fbmc.fbmc_config(num_used_subcarriers=8, num_payload_sym=2, num_overlap_sym=4, modulation="QPSK", preamble="IAM")