From 9b08d49b85fceca164e70e9eaf8c32f1c7442e78 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sun, 15 Sep 2024 13:58:59 +0100 Subject: [PATCH] Adding another heating test --- etl/customers/aiha/epc_data_pull.py | 4 +- recommendations/HeatingRecommender.py | 19 ++++--- .../test_data/heating_recommendations_data.py | 54 +++++++++++++++++++ 3 files changed, 69 insertions(+), 8 deletions(-) diff --git a/etl/customers/aiha/epc_data_pull.py b/etl/customers/aiha/epc_data_pull.py index 5e7c6714..16081205 100644 --- a/etl/customers/aiha/epc_data_pull.py +++ b/etl/customers/aiha/epc_data_pull.py @@ -767,5 +767,5 @@ def app(): on="row_id", how="left" ) - - archetyping_data = archetyping_data.drop(columns=["row_id"]) + archetyping_data.to_csv("/Users/khalimconn-kowlessar/Documents/hestia/Customers/AIHA/archetyping_data.csv", + index=False) diff --git a/recommendations/HeatingRecommender.py b/recommendations/HeatingRecommender.py index dc433806..103fa7b1 100644 --- a/recommendations/HeatingRecommender.py +++ b/recommendations/HeatingRecommender.py @@ -9,6 +9,11 @@ from recommendations.HeatingControlRecommender import HeatingControlRecommender class HeatingRecommender: + ASSUMED_ELECTRIC_HEATING = [ + "Portable electric heaters assumed for most rooms", + "No system present, electric heaters assumed" + ] + ELECTRIC_HEATING_DESCRIPTIONS = [ "Room heaters, electric", "Electric storage heaters", @@ -16,6 +21,10 @@ class HeatingRecommender: "Portable electric heaters assumed for most rooms", ] + ROOM_HEATERS_DESCRIPTIONS = [ + "Room heaters, mains gas", "Room heaters, electric", "Portable electric heaters assumed for most rooms", + ] + high_heat_retention_contols_desc = "Controls for high heat retention storage heaters" def __init__(self, property_instance: Property): @@ -25,8 +34,8 @@ class HeatingRecommender: self.heating_recommendations = [] self.heating_control_recommendations = [] - self.has_electric_heating_description = ( - self.property.main_heating["clean_description"] in self.ELECTRIC_HEATING_DESCRIPTIONS + self.has_electric_heating_description = self.property.main_heating["clean_description"] in ( + self.ELECTRIC_HEATING_DESCRIPTIONS + self.ASSUMED_ELECTRIC_HEATING ) def is_high_heat_retention_valid(self, ashp_only_heating_recommendation, measures): @@ -37,9 +46,7 @@ class HeatingRecommender: # If the property has assumed electric heating, regardless of whether or not it has a mains connection, we # can consider hhr storage heaters - electric_heating_assumed = ( - self.property.main_heating["clean_description"] in ["No system present, electric heaters assumed"] - ) + electric_heating_assumed = self.property.main_heating["clean_description"] in self.ASSUMED_ELECTRIC_HEATING has_electric = self.has_electric_heating_description or electric_heating_assumed @@ -64,7 +71,7 @@ class HeatingRecommender: # The property is using portable heaters and has access to gas mains has_room_heaters = ( - self.property.main_heating["clean_description"] in ["Room heaters, mains gas", "Room heaters, electric"] and + self.property.main_heating["clean_description"] in self.ROOM_HEATERS_DESCRIPTIONS and self.property.data["mains-gas-flag"] ) diff --git a/recommendations/tests/test_data/heating_recommendations_data.py b/recommendations/tests/test_data/heating_recommendations_data.py index f283050b..c64aab6f 100644 --- a/recommendations/tests/test_data/heating_recommendations_data.py +++ b/recommendations/tests/test_data/heating_recommendations_data.py @@ -348,6 +348,50 @@ testing_examples = [ "Programmer and room thermostat for heating controls so we'd expect an ASHP heating recommendation" "as the only option, and heating controls recommendations for programmer, room thermostats and trvs" "as well as ttzc" + }, + { + "epc": { + 'lmk-key': '977006769242013072314202915172178', 'address1': '40, Elswick Road', 'address2': None, + 'address3': None, 'postcode': 'B44 0JQ', 'building-reference-number': 7277661178, + 'current-energy-rating': 'G', 'potential-energy-rating': 'B', 'current-energy-efficiency': 18, + 'potential-energy-efficiency': 88, 'property-type': 'House', 'built-form': 'Mid-Terrace', + 'inspection-date': '2013-07-23', 'local-authority': 'E08000025', 'constituency': 'E14000561', + 'county': None, + 'lodgement-date': '2013-07-23', 'transaction-type': 'none of the above', 'environment-impact-current': 31, + 'environment-impact-potential': 90, 'energy-consumption-current': 536, 'energy-consumption-potential': 59, + 'co2-emissions-current': 7.0, 'co2-emiss-curr-per-floor-area': 96, 'co2-emissions-potential': 0.9, + 'lighting-cost-current': 48, 'lighting-cost-potential': 48, 'heating-cost-current': 1395, + 'heating-cost-potential': 353, 'hot-water-cost-current': 457, 'hot-water-cost-potential': 69, + 'total-floor-area': 73.0, 'energy-tariff': 'Unknown', 'mains-gas-flag': 'Y', 'floor-level': 'NODATA!', + 'flat-top-storey': None, 'flat-storey-count': None, 'main-heating-controls': 2601.0, + 'multi-glaze-proportion': 100.0, 'glazed-type': 'double glazing, unknown install date', + 'glazed-area': 'Normal', 'extension-count': 0, 'number-habitable-rooms': 4, 'number-heated-rooms': 1, + 'low-energy-lighting': 90, 'number-open-fireplaces': 1, + 'hotwater-description': 'Electric immersion, standard tariff', 'hot-water-energy-eff': 'Very Poor', + 'hot-water-env-eff': 'Very Poor', 'floor-description': 'Solid, no insulation (assumed)', + 'floor-energy-eff': None, 'windows-description': 'Fully double glazed', 'windows-energy-eff': 'Average', + 'windows-env-eff': 'Average', 'walls-description': 'Solid brick, as built, no insulation (assumed)', + 'walls-energy-eff': 'Very Poor', 'walls-env-eff': 'Very Poor', + 'secondheat-description': 'Room heaters, mains gas', 'roof-description': 'Pitched, 75 mm loft insulation', + 'roof-energy-eff': 'Average', 'roof-env-eff': 'Average', + 'mainheat-description': 'Portable electric heaters assumed for most rooms', + 'mainheat-energy-eff': 'Very Poor', 'mainheat-env-eff': 'Very Poor', + 'mainheatcont-description': 'No thermostatic control of room temperature', 'mainheatc-energy-eff': 'Poor', + 'mainheatc-env-eff': 'Poor', 'lighting-description': 'Low energy lighting in 90% of fixed outlets', + 'lighting-energy-eff': 'Very Good', 'lighting-env-eff': 'Very Good', + 'main-fuel': 'mains gas (not community)', 'wind-turbine-count': 0, 'heat-loss-corridor': 'NO DATA!', + 'unheated-corridor-length': None, 'floor-height': 2.5, 'photo-supply': 0.0, + 'solar-water-heating-flag': None, + 'mechanical-ventilation': 'natural', 'address': '40, Elswick Road', 'local-authority-label': 'Birmingham', + 'constituency-label': 'Birmingham, Erdington', 'posttown': 'BIRMINGHAM', + 'construction-age-band': 'England and Wales: 1930-1949', + 'lodgement-datetime': '2013-07-23 14:20:29', 'tenure': 'owner-occupied', + 'fixed-lighting-outlets-count': 10.0, 'low-energy-fixed-light-count': 9.0, 'uprn': 100070358594, + 'uprn-source': 'Address Matched' + }, + "heating_recommendation_descriptions": [], + "heating_controls_recommendation_descriptions": [], + "notes": "" } ] @@ -389,3 +433,13 @@ print(eg["mainheat-energy-eff"]) print(eg["property-type"]) print(eg["built-form"]) print(eg["mainheatcont-description"]) + +### We also use the Midlands EPC F/G portfolio to get examples to create tests +portfolio = pd.read_excel( + "/Users/khalimconn-kowlessar/Documents/hestia/Customers/sfr/20240820 portfolio_epc_data.xlsx" +) +portfolio.columns = [c.replace("_", "-").lower() for c in portfolio.columns] +eg = portfolio[ + (portfolio["mainheat-description"] == "Portable electric heaters assumed for most rooms") +].sample(1) +eg = eg.squeeze().to_dict()