Skip to content
from scipy import interpolate
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
plt.style.use('ggplot')
def ff(x):
U_exp = [0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
I_exp = [0 , 2 , 4 , 3 , 1 , 0 , 1 , 3 , 5 , 7 , 5 , 2 , 0 , 2 , 5 , 9 , 11, 13, 9 , 5 , 1 , 0]
tck = interpolate.splrep(U_exp, I_exp)
return interpolate.splev(x, tck)
U_exp = [0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
I_exp = [0 , 2 , 4 , 3 , 1 , 0 , 1 , 3 , 5 , 7 , 5 , 2 , 0 , 2 , 5 , 9 , 11, 13, 9 , 5 , 1 , 0]
U_int = np.arange(0,21,0.1)
I_int = ff(U_int)
plt.scatter(U_exp, I_exp)
plt.scatter(U_int, I_int, s=2)
plt.title("Frank-Hertzov ekspetiment")
plt.ylabel("I (nA)")
plt.xlabel("U (V)")
plt.show()
podaci = pd.read_csv('Frank_Hertz_mjerenja_14april2023.csv', header=None)
podaci.columns = ["U(V)", "I(nA)"]
podaci.head()
def ff(exp_data,x):
U_exp = exp_data["U(V)"]
I_exp = exp_data["I(nA)"]
tck = interpolate.splrep(U_exp, I_exp)
return interpolate.splev(x, tck)
U_int = np.arange(0,60,0.1)
I_int = ff(podaci,U_int)
# PLOT DATA
U_exp = podaci["U(V)"]
I_exp = podaci["I(nA)"]
plt.scatter(U_exp, I_exp)
plt.scatter(U_int, I_int, s=2)
plt.title("Frank-Hertzov ekspetiment")
plt.ylabel("I (nA)")
plt.xlabel("U (V)")
plt.show()
interpolated_df = pd.DataFrame({'U(V)': U_int, 'I(nA)': I_int})
interpolated_df