예제 #1
0
 def test_OFDM_rx_channel_estimate(self):
     z_out_test, H_out_test = (
         np.array(
             [
                 -2.91356233 - 0.93854058j, -3.03083561 - 1.01177886j,
                 3.10687062 + 1.09962706j, 2.91679784 + 2.79392693j,
                 2.95621370 + 0.87789714j, 2.93521287 + 1.12869418j,
                 -3.17675560 - 1.0834705j, 1.25700626 + 1.19497994j,
                 1.16433902 + 2.62068101j, -3.10408334 + 1.08514004j,
                 1.02623864 + 3.01672402j, -0.98366297 - 1.21602375j,
                 0.89577012 + 1.07687508j, 1.05852406 + 1.05134363j,
                 0.93287609 - 3.11042385j, 0.99965390 + 0.88124784j,
                 -1.16293758 + 3.08562314j, -2.84891079 - 1.07199168j,
                 -3.22236927 - 2.90425199j, 3.07028549 - 2.88413491j,
                 -3.12192058 + 2.89625467j, 3.18017151 - 1.09375776j,
                 -2.78212772 + 3.05087219j, 1.13471595 - 2.89218144j,
                 -3.17092453 - 1.11298847j, 3.10927184 + 0.86801524j,
                 -0.76520964 - 3.32101721j, -0.94935570 + 2.86081052j,
                 0.93535950 + 1.10545223j, 1.09394518 - 1.17966519j,
                 3.10748055 + 1.12377382j, -3.12337017 - 0.89848715j,
                 -2.95725651 + 0.97491592j, 3.14041238 - 3.01998896j,
                 -1.05440640 + 3.04843936j, -0.94130790 - 0.82179287j,
                 -0.79049810 - 1.04083796j, 2.96004080 + 1.01692442j,
                 -3.13063510 + 1.32083138j, -2.58084447 - 3.28171534j,
                 3.09664605 + 0.82140179j, 2.87565015 - 1.17002378j,
                 2.82351021 + 2.83242155j, 2.99238994 + 3.06883778j,
                 -0.83601519 - 2.8886988j, 3.05383614 + 1.22402533j,
                 -0.92550302 + 0.92366226j, -0.97707573 + 3.08608891j,
                 0.73489228 - 2.99163649j, 2.89544691 + 2.76671634j
             ]),
         np.array(
             [
                 1.49261307 - 0.12886832j, 1.36399692 - 0.24831791j,
                 1.24438887 - 0.41524198j, 1.15276504 - 0.47480443j,
                 1.09981815 - 0.35438673j, 0.86684483 - 0.31710329j,
                 0.75885865 - 0.23542562j, 0.76309583 - 0.19374055j,
                 0.61556098 + 0.09731796j, 0.77281595 + 0.07096727j,
                 0.87593303 + 0.15642133j, 1.06728467 + 0.29788462j,
                 1.08613086 + 0.23650714j, 1.12082635 + 0.09129381j,
                 1.31026672 + 0.17419224j, 1.19459330 + 0.01027668j,
                 1.19745209 + 0.11471611j, 1.36689249 - 0.07997548j,
                 1.26471663 - 0.07505238j, 1.14356226 - 0.19961235j,
                 0.84149706 - 0.21609579j, 0.85489994 - 0.18101042j,
                 0.79502365 - 0.17155484j, 0.71666634 - 0.02650505j,
                 0.82384118 + 0.0565963j, 0.74313589 + 0.28403893j,
                 0.88570493 + 0.29345603j, 0.95203301 + 0.37888469j,
                 0.98676887 + 0.4108844j, 1.26869289 + 0.35672436j,
                 1.44594176 + 0.3296819j, 1.48817425 + 0.07577518j
             ]))
     hc = np.array([1.0, 0.1, -0.05, 0.15, 0.2, 0.05])
     x1, b1, IQ_data1 = dc.QAM_bb(50000, 1, '16qam')
     x_out = dc.OFDM_tx(IQ_data1, 32, 64, 100, True, 10)
     c_out = signal.lfilter(hc, 1, x_out)  # Apply channel distortion
     r_out = dc.cpx_AWGN(c_out, 25, 64 / 32)  # Es/N0 = 25 dB
     z_out, H = dc.OFDM_rx(r_out, 32, 64, 100, True, 10, alpha=0.95, ht=hc)
     npt.assert_almost_equal(z_out[:50], z_out_test)
     npt.assert_almost_equal(H[:50], H_out_test)
