|
|
@@ -97,10 +97,27 @@ class OpticalChannel(defs.Channel):
|
|
|
val_t = np.power(np.absolute(values), 2)
|
|
|
return t, val_t
|
|
|
|
|
|
+ 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)
|
|
|
|
|
|
+ self.eye_diagram(t, val_t)
|
|
|
+ plt.title('Eye Diagram of "time domain (raw)"')
|
|
|
+ plt.show()
|
|
|
+
|
|
|
if self.show_graphs:
|
|
|
plt.plot(t, val_t)
|
|
|
plt.title('time domain (raw)')
|
|
|
@@ -122,6 +139,10 @@ class OpticalChannel(defs.Channel):
|
|
|
plt.title('time domain (post-distortion)')
|
|
|
plt.show()
|
|
|
|
|
|
+ self.eye_diagram(t, val_t)
|
|
|
+ plt.title('Eye Diagram of "time domain (post-distortion)"')
|
|
|
+ plt.show()
|
|
|
+
|
|
|
# Photodiode Detection
|
|
|
t, val_t = self.__photodiode_detection(val_t)
|
|
|
|
|
|
@@ -166,7 +187,6 @@ if __name__ == '__main__':
|
|
|
channel = OpticalChannel(noise_level=-10, dispersion=-21.7, symbol_rate=10e9,
|
|
|
sample_rate=400e9, length=100, 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))
|