diff --git a/.idea/Model.iml b/.idea/Model.iml index 4413bb06..b0f9c00d 100644 --- a/.idea/Model.iml +++ b/.idea/Model.iml @@ -7,7 +7,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 6f308057..1122b380 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/etl/epc_clean/app.py b/etl/epc_clean/app.py index 3f1a1a80..59561b3c 100644 --- a/etl/epc_clean/app.py +++ b/etl/epc_clean/app.py @@ -2,24 +2,27 @@ from tqdm import tqdm import os import pandas as pd import msgpack +import inspect from etl.epc_clean.EpcClean import EpcClean from etl.epc.settings import EARLIEST_EPC_DATE from pathlib import Path from utils.s3 import save_data_to_s3 +src_file_path = inspect.getfile(lambda: None) + LAND_REGISTRY_PATHS = [ - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-monthly-update-new-version.csv", - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-2022 (1).csv", - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-2021.csv", - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-2020.csv", - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-2019.csv", - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-2018.csv", - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-2017-part1.csv", - os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/pp-2017-part2.csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-monthly-update-new-version.csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-2022 (1).csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-2021.csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-2020.csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-2019.csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-2018.csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-2017-part1.csv", + os.path.abspath(os.path.dirname(src_file_path)) + "/model_data/local_data/pp-2017-part2.csv", ] -EPC_DIRECTORY = Path(__file__).parent / "local_data" / "all-domestic-certificates" +EPC_DIRECTORY = Path(src_file_path).parent / "local_data" / "all-domestic-certificates" ENVIRONMENT = os.getenv("ENVIRONMENT", "dev") diff --git a/etl/epc_clean/epc_attributes/HotWaterAttributes.py b/etl/epc_clean/epc_attributes/HotWaterAttributes.py index e8bce0bb..5603e7d5 100644 --- a/etl/epc_clean/epc_attributes/HotWaterAttributes.py +++ b/etl/epc_clean/epc_attributes/HotWaterAttributes.py @@ -116,7 +116,8 @@ class HotWaterAttributes(Definitions): "instantaneous at " "point of use, " "waste water heat " - "recovery" + "recovery", + "ogçör brif system, adfer gwres d+¦r gwastraff": "from main system, waste water heat recovery", } def __init__(self, description: str): diff --git a/etl/epc_clean/epc_attributes/WindowAttributes.py b/etl/epc_clean/epc_attributes/WindowAttributes.py index ce0b156a..5286fc5a 100644 --- a/etl/epc_clean/epc_attributes/WindowAttributes.py +++ b/etl/epc_clean/epc_attributes/WindowAttributes.py @@ -30,6 +30,7 @@ class WindowAttributes(Definitions): "gwydrau eilaidd llawn": "full secondary glazing", "gwydrau eilaidd mwyaf": "mostly secondary glazing", "gwydrau eilaidd rhannol": "partial secondary glazing", + "gwydrau lluosog ym mhobman": "multiple glazing throughout", } def __init__(self, description: str): diff --git a/etl/epc_clean/epc_attributes/attribute_utils.py b/etl/epc_clean/epc_attributes/attribute_utils.py index b5fc590d..60f4653e 100644 --- a/etl/epc_clean/epc_attributes/attribute_utils.py +++ b/etl/epc_clean/epc_attributes/attribute_utils.py @@ -24,7 +24,7 @@ def extract_thermal_transmittance(result: dict, description: str) -> Tuple[ if match: result['thermal_transmittance'] = float(match.group(1)) - result['thermal_transmittance_unit'] = match.group(3) + result['thermal_transmittance_unit'] = "w/m-¦k" # We standardise the unit # Remove the match from the description description = re.sub(THERMAL_TRANSMITTANCE_STR, "", description) else: diff --git a/recommendations/WallRecommendations.py b/recommendations/WallRecommendations.py index 8d7915cd..243a5edb 100644 --- a/recommendations/WallRecommendations.py +++ b/recommendations/WallRecommendations.py @@ -61,6 +61,7 @@ class WallRecommendations(Definitions): "system_built": "System built, with external insulation", "granite_or_whinstone": 'Granite or whinstone, with external insulation', "sandstone_or_limestone": 'Sandstone or limestone, with external insulation', + "timber_frame": "Timber frame, with external insulation" } # These are the ending descriptions we consider for walls with internal insulation @@ -70,6 +71,7 @@ class WallRecommendations(Definitions): "system_built": "System built, with internal insulation", "granite_or_whinstone": 'Granite or whinstone, with internal insulation', "sandstone_or_limestone": 'Sandstone or limestone, with internal insulation', + "timber_frame": "Timber frame, with internal insulation" } def __init__( @@ -337,7 +339,7 @@ class WallRecommendations(Definitions): self.recommendations = recommendations - def get_internal_external_wall_description(self, description_map): + def get_internal_external_wall_description(self, description_map, new_u_value): if self.property.walls["is_solid_brick"]: return description_map["solid_brick"] @@ -353,6 +355,14 @@ class WallRecommendations(Definitions): if self.property.walls["is_sandstone_or_limestone"]: return description_map["sandstone_or_limestone"] + if self.property.walls["is_timber_frame"]: + return description_map["timber_frame"] + + if "Average thermal transmittance" in self.property.walls["clean_description"]: + if new_u_value is None: + raise ValueError("New u value is None") + return f'Average thermal transmittance {new_u_value} W/m-¦K' + raise NotImplementedError("Not implemented yet") def _find_insulation(self, u_value, insulation_materials, non_insulation_materials, phase): @@ -394,7 +404,7 @@ class WallRecommendations(Definitions): cost_result = override_costs(cost_result) new_description = self.get_internal_external_wall_description( - self.INTERNALLY_INSULATED_WALL_DESCRIPTIONS + self.INTERNALLY_INSULATED_WALL_DESCRIPTIONS, new_u_value ) elif material["type"] == "external_wall_insulation": @@ -408,7 +418,7 @@ class WallRecommendations(Definitions): cost_result = override_costs(cost_result) new_description = self.get_internal_external_wall_description( - self.EXTERNALLY_INSULATED_WALL_DESCRIPTIONS + self.EXTERNALLY_INSULATED_WALL_DESCRIPTIONS, new_u_value ) else: raise ValueError("Invalid material type") @@ -418,7 +428,6 @@ class WallRecommendations(Definitions): simulation_config = {} if self.property.data["walls-energy-eff"] not in ["Good", "Very Good"]: simulation_config = { - "walls_thermal_transmittance_ending": new_u_value, "walls_energy_eff_ending": "Good" } @@ -426,7 +435,11 @@ class WallRecommendations(Definitions): new_config=wall_ending_config, old_config=self.property.walls, prefix="walls_" ) - simulation_config = {**simulation_config, **walls_simulation_config} + simulation_config = { + **walls_simulation_config, + **simulation_config, + "walls_thermal_transmittance_ending": new_u_value + } recommendations.append( { diff --git a/recommendations/recommendation_utils.py b/recommendations/recommendation_utils.py index c78c4f68..996f5c9c 100644 --- a/recommendations/recommendation_utils.py +++ b/recommendations/recommendation_utils.py @@ -766,7 +766,7 @@ def check_simulation_difference(old_config, new_config, prefix=""): differences = {} for key in new_config: if old_config[key] != new_config[key]: - new_key = prefix + key + "_ending" if key == "is_assumed" else key + "_ending" + new_key = prefix + key + "_ending" if key in ["is_assumed", "thermal_transmittance"] else key + "_ending" differences[new_key] = new_config[key] return differences