예제 #2
0
 def test_fec_conv_viterbi_decoder(self):
     cc1 = fec_conv.fec_conv()
     x = np.random.randint(0,2,20)
     state = '00'
     y, state = cc1.conv_encoder(x, state)
     z_test = [ 0.,  0.,  1.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.]
     yn = dc.cpx_AWGN(2 * y - 1, 5, 1)
     yn = (yn.real + 1) / 2 * 7
     z = cc1.viterbi_decoder(yn)
     npt.assert_almost_equal(z_test, z)
예제 #3
0
 def test_QAM_SEP_256qam(self):
     Nsymb_test, Nerr_test, SEP_test = (4986, 2190, 0.43922984356197353)
     x, b, tx_data = dc.QAM_bb(5000, 10, '256qam', 'src')
     x = dc.cpx_AWGN(x, 20, 10)
     y = signal.lfilter(b, 1, x)
     Nsymb, Nerr, SEP = dc.QAM_SEP(tx_data,
                                   y[10 + 10 * 12::10],
                                   '256qam',
                                   Ntransient=0)
     self.assertEqual(Nsymb, Nsymb_test)
     self.assertEqual(Nerr, Nerr_test)
     self.assertEqual(SEP, SEP_test)
예제 #4
0
 def test_QAM_SEP_64qam(self):
     Nsymb_test, Nerr_test, SEP_test = (4986, 245, 0.04913758523866827)
     x, b, tx_data = dc.QAM_bb(5000, 10, '64qam', 'src')
     x = dc.cpx_AWGN(x, 20, 10)
     y = signal.lfilter(b, 1, x)
     Nsymb, Nerr, SEP = dc.QAM_SEP(tx_data,
                                   y[10 + 10 * 12::10],
                                   '64qam',
                                   Ntransient=0)
     self.assertEqual(Nsymb, Nsymb_test)
     self.assertEqual(Nerr, Nerr_test)
     self.assertEqual(SEP, SEP_test)
예제 #5
0
 def test_QAM_SEP_qpsk(self):
     Nsymb_test, Nerr_test, SEP_test = (4986, 0, 0.0)
     x, b, tx_data = dc.QAM_bb(5000, 10, 'qpsk', 'src')
     x = dc.cpx_AWGN(x, 20, 10)
     y = signal.lfilter(b, 1, x)
     Nsymb, Nerr, SEP = dc.QAM_SEP(tx_data,
                                   y[10 + 10 * 12::10],
                                   'qpsk',
                                   Ntransient=0)
     self.assertEqual(Nsymb, Nsymb_test)
     self.assertEqual(Nerr, Nerr_test)
     self.assertEqual(SEP, SEP_test)
예제 #6
0
 def test_QAM_SEP_16qam_error(self):
     Nsymb_test, Nerr_test, SEP_test = (9976, 172, 0.017241379310344827)
     x, b, tx_data = dc.QAM_bb(10000, 1, '16qam', 'rect')
     x = dc.cpx_AWGN(x, 15, 1)
     y = signal.lfilter(b, 1, x)
     Nsymb, Nerr, SEP = dc.QAM_SEP(tx_data,
                                   y[1 * 12::1],
                                   '16qam',
                                   Ntransient=0)
     self.assertEqual(Nsymb, Nsymb_test)
     self.assertEqual(Nerr, Nerr_test)
     self.assertEqual(SEP, SEP_test)
예제 #7
0
    def test_fec_conv_depuncture(self):
        zdpn_test = [-0.18077499,  0.24326595, -0.43694799,  3.5,         3.5,         7.41513671,
                     -0.55673726,  7.77925472,  7.64176133,  3.5,         3.5,        -0.09960601,
                     -0.50683017,  7.98234306,  6.58202794,  3.5,         3.5,        -1.0668518,
                     1.54447404,  1.47065852, -0.24028734,  3.5,         3.5,         6.19633424,
                     7.1760269,   0.89395647,  7.69735877,  3.5,         3.5,         1.29889556,
                     -0.31122416,  0.05311373,  7.21216449,  3.5,         3.5,        -1.37679829]
        cc1 = fec_conv.fec_conv()

        x = np.random.randint(0, 2, 20)
        state = '00'
        y, state = cc1.conv_encoder(x, state)
        yp = cc1.puncture(y, ('110', '101'))
        ypn = dc.cpx_AWGN(2 * yp - 1, 8, 1)
        ypn = (ypn.real + 1) / 2 * 7
        zdpn = cc1.depuncture(ypn, ('110', '101'), 3.5)  # set erase threshold to 7/2
        npt.assert_almost_equal(zdpn_test, zdpn)
