Skip to content

Commit

Permalink
Merge pull request #31 from kingsleynweye/develop
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
kingsleynweye authored Sep 29, 2023
2 parents 307844c + 36d3c50 commit e9bd42d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def calculate(
)

value = (
vs.flexible_electric_power_profile.value[vs.evaluation_mask]
- vs.baseline_electric_power_profile.value[vs.evaluation_mask]
vs.baseline_electric_power_profile.value[vs.evaluation_mask]
- vs.flexible_electric_power_profile.value[vs.evaluation_mask]
).mean()*vs.evaluation_length

return value
Expand Down Expand Up @@ -77,24 +77,31 @@ def calculate(
cls,
baseline_electric_power_profile: List[List[float]],
flexible_electric_power_profile: List[List[float]],
generic_signal_start_timestamp: Union[int, datetime.datetime, str],
generic_signal_end_timestamp: Union[int, datetime.datetime, str],
timestamps: Union[List[int], List[datetime.datetime], List[str]] = None,
evaluation_start_timestamp: Union[int, datetime.datetime, str] = None,
evaluation_end_timestamp: Union[int, datetime.datetime, str] = None,
) -> float:
_, vs = super().calculate(
baseline_electric_power_profile=baseline_electric_power_profile,
flexible_electric_power_profile=flexible_electric_power_profile,
generic_signal_start_timestamp=generic_signal_start_timestamp,
generic_signal_end_timestamp=generic_signal_end_timestamp,
timestamps=timestamps,
evaluation_start_timestamp=evaluation_start_timestamp,
evaluation_end_timestamp=evaluation_end_timestamp,
)

assert vs.evaluation_length > 1, 'The evaluation period must be > 1 timestep'
mask = vs.evaluation_mask\
& (vs.timestamps.value >= vs.generic_signal_start_timestamp.value)\
& (vs.timestamps.value <= vs.generic_signal_end_timestamp.value)
mask_length = mask[mask].shape[0]
resource_count = len(baseline_electric_power_profile)
value = (
vs.baseline_electric_power_profile.value[vs.evaluation_mask]
- vs.flexible_electric_power_profile.value[vs.evaluation_mask]
)[1:].sum()/(resource_count*(vs.evaluation_length - 1))
vs.baseline_electric_power_profile.value[mask]
- vs.flexible_electric_power_profile.value[mask]
)[1:].sum()/(resource_count*(mask_length - 1))

return value

Expand Down
33 changes: 24 additions & 9 deletions energy_flexibility_kpis/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ def availability(cls) -> Variable:
definition='Equipment availability mask.',
primitive_type=DefaultPrimitiveType.unspecified,
value_type=ValueType.SERIAL,
operation_condition=OperationCondition.GENERIC,
)

@property
Expand Down Expand Up @@ -302,56 +301,72 @@ def grid_peak_timestamp(cls) -> DateTimeVariable:
def generic_signal_start_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='generic_signal_start_timestamp',
definition='The starting timestamp of a signal e.g. price, emissions, e.t.c.'
definition='The starting timestamp of a signal e.g. price, emissions, e.t.c.',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
def generic_signal_end_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='generic_signal_end_timestamp',
definition='The ending timestamp of a signal e.g. price, emissions, e.t.c..'
definition='The ending timestamp of a signal e.g. price, emissions, e.t.c..',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
def low_generic_signal_start_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='low_generic_signal_start_timestamp',
definition='The starting timestamp of a period when a signal e.g. price, emissions, e.t.c. is low.'
definition='The starting timestamp of a period when a signal e.g. price, emissions, e.t.c. is low.',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
def low_generic_signal_end_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='low_generic_signal_end_timestamp',
definition='The ending timestamp of a period when a signal e.g. price, emissions, e.t.c. is low.'
definition='The ending timestamp of a period when a signal e.g. price, emissions, e.t.c. is low.',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
def medium_generic_signal_start_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='medium_generic_signal_start_timestamp',
definition='The starting timestamp of a period when a signal e.g. price, emissions, e.t.c. is medium.'
definition='The starting timestamp of a period when a signal e.g. price, emissions, e.t.c. is medium.',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
def medium_generic_signal_end_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='medium_generic_signal_end_timestamp',
definition='The ending timestamp of a period when a signal e.g. price, emissions, e.t.c. is medium.'
definition='The ending timestamp of a period when a signal e.g. price, emissions, e.t.c. is medium.',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
def high_generic_signal_start_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='high_generic_signal_start_timestamp',
definition='The starting timestamp of a period when a signal e.g. price, emissions, e.t.c. is high.'
definition='The starting timestamp of a period when a signal e.g. price, emissions, e.t.c. is high.',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
def high_generic_signal_end_timestamp(cls) -> DateTimeVariable:
return DateTimeVariable(
name='high_generic_signal_end_timestamp',
definition='The ending timestamp of a period when a signal e.g. price, emissions, e.t.c. is high.'
definition='The ending timestamp of a period when a signal e.g. price, emissions, e.t.c. is high.',
primitive_type=DefaultPrimitiveType.timestamp,
value_type=ValueType.SINGLE
)

@property
Expand Down
8 changes: 5 additions & 3 deletions examples/demo.ipynb

Large diffs are not rendered by default.

0 comments on commit e9bd42d

Please sign in to comment.