From 428537aac39e9c96e7d12858ea4cae0fe894c8d9 Mon Sep 17 00:00:00 2001 From: Andrej Date: Thu, 6 May 2021 15:06:43 +0200 Subject: [PATCH] dodan debug plot --- s2eps.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/s2eps.py b/s2eps.py index 1d286ba..691a6f2 100644 --- a/s2eps.py +++ b/s2eps.py @@ -2,6 +2,7 @@ import numpy as np from operator import itemgetter +import matplotlib.pyplot as plt def s2p_to_narray(file): """ prebere s2p file v narray. STOLPCI --> VRSTICE!!! """ @@ -25,14 +26,27 @@ def s_to_eps(s, L): X = (s11**2 - s21**2 + 1)/2/s11 G = X + np.sqrt(X**2 - 1) - if np.abs(G) > 1: - G = X - np.sqrt(X**2 - 1) + Gm = X - np.sqrt(X**2 - 1) + G[np.abs(G) > 1] = Gm[np.abs(G) > 1] + test_plot(f,G) P = (s11 + s21 - G)/(1-(s11+s21)*G) Lambda2 = - (1/2/np.pi/L * np.log(1/P))**2 #izmisli resitev za korene kompleksnega logaritma # argument korena mora biti 2*pi*n, kjer je n=L/lambda_g + test_plot(f,np.log(P)) - return + return measured_group_delay(f,P) -a=s2p_to_narray('20.s2p') +def measured_group_delay(f, P): + phase = np.unwrap(np.angle(P)) + test_plot(f,phase) + return -np.diff(phase)/np.diff(f)/2/np.pi + +def test_plot(x,y): + plt.plot(x,y) + plt.show() + +a=s2p_to_narray('teflon.s2p') b = narray_to_s(a) -s_to_eps(b,0,0,0) +locals().update(b) +c= s_to_eps(b,6e-2) +test_plot(f[:-1],c)