Skip to content

Commit

Permalink
convert units to MW
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 Mar 11, 2024
1 parent 2f3ea42 commit 986ccb0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion documentation/features/scheduling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ With the flexibility context, we aim to describe the system in which the flexibl
- Description
* - ``inflexible-device-sensors``
- ``[3,4]``
- Power sensors that are relevant, but not flexible, such as a sensor recording rooftop solar power connected behind the main meter, whose production falls under the same contract as the flexible device(s) being scheduled. * Note:* For now, the inflexible-device-sensors need to have MW units.
- Power sensors that are relevant, but not flexible, such as a sensor recording rooftop solar power connected behind the main meter, whose production falls under the same contract as the flexible device(s) being scheduled.
* - ``consumption-price-sensor``
- ``5``
- The sensor that defines the price of consuming energy. This sensor can be recording market prices, but also CO₂ - whatever fits your optimization problem.
Expand Down
4 changes: 2 additions & 2 deletions flexmeasures/data/models/planning/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ def inflexible_devices(db, building) -> dict[str, Sensor]:
name="PV power sensor",
generic_asset=building,
event_resolution=timedelta(hours=1),
unit="kW",
unit="MW",
attributes={"capacity_in_mw": 2},
)
db.session.add(pv_sensor)
residual_demand_sensor = Sensor(
name="residual demand power sensor",
generic_asset=building,
event_resolution=timedelta(hours=1),
unit="kW",
unit="MW",
attributes={"capacity_in_mw": 2},
)
db.session.add(residual_demand_sensor)
Expand Down
8 changes: 5 additions & 3 deletions flexmeasures/data/models/planning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get_power_values(
beliefs_before: datetime | None,
sensor: Sensor,
) -> np.ndarray:
"""Get measurements or forecasts of an inflexible device represented by a power sensor.
"""Get measurements or forecasts of an inflexible device represented by a power sensor in MW.
If the requested schedule lies in the future, the returned data will consist of (the most recent) forecasts (if any exist).
If the requested schedule lies in the past, the returned data will consist of (the most recent) measurements (if any exist).
Expand Down Expand Up @@ -208,12 +208,14 @@ def get_power_values(
)
df = df.fillna(0)

series = convert_units(df.values, sensor.unit, "MW")

if sensor.get_attribute(
"consumption_is_positive", False
): # FlexMeasures default is to store consumption as negative power values
return df.values
return series

return -df.values
return -series


def fallback_charging_policy(
Expand Down

0 comments on commit 986ccb0

Please sign in to comment.