modifizierung
This commit is contained in:
parent
4363b6ec29
commit
c47a3d76c5
2
Durschlag_Daten.csv
Normal file
2
Durschlag_Daten.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
2;3;4;5;mm
|
||||||
|
11;15.Jän;16.Jun;21.Jun;kV
|
||||||
|
@ -3,29 +3,20 @@ import numpy as np
|
|||||||
from matplotlib.colors import LinearSegmentedColormap
|
from matplotlib.colors import LinearSegmentedColormap
|
||||||
|
|
||||||
def analyze_paper_breakdown(lengths, voltages, ed_standard_values):
|
def analyze_paper_breakdown(lengths, voltages, ed_standard_values):
|
||||||
"""
|
|
||||||
Analysiert die Durchschlageigenschaften von Papier.
|
|
||||||
Zeigt Spannung und Feldstärke mit passenden Farben.
|
|
||||||
Farbliche Darstellung der Fläche zwischen Realwert und 5 kV/mm mit glatterem Verlauf.
|
|
||||||
Hervorhebung des ED-Real-Verlaufs im unteren Graphen.
|
|
||||||
"""
|
|
||||||
|
|
||||||
lengths = np.array(lengths)
|
lengths = np.array(lengths)
|
||||||
voltages = np.array(voltages)
|
voltages = np.array(voltages)
|
||||||
ed_real = voltages / lengths
|
ed_real = voltages / lengths
|
||||||
|
|
||||||
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 8), sharex=True)
|
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 8), sharex=True)
|
||||||
|
|
||||||
# Farben für die Standardwerte definieren
|
|
||||||
colors = ['red', 'green', 'purple', 'orange', 'brown', 'cyan', 'magenta', 'olive']
|
colors = ['red', 'green', 'purple', 'orange', 'brown', 'cyan', 'magenta', 'olive']
|
||||||
if len(ed_standard_values) > len(colors):
|
if len(ed_standard_values) > len(colors):
|
||||||
import itertools
|
import itertools
|
||||||
colors = list(itertools.islice(itertools.cycle(colors), len(ed_standard_values)))
|
colors = list(itertools.islice(itertools.cycle(colors), len(ed_standard_values)))
|
||||||
|
|
||||||
# Farbpalette für den Verlauf erstellen (Grün zu Dunkelrot)
|
# Feste rote Farbe
|
||||||
cmap = LinearSegmentedColormap.from_list("mycmap", ["green", "darkred"], N=500) #5x mehr Stufen
|
red_color = 'red'
|
||||||
|
|
||||||
# Spannung plotten
|
|
||||||
ax1.plot(lengths, voltages, label="U (gemessen)", marker='o', linestyle='-', color='blue')
|
ax1.plot(lengths, voltages, label="U (gemessen)", marker='o', linestyle='-', color='blue')
|
||||||
|
|
||||||
for i, ed_standard in enumerate(ed_standard_values):
|
for i, ed_standard in enumerate(ed_standard_values):
|
||||||
@ -34,34 +25,36 @@ def analyze_paper_breakdown(lengths, voltages, ed_standard_values):
|
|||||||
|
|
||||||
if ed_standard == 5:
|
if ed_standard == 5:
|
||||||
deviation = u_erwartung - voltages
|
deviation = u_erwartung - voltages
|
||||||
# Farbliche Darstellung der Fläche zwischen Realwert und 5 kV/mm mit glatterem Verlauf
|
mask = (ed_real >= 4) & (ed_real <= 6)
|
||||||
for k in range(len(lengths)):
|
for k in np.where(mask)[0]:
|
||||||
if ed_real[k] > 5:
|
x_vals = lengths[k:k+2]
|
||||||
rel_dist = (ed_real[k] - 5)
|
if len(x_vals) == 2:
|
||||||
else:
|
|
||||||
rel_dist = (5 - ed_real[k])
|
|
||||||
|
|
||||||
color_index = min(499, int(rel_dist * 250)) #Angepasst an die erhöhte Stufenzahl
|
|
||||||
|
|
||||||
if 4 <= ed_real[k] <= 6:
|
|
||||||
if deviation[k] > 0:
|
if deviation[k] > 0:
|
||||||
ax1.fill_between(lengths[k:k+2], voltages[k:k+2], u_erwartung[k:k+2], color=cmap(color_index), alpha=0.5, zorder=5)
|
ax1.fill_between(x_vals, voltages[k:k+2], u_erwartung[k:k+2], color=red_color, alpha=0.5, zorder=5)
|
||||||
elif deviation[k] < 0:
|
elif deviation[k] < 0:
|
||||||
ax1.fill_between(lengths[k:k+2], u_erwartung[k:k+2], voltages[k:k+2], color=cmap(color_index), alpha=0.5, zorder=5)
|
ax1.fill_between(x_vals, u_erwartung[k:k+2], voltages[k:k+2], color=red_color, alpha=0.5, zorder=5)
|
||||||
|
#Füllen im unteren Graphen
|
||||||
|
ed_5 = np.full_like(lengths, 5) # Erzeugt ein Array mit dem Wert 5
|
||||||
|
for k in np.where(mask)[0]:
|
||||||
|
x_vals = lengths[k:k+2]
|
||||||
|
if len(x_vals) == 2:
|
||||||
|
if ed_real[k] > 5:
|
||||||
|
ax2.fill_between(x_vals, ed_5[k:k+2], ed_real[k:k+2], color=red_color, alpha=0.5, zorder=5)
|
||||||
|
elif ed_real[k] < 5:
|
||||||
|
ax2.fill_between(x_vals, ed_real[k:k+2],ed_5[k:k+2], color=red_color, alpha=0.5, zorder=5)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ax1.set_ylabel("Spannung [kV]")
|
ax1.set_ylabel("Spannung [kV]")
|
||||||
ax1.set_title("Durchschlageigenschaften in Abhängigkeit von Materialstärke")
|
ax1.set_title("Durchschlageigenschaften in Abhängigkeit von Materialstärke")
|
||||||
|
|
||||||
# Legende anpassen (Duplikate entfernen)
|
|
||||||
handles1, labels1 = ax1.get_legend_handles_labels()
|
handles1, labels1 = ax1.get_legend_handles_labels()
|
||||||
by_label = dict(zip(labels1, handles1))
|
by_label = dict(zip(labels1, handles1))
|
||||||
ax1.legend(by_label.values(), by_label.keys(), loc='upper left')
|
ax1.legend(by_label.values(), by_label.keys(), loc='upper left')
|
||||||
|
|
||||||
ax1.grid(True)
|
ax1.grid(True)
|
||||||
|
|
||||||
# Durchschlagsfeldstärke plotten MIT Hervorhebung
|
ax2.plot(lengths, ed_real, label="ED (gemessen)", marker='s', color='blue', linestyle='-')
|
||||||
ax2.plot(lengths, ed_real, label="ED (gemessen)", marker='s', color='blue', linestyle='-', linewidth=3, zorder=10) #Dickere Linie, oberste Ebene
|
|
||||||
|
|
||||||
for i, ed_standard in enumerate(ed_standard_values):
|
for i, ed_standard in enumerate(ed_standard_values):
|
||||||
ax2.plot(lengths, np.full_like(lengths, ed_standard), label=f"ED (Erwartung, {ed_standard} kV/mm)", linestyle='--', color=colors[i])
|
ax2.plot(lengths, np.full_like(lengths, ed_standard), label=f"ED (Erwartung, {ed_standard} kV/mm)", linestyle='--', color=colors[i])
|
||||||
|
|
||||||
@ -71,6 +64,7 @@ def analyze_paper_breakdown(lengths, voltages, ed_standard_values):
|
|||||||
ax2.grid(True)
|
ax2.grid(True)
|
||||||
|
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
|
plt.show()
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
# Beispieldaten
|
# Beispieldaten
|
||||||
@ -80,7 +74,6 @@ ed_standard_values = [4, 5, 6]
|
|||||||
|
|
||||||
# Analyse und Anzeige
|
# Analyse und Anzeige
|
||||||
fig = analyze_paper_breakdown(papier_lengths, papier_voltages, ed_standard_values)
|
fig = analyze_paper_breakdown(papier_lengths, papier_voltages, ed_standard_values)
|
||||||
plt.show()
|
|
||||||
|
|
||||||
papier_ed_real = np.array(papier_voltages) / np.array(papier_lengths)
|
papier_ed_real = np.array(papier_voltages) / np.array(papier_lengths)
|
||||||
print(f"Gemessene Durchschlagsfeldstärken (ED-Real): {papier_ed_real} kV/mm")
|
print(f"Gemessene Durchschlagsfeldstärken (ED-Real): {papier_ed_real} kV/mm")
|
||||||
Loading…
Reference in New Issue
Block a user