In [23]:
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

# Larger figure size
fig_size = [14, 8]
plt.rcParams['figure.figsize'] = fig_size

freq = 0
mag_db = 1
phase_deg = 2

file = '/home/daniel/vbox/mains-choke6.csv'
file = '/home/daniel/vbox/middle-choke.csv'
data = np.loadtxt(file, skiprows=2, delimiter=',')

plt.plot(data[:, freq], data[:, mag_db]);



In [26]:
R = (100*10**(-data[:, mag_db]/20))/(np.sqrt(1+(np.tan(data[:,phase_deg]/57.29578))**2))-100
X = -(R+100)*np.tan(data[:, phase_deg]/57.29578)
Z = np.sqrt(R**2 + X**2)

plt.plot(data[:, freq]/1e6, Z, data[:, freq]/1e6, R, 'red')
plt.legend(['Z', 'R'])
plt.xlabel('Frequency (MHz)')
plt.ylabel('Impedance (Ohms)')
plt.xticks([1.8, 3.7, 7.1,10.1, 14.2, 18.1, 21.2, 24.9, 28.5])
plt.yticks(np.arange(0,6e3,1e3))
plt.ylim([0, 6e3])
plt.grid()
plt.title('Resistance and impedance');



In [25]:
plt.plot(data[:, freq]/1e6, X)
plt.legend('X')
plt.xlabel('Frequency (MHz)')
plt.ylabel('Reactance (Ohms)')
plt.xticks([1.8, 3.7, 7.1,10.1, 14.2, 18.1, 21.2, 24.9, 28.5])
plt.grid()
plt.title('Reactance');