|
|
@@ -108,6 +108,19 @@ class OpticalChannel(defs.Channel):
|
|
|
|
|
|
pass
|
|
|
|
|
|
+ # def eye_diagram(self, t, val_t, num_of_symbols=100):
|
|
|
+ # symbol_width = int(len(val_t)/num_of_symbols)
|
|
|
+ # time_scale = t[0:symbol_width]
|
|
|
+ # counter = 0
|
|
|
+ # l = 0
|
|
|
+ # u = symbol_width
|
|
|
+ # while counter < 100:
|
|
|
+ # symbol = val_t[l:u]
|
|
|
+ # plt.plot(time_scale, symbol)
|
|
|
+ # counter += 1
|
|
|
+ # l += symbol_width
|
|
|
+ # u += symbol_width
|
|
|
+
|
|
|
def forward(self, values):
|
|
|
# Converting APF representation to time-series
|
|
|
t, val_t = self.__get_time_domain(values)
|
|
|
@@ -142,6 +155,8 @@ class OpticalChannel(defs.Channel):
|
|
|
t_descision = self.sample_period * idx
|
|
|
|
|
|
if self.show_graphs:
|
|
|
+ self.__plot_eye(val_t)
|
|
|
+
|
|
|
plt.plot(t, val_t)
|
|
|
plt.title('time domain (post-detection)')
|
|
|
plt.show()
|
|
|
@@ -175,9 +190,8 @@ if __name__ == '__main__':
|
|
|
symbol_vals[:, 2] = 0
|
|
|
|
|
|
channel = OpticalChannel(noise_level=-20, dispersion=-21.7, symbol_rate=7e9,
|
|
|
- sample_rate=336e9, length=0, pulse_shape='rrcos', show_graphs=False)
|
|
|
+ sample_rate=336e9, length=0, pulse_shape='rcos', show_graphs=True)
|
|
|
v = channel.forward(symbol_vals)
|
|
|
-
|
|
|
rx = (v > 0.5).astype(int)
|
|
|
tru = np.sum(rx == symbol_vals[:, 0].astype(int))
|
|
|
print("Accuracy: {}".format(tru/num_of_symbols))
|