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. 2
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. 3
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)
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. 5
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. 6
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. 7
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. 8
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)