Now we are ready for measuring the antenna impedance. First, a dummy load is used as a DUT.
You see that Z(DUT)=49.64-0.50j [ohm], and VSWR=1.01.
The DUT is an open circuit.
Since V2/V1 is 2.0036, which exceeds the maximum value of 2.0, Z(DUT) is not obtained correctly.
Finally, my dipole antenna for 40m band with stub match removed.
Now Z(DUT)=5.21+j14.39 [ohm], and VSWR=10.38.
import numpy as np
import pylab as pl
from scipy.optimize import curve_fit
def sinfunc(x,a,b,c,d):
# positive c means graph in right
return a*np.sin((x-c)*(2.0*np.pi/b))+d
def findamp(x):
return (max(x)-min(x))/2.0
def find0cross(x):
n=0
while x[n] >= 0: # skip while positive
n+=1
while x[n] < 0: # skip while negative
n+=1
n1=n # 1st neg to pos transition
n+=10 # skip a little bit
while x[n] >= 0: # skip while positive
n+=1
while x[n] < 0: # skip while negative
n+=1 # 2nd neg to pos transition
n2=n
return [n1, n2]
t, v1, v2 = np.loadtxt('7026kHzAnt.csv', unpack=True, delimiter=',')
#v1=3456*sin(t*(2.0*np.pi/444)+0.2)-111.1
#v2=4321*cos(t*(2.0*np.pi/444)+0.2)+222.2
fig=pl.figure(figsize=(12,8),dpi=75)
axes=fig.add_axes([0.1,0.1,0.8,0.8])
axes.plot(t,v1,'g--',lw=4)
axes.plot(t,v2,'b--',lw=4)
axes.set_xlabel('time')
axes.set_ylabel('Voltage')
axes.set_title('7MHz Dipole')
a1=findamp(v1)
a2=findamp(v2)
n11, n12 = find0cross(v1)
n21, n22 = find0cross(v2)
p1=n12-n11
p2=n22-n21
pave=(p1+p2)/2
o1=0.0
o2=0.0
guess1=[a1,pave,n11,o1]
guess2=[a2,pave,n21,o2]
fitpars1, covmat1 = curve_fit(sinfunc,t,v1,guess1)
fitpars2, covmat2 = curve_fit(sinfunc,t,v2,guess2)
axes.plot(t,sinfunc(t, *fitpars1),'r')
axes.plot(t,sinfunc(t, *fitpars2),'r')
axes.grid(True)
vratio=fitpars2[0]/fitpars1[0]
# positive c means graph in right, or delay is positive
phase2delay=2.0*np.pi*((fitpars2[2]-fitpars1[2])/((fitpars1[1]+fitpars2[1])/2.0))
phase2advance=-phase2delay
z0=50.0+0.0j
cv1=1.0+0.0j
cv2=vratio*(cos(phase2advance)+sin(phase2advance)*1.0j)
cvr=2.0*cv1-cv2
cz=z0*(cv2/cvr)
gamma=(cz-z0)/(cz+z0)
swr=(1+abs(gamma))/(1-abs(gamma))
print gamma, swr
cvfwd=cv1
cvrfl=cv2-cv1
gamma2=cvrfl/cvfwd
print gamma2
print z0,cv1,cv2,cvr,cz
print n11,n12,p1
print n21,n22,p2
print guess1, guess2
print fitpars1, fitpars2
print np.sqrt(np.diag(covmat1)), np.sqrt(np.diag(covmat2))
print "V2(blue)/V1(green) =",vratio
print "V2(blue) phase advance against V1(green)=",phase2advance*360.0/(2.0*np.pi), "deg. (V2 is in advance if positive)"