Ejemplo n.º 1
0
 def test_vstheory_ser(self, M, snr, synced):
     s = signals.SignalQAMGrayCoded(M, 2 ** 16)
     off = {4: 6, 16: 13, 64: 18, 128: 20}
     ss = impairments.change_snr(s, snr+off[M])
     ser = ss.cal_ser(synced=synced)
     ser_t = theory.ser_vs_es_over_n0_qam(10**((snr+off[M])/10), M)
     npt.assert_allclose(ser, ser_t, rtol=0.3)
Ejemplo n.º 2
0
 def test_vstheory_ser(self, M, snr, os):
     s = signals.SignalQAMGrayCoded(M, 2 ** 16)
     off = {4: 6, 16: 13, 64: 18, 128: 20}
     s = s.resample(os, beta=0.1, renormalise=True)
     ss = impairments.change_snr(s, snr+off[M])
     ss = ss.resample(1, beta=0.1, renormalise=True)
     ser = ss.cal_ser()
     ser_t = theory.ser_vs_es_over_n0_qam(10**((snr+off[M])/10), M)
     npt.assert_allclose(ser, ser_t, rtol=0.3)
Ejemplo n.º 3
0
 def test_ser_vs_theory(self, shift, M, snr):
     from qampy import theory, impairments
     s = signals.SignalQAMGrayCoded(M, 10**5, nmodes=1)
     ser_t = theory.ser_vs_es_over_n0_qam(10**(snr / 10), M)
     if ser_t < 1e-4:
         assert True
         return
     s2 = impairments.change_snr(s, snr)
     s2 = np.roll(s2, shift, axis=-1)
     ser = s2.cal_ser()
     npt.assert_allclose(ser, ser_t, rtol=0.4)
def plot_setup_SNR(M,
                   N,
                   snrf,
                   snr,
                   ber,
                   ser,
                   evmf,
                   evm1,
                   evm_known,
                   gmi,
                   Q_fc,
                   t_ory=True):
    fig = plt.figure()
    ax1 = fig.add_subplot(231)
    ax2 = fig.add_subplot(232)
    ax3 = fig.add_subplot(233)
    ax4 = fig.add_subplot(234)
    ax5 = fig.add_subplot(235)
    ax6 = fig.add_subplot(236)

    ax1.set_title("BER vs SNR")
    ax2.set_title("SER vs SNR")
    ax3.set_title("BER vs EVM")
    ax4.set_title("EVM vs SNR")
    ax5.set_title("Q-factor vs SNR")
    ax6.set_title("GMI vs SNR")
    ax1.set_xlabel('SNR [dB]')
    ax1.set_ylabel('BER [dB]')
    ax1.set_yscale('log')
    ##    ax1.set_xlim(0,20)
    ##    ax1.set_ylim(1e-5,1)
    ax2.set_xlabel('SNR [dB]')
    ax2.set_ylabel('SER [dB]')
    ax2.set_yscale('log')
    ##    ax2.set_xlim(0,20)
    ##    ax2.set_ylim(1e-5,1)
    ax3.set_xlabel('EVM [dB]')
    ax3.set_ylabel('BER [dB]')
    ax3.set_yscale('log')
    ##    ax3.set_xlim(-15,0)
    ##    ax3.set_ylim(1e-6,1)
    ax4.set_xlabel('SNR [dB]')
    ax4.set_ylabel('EVM [dB]')
    ##    ax4.set_xlim(0, 30)
    ##    ax4.set_ylim(-30, 0)
    ax5.set_xlabel('SNR [dB]')
    ax5.set_ylabel('Q-factor [dB]')
    ax5.set_yscale('log', base=10)
    ax5.set_xscale('log', base=10)
    ax6.set_xlabel('SNR [dB]')
    ax6.set_ylabel('GMI')

    ax1.grid(True)
    ax2.grid(True)
    ax3.grid(True)
    ax4.grid(True)
    ax5.grid(True)
    ax6.grid(True)

    c = ['b', 'r', 'g', 'c', 'k']
    s = ['o', '<', 's', '+', 'd']

    j = 0
    if t_ory == True:
        ax1.plot(snrf,
                 theory.ber_vs_es_over_n0_qam(10**(snrf / 10), M),
                 color=c[j + 1],
                 label="%d-QAM theory" % M)
        ax2.plot(snrf,
                 theory.ser_vs_es_over_n0_qam(10**(snrf / 10), M),
                 color=c[j + 1],
                 label="%d-QAM theory" % M)
        ax5.plot(
            snrf,
            20 * np.log10(
                special.erfcinv(
                    theory.ber_vs_es_over_n0_qam(10**(snrf / 10), M) * 2) *
                np.sqrt(2)),
            color=c[j + 1],
            label="%d-QAM theory" % M)
        ax6.plot(snrf,
                 theory.cal_gmi(M, snrf, N=N),
                 color=c[j],
                 label="GMI theory")
    ax1.plot(snr, ber, color=c[j], marker=s[j], lw=0, label="%d-QAM" % M)
    ax2.plot(snr, ser, color=c[j], marker=s[j], lw=0, label="%d-QAM" % M)
    ax3.plot(evmf,
             theory.ber_vs_evm_qam(evmf, M),
             color=c[j],
             label="%d-QAM theory" % M)
    ##    ax3.plot(qampy.helpers.lin2dB(evm1 ** 2), ber, color=c[j+1], marker=s[j], lw=0, label="%d-QAM" % M)
    # illustrate the difference between a blind and non-blind EVM
    ax3.plot(qampy.helpers.lin2dB(evm_known**2),
             ber,
             color=c[j + 2],
             marker='*',
             lw=0,
             label="%d-QAM" % M)  # non-blind" % M)
    ##    ax4.plot(snr, qampy.helpers.lin2dB(evm1 ** 2), color=c[j], marker=s[j], lw=0, label="%d-QAM" % M)
    ax4.plot(snr,
             qampy.helpers.lin2dB(evm_known**2),
             color=c[j + 1],
             marker='*',
             lw=0,
             label="%d-QAM" % M)  # non-blind" % M)
    #ax4.plot(snr, utils.lin2dB(evm2), color=c[j], marker='*', lw=0, label="%d-QAM signalq"%M)
    ax5.plot(snr, Q_fc, color=c[j], marker=s[j], lw=0, label="Q-factor")
    ax6.plot(snr, gmi[:, 0], color=c[j], marker=s[j], lw=0, label="GMI")

    ax1.legend()
    ax2.legend()
    ax3.legend()
    ax4.legend()
    ax5.legend()
    ax6.legend()
