Exemplo n.º 1
0
 def test_shift(self, shiftN, snr, N1):
     sig = impairments.change_snr(self.s, self.s.fb, self.s.fs, snr)
     sig = sig[0]
     syms = sig.symbols[0]
     sig2 = np.roll(sig, shift=shiftN)
     offset = ber_functions.find_sequence_offset(syms[:N1], sig2)
     assert (offset == -shiftN) or ((3*10**4 - offset )== shiftN)
Exemplo n.º 2
0
 def test_change_snr(self, dtype):
     s = signals.SignalQAMGrayCoded(16,
                                    2**16,
                                    fb=10e9,
                                    nmodes=2,
                                    dtype=dtype)
     s2 = cimpairments.change_snr(s, 20, s.fb, s.fb)
     assert s.dtype == s2.dtype
Exemplo n.º 3
0
 def test_nd_dualmode(self, N):
     import numpy as np
     from qampy import impairments
     s = signals.ResampledQAM(16, 2**16, fb=20e9, fs=40e9, nmodes=N)
     s2 = impairments.change_snr(s, 25)
     E, wx, err = equalisation.dual_mode_equalisation(
         s2, (1e-3, 1e-3), 11, apply=True, adaptive_stepsize=(True, True))
     assert np.mean(E.cal_ber() < 1e-3)
l_temp = np.linspace(10 * 10**3, 10 * 10**4, 5)
for lw in range(3, 9):
    lwdth = np.delete(lwdth, -1)
    lwdth = np.append(lwdth, l_temp * (10**(lw - 3)))

#############################################################################################
##Signal with SNR impairment
ser = np.zeros(snr.shape)
ber = np.zeros(snr.shape)
evm1 = np.zeros(snr.shape)
evm_known = np.zeros(snr.shape)
gmi = np.zeros([snr.shape[0], 2])
i = 0
for sr in snr:
    print("SNR = %2f dB" % sr)
    signal_s = impairments.change_snr(resampled_sig, sr)
    #signalx = np.atleast_2d(filtering.rrcos_pulseshaping(signal_s, beta))
    E, BER, errs, tx_synced = equalize_synchronize_signal(
        resampled_sig=signal_s)  #Equalizing and synchronizing signal
    evm1[i] = sig.cal_evm()[0]
    evm_known[i] = E.cal_evm()[0]
    ser[i] = E.cal_ser()[0]
    ber[i] = E.cal_ber()[0]
    gmi[i] = E.cal_gmi()[0]
    i += 1

Q_fc = 20 * np.log10(
    special.erfcinv(ber * 2) * np.sqrt(2))  #Calculating Q-factor
plot_setup_SNR(M, N, snrf, snr, ber, ser, evmf, evm1, evm_known, gmi, Q_fc)

##############################################################################################