Files
gem/1.py
2026-02-02 16:52:12 +01:00

61 lines
1.5 KiB
Python

import plot_lib
import read_file
import editing_data
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal as signal
import os
voltage=[-8.9205,-6.704,-4.486,-2.266,-0.0205,2.225,4.445,6.662,8.88]
current = [-800, -600, -400, -200, 0, 200, 400, 600, 800]
voltage_ideal = np.array(current)*(10/(9*100))
y = [voltage_ideal, voltage]
x = current
labels = ["Ideale", "Messwerte"]
# plot_lib.plot_shared_xy(
# x=x,
# y_list=y,
# xlabel="Strom (mA)",
# ylabel="Spannung (V)",
# title="Stromwandler Kennlinie",
# show_points=True,
# save_path="prak1/Stromwandler-Kennlinie.svg",
# labels=labels
# )
figsize = (10, 6)
plt.figure(figsize=figsize)
plt.plot(x, y[1], label="Messwerte", color="purple", linestyle='--', marker='o', markersize=8)
plt.plot(x, y[0], label="Ideale", color="red", linestyle='-', marker='', markersize=8)
plt.xlim(-800, 800)
plt.ylim(-10, 10)
plt.xlabel(r"Zeit ($\mu s$)")
# plt.xlabel(r"Zeit (ms)")
plt.ylabel("Voltage (V)")
plt.title("Sprungantwort des Tiefpassfilters")
plt.grid()
plt.legend()
plt.tight_layout()
save_path=f"prak1/Stromwandler-Kennlinie.svg"
plt.savefig(save_path, format="svg")
plt.show()
# diff = plot_lib.plot_difference(
# x=x,
# y1=y[0],
# y2=y[1],
# return_sum=True,
# xlabel="Strom (mA)",
# ylabel="Spannung (V)",
# title="Stromwandler Messkennlinie - Idealkennlinie",
# show_points=True,
# save_path="prak1/Stromwandler-Vergleich-Kennlinie.svg"
# )
# print(diff)