Exemplo n.º 1
0
Pest = np.zeros(SNRbdBs.size)
Pebt = np.zeros(SNRbdBs.size)

threshold = 1e-5

for i, SNRbdB in enumerate(SNRbdBs):

    s = psk_simulation(max_iterations=int(1e6),
                       M=M,
                       SNRbdB=SNRbdB,
                       report_step=100000,
                       keep_realizations=False,
                       max_symbol_errors=100,
                       report=True)
    Pest[i] = s.constellation.ser()
    c = psk_constellation(M=M, SNRbdB=SNRbdB)
    Pest[i] = c.ser()
    Pebt[i] = c.ber()
    s.execute()
    Pes[i] = s.symbol_errors / s.iterations_performed
    Peb[i] = s.bit_errors / s.iterations_performed / np.log2(M)
    if Pes[i] < threshold:
        break
    print('M = %d, SNRbdB = %6.2f Pe = %e / %e' % (M, SNRbdB, Pes[i], Pest[i]))
    print('M = %d, SNRbdB = %6.2f Pe = %e' % (M, SNRbdB, Pest[i]))

#---secondpart
plt.close('all')

plt.figure(1)
plt.semilogy(SNRbdBs, Pest, label='theoretical')
Exemplo n.º 2
0
from commlib import pam_constellation, psk_constellation
import matplotlib.pyplot as plt
import numpy as np

SNRbdBs = np.arange(4, 25, 1)
M = 4

PesPAM = np.zeros(SNRbdBs.size)
PebPAM = np.zeros(SNRbdBs.size)
PesPSK = np.zeros(SNRbdBs.size)
PebPSK = np.zeros(SNRbdBs.size)

for i, SNRbdB in enumerate(SNRbdBs):

    cpsk = psk_constellation(M, SNRbdB=SNRbdB)
    cpam = pam_constellation(M, SNRbdB=SNRbdB)

    PesPAM[i] = cpam.ser()
    PesPSK[i] = cpsk.ser()
    PebPAM[i] = cpam.ber()
    PebPSK[i] = cpsk.ber()

plt.close('all')

plt.figure(1)
plt.semilogy(SNRbdBs, PesPAM, label='%d-PAM' % M)
plt.semilogy(SNRbdBs, PesPSK, label='%d-PSK' % M)
plt.xlabel('SNRb [dB]')
plt.ylabel('SER')
plt.legend()
plt.title('PSK vs PAM SER for M=%d' % M)
Exemplo n.º 3
0
import commlib as cl
import matplotlib.pyplot as plt

M = 16
c = cl.psk_constellation(M)
plt.close('all')
c.plot_map(rotation=0)
Exemplo n.º 4
0
import matplotlib.pyplot as plt
import numpy as np
import commlib as cl

M = 4
rSs = np.array([1,2,4,10])
plt.close('all')

for rS in rSs:
    SNRbdB = 10 * np.log10(rS / np.log2(M) )    
    s = cl.psk_constellation(M, SNRbdB = SNRbdB)
    phi = np.arange(-2*np.pi, 2*np.pi, 0.01)
    f = s.fphi(phi)
    
    plt.figure(1)
    plt.plot(phi, f, label = "$r_S = %d$" % rS)
    plt.xlabel('$\phi/\pi$')
    plt.ylabel('$f$')

plt.legend()