From e936aaf1348e53b94ff03cb8904e9a41fd3197c9 Mon Sep 17 00:00:00 2001 From: Dominique Lasserre Date: Sat, 16 Nov 2024 21:52:51 +0100 Subject: [PATCH] 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. --- src/akkudoktoreos/class_sommerzeit.py | 1 + src/akkudoktoreos/visualize.py | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/akkudoktoreos/class_sommerzeit.py b/src/akkudoktoreos/class_sommerzeit.py index 7cd6341..2693362 100644 --- a/src/akkudoktoreos/class_sommerzeit.py +++ b/src/akkudoktoreos/class_sommerzeit.py @@ -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) diff --git a/src/akkudoktoreos/visualize.py b/src/akkudoktoreos/visualize.py index 538796b..01af1bf 100644 --- a/src/akkudoktoreos/visualize.py +++ b/src/akkudoktoreos/visualize.py @@ -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