From 532bb684d24a5e0d7ffd346c15650d56beb0a1a3 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 8 Jun 2023 09:59:33 +0100 Subject: [PATCH] Added function to extract thermal transmittence --- epc_data/tests/app.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/epc_data/tests/app.py b/epc_data/tests/app.py index c388fbba..2e03fc7e 100644 --- a/epc_data/tests/app.py +++ b/epc_data/tests/app.py @@ -81,6 +81,24 @@ def handler(): raise Exception("Unhandled") + import re + def extract_thermal_transmittence(description_lower): + # Find U-value + u_value = re.search(r"(\d+\.\d+)", description_lower) + if u_value is not None: + u_value = float(u_value.group(1)) + else: + u_value = None + + # Find unit + unit = re.search(r"(w/m-¦k)", description_lower) + if unit is not None: + unit = unit.group(1) + else: + unit = None + + return u_value, unit + def clean_roof(description): """ We aim to extract features about the roof, so we can characterise it. We will check: @@ -104,7 +122,9 @@ def handler(): "insulation_thickness": 0, "has_dwelling_above": True, "assumed": "assumed" in description_lower, - "is_flat": "flat" in description_lower + "is_flat": "flat" in description_lower, + "thermal_transmittence": None, + "thermal_transmittence_unit": None, } is_pitched = "pitched" in description_lower @@ -112,14 +132,11 @@ def handler(): has_loft = "loft" in description_lower is_flat = "flat" in description_lower + thermal_transmittence, thermal_transmittence_unit, insulation_thickness = None, None, None if "insulation" in description_lower or "insulated" in description_lower: - # if has_loft and is_pitched: - # insulation_thickness = find_insulation_thickness(description_lower) - # elif not has_loft and is_pitched: - # insulation_thickness = find_insulation_thickness(description_lower) - # else: - # raise Exception("Implement me") insulation_thickness = find_insulation_thickness(description_lower, is_pitched, is_roof_room, is_flat) + elif "thermal transmittance" in description_lower: + thermal_transmittence, thermal_transmittence_unit = extract_thermal_transmittence(description_lower) else: raise Exception("Implment me 2") @@ -130,7 +147,9 @@ def handler(): "insulation_thickness": insulation_thickness, "has_dwelling_above": False, "assumed": "assumed" in description_lower, - "is_flat": is_flat + "is_flat": is_flat, + "thermal_transmittence": thermal_transmittence, + "thermal_transmittence_unit": thermal_transmittence_unit } return attributes