|
@@ -28,38 +28,43 @@ def plot_e2e_spectrum(model_name=None, num_samples=10000, plot_theoretical_nulls
|
|
|
|
|
|
|
|
# Pass the output of the encoder through LPF
|
|
# Pass the output of the encoder through LPF
|
|
|
lpf = DigitizationLayer(fs=params["fs"],
|
|
lpf = DigitizationLayer(fs=params["fs"],
|
|
|
- num_of_samples=params["cardinality"] * num_samples,
|
|
|
|
|
|
|
+ num_of_samples=params["samples_per_symbol"] * num_samples,
|
|
|
sig_avg=0)(a).numpy()
|
|
sig_avg=0)(a).numpy()
|
|
|
|
|
|
|
|
# Plot the frequency spectrum of the signal
|
|
# Plot the frequency spectrum of the signal
|
|
|
freq = np.fft.fftfreq(lpf.shape[-1], d=1 / params["fs"])
|
|
freq = np.fft.fftfreq(lpf.shape[-1], d=1 / params["fs"])
|
|
|
|
|
|
|
|
- plt.plot(freq, np.fft.fft(lpf), 'x')
|
|
|
|
|
- plt.ylim((-500, 500))
|
|
|
|
|
- plt.xlim((-5e10, 5e10))
|
|
|
|
|
|
|
+ plt.plot(freq, np.abs(np.fft.fft(lpf)), 'x')
|
|
|
|
|
+ plt.ylim((0, 500))
|
|
|
|
|
+ plt.xlim((0, 4e10))
|
|
|
|
|
|
|
|
if plot_theoretical_nulls:
|
|
if plot_theoretical_nulls:
|
|
|
f_curr = np.sqrt(np.pi / (-params["dispersion_factor"] * params["fiber_length"])) / (2 * np.pi)
|
|
f_curr = np.sqrt(np.pi / (-params["dispersion_factor"] * params["fiber_length"])) / (2 * np.pi)
|
|
|
i = 1
|
|
i = 1
|
|
|
|
|
|
|
|
|
|
+ print(f_curr)
|
|
|
|
|
+
|
|
|
plt.axvline(x=f_curr, color="black", linestyle="--", label="null frequency")
|
|
plt.axvline(x=f_curr, color="black", linestyle="--", label="null frequency")
|
|
|
plt.axvline(x=-f_curr, color="black", linestyle="--")
|
|
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="--", label="double of null frequency")
|
|
|
plt.axvline(x=-2*f_curr, color="red", linestyle="--")
|
|
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)
|
|
|
|
|
|
|
+ f_curr = np.sqrt((3 * 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="--")
|
|
|
|
|
|
|
+ print(f_curr)
|
|
|
|
|
+ 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.axvline(x=f_curr, color="black", linestyle="--")
|
|
|
|
|
+ plt.axvline(x=-f_curr, color="black", linestyle="--")
|
|
|
|
|
|
|
|
plt.legend(loc=0)
|
|
plt.legend(loc=0)
|
|
|
|
|
|
|
|
|
|
+ plt.title("Frequency Spectrum of transmitted signal")
|
|
|
|
|
+ plt.xlabel("Frequency")
|
|
|
|
|
+ plt.ylabel("Magnitude")
|
|
|
|
|
+ plt.tight_layout()
|
|
|
|
|
+ plt.savefig('encoder_spectrum.eps', format='eps')
|
|
|
plt.show()
|
|
plt.show()
|
|
|
|
|
|
|
|
def plot_e2e_encoded_output(model_name=None):
|
|
def plot_e2e_encoded_output(model_name=None):
|
|
@@ -94,7 +99,7 @@ def plot_e2e_encoded_output(model_name=None):
|
|
|
t = t / params["fs"]
|
|
t = t / params["fs"]
|
|
|
|
|
|
|
|
# Plot the concatenated symbols before and after LPF
|
|
# Plot the concatenated symbols before and after LPF
|
|
|
- plt.figure(figsize=(2 * params["messages_per_block"], 6))
|
|
|
|
|
|
|
+ plt.figure(figsize=(1.4*params["messages_per_block"], 4.5))
|
|
|
|
|
|
|
|
for i in range(1, params["messages_per_block"]):
|
|
for i in range(1, params["messages_per_block"]):
|
|
|
plt.axvline(x=t[i * params["samples_per_symbol"]], color='black')
|
|
plt.axvline(x=t[i * params["samples_per_symbol"]], color='black')
|
|
@@ -102,11 +107,20 @@ def plot_e2e_encoded_output(model_name=None):
|
|
|
plt.plot(t, lpf_out.numpy().T, label='optical field at tx')
|
|
plt.plot(t, lpf_out.numpy().T, label='optical field at tx')
|
|
|
plt.plot(t, chan_out.numpy().flatten(), label='optical field at rx')
|
|
plt.plot(t, chan_out.numpy().flatten(), label='optical field at rx')
|
|
|
plt.xlim((t.min(), t.max()))
|
|
plt.xlim((t.min(), t.max()))
|
|
|
- plt.title(str(val[0, :, 0]))
|
|
|
|
|
|
|
+ plt.title("Sample block of transmitted/received waveform")
|
|
|
|
|
+ print(str(val[0, :, 0]))
|
|
|
|
|
+ # plt.text(0, 0, str(val[0, :, 0]))
|
|
|
plt.legend(loc='upper right')
|
|
plt.legend(loc='upper right')
|
|
|
|
|
+ plt.tight_layout()
|
|
|
|
|
+ plt.savefig('sample_transmission_block.eps', format='eps')
|
|
|
plt.show()
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
- plot_e2e_spectrum('20210317-124015', plot_theoretical_nulls=True)
|
|
|
|
|
- # plot_e2e_encoded_output()
|
|
|
|
|
|
|
+ ae_model, params = load_model(model_name='20210502-135450')
|
|
|
|
|
+
|
|
|
|
|
+ ae_model.view_encoder()
|
|
|
|
|
+ # ae_model.view_sample_block()
|
|
|
|
|
+ #
|
|
|
|
|
+ plot_e2e_spectrum('20210502-135450', plot_theoretical_nulls=True)
|
|
|
|
|
+ # plot_e2e_encoded_output('20210502-135450')
|