Compute Error Between S Parameter Matrices

[1]:
import matplotlib.pyplot as plt
import numpy as np

import skrf as rf

Load data

[2]:
ns = rf.networkSet.NetworkSet.from_zip("LFCN-2352+_S2P.zip")
ns.plot_s_db()
plt.legend(loc="lower center", ncols=2, fontsize="x-small")
plt.grid()
plt.ylim(-40, 0)
plt.xlim(0, 50e9)
plt.title("LFCN-2352+")
[2]:
Text(0.5, 1.0, 'LFCN-2352+')
../../_images/examples_networks_Compute_Error_Between_S_Parameter_Matrices_3_1.png

Compute Error and Plot Results

[3]:
error_functions = [
    "average_l1_norm",
    "average_l2_norm",
    "maximum_l1_norm",
    "average_normalized_l1_norm",
]

for ef in error_functions:
    error = rf.network.s_error(ntwkA=ns[2], ntwkB=ns[1], error_function=ef)
    plt.plot(ns[2].frequency.f_scaled, 20 * np.log10(error), label=ef)

plt.legend(fontsize="small", ncols=2, loc="lower center")
plt.grid()
plt.ylim(-50, 0)
plt.xlim(0, 50000)
plt.title(f"Error Between {ns[2].name} and {ns[1].name}", fontsize="small")
plt.xlabel("Frequency (MHz)")
[3]:
Text(0.5, 0, 'Frequency (MHz)')
../../_images/examples_networks_Compute_Error_Between_S_Parameter_Matrices_5_1.png