Ejemplo n.º 5
0
     signalafter = equalisation.apply_filter(signal_s, wx)
     signalafter = helpers.normalise_and_center(signalafter)
     evm1[i] = signal.cal_evm()[0]
     evm_known[i] = signalafter.cal_evm()
     # check to see that we can recovery timing delay
     #signalafter = np.roll(signalafter * 1.j**np.random.randint(0,4), np.random.randint(4, 3000))
     ser[i] = signalafter.cal_ser()
     ber[i] = signalafter.cal_ber()
     i += 1
 ax1.plot(snrf,
          theory.ber_vs_es_over_n0_qam(10**(snrf / 10), M),
          color=c[j],
          label="%d-QAM theory" % M)
 ax1.plot(snr, ber, color=c[j], marker=s[j], lw=0, label="%d-QAM" % M)
 ax2.plot(snrf,
          theory.ser_vs_es_over_n0_qam(10**(snrf / 10), M),
          color=c[j],
          label="%d-QAM theory" % M)
 ax2.plot(snr, ser, color=c[j], marker=s[j], lw=0, label="%d-QAM" % M)
 ax3.plot(evmf,
          theory.ber_vs_evm_qam(evmf, M),
          color=c[j],
          label="%d-QAM theory" % M)
 ax3.plot(qampy.helpers.lin2dB(evm1**2),
          ber,
          color=c[j],
          marker=s[j],
          lw=0,
          label="%d-QAM" % M)
 # illustrate the difference between a blind and non-blind EVM
 ax3.plot(qampy.helpers.lin2dB(evm_known**2),
Ejemplo n.º 6
0
        signal = signal.resample(fnew=fs, beta=beta, renormalise=True)
        signal_s = impairments.change_snr(signal, sr)
        #signalx = np.atleast_2d(filtering.rrcos_pulseshaping(signal_s, beta))
        wx, er = equalisation.equalise_signal(signal_s, 3e-4, Ntaps=ntaps, method="mcma", adaptive_step=True, avoid_cma_sing=False)
        signalafter = equalisation.apply_filter(signal_s,  wx )
        signalafter = helpers.normalise_and_center(signalafter)
        evm1[i] = signal.cal_evm()[0]
        evm_known[i] = signalafter.cal_evm()
        # check to see that we can recovery timing delay
        #signalafter = np.roll(signalafter * 1.j**np.random.randint(0,4), np.random.randint(4, 3000))
        ser[i] = signalafter.cal_ser()
        ber[i] = signalafter.cal_ber()
        i += 1
    ax1.plot(snrf, theory.ber_vs_es_over_n0_qam(10 ** (snrf / 10), M), color=c[j], label="%d-QAM theory" % M)
    ax1.plot(snr, ber, color=c[j], marker=s[j], lw=0, label="%d-QAM"%M)
    ax2.plot(snrf, theory.ser_vs_es_over_n0_qam(10 ** (snrf / 10), M), color=c[j], label="%d-QAM theory" % M)
    ax2.plot(snr, ser, color=c[j], marker=s[j], lw=0, label="%d-QAM"%M)
    ax3.plot(evmf, theory.ber_vs_evm_qam(evmf, M), color=c[j], label="%d-QAM theory" % M)
    ax3.plot(qampy.helpers.lin2dB(evm1 ** 2), ber, color=c[j], marker=s[j], lw=0, label="%d-QAM" % M)
    # illustrate the difference between a blind and non-blind EVM
    ax3.plot(qampy.helpers.lin2dB(evm_known ** 2), ber, color=c[j], marker='*', lw=0, label="%d-QAM non-blind" % M)
    ax4.plot(snr, qampy.helpers.lin2dB(evm1 ** 2), color=c[j], marker=s[j], lw=0, label="%d-QAM" % M)
    ax4.plot(snr, qampy.helpers.lin2dB(evm_known ** 2), color=c[j], marker='*', lw=0, label="%d-QAM non-blind" % M)
    #ax4.plot(snr, utils.lin2dB(evm2), color=c[j], marker='*', lw=0, label="%d-QAM signalq"%M)
    j += 1
ax1.legend()
ax2.legend()
#ax3.legend()
ax4.legend()
plt.show()