浏览代码

resolved conflicts

Tharmetharan Balendran 5 年之前
父节点
当前提交
fcd0f1d50b
共有 1 个文件被更改,包括 16 次插入2 次删除
  1. 16 2
      models/optical_channel.py

+ 16 - 2
models/optical_channel.py

@@ -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))