Explorar el Código

Photodiode detection added

Tharmetharan Balendran hace 5 años
padre
commit
17670fda2d
Se han modificado 1 ficheros con 14 adiciones y 5 borrados
  1. 14 5
      models/optical_channel.py

+ 14 - 5
models/optical_channel.py

@@ -21,7 +21,7 @@ class OpticalChannel(defs.Channel):
         super().__init__(**kwargs)
         self.noise = 10 ** (noise_level / 10)
 
-        self.dispersion = dispersion
+        self.dispersion = dispersion # * 1e-24  # Converting from ps^2/km to s^2/km
         self.symbol_rate = symbol_rate
         self.symbol_period = 1 / self.symbol_rate
         self.sample_rate = sample_rate
@@ -60,10 +60,6 @@ class OpticalChannel(defs.Channel):
             plt.title('frequency domain (pre-distortion)')
             plt.show()
 
-        np.savetxt("foo.csv", f, delimiter=",")
-        np.savetxt("barr.csv", np.real(val_f), delimiter=",")
-        np.savetxt("bari.csv", np.imag(val_f), delimiter=",")
-
         # Apply distortion
         dist_val_f = val_f * np.exp(0.5j * self.dispersion * self.length * np.power(2 * math.pi * f, 2))
 
@@ -77,6 +73,11 @@ class OpticalChannel(defs.Channel):
 
         return t, val_t
 
+    def __photodiode_detection(self, values):
+        t = np.linspace(start=0, stop=values.size * self.sample_period, num=values.size)
+        val_t = np.power(np.absolute(values), 2)
+        return t, val_t
+
     def forward(self, values):
         # Converting APF representation to time-series
         t, val_t = self.__get_time_domain(values)
@@ -102,6 +103,14 @@ class OpticalChannel(defs.Channel):
             plt.title('time domain (post-distortion)')
             plt.show()
 
+        # Photodiode Detection
+        t, val_t = self.__photodiode_detection(val_t)
+
+        if self.show_graphs:
+            plt.plot(t, val_t)
+            plt.title('time domain (post-detection)')
+            plt.show()
+
         return t, val_t