Browse Source

null frequency analysis

Tharmetharan Balendran 4 years ago
parent
commit
821da4cdf2
1 changed files with 26 additions and 4 deletions
  1. 26 4
      models/plots.py

+ 26 - 4
models/plots.py

@@ -8,7 +8,7 @@ from matplotlib import pyplot as plt
 import math
 
 
-def plot_e2e_spectrum(model_name=None, num_samples=10000):
+def plot_e2e_spectrum(model_name=None, num_samples=10000, plot_theoretical_nulls=False):
     '''
     Plot frequency spectrum of the output signal at the encoder
     @param model_name: The name of the model to import. If None, then the latest model will be imported.
@@ -37,8 +37,30 @@ def plot_e2e_spectrum(model_name=None, num_samples=10000):
     plt.plot(freq, np.fft.fft(lpf), 'x')
     plt.ylim((-500, 500))
     plt.xlim((-5e10, 5e10))
-    plt.show()
 
+    if plot_theoretical_nulls:
+        f_curr = np.sqrt(np.pi / (-params["dispersion_factor"] * params["fiber_length"])) / (2 * np.pi)
+        i = 1
+
+        plt.axvline(x=f_curr, color="black", linestyle="--", label="null frequency")
+        plt.axvline(x=-f_curr, color="black", linestyle="--")
+        plt.axvline(x=2*f_curr, color="red", linestyle="--", label="double of null frequency")
+        plt.axvline(x=-2*f_curr, color="red", linestyle="--")
+
+        while f_curr < params["lpf_cutoff"]:
+            f_curr = np.sqrt(((2 * i + 1) * np.pi) / (-params["dispersion_factor"] * params["fiber_length"])) / (2 * np.pi)
+
+            if 2 * f_curr < params["lpf_cutoff"]:
+                plt.axvline(x=2 * f_curr, color="red", linestyle="--")
+                plt.axvline(x=-2 * f_curr, color="red", linestyle="--")
+
+            plt.axvline(x=f_curr, color="black", linestyle="--")
+            plt.axvline(x=-f_curr, color="black", linestyle="--")
+            i += 1
+
+        plt.legend(loc=0)
+
+    plt.show()
 
 def plot_e2e_encoded_output(model_name=None):
     '''
@@ -86,5 +108,5 @@ def plot_e2e_encoded_output(model_name=None):
 
 
 if __name__ == '__main__':
-    plot_e2e_spectrum()
-    plot_e2e_encoded_output()
+    plot_e2e_spectrum('20210317-124015', plot_theoretical_nulls=True)
+    # plot_e2e_encoded_output()