Skip to content

Commit

Permalink
Normalise the SBR score
Browse files Browse the repository at this point in the history
  • Loading branch information
charlotte-avery committed Jun 24, 2024
1 parent e8ad72c commit e5368b9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/smart_building_rating_calculator/calculate_sbr_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,10 @@ def sbr_score(
integrated_control_sys,
)
sbr_val, sbr, flex_archetype = get_sbr_scores(user_inputs)
return sbr_val, sbr, flex_archetype

# Normalise score between 0 & 100
min_sbr = -3.0
max_sbr = 27.75
sbr_normalised = 100 * (sbr_val - min_sbr) / (max_sbr - min_sbr)

return sbr_normalised, sbr, flex_archetype
31 changes: 27 additions & 4 deletions tests/test_sbr_calculator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from src.smart_building_rating_calculator.calculate_sbr_score import get_sbr_scores
from src.smart_building_rating_calculator.calculate_sbr_score import (
get_sbr_scores,
sbr_score,
)
from src.smart_building_rating_calculator.flex_archetype import FlexArchetype
from src.smart_building_rating_calculator.inputs import (
BatterySize,
Expand All @@ -16,6 +19,8 @@


class TestScoreCalculators:
"""Test the scoring calculations using the results in the SBR excel sheet created by ESC"""

def test_smartest_home(self):
user_inputs = UserInputs(
smart_meter=True,
Expand Down Expand Up @@ -247,8 +252,9 @@ def no_smart_meter(self):
assert flex_archetype == FlexArchetype.LOW_TECH_FLEXER


# Test all combinations of get_sbr_scores inputs
def test_all_combinations():
"""Test all combinations of get_sbr_scores inputs"""
scores = []
for smart_meter in [True, False]:
for smart_ev_charger in [True, False]:
for charger_power in EVChargerPower:
Expand Down Expand Up @@ -315,8 +321,21 @@ def test_all_combinations():
sbr_val,
sbr,
flex_archetype,
) = get_sbr_scores(
user_inputs
) = sbr_score(
smart_meter,
smart_ev_charger,
charger_power,
smart_v2g_enabled,
home_battery,
battery_size,
solar_pv,
pv_inverter_size,
electric_heating,
heating_source,
hot_water_source,
secondary_heating,
secondary_hot_water,
integrated_control_sys,
)

assert isinstance(
Expand All @@ -328,3 +347,7 @@ def test_all_combinations():
flex_archetype,
str,
)
scores.append(sbr_val)

assert min(scores) == 0.0
assert max(scores) == 100.0

0 comments on commit e5368b9

Please sign in to comment.