modified: add phase responses

This commit is contained in:
mayge
2025-09-22 01:30:46 -04:00
parent 9c68dbbae9
commit 4dfe933f39

View File

@@ -166,7 +166,7 @@ class BasicBasisQR:
if __name__ == "__main__":
network = rf.Network("/tmp/paramer/simulation/3000/3000.s2p")
K = 100
K = 10
H11,freqs = auto_select([network.y[i][0][0] for i in range(2,len(network.y))],network.f[2:],max_points=20)
poles = generate_starting_poles(2,beta_min=freqs[0]/1.1,beta_max=freqs[-1]*1.1)
@@ -212,37 +212,45 @@ if __name__ == "__main__":
import matplotlib.pyplot as plt
fig, axes = plt.subplots(3, 2, figsize=(15, 16), sharex=False)
ax0 = axes[0][0]
ax0.plot(network.f[2:], np.abs([network.y[i][0][0] for i in range(2,len(network.y))]), 'o', ms=4, color='red', label='Samples')
ax0.plot(network.f[2:], np.abs(H11_evaluated), '-', lw=2, color='k', label='Fit')
ax0.plot(freqs, np.abs(H11), 'x', ms=4, color='blue', label='Input Samples')
ax0.set_title("Response i=0, j=0")
ax0.set_ylabel("Magnitude")
ax0.legend(loc="best")
ax00 = axes[0][0]
ax00.plot(network.f[2:], np.abs([network.y[i][0][0] for i in range(2,len(network.y))]), 'o', ms=4, color='red', label='Samples')
ax00.plot(network.f[2:], np.abs(H11_evaluated), '-', lw=2, color='k', label='Fit')
ax00.plot(freqs, np.abs(H11), 'x', ms=4, color='blue', label='Input Samples')
ax00.set_title("Response i=0, j=0")
ax00.set_ylabel("Magnitude")
ax00.legend(loc="best")
ax1 = axes[1][0]
ax1.plot(least_squares_condition, label='Least Squares Condition')
ax1.set_title("least_squares_condition")
ax1.set_ylabel("Magnitude")
ax1.legend(loc="best")
ax01 = axes[0][1]
ax01.set_title("Response i=0, j=0")
ax01.set_ylabel("Phase (deg)")
ax01.plot(network.f[2:], np.angle([network.y[i][0][0] for i in range(2,len(network.y))],deg=True), 'o', ms=4, color='red', label='Samples')
ax01.plot(network.f[2:], np.angle(H11_evaluated,deg=True), '-', lw=2, color='k', label='Fit')
ax01.plot(freqs, np.angle(H11,deg=True), 'x', ms=4, color='blue', label='Input Samples')
ax01.legend(loc="best")
ax2 = axes[1][1]
ax2.plot(least_squares_rms_error, label='Least Squares RMS Error')
ax2.set_title("least_squares_rms_error")
ax2.set_ylabel("Magnitude")
ax2.legend(loc="best")
ax10 = axes[1][0]
ax10.plot(least_squares_condition, label='Least Squares Condition')
ax10.set_title("least_squares_condition")
ax10.set_ylabel("Magnitude")
ax10.legend(loc="best")
ax3 = axes[2][0]
ax3.plot(eigenval_condition, label='Eigenvalue Condition')
ax3.set_title("eigenval_condition")
ax3.set_ylabel("Magnitude")
ax3.legend(loc="best")
ax11 = axes[1][1]
ax11.plot(least_squares_rms_error, label='Least Squares RMS Error')
ax11.set_title("least_squares_rms_error")
ax11.set_ylabel("Magnitude")
ax11.legend(loc="best")
ax4 = axes[2][1]
ax4.plot(eigenval_rms_error, label='Eigenvalue RMS Error')
ax4.set_title("eigenval_rms_error")
ax4.set_ylabel("Magnitude")
ax4.legend(loc="best")
ax20 = axes[2][0]
ax20.plot(eigenval_condition, label='Eigenvalue Condition')
ax20.set_title("eigenval_condition")
ax20.set_ylabel("Magnitude")
ax20.legend(loc="best")
ax21 = axes[2][1]
ax21.plot(eigenval_rms_error, label='Eigenvalue RMS Error')
ax21.set_title("eigenval_rms_error")
ax21.set_ylabel("Magnitude")
ax21.legend(loc="best")
fig.tight_layout()
plt.savefig(f"basic_basis_QR.png")