-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from kingsleynweye/develop
Updates to KPI definitions and calculation
- Loading branch information
Showing
16 changed files
with
494 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 56 additions & 5 deletions
61
...exibility_kpis/kpi/energy_flexibility/demand_response_emission_or_environmental_impact.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,97 @@ | ||
import datetime | ||
from typing import List, Union | ||
from scipy import integrate | ||
from energy_flexibility_kpis.kpi.base import KPI | ||
from energy_flexibility_kpis.enumerations import BaseUnit, Complexity, DOEFlexibilityCategory, KPICategory, PerformanceAspect, Relevance | ||
from energy_flexibility_kpis.enumerations import Stakeholder, TemporalEvaluationWindow,TemporalResolution, SpatialResolution | ||
from energy_flexibility_kpis.unit import Unit | ||
|
||
class RelativeCO2EmissionsReduction(KPI): | ||
"""CO2 emissions savings due to the demand response of the building.""" | ||
|
||
NAME = 'relative CO2 emissions reduction' | ||
DEFINITION = __doc__ | ||
UNIT = Unit(numerator=[BaseUnit.PERCENT]) | ||
CATEGORY = KPICategory.EF_DEMAND_RESPONSE_EMISSION_OR_ENVIRONMENTAL_IMPACT | ||
RELEVANCE = Relevance.MEDIUM | ||
STAKEHOLDERS = [Stakeholder.GRID_OPERATOR, Stakeholder.POLICYMAKER, Stakeholder.UTILITY_COMPANY] | ||
COMPLEXITY = Complexity.LOW | ||
NEED_BASELINE = True | ||
TEMPORAL_EVALUATION_WINDOW = TemporalEvaluationWindow.UNSPECIFIED | ||
TEMPORAL_RESOLUTION = TemporalResolution.UNSPECIFIED | ||
SPATIAL_RESOLUTION = SpatialResolution.UNSPECIFIED | ||
DOE_FLEXIBILITY_CATEGORY = [DOEFlexibilityCategory.LOAD_SHEDDING, DOEFlexibilityCategory.LOAD_SHIFTING] | ||
PERFORMANCE_ASPECT = [PerformanceAspect.EMISSION] | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
@classmethod | ||
def calculate( | ||
cls, | ||
#test | ||
baseline_carbon_emissions_profile: List[float], | ||
flexible_carbon_emissions_profile: List[float], | ||
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: | ||
) -> List[float]: | ||
_, vs = super().calculate( | ||
baseline_carbon_emissions_profile=baseline_carbon_emissions_profile, | ||
flexible_carbon_emissions_profile=flexible_carbon_emissions_profile, | ||
timestamps=timestamps, | ||
evaluation_start_timestamp=evaluation_start_timestamp, | ||
evaluation_end_timestamp=evaluation_end_timestamp, | ||
) | ||
|
||
raise NotImplementedError | ||
value = ( | ||
vs.flexible_carbon_emissions_profile.value[vs.evaluation_mask] | ||
- vs.baseline_carbon_emissions_profile.value[vs.evaluation_mask] | ||
)*100.0/vs.baseline_carbon_emissions_profile.value[vs.evaluation_mask] | ||
|
||
return value | ||
|
||
class EnvironmentalSavings(KPI): | ||
"""CO2 emissions savings due to the demand response of the building.""" | ||
|
||
NAME = 'environmental savings' | ||
DEFINITION = __doc__ | ||
UNIT = Unit(numerator=[BaseUnit.KG_OF_CO2]) | ||
CATEGORY = KPICategory.EF_DEMAND_RESPONSE_EMISSION_OR_ENVIRONMENTAL_IMPACT | ||
RELEVANCE = Relevance.MEDIUM | ||
STAKEHOLDERS = [Stakeholder.GRID_OPERATOR, Stakeholder.POLICYMAKER, Stakeholder.UTILITY_COMPANY] | ||
COMPLEXITY = Complexity.LOW | ||
NEED_BASELINE = True | ||
TEMPORAL_EVALUATION_WINDOW = TemporalEvaluationWindow.WHOLE_DAY | ||
TEMPORAL_RESOLUTION = TemporalResolution.HOURLY | ||
SPATIAL_RESOLUTION = SpatialResolution.UNSPECIFIED | ||
DOE_FLEXIBILITY_CATEGORY = [DOEFlexibilityCategory.LOAD_SHEDDING, DOEFlexibilityCategory.LOAD_SHIFTING] | ||
PERFORMANCE_ASPECT = [PerformanceAspect.EMISSION] | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
@classmethod | ||
def calculate( | ||
cls, | ||
timestamps: Union[List[int], List[datetime.datetime], List[str]] = None, | ||
baseline_electric_power_profile: List[float], | ||
flexible_electric_power_profile: List[float], | ||
generic_carbon_intensity_profile: List[float], | ||
timestamps: Union[List[int], List[datetime.datetime], List[str]], | ||
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_carbon_intensity_profile=generic_carbon_intensity_profile, | ||
timestamps=timestamps, | ||
evaluation_start_timestamp=evaluation_start_timestamp, | ||
evaluation_end_timestamp=evaluation_end_timestamp, | ||
) | ||
|
||
raise NotImplementedError | ||
electric_power_profile = vs.flexible_electric_power_profile.value[vs.evaluation_mask] - vs.baseline_electric_power_profile.value[vs.evaluation_mask] | ||
carbon_emissions_profile = electric_power_profile*vs.generic_carbon_intensity_profile.value[vs.evaluation_mask] | ||
dx = vs.get_temporal_resolution(BaseUnit.HOUR, value=vs.timestamps.value[vs.evaluation_mask]) | ||
value = integrate.simpson(carbon_emissions_profile, dx=dx) | ||
|
||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.