Skip to content

Commit

Permalink
check if the resolution match
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
  • Loading branch information
victorgarcia98 committed Feb 5, 2024
1 parent 1d3ce81 commit 1e370c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion flexmeasures/data/models/planning/tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,13 @@ def test_battery_efficiency_quantity(
("storage efficiency 90%", 0.9), # regular value
("storage efficiency 110%", 1), # clip values that exceed 100%
("storage efficiency negative", 0), # clip negative values
# ("storage efficiency hourly", 0.974003) # this one fails.
pytest.param(
"storage efficiency hourly",
0.974003,
marks=pytest.mark.xfail(
reason="resampling storage efficiency is not supported"
),
), # this one fails.
# We should resample making sure that the efficiencies are equivalent.
# For example, 90% defined in 1h is equivalent to 97% in a 15min period (0.97^4≈0.9).
# Plans to support resampling efficiencies can be found here https://github.com/FlexMeasures/flexmeasures/issues/720
Expand Down
10 changes: 10 additions & 0 deletions flexmeasures/data/schemas/scheduling/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ def check_whether_targets_exceed_max_planning_horizon(self, data: dict, **kwargs
f"Target datetime exceeds {max_server_datetime}. Maximum scheduling horizon is {max_server_horizon}."
)

@validates("storage_efficiency")
def validate_storage_efficiency_resolution(self, unit: Sensor | ur.Quantity):
if (
isinstance(unit, Sensor)
and unit.event_resolution != self.sensor.event_resolution
):
raise ValidationError(
"Event resolution of the storage efficiency and the power sensor don't match. Resampling the storage efficiency is not supported."
)

@validates_schema
def check_redundant_efficiencies(self, data: dict, **kwargs):
"""
Expand Down

0 comments on commit 1e370c9

Please sign in to comment.