Commit cc238aca authored by Carl Magnus Meier's avatar Carl Magnus Meier
Browse files

correct plots

parent 750fe5bb
......@@ -56,18 +56,18 @@ def check_validity(value, next_values):
return False
return True
def voltage_tief(x_value,Ue, RC):
w = 2*np.pi*x_value
return Ue/(np.sqrt(1 + w**2 * RC**2))
def voltage_tief(f, Ue, a):
w = 2*np.pi*f
return Ue/(np.sqrt(1 + w**2 * a**2))
def voltage_hoch(x_value,Ue,RC):
w = 2*np.pi*x_value
return (Ue * w * RC)/(np.sqrt(1 + w**2 * RC**2))
def voltage_hoch(f, Ue,a):
w = 2*np.pi*f
return (Ue * w * a)/(np.sqrt(1 + w**2 * a**2))
def create_func_values(func, x, Ue, RC):
def create_func_values(func, x, Ue, a):
values = []
for x_value in x:
values.append(func(x_value, Ue, RC))
values.append(func(x_value, Ue, a))
return values
def fit_results_legend(var_names, c, cov):
......@@ -87,14 +87,14 @@ def fit_data(x, y, resistance, capacity, p2p, filter_type):
fit_Ue = fit_parameters[0]
fit_error_Ue = np.sqrt(fit_errors[0][0])
print("Eingangsspannung: " + str(fit_Ue) + " +- " + str(fit_error_Ue) + " mV")
fit_RC = fit_parameters[1]
fit_error_RC = np.sqrt(fit_errors[1][1])
print("Widerstand*Kapazität: " + str(fit_RC) + " +- " + str(fit_error_RC) + " OhmF")
fit_a = fit_parameters[1]
fit_error_a = np.sqrt(fit_errors[1][1])
print("Widerstand*Kapazität: " + str(fit_a) + " +- " + str(fit_error_a) + " OhmF")
print("Widerstand*Kapazität erwartet: " + str(resistance*capacity))
fitted_error_values = [create_func_values(fit_fuction, x, fit_Ue - fit_error_Ue, fit_RC - fit_error_RC), create_func_values(fit_fuction, x, fit_Ue + fit_error_Ue, fit_RC + fit_error_RC)]
fitted_values = create_func_values(fit_fuction, x, fit_Ue, fit_RC)
fitted_error_values = [create_func_values(fit_fuction, x, fit_Ue - fit_error_Ue, fit_a - fit_error_a), create_func_values(fit_fuction, x, fit_Ue + fit_error_Ue, fit_a + fit_error_a)]
fitted_values = create_func_values(fit_fuction, x, fit_Ue, fit_a)
fit_legend_text = fit_results_legend(["Ue", "RC"], fit_parameters, fit_errors)
fit_legend_text = fit_results_legend(["Ue", "a"], fit_parameters, fit_errors)
return fitted_values, fitted_error_values, fit_legend_text
......@@ -119,21 +119,23 @@ def plot_data(x, y, filename, pass_type):
y = [abs(y_value) for y_value in y]
resistance, capacity, title = get_data_from_filename(filename, pass_type)
x,y = process_data(x, y, pass_type)
x_processed,y_processed = process_data(x, y, pass_type)
fitted_values, fitted_error_values, fit_legend_text = fit_data(x, y, resistance, capacity, p2p, pass_type)
plt.fill_between(x, fitted_error_values[0], fitted_error_values[1], color = "green", alpha = 0.2)
plt.plot(x, fitted_values, color = "green", label = "Anpassungsfunktion" + fit_legend_text)
fitted_values, fitted_error_values, fit_legend_text = fit_data(x_processed, y_processed, resistance, capacity, p2p, pass_type)
plt.fill_between(x_processed, fitted_error_values[0], fitted_error_values[1], color = "green", alpha = 0.2)
plt.scatter(x_processed, y_processed, marker="x", label="Messwerte")
plt.plot(x_processed, fitted_values, color = "green", label = "Anpassungsfunktion" + fit_legend_text)
plt.scatter(x, y, marker="x", label="Messwerte")
# plt.scatter([time_to_frequency(x_value, x[0]) for x_value in x], [y_value/1000 for y_value in y], marker="x", label="Messwerte")
plt.xlabel("Frequenz f in Hz")
plt.ylabel("Spannung U in V")
plt.title(title)
plt.title(title.replace("mu", "µ"))
plt.legend()
plt.savefig("plots/" + title + ".png", dpi=500)
# plt.show()
plt.clf()
filenames = get_csv_file_names("data/Hochpass")
for filename in filenames:
......
plots/Hochpass 0.4 muF 1 kOhm.png

304 KB | W: | H:

plots/Hochpass 0.4 muF 1 kOhm.png

303 KB | W: | H:

plots/Hochpass 0.4 muF 1 kOhm.png
plots/Hochpass 0.4 muF 1 kOhm.png
plots/Hochpass 0.4 muF 1 kOhm.png
plots/Hochpass 0.4 muF 1 kOhm.png
  • 2-up
  • Swipe
  • Onion skin
plots/Hochpass 0.4 muF 100 Ohm.png

643 KB | W: | H:

plots/Hochpass 0.4 muF 100 Ohm.png

313 KB | W: | H:

plots/Hochpass 0.4 muF 100 Ohm.png
plots/Hochpass 0.4 muF 100 Ohm.png
plots/Hochpass 0.4 muF 100 Ohm.png
plots/Hochpass 0.4 muF 100 Ohm.png
  • 2-up
  • Swipe
  • Onion skin
plots/Hochpass 40 nF 1 kOhm.png

456 KB | W: | H:

plots/Hochpass 40 nF 1 kOhm.png

335 KB | W: | H:

plots/Hochpass 40 nF 1 kOhm.png
plots/Hochpass 40 nF 1 kOhm.png
plots/Hochpass 40 nF 1 kOhm.png
plots/Hochpass 40 nF 1 kOhm.png
  • 2-up
  • Swipe
  • Onion skin
plots/Hochpass 40 nF 10 kOhm.png

539 KB | W: | H:

plots/Hochpass 40 nF 10 kOhm.png

315 KB | W: | H:

plots/Hochpass 40 nF 10 kOhm.png
plots/Hochpass 40 nF 10 kOhm.png
plots/Hochpass 40 nF 10 kOhm.png
plots/Hochpass 40 nF 10 kOhm.png
  • 2-up
  • Swipe
  • Onion skin
plots/Tiefpass 0.4 muF 100 Ohm.png

884 KB | W: | H:

plots/Tiefpass 0.4 muF 100 Ohm.png

247 KB | W: | H:

plots/Tiefpass 0.4 muF 100 Ohm.png
plots/Tiefpass 0.4 muF 100 Ohm.png
plots/Tiefpass 0.4 muF 100 Ohm.png
plots/Tiefpass 0.4 muF 100 Ohm.png
  • 2-up
  • Swipe
  • Onion skin
plots/Tiefpass 40 nF 1 kOhm.png

737 KB | W: | H:

plots/Tiefpass 40 nF 1 kOhm.png

235 KB | W: | H:

plots/Tiefpass 40 nF 1 kOhm.png
plots/Tiefpass 40 nF 1 kOhm.png
plots/Tiefpass 40 nF 1 kOhm.png
plots/Tiefpass 40 nF 1 kOhm.png
  • 2-up
  • Swipe
  • Onion skin
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment