dodan debug plot

master
Andrej 2021-05-06 15:06:43 +02:00
parent b67970a4ec
commit 428537aac3
1 changed files with 19 additions and 5 deletions

View File

@ -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)