2024-02-18 15:07:20 +01:00
|
|
|
import numpy as np
|
2024-03-03 10:46:46 +01:00
|
|
|
from modules.class_load_container import Gesamtlast # Stellen Sie sicher, dass dies dem tatsächlichen Importpfad entspricht
|
2024-03-03 18:32:47 +01:00
|
|
|
import matplotlib.pyplot as plt
|
2024-02-18 15:07:20 +01:00
|
|
|
|
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
def visualisiere_ergebnisse(gesamtlast, pv_forecast, strompreise, ergebnisse, discharge_hours, laden_moeglich, temperature, start_hour, prediction_hours):
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# 24h
|
|
|
|
#####################
|
2024-02-18 15:07:20 +01:00
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
# Last und PV-Erzeugung
|
|
|
|
plt.figure(figsize=(14, 14))
|
2024-03-03 18:32:47 +01:00
|
|
|
plt.subplot(3, 2, 1)
|
2024-03-25 14:40:48 +01:00
|
|
|
stunden = np.arange(0, prediction_hours)
|
2024-03-03 10:46:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Einzellasten plotten
|
|
|
|
for name, last_array in gesamtlast.lasten.items():
|
|
|
|
plt.plot(stunden, last_array, label=f'{name} (Wh)', marker='o')
|
|
|
|
|
|
|
|
# Gesamtlast berechnen und plotten
|
|
|
|
gesamtlast_array = gesamtlast.gesamtlast_berechnen()
|
|
|
|
plt.plot(stunden, gesamtlast_array, label='Gesamtlast (Wh)', marker='o', linewidth=2, linestyle='--')
|
|
|
|
plt.xlabel('Stunde')
|
|
|
|
plt.ylabel('Last (Wh)')
|
|
|
|
plt.title('Lastprofile')
|
2024-02-18 15:07:20 +01:00
|
|
|
plt.grid(True)
|
2024-03-03 10:46:46 +01:00
|
|
|
plt.legend()
|
2024-02-18 15:07:20 +01:00
|
|
|
|
2024-03-03 18:32:47 +01:00
|
|
|
|
2024-02-18 15:07:20 +01:00
|
|
|
# Strompreise
|
2024-02-25 16:47:28 +01:00
|
|
|
stundenp = np.arange(1, len(strompreise)+1)
|
2024-03-03 18:32:47 +01:00
|
|
|
plt.subplot(3, 2, 2)
|
2024-02-25 16:47:28 +01:00
|
|
|
plt.plot(stundenp, strompreise, label='Strompreis (€/Wh)', color='purple', marker='s')
|
2024-02-18 15:07:20 +01:00
|
|
|
plt.title('Strompreise')
|
|
|
|
plt.xlabel('Stunde des Tages')
|
2024-02-18 21:28:02 +01:00
|
|
|
plt.ylabel('Preis (€/Wh)')
|
2024-02-18 15:07:20 +01:00
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
# Strompreise
|
|
|
|
stundenp = np.arange(1, len(strompreise)+1)
|
|
|
|
plt.subplot(3, 2, 3)
|
|
|
|
plt.plot(stunden, pv_forecast, label='PV-Erzeugung (Wh)', marker='x')
|
|
|
|
plt.title('PV Forecast')
|
|
|
|
plt.xlabel('Stunde des Tages')
|
|
|
|
plt.ylabel('Wh')
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
2024-02-18 15:07:20 +01:00
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
# Temperatur Forecast
|
|
|
|
plt.subplot(3, 2, 4)
|
|
|
|
plt.title('Temperatur Forecast °C')
|
|
|
|
plt.plot(stunden, temperature, label='Temperatur °C', marker='x')
|
|
|
|
plt.xlabel('Stunde des Tages')
|
|
|
|
plt.ylabel('°C')
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Start_Hour
|
|
|
|
#####################
|
2024-03-03 18:32:47 +01:00
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
plt.figure(figsize=(14, 10))
|
|
|
|
stunden = np.arange(start_hour, prediction_hours)
|
2024-02-18 15:07:20 +01:00
|
|
|
# Eigenverbrauch, Netzeinspeisung und Netzbezug
|
2024-03-25 14:40:48 +01:00
|
|
|
plt.subplot(3, 2, 1)
|
2024-02-18 15:07:20 +01:00
|
|
|
plt.plot(stunden, ergebnisse['Eigenverbrauch_Wh_pro_Stunde'], label='Eigenverbrauch (Wh)', marker='o')
|
|
|
|
plt.plot(stunden, ergebnisse['Netzeinspeisung_Wh_pro_Stunde'], label='Netzeinspeisung (Wh)', marker='x')
|
|
|
|
plt.plot(stunden, ergebnisse['Netzbezug_Wh_pro_Stunde'], label='Netzbezug (Wh)', marker='^')
|
2024-03-25 14:40:48 +01:00
|
|
|
plt.plot(stunden, ergebnisse['Verluste_Pro_Stunde'], label='Verluste (Wh)', marker='^')
|
2024-02-18 15:07:20 +01:00
|
|
|
plt.title('Energiefluss pro Stunde')
|
|
|
|
plt.xlabel('Stunde')
|
|
|
|
plt.ylabel('Energie (Wh)')
|
|
|
|
plt.legend()
|
2024-03-03 18:32:47 +01:00
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plt.subplot(3, 2, 2)
|
|
|
|
plt.plot(stunden, ergebnisse['akku_soc_pro_stunde'], label='PV Akku (%)', marker='x')
|
|
|
|
plt.plot(stunden, ergebnisse['E-Auto_SoC_pro_Stunde'], label='E-Auto Akku (%)', marker='x')
|
2024-03-03 18:32:47 +01:00
|
|
|
plt.legend(loc='upper left')
|
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
ax1 = plt.subplot(3, 2, 3)
|
2024-03-03 18:32:47 +01:00
|
|
|
for hour, value in enumerate(discharge_hours):
|
2024-03-04 12:37:47 +01:00
|
|
|
#if value == 1:
|
|
|
|
ax1.axvspan(hour, hour+1, color='red',ymax=value, alpha=0.3, label='Entlademöglichkeit' if hour == 0 else "")
|
2024-03-03 18:32:47 +01:00
|
|
|
for hour, value in enumerate(laden_moeglich):
|
2024-03-04 12:37:47 +01:00
|
|
|
#if value == 1:
|
|
|
|
ax1.axvspan(hour, hour+1, color='green',ymax=value, alpha=0.3, label='Lademöglichkeit' if hour == 0 else "")
|
2024-03-03 18:32:47 +01:00
|
|
|
ax1.legend(loc='upper left')
|
2024-02-18 15:07:20 +01:00
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
|
2024-03-08 14:22:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-03 18:32:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
plt.grid(True)
|
|
|
|
plt.figure(figsize=(14, 10))
|
2024-02-18 15:07:20 +01:00
|
|
|
# Kosten und Einnahmen pro Stunde
|
2024-03-03 18:32:47 +01:00
|
|
|
plt.subplot(1, 2, 1)
|
2024-02-18 15:07:20 +01:00
|
|
|
plt.plot(stunden, ergebnisse['Kosten_Euro_pro_Stunde'], label='Kosten (Euro)', marker='o', color='red')
|
|
|
|
plt.plot(stunden, ergebnisse['Einnahmen_Euro_pro_Stunde'], label='Einnahmen (Euro)', marker='x', color='green')
|
|
|
|
plt.title('Finanzielle Bilanz pro Stunde')
|
|
|
|
plt.xlabel('Stunde')
|
|
|
|
plt.ylabel('Euro')
|
|
|
|
plt.legend()
|
2024-03-25 14:40:48 +01:00
|
|
|
|
2024-02-18 15:07:20 +01:00
|
|
|
|
|
|
|
# Zusammenfassende Finanzen
|
2024-03-25 14:40:48 +01:00
|
|
|
fig, ax1 = plt.subplots()
|
2024-02-18 15:07:20 +01:00
|
|
|
gesamtkosten = ergebnisse['Gesamtkosten_Euro']
|
2024-02-18 15:53:29 +01:00
|
|
|
gesamteinnahmen = ergebnisse['Gesamteinnahmen_Euro']
|
|
|
|
gesamtbilanz = ergebnisse['Gesamtbilanz_Euro']
|
2024-03-25 14:40:48 +01:00
|
|
|
labels = ['GesamtKosten [€]', 'GesamtEinnahmen [€]', 'GesamtBilanz [€]']
|
|
|
|
werte = [gesamtkosten, gesamteinnahmen, gesamtbilanz]
|
|
|
|
colors = ['red' if wert > 0 else 'green' for wert in werte]
|
|
|
|
|
|
|
|
ax1.bar(labels, werte, color=colors)
|
|
|
|
ax1.set_ylabel('Euro')
|
|
|
|
ax1.set_title('Finanzübersicht')
|
|
|
|
|
|
|
|
# Zweite Achse (ax2) für die Verluste, geteilt mit ax1
|
|
|
|
ax2 = ax1.twinx()
|
|
|
|
verluste = ergebnisse['Gesamt_Verluste']
|
|
|
|
ax2.bar('GesamtVerluste', verluste, color='blue')
|
|
|
|
ax2.set_ylabel('Verluste [Wh]', color='blue')
|
|
|
|
|
|
|
|
# Stellt sicher, dass die Achsenbeschriftungen der zweiten Achse in der gleichen Farbe angezeigt werden
|
|
|
|
ax2.tick_params(axis='y', labelcolor='blue')
|
|
|
|
|
2024-02-18 15:53:29 +01:00
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
# plt.title('Gesamtkosten')
|
|
|
|
# plt.ylabel('Euro')
|
2024-02-18 15:07:20 +01:00
|
|
|
|
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
# plt.legend()
|
|
|
|
# plt.grid(True)
|
2024-02-18 15:07:20 +01:00
|
|
|
|
2024-03-25 14:40:48 +01:00
|
|
|
# plt.tight_layout()
|
2024-02-18 15:07:20 +01:00
|
|
|
plt.show()
|
2024-02-18 15:53:29 +01:00
|
|
|
|