예제 #8
0
 def test_OFDM_rx(self):
     z_out_test, H_test = (
         np.array(
             [
                 -3.11740028 - 0.90748269j, -3.11628187 - 0.88948888j,
                 2.88565859 + 1.13255112j, 2.89076997 + 3.16052588j,
                 2.90396853 + 1.19595053j, 2.93439648 + 1.23703401j,
                 -3.00724063 - 0.72880083j, 1.07519281 + 1.27075039j,
                 1.14472192 + 3.22099905j, -2.82962216 + 1.15148633j,
                 1.16245397 + 3.09533441j, -0.85799363 - 0.94063529j,
                 1.12036257 + 1.03825793j, 1.10109739 + 1.02622557j,
                 1.08488052 - 2.98041713j, 1.07132873 + 1.01625511j,
                 -0.92119499 + 3.01872286j, -2.91683903 - 0.9906338j,
                 -2.91213253 - 3.00295552j, 3.09229992 - 3.01974828j
             ]),
         np.array([
             1.42289223 - 1.43696423e-01j, 1.34580486 - 2.66705232e-01j,
             1.23071709 - 3.51736667e-01j, 1.09530096 - 3.87688911e-01j,
             0.95992898 - 3.71339473e-01j, 0.84428862 - 3.07656711e-01j,
             0.76421410 - 2.08710707e-01j, 0.72928932 - 9.14213562e-02j,
             0.74161551 + 2.54124114e-02j, 0.79590656 + 1.24244087e-01j,
             0.88082345 + 1.91510354e-01j, 0.98123573 + 2.19504072e-01j,
             1.08094630 + 2.07118520e-01j, 1.16536231 + 1.59418930e-01j,
             1.22364402 + 8.62177170e-02j, 1.25000000 - 2.77555756e-17j,
             1.25000000 + 2.77555756e-17j, 1.22364402 - 8.62177170e-02j,
             1.16536231 - 1.59418930e-01j, 1.08094630 - 2.07118520e-01j,
             0.98123573 - 2.19504072e-01j, 0.88082345 - 1.91510354e-01j,
             0.79590656 - 1.24244087e-01j, 0.74161551 - 2.54124114e-02j,
             0.72928932 + 9.14213562e-02j, 0.76421410 + 2.08710707e-01j,
             0.84428862 + 3.07656711e-01j, 0.95992898 + 3.71339473e-01j,
             1.09530096 + 3.87688911e-01j, 1.23071709 + 3.51736667e-01j,
             1.34580486 + 2.66705232e-01j, 1.42289223 + 1.43696423e-01j
         ]))
     hc = np.array([1.0, 0.1, -0.05, 0.15, 0.2, 0.05])
     x1, b1, IQ_data1 = dc.QAM_bb(50000, 1, '16qam')
     x_out = dc.OFDM_tx(IQ_data1, 32, 64, 0, True, 0)
     c_out = signal.lfilter(hc, 1, x_out)  # Apply channel distortion
     r_out = dc.cpx_AWGN(c_out, 100, 64 / 32)  # Es/N0 = 100 dB
     z_out, H = dc.OFDM_rx(r_out, 32, 64, -1, True, 0, alpha=0.95, ht=hc)
     npt.assert_almost_equal(z_out[:20], z_out_test)
     npt.assert_almost_equal(H, H_test)
예제 #9
0
 def channelOutput(self,x):
      #orig_shape = x.shape
     x_flat = np.ravel(x)
     if(self.channel_type=='OFDM'):
         symbols = self.Modulation(x_flat);
         orig_symb_size = np.size(symbols);
         symbols = self.fit_to_input(x,self.num_carriers) 
         symb_rows = symbols.shape[0];
         self.myOFDM = OFDM_module(symbols[0,:]);
         self.myOFDM.setSNR(self.EbN0)
         y = self.myOFDM.OFDM_run()
         for i in range(1,symb_rows):
             self.myOFDM = OFDM_module(symbols[i,:])
             self.myOFDM.setSNR(self.EbN0)
             y = np.append(y,self.myOFDM.OFDM_run())
             y = np.ravel(y);
             y = y[0:orig_symb_size];
     else:
          y = dc.cpx_AWGN(2*x_flat-1,self.EbN0+10*np.log10(self.k/self.N),1);
 
     if((self.channel_type=='OFDM')):
         return y;
     else:
         return y.real;