mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
61 lines
2.7 KiB
Python
61 lines
2.7 KiB
Python
from model_data.BaseUtility import BaseUtility
|
|
from model_data.epc_attributes.attribute_utils import clean_description, process_part
|
|
from typing import Dict, Union
|
|
|
|
|
|
class MainHeatAttributes(BaseUtility):
|
|
HEAT_SYSTEMS = ["boiler", "air source heat pump", "room heaters", "electric storage heaters", "warm air",
|
|
"electric underfloor heating", "electric ceiling heating", "community scheme",
|
|
"ground source heat pump", "no system present", "portable electric heaters",
|
|
"water source heat pump"]
|
|
FUEL_TYPES = ["electric", "mains gas", "wood logs", "LPG", "coal", "oil", "wood pellets", "anthracite",
|
|
"dual fuel mineral and wood", "smokeless fuel", "lpg"]
|
|
DISTRIBUTION_SYSTEMS = ["radiators", "fan coil units", "pipes in screed above insulation",
|
|
"pipes in insulated timber floor", "pipes in concrete slab"]
|
|
OTHERS = ["assumed", "electricaire", "assumed for most rooms"]
|
|
|
|
def __init__(self, description: str):
|
|
self.description: str = clean_description(description.lower())
|
|
# Remove special characters
|
|
self.nodata = not description or description in self.DATA_ANOMALY_MATCHES
|
|
|
|
if not description or not any(
|
|
rt in self.description for rt in
|
|
self.HEAT_SYSTEMS + self.FUEL_TYPES + self.DISTRIBUTION_SYSTEMS + self.OTHERS
|
|
):
|
|
raise ValueError('Invalid description')
|
|
|
|
def process(self) -> Dict[str, Union[str, bool]]:
|
|
|
|
result: Dict[str, Union[str, bool]] = {f'has_{ds.replace(" ", "_")}': False for ds in self.DISTRIBUTION_SYSTEMS}
|
|
result.update({f'has_{hs.replace(" ", "_")}': False for hs in self.HEAT_SYSTEMS})
|
|
result.update({f'has_{ft.replace(" ", "_")}': False for ft in self.FUEL_TYPES})
|
|
result.update({f'has_{ot.replace(" ", "_")}': False for ot in self.OTHERS})
|
|
result['has_underfloor_heating'] = False
|
|
|
|
if self.nodata:
|
|
return result
|
|
|
|
description = self.description.split(',')
|
|
|
|
# Process each part separately
|
|
for part in description:
|
|
part = part.strip() # remove leading/trailing white spaces
|
|
|
|
# Heating Systems
|
|
process_part(result, part, self.HEAT_SYSTEMS, 'has_')
|
|
|
|
# Fuel Types
|
|
process_part(result, part, self.FUEL_TYPES, 'has_')
|
|
|
|
# Distribution Systems
|
|
process_part(result, part, self.DISTRIBUTION_SYSTEMS, 'has_')
|
|
|
|
# Other epc_attributes
|
|
process_part(result, part, self.OTHERS, 'has_')
|
|
|
|
# Check for "underfloor" separately in the entire description
|
|
if "underfloor" in self.description:
|
|
result['has_underfloor_heating'] = True
|
|
|
|
return result
|