Esempio n. 1
0
 def test_BERReference_SM(self):
     from imtoolkit import Parameters, IMCode, IdealRayleighChannel, CoherentMLDSimulator
     truth = np.log10(
         np.array([
             3.39290432141913567143e-01, 2.28799154240169139163e-01,
             1.16562376687524657526e-01, 4.63410907317818518414e-02,
             1.58151968369606328590e-02, 5.27619894476021120827e-03,
             1.64459967108006571007e-03
         ]))
     params = Parameters(
         "BER_sim=coh_code=index_dm=dic_M=2_K=1_Q=2_L=4_mod=PSK_N=1_IT=1e5_snrfrom=0.00_to=30.00_len=7"
     )
     code = IMCode(params.dm,
                   params.M,
                   params.K,
                   params.Q,
                   params.mod,
                   params.L,
                   meanPower=1)
     channel = IdealRayleighChannel(1, params.M, params.N)
     sim = CoherentMLDSimulator(code.codes, channel)
     ret = sim.simulateBERReference(params,
                                    outputFile=False,
                                    printValue=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
Esempio n. 2
0
 def test_AMIParallel_SM(self):
     from imtoolkit import Parameters, IMCode, IdealRayleighChannel, CoherentMLDSimulator
     truth = np.array([
         1.42818014515766478212e-02, 4.46896133972787268362e-02,
         1.35020118355007934241e-01, 3.74152908820060137174e-01,
         8.88430916560169148255e-01, 1.63202684937455133607e+00,
         2.32075268455922545385e+00, 2.73556303528255551072e+00,
         2.90887984047466385817e+00
     ])
     params = Parameters(
         "AMIP_sim=coh_code=index_dm=dic_M=2_K=1_Q=2_L=4_mod=PSK_N=1_ITo=1e1_ITi=1e4_snrfrom=-20.00_to=20.00_len=9"
     )
     code = IMCode(params.dm,
                   params.M,
                   params.K,
                   params.Q,
                   params.mod,
                   params.L,
                   meanPower=1)
     channel = IdealRayleighChannel(params.ITi, params.M, params.N)
     sim = CoherentMLDSimulator(code.codes, channel)
     ret = sim.simulateAMIParallel(params,
                                   outputFile=False,
                                   printValue=False)
     np.testing.assert_almost_equal(ret["ami"], truth, 1)
def simulateBER(argstr):
    params = Parameters(argstr)
    if params.code == "symbol":
        codes = np.array(Modulator(params.mod,
                                   params.L).symbols).reshape(params.L, 1, 1)
    elif params.code == "OSTBC":
        codes = OSTBCode(params.M, params.mod, params.L).codes
    elif params.code == "DUC":
        codes = DiagonalUnitaryCode(params.M, params.L).codes
    elif params.code == "ADSM":
        codes = ADSMCode(params.M, params.mod, params.L).codes

    if params.mode == "BER":
        channel = IdealRayleighChannel(1, params.M, params.N)
    else:
        channel = IdealRayleighChannel(params.ITi, params.M, params.N)

    if params.sim == "diff":
        sim = DifferentialMLDSimulator(codes, channel)
    elif params.sim == "sudiff":
        sim = SemiUnitaryDifferentialMLDSimulator(codes, channel)
    elif params.sim == "nsdiff":
        bases = Basis(params.basis, params.M, params.T).bases
        sim = NonSquareDifferentialMLDSimulator(codes, channel, bases)

    if params.mode == "BER":
        return sim.simulateBERReference(params,
                                        outputFile=False,
                                        printValue=False)
    else:
        return sim.simulateBERParallel(params,
                                       outputFile=False,
                                       printValue=False)
Esempio n. 4
0
 def test_Parameters(self):
     arg = "BER_sim=coh_channel=rayleigh_M=1_N=1_L=2_mod=PSK_IT=1e7_snrfrom=00.00_to=50.00_len=11_d=1e-6"
     params = Parameters(arg)
     
     self.assertEqual(params.mode, "BER")
     self.assertEqual(params["mode"], "BER")
     self.assertEqual(params.table["mode"], "BER")
     self.assertAlmostEqual(params.snrfrom, 0.00, "The Parameter class failed to parse.")
     self.assertAlmostEqual(params.d, 1e-6)
Esempio n. 5
0
def simulateAMI(argstr):
    params = Parameters(argstr)
    code = IMCode(params.dm,
                  params.M,
                  params.K,
                  params.Q,
                  params.mod,
                  params.L,
                  meanPower=1)
    channel = IdealRayleighChannel(params.ITi, params.M, params.N)
    sim = CoherentMLDSimulator(code.codes, channel)
    return sim.simulateAMIParallel(params, outputFile=False, printValue=False)
 def test_BERParallel_TAST(self):
     truth = np.log10(
         np.array([
             4.42719114561770876737e-01, 3.35158329683340638905e-01,
             1.74362651274697438852e-01, 4.47959104081791861796e-02,
             4.18899162201675622635e-03
         ]))
     params = Parameters(
         "BERP_sim=sudiff_channel=rayleigh_code=TAST_M=2_T=2_Q=2_L=16_mod=SQAM_N=2_ITo=1e1_ITi=1e4_snrfrom=0.00_to=20.00_len=5"
     )
     codes = TASTCode(params.M, params.Q, params.L).codes
     channel = IdealRayleighChannel(params.ITi, params.M, params.N)
     sim = SemiUnitaryDifferentialMLDSimulator(codes, channel)
     ret = sim.simulateBERParallel(params, outputFile=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
Esempio n. 7
0
 def test_BERReference_NDOSTC_AWGN(self):
     truth = np.log10(
         np.array([
             4.90489052631578936747e-01, 4.68008763157894747131e-01,
             3.89989789473684234089e-01, 1.77222684210526310045e-01,
             8.28273684210526286997e-03
         ]))
     params = Parameters(
         "BER_sim=nsdiff_channel=AWGN_code=OSTBC_basis=i_M=2_N=2_T=1_L=2_W=40_IT=1e4_snrfrom=-10.00_to=10.00_len=5"
     )
     codes = OSTBCode(params.M, params.mod, params.L).codes
     channel = AWGNChannel(1, params.M)
     bases = Basis(params.basis, params.M, params.T).bases
     sim = NonSquareDifferentialMLDSimulator(codes, channel, bases)
     ret = sim.simulateBERReference(params, outputFile=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
Esempio n. 8
0
 def test_BERReference_NDOSTC_Rayleigh(self):
     truth = np.log10(
         np.array([
             4.80833947368421055213e-01, 4.41299473684210519231e-01,
             3.40417894736842086001e-01, 1.59756578947368416133e-01,
             3.54696052631578925829e-02, 4.77671052631578954561e-03
         ]))
     params = Parameters(
         "BER_sim=nsdiff_channel=rayleigh_code=OSTBC_basis=i_M=2_N=2_T=1_L=2_W=40_IT=1e4_snrfrom=-10.00_to=15.00_len=6"
     )
     codes = OSTBCode(params.M, params.mod, params.L).codes
     channel = IdealRayleighChannel(1, params.M, params.N)
     bases = Basis(params.basis, params.M, params.T).bases
     sim = NonSquareDifferentialMLDSimulator(codes, channel, bases)
     ret = sim.simulateBERReference(params, outputFile=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
Esempio n. 9
0
 def test_BERReference_ADSM(self):
     truth = np.log10(
         np.array([
             3.23886999999999980471e-01, 1.08588000000000003964e-01,
             1.21379999999999994842e-02, 5.29999999999999980675e-04
         ]))
     params = Parameters(
         "BER_sim=diff_channel=rayleigh_code=ADSM_M=4_L=4_mod=PSK_T=4_N=1_IT=1e5_snrfrom=0.00_to=15.00_len=4"
     )
     code = ADSMCode(params.M, "PSK", params.L)
     channel = IdealRayleighChannel(1, params.M, params.N)
     sim = DifferentialMLDSimulator(code.codes, channel)
     ret = sim.simulateBERReference(params,
                                    outputFile=False,
                                    printValue=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
 def test_BERReference_SQAM(self):
     truth = np.log10(
         np.array([
             3.94573999999999980304e-01, 3.05669000000000024020e-01,
             2.02045000000000002371e-01, 1.10306000000000001271e-01,
             4.76810000000000011600e-02, 1.77129999999999995786e-02,
             6.14199999999999989020e-03
         ]))
     params = Parameters(
         "BER_sim=sudiff_channel=rayleigh_M=1_N=1_L=16_mod=SQAM_IT=1e5_snrfrom=0.00_to=30.00_len=7"
     )
     codes = Modulator(params.mod, params.L).symbols.reshape(params.L, 1, 1)
     channel = IdealRayleighChannel(1, params.M, params.N)
     sim = SemiUnitaryDifferentialMLDSimulator(codes, channel)
     ret = sim.simulateBERReference(params, outputFile=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
def simulateBER(argstr):
    params = Parameters(argstr)
    if params.code == "symbol":
        codes = np.array(Modulator("PSK",
                                   params.L).symbols).reshape(params.L, 1, 1)
    elif params.code == "OSTBC":
        codes = OSTBCode(params.M, "PSK", params.L).codes
    elif params.code == "DUC":
        codes = DiagonalUnitaryCode(params.M, params.L).codes
    elif params.code == "ADSM":
        codes = ADSMCode(params.M, params.mod, params.L).codes
    elif params.code == "TAST":
        codes = TASTCode(params.M, params.Q, params.L).codes

    channel = IdealRayleighChannel(params.ITi, params.M, params.N)
    sim = DifferentialMLDSimulator(codes, channel)
    return sim.simulateBERParallel(params, outputFile=False, printValue=False)
Esempio n. 12
0
 def test_BERParallel_OSTBC(self):
     from imtoolkit import Parameters, OSTBCode, IdealRayleighChannel, CoherentMLDSimulator
     truth = np.log10(
         np.array([
             2.72212300000000018141e-01, 1.46606500000000000705e-01,
             4.03784000000000017905e-02, 3.73150000000000000785e-03
         ]))
     params = Parameters(
         "BERP_sim=coh_channel=rayleigh_code=OSTBC_M=2_N=2_T=2_L=2_mod=PSK_ITo=1e1_ITi=1e4_snrfrom=-10.00_to=5.00_len=4"
     )
     code = OSTBCode(params.M, "PSK", params.L)
     channel = IdealRayleighChannel(params.ITi, params.M, params.N)
     sim = CoherentMLDSimulator(code.codes, channel)
     ret = sim.simulateBERParallel(params,
                                   outputFile=False,
                                   printValue=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
Esempio n. 13
0
 def test_BERReference_DUC(self):
     truth = np.log10(
         np.array([
             4.86660099999999984366e-01, 4.48927299999999973590e-01,
             3.32694099999999992612e-01, 1.44086500000000006239e-01,
             2.63749999999999991396e-02
         ]))
     params = Parameters(
         "BER_sim=diff_channel=rayleigh_code=DUC_M=2_L=16_N=2_T=2_IT=1e5_snrfrom=-10.00_to=10.00_len=5"
     )
     code = DiagonalUnitaryCode(params.M, params.L)
     channel = IdealRayleighChannel(1, params.M, params.N)
     sim = DifferentialMLDSimulator(code.codes, channel)
     ret = sim.simulateBERReference(params,
                                    outputFile=False,
                                    printValue=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
Esempio n. 14
0
 def test_AMIParallel_OSTBC(self):
     from imtoolkit import Parameters, OSTBCode, IdealRayleighChannel, CoherentMLDSimulator
     truth = np.array([
         2.34009305866733186008e-01, 5.31335636295124702499e-01,
         8.56159232876912645871e-01, 9.85823618846433324947e-01,
         9.99561665572359148157e-01, 9.99989963240521695376e-01,
         9.99999993834903122547e-01
     ])
     params = Parameters(
         "AMIP_sim=coh_channel=rayleigh_code=OSTBC_M=2_N=2_T=2_L=2_mod=PSK_ITo=1e1_ITi=1e2_snrfrom=-10.00_to=20.00_len=7"
     )
     code = OSTBCode(params.M, "PSK", params.L)
     channel = IdealRayleighChannel(params.ITi, params.M, params.N)
     sim = CoherentMLDSimulator(code.codes, channel)
     ret = sim.simulateAMIParallel(params,
                                   outputFile=False,
                                   printValue=False)
     np.testing.assert_almost_equal(ret["ami"], truth, 1)
Esempio n. 15
0
 def test_BERReference_OSTBC(self):
     truth = np.log10(
         np.array([
             4.30007799999999995588e-01, 3.16763799999999984269e-01,
             1.40630900000000003125e-01, 2.39459999999999985365e-02,
             1.21079999999999994055e-03
         ]))
     params = Parameters(
         "BER_sim=diff_channel=rayleigh_code=OSTBC_M=2_N=2_T=2_L=2_mod=PSK_IT=1e4_snrfrom=-10.00_to=10.00_len=5"
     )
     #params = Parameters("BER_sim=diff_channel=rayleigh_code=OSTBC_M=2_N=2_T=2_L=2_mod=PSK_IT=1e6_snrfrom=-10.00_to=10.00_len=5")
     code = OSTBCode(params.M, "PSK", params.L)
     channel = IdealRayleighChannel(1, params.M, params.N)
     sim = DifferentialMLDSimulator(code.codes, channel)
     ret = sim.simulateBERReference(params,
                                    outputFile=False,
                                    printValue=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)
Esempio n. 16
0
 def test_BERParallel_NDOSTC(self):
     from imtoolkit import Parameters, OSTBCode, IdealRayleighChannel, CoherentMLDSimulator, Basis
     truth = np.log10(
         np.array([
             3.43530300000000010652e-01, 2.47677700000000000635e-01,
             1.30837700000000001221e-01, 4.04209000000000026609e-02,
             7.00869999999999965246e-03, 8.46599999999999978419e-04,
             9.30999999999999997046e-05
         ]))
     params = Parameters(
         "BERP_sim=rcoh_channel=rayleigh_code=OSTBC_basis=i_M=2_N=2_T=1_L=2_ITo=1e1_ITi=1e5_snrfrom=-10.00_to=20.00_len=7"
     )
     codes = OSTBCode(params.M, params.mod, params.L).codes
     bases = Basis(params.basis, params.M, params.T).bases
     codes = np.matmul(codes, bases[0])
     channel = IdealRayleighChannel(params.ITi, params.M, params.N)
     sim = CoherentMLDSimulator(codes, channel)
     ret = sim.simulateBERParallel(params,
                                   outputFile=False,
                                   printValue=False)
     np.testing.assert_almost_equal(np.log10(ret["ber"]), truth, 1)