mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
working on MainheatControlAttributes
This commit is contained in:
parent
a39367474c
commit
8d6cc5a3e1
2 changed files with 69 additions and 39 deletions
|
|
@ -56,20 +56,18 @@ def handler():
|
||||||
df = df.reset_index(drop=True)
|
df = df.reset_index(drop=True)
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
idx = 88
|
idx = 5
|
||||||
record = df[df.index == idx].to_dict("records")[0]
|
record = df[df.index == idx].to_dict("records")[0]
|
||||||
record = {k: v for k, v in record.items() if v not in [None, np.nan, False]}
|
record = {k: v for k, v in record.items() if v not in [None, np.nan, False]}
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
pprint(record)
|
pprint(record)
|
||||||
|
|
||||||
# This has has_electric as true and not sure if we want that
|
# Issues:
|
||||||
description = 'Boiler and radiators, mains gas, Electric storage heaters'
|
# 1) '2207 Time and temperature zone control' - we don't pick up any reference to the fact this is a time and
|
||||||
# This has has_electric as true and has has_underfloor_heating as true and has_electric_underfloor_heating as true
|
# temperature zone control
|
||||||
# and not sure if we want that but might be fine
|
# and we only pick up temperature zone control at the moment. Can we capture this too
|
||||||
description = 'Boiler and radiators, mains gas, Electric underfloor heating'
|
# 2) 'Charging system linked to use of community heating, programmer and at least two room stats' - what are room
|
||||||
|
# stats and how should
|
||||||
z = df[df["original_description"] == 'Air source heat pump, radiators and underfloor, electric']
|
# we capture this?
|
||||||
|
|
||||||
# LPG boiler
|
|
||||||
|
|
||||||
df.to_dict("records")
|
df.to_dict("records")
|
||||||
|
|
|
||||||
|
|
@ -3,51 +3,83 @@ from epc_data.attributes.attribute_utils import clean_description
|
||||||
|
|
||||||
|
|
||||||
class MainheatControlAttributes:
|
class MainheatControlAttributes:
|
||||||
CONTROL_SYSTEM_KEYWORDS = [
|
# These systems allow for the automatic regulation of temperature
|
||||||
"charging system", "flat rate charging", "no thermostatic control",
|
THERMOSTATIC_CONTROL_KEYWORDS = [
|
||||||
"programmer", "room thermostats", "trvs", "bypass", "flow switch",
|
'room thermostats',
|
||||||
"automatic charge control", "manual charge control",
|
'appliance thermostats',
|
||||||
"temperature zone control", "time and temperature zone control",
|
'trvs',
|
||||||
"high heat retention storage heaters", "appliance thermostats", "dhw only",
|
'room thermostat',
|
||||||
"no time or thermostatic control", "room thermostat"
|
'temperature zone control',
|
||||||
|
'time and temperature zone control',
|
||||||
|
'no thermostatic control'
|
||||||
]
|
]
|
||||||
|
|
||||||
# These systems allow for the automatic regulation of temperature
|
|
||||||
THERMOSTATIC_CONTROL_KEYWORDS = []
|
|
||||||
|
|
||||||
# These systems provide a way to store and manage energy usage
|
# These systems provide a way to store and manage energy usage
|
||||||
CHARGING_SYSTEM_KEYWORDS = []
|
CHARGING_SYSTEM_KEYWORDS = [
|
||||||
|
'charging system',
|
||||||
|
'automatic charge control',
|
||||||
|
'manual charge control',
|
||||||
|
'flat rate charging',
|
||||||
|
'high heat retention storage heaters'
|
||||||
|
]
|
||||||
|
|
||||||
# These systems are mainly focused on on/off operations
|
# These systems are mainly focused on on/off operations
|
||||||
SWITCH_SYSTEM_KEYWORDS = []
|
SWITCH_SYSTEM_KEYWORDS = [
|
||||||
|
'programmer',
|
||||||
|
'flow switch',
|
||||||
|
'bypass'
|
||||||
|
]
|
||||||
|
|
||||||
# hese keywords indicate a lack of control system
|
# These keywords indicate a lack of control system
|
||||||
NO_CONTROL_SYSTEM_KEYWORDS = ["none"]
|
NO_CONTROL_SYSTEM_KEYWORDS = [
|
||||||
|
'no time or thermostatic control',
|
||||||
|
'none'
|
||||||
|
]
|
||||||
|
|
||||||
# These systems provide control specifically for Domestic Hot Water
|
# These systems provide control specifically for Domestic Hot Water
|
||||||
DHW_CONTROL_KEYWORDS = []
|
DHW_CONTROL_KEYWORDS = [
|
||||||
|
'dhw only'
|
||||||
|
]
|
||||||
|
|
||||||
|
# This system indicates the use of community heating
|
||||||
|
COMMUNITY_HEATING_KEYWORDS = [
|
||||||
|
'use of community heating'
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, description: str):
|
def __init__(self, description: str):
|
||||||
self.description: str = clean_description(description.lower())
|
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
|
self.nodata = not description or any(keyword in self.description for keyword in self.NO_CONTROL_SYSTEM_KEYWORDS)
|
||||||
# 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 self.nodata and not any(
|
||||||
if not any(keyword in self.description for keyword in self.CONTROL_SYSTEM_KEYWORDS):
|
self._keyword_in_description(keywords)
|
||||||
raise ValueError('Invalid description')
|
for keywords in [
|
||||||
|
self.THERMOSTATIC_CONTROL_KEYWORDS,
|
||||||
|
self.CHARGING_SYSTEM_KEYWORDS,
|
||||||
|
self.SWITCH_SYSTEM_KEYWORDS,
|
||||||
|
self.DHW_CONTROL_KEYWORDS
|
||||||
|
]
|
||||||
|
):
|
||||||
|
raise ValueError('Invalid description')
|
||||||
|
|
||||||
|
def _keyword_in_description(self, keywords):
|
||||||
|
return any(keyword in self.description for keyword in keywords)
|
||||||
|
|
||||||
def process(self) -> Dict[str, Union[str, bool]]:
|
def process(self) -> Dict[str, Union[str, bool]]:
|
||||||
result: Dict[str, Union[str, bool]] = {
|
result: Dict[str, Union[str, bool]] = {
|
||||||
"no_data": self.nodata
|
"thermostatic_control": self._find_keyword(self.THERMOSTATIC_CONTROL_KEYWORDS),
|
||||||
|
"charging_system": self._find_keyword(self.CHARGING_SYSTEM_KEYWORDS),
|
||||||
|
"switch_system": self._find_keyword(self.SWITCH_SYSTEM_KEYWORDS),
|
||||||
|
"no_control": self._find_keyword(self.NO_CONTROL_SYSTEM_KEYWORDS),
|
||||||
|
"dhw_control": self._find_keyword(self.DHW_CONTROL_KEYWORDS),
|
||||||
|
"community_heating": self._find_keyword(self.COMMUNITY_HEATING_KEYWORDS),
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
return result
|
||||||
|
|
||||||
|
def _find_keyword(self, keywords):
|
||||||
|
for keyword in keywords:
|
||||||
|
if keyword in self.description:
|
||||||
|
return keyword
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue