mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-10-11 11:56:17 +00:00
Fix config and prediction revamp. (#259)
Extend single_test_optimization.py to be able to use real world data from new prediction classes. - .venv/bin/python single_test_optimization.py --real_world --verbose Can also be run with profiling "--profile". Add single_test_prediction.py to fetch predictions from remote prediction providers - .venv/bin/python single_test_prediction.py --verbose --provider-id PVForecastAkkudoktor | more - .venv/bin/python single_test_prediction.py --verbose --provider-id LoadAkkudoktor | more - .venv/bin/python single_test_prediction.py --verbose --provider-id ElecPriceAkkudoktor | more - .venv/bin/python single_test_prediction.py --verbose --provider-id BrightSky | more - .venv/bin/python single_test_prediction.py --verbose --provider-id ClearOutside | more Can also be run with profiling "--profile". single_test_optimization.py is an example on how to retrieve prediction data for optimization and use it to set up the optimization parameters. Changes: - load: Only one load provider at a time (vs. 5 before) Bug fixes: - prediction: only use providers that are enabled to retrieve or set data. - prediction: fix pre pendulum format strings - dataabc: Prevent error when resampling data with no datasets. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -7,7 +7,7 @@ Notes:
|
||||
from abc import abstractmethod
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import Field, computed_field
|
||||
from pydantic import Field
|
||||
|
||||
from akkudoktoreos.prediction.predictionabc import PredictionProvider, PredictionRecord
|
||||
from akkudoktoreos.utils.logutil import get_logger
|
||||
@@ -18,41 +18,8 @@ logger = get_logger(__name__)
|
||||
class LoadDataRecord(PredictionRecord):
|
||||
"""Represents a load data record containing various load attributes at a specific datetime."""
|
||||
|
||||
load0_mean: Optional[float] = Field(default=None, description="Load 0 mean value (W)")
|
||||
load0_std: Optional[float] = Field(default=None, description="Load 0 standard deviation (W)")
|
||||
load1_mean: Optional[float] = Field(default=None, description="Load 1 mean value (W)")
|
||||
load1_std: Optional[float] = Field(default=None, description="Load 1 standard deviation (W)")
|
||||
load2_mean: Optional[float] = Field(default=None, description="Load 2 mean value (W)")
|
||||
load2_std: Optional[float] = Field(default=None, description="Load 2 standard deviation (W)")
|
||||
load3_mean: Optional[float] = Field(default=None, description="Load 3 mean value (W)")
|
||||
load3_std: Optional[float] = Field(default=None, description="Load 3 standard deviation (W)")
|
||||
load4_mean: Optional[float] = Field(default=None, description="Load 4 mean value (W)")
|
||||
load4_std: Optional[float] = Field(default=None, description="Load 4 standard deviation (W)")
|
||||
|
||||
# Computed fields
|
||||
@computed_field # type: ignore[prop-decorator]
|
||||
@property
|
||||
def load_total_mean(self) -> float:
|
||||
"""Total load mean value (W)."""
|
||||
total_mean = 0.0
|
||||
for i in range(5):
|
||||
load_mean_attr = f"load{i}_mean"
|
||||
value = getattr(self, load_mean_attr)
|
||||
if value:
|
||||
total_mean += value
|
||||
return total_mean
|
||||
|
||||
@computed_field # type: ignore[prop-decorator]
|
||||
@property
|
||||
def load_total_std(self) -> float:
|
||||
"""Total load standard deviation (W)."""
|
||||
total_std = 0.0
|
||||
for i in range(5):
|
||||
load_std_attr = f"load{i}_std"
|
||||
value = getattr(self, load_std_attr)
|
||||
if value:
|
||||
total_std += value
|
||||
return total_std
|
||||
load_mean: Optional[float] = Field(default=None, description="Load mean value (W)")
|
||||
load_std: Optional[float] = Field(default=None, description="Load standard deviation (W)")
|
||||
|
||||
|
||||
class LoadProvider(PredictionProvider):
|
||||
@@ -86,17 +53,4 @@ class LoadProvider(PredictionProvider):
|
||||
return "LoadProvider"
|
||||
|
||||
def enabled(self) -> bool:
|
||||
logger.debug(
|
||||
f"LoadProvider ID {self.provider_id()} vs. config {self.config.load_providers}"
|
||||
)
|
||||
return self.provider_id() == self.config.load_providers
|
||||
|
||||
def loads(self) -> List[str]:
|
||||
"""Returns a list of key prefixes of the loads managed by this provider."""
|
||||
loads_prefix = []
|
||||
for i in range(self.config.load_count):
|
||||
load_provider_attr = f"load{i}_provider"
|
||||
value = getattr(self.config, load_provider_attr)
|
||||
if value == self.provider_id():
|
||||
loads_prefix.append(f"load{i}")
|
||||
return loads_prefix
|
||||
return self.provider_id() == self.config.load_provider
|
||||
|
Reference in New Issue
Block a user