visualize: Keep shape of plots the same on dst change Closes #185 (#203)

* Currently prediction hours are relative from current hour and don't
   adjust on daylight saving change.
 * ist_dst_wechsel now unused.
This commit is contained in:
Dominique Lasserre 2024-11-16 21:52:51 +01:00 committed by GitHub
parent fe9c8ecbbb
commit e936aaf134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 12 deletions

View File

@ -2,6 +2,7 @@ import datetime
import zoneinfo
# currently unused
def ist_dst_wechsel(tag: datetime.datetime, timezone="Europe/Berlin") -> bool:
"""Checks if Daylight Saving Time (DST) starts or ends on a given day."""
tz = zoneinfo.ZoneInfo(timezone)

View File

@ -1,12 +1,9 @@
import datetime
# Set the backend for matplotlib to Agg
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
from akkudoktoreos.class_sommerzeit import ist_dst_wechsel
from akkudoktoreos.config import AppConfig, SetupIncomplete
matplotlib.use("Agg")
@ -100,11 +97,7 @@ def visualisiere_ergebnisse(
#####################
plt.figure(figsize=(14, 10))
if ist_dst_wechsel(datetime.datetime.now()):
hours = np.arange(start_hour, config.eos.prediction_hours - 1)
else:
hours = np.arange(start_hour, config.eos.prediction_hours)
hours = np.arange(start_hour, config.eos.prediction_hours)
# Energy flow, grid feed-in, and grid consumption
plt.subplot(3, 2, 1)
@ -216,10 +209,7 @@ def visualisiere_ergebnisse(
ax1.set_title("AC/DC Charging and Discharge Overview")
ax1.grid(True)
if ist_dst_wechsel(datetime.datetime.now()):
hours = np.arange(start_hour, config.eos.prediction_hours - 1)
else:
hours = np.arange(start_hour, config.eos.prediction_hours)
hours = np.arange(start_hour, config.eos.prediction_hours)
pdf.savefig() # Save the current figure state to the PDF
plt.close() # Close the current figure to free up memory