mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
moving epc_to_sap_lower_bound
This commit is contained in:
parent
33b142aea2
commit
cc64fdfd21
3 changed files with 53 additions and 55 deletions
|
|
@ -30,7 +30,7 @@ from backend.app.db.connection import db_engine
|
|||
|
||||
from model_data.optimiser.GainOptimiser import GainOptimiser
|
||||
from model_data.optimiser.CostOptimiser import CostOptimiser
|
||||
from model_data.utils import epc_to_sap_lower_bound
|
||||
from backend.app.utils import epc_to_sap_lower_bound
|
||||
from model_data.optimiser.optimiser_functions import prepare_input_measures
|
||||
|
||||
# TODO: This is placeholder until data is stored in DB
|
||||
|
|
|
|||
|
|
@ -65,3 +65,55 @@ def generate_api_key():
|
|||
# Generate a 40 character long api key
|
||||
api_key = ''.join(secrets.choice(characters) for _ in range(40))
|
||||
return api_key
|
||||
|
||||
|
||||
def sap_to_epc(sap_points: int):
|
||||
"""
|
||||
Simple utility function to convert SAP points to EPC rating.
|
||||
:param sapPoints: numerical value of SAP points, typically between 0 and 100
|
||||
:return:
|
||||
"""
|
||||
|
||||
if sap_points <= 0 or sap_points > 100:
|
||||
raise ValueError("SAP points should be between 1 and 100.")
|
||||
|
||||
if sap_points > 91:
|
||||
return "A"
|
||||
elif sap_points > 80:
|
||||
return "B"
|
||||
elif sap_points > 69:
|
||||
return "C"
|
||||
elif sap_points > 55:
|
||||
return "D"
|
||||
elif sap_points > 39:
|
||||
return "E"
|
||||
elif sap_points > 21:
|
||||
return "F"
|
||||
else:
|
||||
return "G"
|
||||
|
||||
|
||||
def epc_to_sap_lower_bound(epc: str):
|
||||
"""
|
||||
Given an EPC rating, returns the lower bound SAP score required
|
||||
to hit that EPC rating
|
||||
:param epc: EPC rating, between A and G
|
||||
:return:
|
||||
"""
|
||||
|
||||
if epc == "A":
|
||||
return 92
|
||||
elif epc == "B":
|
||||
return 81
|
||||
elif epc == "C":
|
||||
return 70
|
||||
elif epc == "D":
|
||||
return 56
|
||||
elif epc == "E":
|
||||
return 40
|
||||
elif epc == "F":
|
||||
return 22
|
||||
elif epc == "G":
|
||||
return 1
|
||||
else:
|
||||
raise ValueError("EPC rating should be between A and G")
|
||||
|
|
|
|||
|
|
@ -24,57 +24,3 @@ def correct_spelling(text):
|
|||
|
||||
corrected_text = ' '.join(corrected_words)
|
||||
return corrected_text
|
||||
|
||||
|
||||
def sap_to_epc(sap_points: int):
|
||||
"""
|
||||
Simple utility function to convert SAP points to EPC rating.
|
||||
:param sapPoints: numerical value of SAP points, typically between 0 and 100
|
||||
:return:
|
||||
"""
|
||||
|
||||
if sap_points <= 0 or sap_points > 100:
|
||||
raise ValueError("SAP points should be between 1 and 100.")
|
||||
|
||||
if sap_points > 91:
|
||||
return "A"
|
||||
elif sap_points > 80:
|
||||
return "B"
|
||||
elif sap_points > 69:
|
||||
return "C"
|
||||
elif sap_points > 55:
|
||||
return "D"
|
||||
elif sap_points > 39:
|
||||
return "E"
|
||||
elif sap_points > 21:
|
||||
return "F"
|
||||
else:
|
||||
return "G"
|
||||
|
||||
|
||||
def epc_to_sap_lower_bound(epc: str):
|
||||
"""
|
||||
Given an EPC rating, returns the lower bound SAP score required
|
||||
to hit that EPC rating
|
||||
:param epc: EPC rating, between A and G
|
||||
:return:
|
||||
"""
|
||||
|
||||
if epc == "A":
|
||||
return 92
|
||||
elif epc == "B":
|
||||
return 81
|
||||
elif epc == "C":
|
||||
return 70
|
||||
elif epc == "D":
|
||||
return 56
|
||||
elif epc == "E":
|
||||
return 40
|
||||
elif epc == "F":
|
||||
return 22
|
||||
elif epc == "G":
|
||||
return 1
|
||||
else:
|
||||
raise ValueError("EPC rating should be between A and G")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue