Example #1
0
#print('Fit 1:')
params, pcov = curve_fit(t,
                         f[3:-3],
                         unp.nominal_values(rel)[3:-3],
                         p0=[1e2, 10e-3, 1e-9],
                         maxfev=1000000000)
params = unc.correlated_values(params, pcov)

x = np.linspace(0, 1e6, 10000)
y_e = t2(x, *params)
y = unp.nominal_values(y_e)
q = y_e.max()

y_e = unp.std_devs(y_e)

writevalue(q, 'build/q.txt')
q_t = 1 / R_ges * unp.sqrt(L / C)
writevalue(q_t, 'build/q_t.txt')
#print(q, q_t)

drüber = np.where(y > 1 / np.sqrt(2) * q)[0]
drüber_p = np.where(y + y_e > 1 / np.sqrt(2) * q)[0]
drüber_m = np.where(y - y_e > 1 / np.sqrt(2) * q)[0]

#print(drüber_p[0], drüber_p[-1])
#print(drüber_m[0], drüber_m[-1])

ny_minus = unc.ufloat(x[drüber[0]], np.abs(x[drüber_p[0]] - x[drüber_m[0]]))
ny_plus = unc.ufloat(x[drüber[-1]], np.abs(x[drüber_p[-1]] - x[drüber_m[-1]]))

breite = ny_plus - ny_minus
Example #2
0
File: a.py Project: larsfu/ap
maxs_y = maxs[:, 1]
mins_x = mins[:, 0]
mins_y = mins[:, 1]


def envelope(t, tau, U):
    return U * np.exp(-t * tau)


paramsmax, pcovmax = curve_fit(envelope, maxs_x, maxs_y)
paramsmin, pcovmin = curve_fit(envelope, mins_x, mins_y)

tau, U0 = unc.correlated_values(paramsmax, pcovmax)
T_ex = 1 / tau
R_eff = 2 * L / T_ex
writevalue(T_ex * 1e6, 'build/T_ex.txt')
writevalue(R_eff, 'build/R_eff.txt')

#print(T_ex*1e6, R_eff)
R_ap = unp.sqrt(4 * L**2 / (L * C))
print(R_ap)
writevalue(R_ap, 'build/R_ap_t.txt')

x = np.linspace(0, t[len(t) - 1], 1000)
plt.xlim(0, 0.74)
plt.xlabel(r't/\si{\milli\second}')
plt.ylabel(r'U/\si{\volt}')
plt.plot(t * 1000, U, 'b-', label='Spannungsverlauf')
plt.plot(x * 1000, envelope(x, *paramsmax), 'r-', label='Einhüllende')
plt.plot(x * 1000, envelope(x, *paramsmin), 'r-')
plt.plot(maxs[:, 0] * 1000, maxs[:, 1], 'rx')
Example #3
0
    omega = 2 * np.pi * f
    return 1/np.sqrt((1-L*C*omega**2)**2 + omega**2 * R**2 * C**2)

f, U, U_C, a = np.genfromtxt('daten/c.txt', unpack=True)
a /= 1e6
phi = a / (1/f) * 2 * np.pi

maketable((f, U, U_C, a*1e6, phi), 'build/daten.txt')

#print('Fit 1:')
params, pcov = curve_fit(t, f, U_C/U, p0=[1e2, 10e-3, 1e-9], maxfev=10000)
x = np.linspace(0, 1e6, 1000000)
y = t(x, *params)
q = y.max()

writevalue(q, 'build/q.txt')
q_t = 1/R_ges * unp.sqrt(L/C)
writevalue(q_t , 'build/q_t.txt')
print(q, q_t)

drüber = np.where(y > 1/np.sqrt(2) * q)[0]
ny_minus = x[drüber[0]]
ny_plus = x[drüber[-1]]

breite = ny_plus - ny_minus
writevalue(breite, 'build/breite.txt')
breite_t = R_ges / L / (2*np.pi)
writevalue(breite_t, 'build/breite_t.txt')
print(breite, breite_t)

plt.plot(f, U_C/U, 'rx', label='Messwerte')
Example #4
0
File: cd.py Project: Fujnky/ap
phi = a / (1 / f) * 2 * np.pi
rel = U_C / U

# print('Fit 1:')
params, pcov = curve_fit(t, f[3:-3], unp.nominal_values(rel)[3:-3], p0=[1e2, 10e-3, 1e-9], maxfev=1000000000)
params = unc.correlated_values(params, pcov)

x = np.linspace(0, 1e6, 10000)
y_e = t2(x, *params)
y = unp.nominal_values(y_e)
q = y_e.max()

y_e = unp.std_devs(y_e)

writevalue(q, "build/q.txt")
q_t = 1 / R_ges * unp.sqrt(L / C)
writevalue(q_t, "build/q_t.txt")
# print(q, q_t)

drüber = np.where(y > 1 / np.sqrt(2) * q)[0]
drüber_p = np.where(y + y_e > 1 / np.sqrt(2) * q)[0]
drüber_m = np.where(y - y_e > 1 / np.sqrt(2) * q)[0]

# print(drüber_p[0], drüber_p[-1])
# print(drüber_m[0], drüber_m[-1])


ny_minus = unc.ufloat(x[drüber[0]], np.abs(x[drüber_p[0]] - x[drüber_m[0]]))
ny_plus = unc.ufloat(x[drüber[-1]], np.abs(x[drüber_p[-1]] - x[drüber_m[-1]]))
Example #5
0
File: a.py Project: Fujnky/ap
maxs_y = maxs[:, 1]
mins_x = mins[:, 0]
mins_y = mins[:, 1]


def envelope(t, tau, U):
    return U * np.exp(-t * tau)


paramsmax, pcovmax = curve_fit(envelope, maxs_x, maxs_y)
paramsmin, pcovmin = curve_fit(envelope, mins_x, mins_y)

tau, U0 = unc.correlated_values(paramsmax, pcovmax)
T_ex = 1 / tau
R_eff = 2 * L / T_ex
writevalue(T_ex * 1e6, "build/T_ex.txt")
writevalue(R_eff, "build/R_eff.txt")

# print(T_ex*1e6, R_eff)
R_ap = unp.sqrt(4 * L ** 2 / (L * C))
print(R_ap)
writevalue(R_ap, "build/R_ap_t.txt")

x = np.linspace(0, t[len(t) - 1], 1000)
plt.xlim(0, 0.74)
plt.xlabel(r"t/\si{\milli\second}")
plt.ylabel(r"U/\si{\volt}")
plt.plot(t * 1000, U, "b-", label="Spannungsverlauf")
plt.plot(x * 1000, envelope(x, *paramsmax), "r-", label="Einhüllende")
plt.plot(x * 1000, envelope(x, *paramsmin), "r-")
plt.plot(maxs[:, 0] * 1000, maxs[:, 1], "rx")