-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerformance_evaluation.py
More file actions
62 lines (50 loc) · 1.81 KB
/
Performance_evaluation.py
File metadata and controls
62 lines (50 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pickle, os
import numpy as np
from Modulatore.Modulatore import fasi_possibili, modulate_signal
from ImpostazioneSistema.generate_impulse import LREC, LRC
from ImpostazioneSistema.generate_fwaveform import fwaveform
from Ricevitore.Ricevitore import receive_signal, receive_signal_optimal, receive_signal_exaustive
from ImpostazioneSistema.utilities import *
from scipy.signal import lfilter, butter
from CPM_Spettri import set_parameters
from matplotlib import pyplot as plt
# Simuliamo una comunicazione con modulazione, trasmissione su canale e demodulazione
if __name__ =='__main__':
# Shared parameters
n_symbols=100
T_symbol = 1e-4
f_0 = 1e5
T_sample = 1/(100*f_0)
M=2
# windowSize = 50 # filtering window size
modType = LRC
###################################################
# CPFSK
# h=0.25, L=1
###################################################
# MODULAZIONE
j=1
m=2
L=2
set_parameters(j, m, T_symbol, T_sample, L, f_0, M)
fwaveform(modType)
a,s = modulate_signal(n_symbols)
# TRASMISSIONE SU CANALE
# r = s + noise
r = s
# RICEZIONE E RICOSTRUZIONE DELLA SEQUENZA
a_hat = receive_signal(r, 10)
# Ricostruzione esaustiva (altissima complessità. Tenere n_symbols basso)
# a_hat = receive_signal_exaustive(r)
# _, s_1 = modulate_signal(n_symbols, a_hat)
# print('Sequenza vera:',a, 'Correlazione:', (s@s.T)*T_sample)
# print('Sequenza stimata:',a_hat, 'Correlazione:', (s_1@s.T)*T_sample)
plt.plot(s, alpha=0.3)
# plt.plot(s_1, '--', alpha=0.3)
plt.show()
# Ricostruzione per finestre con viterbi
# a_hat = receive_signal_optimal(r, T_symbol=T_symbol, T_sample=T_sample, N=30)
# STIMA Pe
right = (a == a_hat)
Pe = 1-right.sum()/len(right)
print('Stima della Pe:', Pe)