def test_vstheory_ber(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]) ber = ss.cal_ber(synced=synced) ber_t = theory.ber_vs_es_over_n0_qam(10**((snr+off[M])/10), M) npt.assert_allclose(ber, ber_t, rtol=0.15)
def test_vstheory_ber(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) ber = ss.cal_ber() ber_t = theory.ber_vs_es_over_n0_qam(10**((snr+off[M])/10), M) npt.assert_allclose(ber, ber_t, rtol=0.18)
wx, er = equalisation.equalise_signal(signal_s, 3e-4, Ntaps=ntaps, method="mcma", adaptive_step=True) 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],
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()
print("SNR = %2f.0 dB"%sr) signal = signals.SignalQAMGrayCoded(M, N, nmodes=1, fb=fb) 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()