mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-01-12 13:46:17 +00:00
fix: load prediction adjustment with measurement in kwh (#826)
Use load energy meter reading in kWh for load prediction adjustment. Before the reading was falsely regarded to be in Wh. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -176,7 +176,7 @@ class Measurement(SingletonMixin, DataImportMixin, DataSequence):
|
||||
logger.debug(debug_msg)
|
||||
return energy_array
|
||||
|
||||
def load_total(
|
||||
def load_total_kwh(
|
||||
self,
|
||||
start_datetime: Optional[DateTime] = None,
|
||||
end_datetime: Optional[DateTime] = None,
|
||||
@@ -207,7 +207,7 @@ class Measurement(SingletonMixin, DataImportMixin, DataSequence):
|
||||
if end_datetime is None:
|
||||
end_datetime = self[-1].date_time
|
||||
size = self._interval_count(start_datetime, end_datetime, interval)
|
||||
load_total_array = np.zeros(size)
|
||||
load_total_kwh_array = np.zeros(size)
|
||||
# Loop through all loads
|
||||
if isinstance(self.config.measurement.load_emr_keys, list):
|
||||
for key in self.config.measurement.load_emr_keys:
|
||||
@@ -219,11 +219,11 @@ class Measurement(SingletonMixin, DataImportMixin, DataSequence):
|
||||
interval=interval,
|
||||
)
|
||||
# Add calculated load to total load
|
||||
load_total_array += load_array
|
||||
debug_msg = f"Total load '{key}' calculation: {load_total_array}"
|
||||
load_total_kwh_array += load_array
|
||||
debug_msg = f"Total load '{key}' calculation: {load_total_kwh_array}"
|
||||
logger.debug(debug_msg)
|
||||
|
||||
return load_total_array
|
||||
return load_total_kwh_array
|
||||
|
||||
|
||||
def get_measurement() -> Measurement:
|
||||
|
||||
@@ -124,23 +124,23 @@ class LoadAkkudoktorAdjusted(LoadAkkudoktor):
|
||||
compare_end = self.measurement.max_datetime
|
||||
compare_interval = to_duration("1 hour")
|
||||
|
||||
load_total_array = self.measurement.load_total(
|
||||
load_total_kwh_array = self.measurement.load_total_kwh(
|
||||
start_datetime=compare_start,
|
||||
end_datetime=compare_end,
|
||||
interval=compare_interval,
|
||||
)
|
||||
compare_dt = compare_start
|
||||
for i in range(len(load_total_array)):
|
||||
load_total = load_total_array[i]
|
||||
for i in range(len(load_total_kwh_array)):
|
||||
load_total_wh = load_total_kwh_array[i] * 1000
|
||||
# Extract mean (index 0) and standard deviation (index 1) for the given day and hour
|
||||
# Day indexing starts at 0, -1 because of that
|
||||
hourly_stats = data_year_energy[compare_dt.day_of_year - 1, :, compare_dt.hour]
|
||||
weight = 1 / ((compare_end - compare_dt).days + 1)
|
||||
if compare_dt.day_of_week < 5:
|
||||
weekday_adjust[compare_dt.hour] += (load_total - hourly_stats[0]) * weight
|
||||
weekday_adjust[compare_dt.hour] += (load_total_wh - hourly_stats[0]) * weight
|
||||
weekday_adjust_weight[compare_dt.hour] += weight
|
||||
else:
|
||||
weekend_adjust[compare_dt.hour] += (load_total - hourly_stats[0]) * weight
|
||||
weekend_adjust[compare_dt.hour] += (load_total_wh - hourly_stats[0]) * weight
|
||||
weekend_adjust_weight[compare_dt.hour] += weight
|
||||
compare_dt += compare_interval
|
||||
# Calculate mean
|
||||
|
||||
Reference in New Issue
Block a user