outline of epc_data/attributes/MainheatControlAttributes.py

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-14 14:31:36 +01:00
parent 320aec959e
commit a39367474c
3 changed files with 57 additions and 4 deletions

View file

@ -40,11 +40,11 @@ def handler():
cleaner.clean()
# For testing:
from epc_data.attributes.WindowAttributes import WindowAttributes
descriptions = {x["windows-description"] for x in data}
from epc_data.attributes.MainheatControlAttributes import MainheatControlAttributes
descriptions = {x["mainheatcont-description"] for x in data}
out = []
for description in descriptions:
res = WindowAttributes(description).process()
res = MainheatControlAttributes(description).process()
out.append(
{
"original_description": description,

View file

@ -0,0 +1,53 @@
from typing import Dict, Union
from epc_data.attributes.attribute_utils import clean_description
class MainheatControlAttributes:
CONTROL_SYSTEM_KEYWORDS = [
"charging system", "flat rate charging", "no thermostatic control",
"programmer", "room thermostats", "trvs", "bypass", "flow switch",
"automatic charge control", "manual charge control",
"temperature zone control", "time and temperature zone control",
"high heat retention storage heaters", "appliance thermostats", "dhw only",
"no time or thermostatic control", "room thermostat"
]
# These systems allow for the automatic regulation of temperature
THERMOSTATIC_CONTROL_KEYWORDS = []
# These systems provide a way to store and manage energy usage
CHARGING_SYSTEM_KEYWORDS = []
# These systems are mainly focused on on/off operations
SWITCH_SYSTEM_KEYWORDS = []
# hese keywords indicate a lack of control system
NO_CONTROL_SYSTEM_KEYWORDS = ["none"]
# These systems provide control specifically for Domestic Hot Water
DHW_CONTROL_KEYWORDS = []
def __init__(self, description: str):
self.description: str = clean_description(description.lower())
# In the case of an empty description, we want to return a dictionary with all values set to False
# and indicate there was no data
self.nodata = not description or self.description in self.NO_CONTROL_SYSTEM_KEYWORDS
if not self.nodata:
if not any(keyword in self.description for keyword in self.CONTROL_SYSTEM_KEYWORDS):
raise ValueError('Invalid description')
def process(self) -> Dict[str, Union[str, bool]]:
result: Dict[str, Union[str, bool]] = {
"no_data": self.nodata
}
if self.nodata:
return result
# We consolidate CONTROL_SYSTEM_KEYWORDS into separate attributes
for keyword in self.CONTROL_SYSTEM_KEYWORDS:
result[f'has_{keyword.replace(" ", "_")}'] = keyword in self.description
return result

View file

@ -1,6 +1,6 @@
import re
from typing import Dict, Union
from epc_data.attributes.attribute_utils import extract_component_types, extract_thermal_transmittance, process_part
from epc_data.attributes.attribute_utils import extract_component_types, extract_thermal_transmittance
class RoofAttributes: