From 981e0d5c9323dcd1705b3f91a940856c2b738dad Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 28 Aug 2025 23:54:11 +0100 Subject: [PATCH] fixed edge case where we have an appliance heating system and are unable to map a fuel type for hot water --- backend/Property.py | 13 ++++++++++--- backend/tests/test_integration.py | 5 ++++- etl/epc_clean/epc_attributes/HotWaterAttributes.py | 2 ++ .../test_data/test_hot_water_attributes_cases.py | 7 ++++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/backend/Property.py b/backend/Property.py index 08e7ebf2..1fc20c88 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -1168,7 +1168,8 @@ class Property: 'heat pump': 'Electricity', 'solid fuel boiler': 'Solid Fuel', 'solid fuel range cooker': 'Solid Fuel', - 'room heaters': 'Varied' # Could be any fuel, further specifics needed based on context + 'room heaters': 'Varied', # Could be any fuel, further specifics needed based on context + "single-point gas": "Natural Gas" } # Define a mapping from system types to general categories or modifications of fuel types @@ -1179,6 +1180,11 @@ class Property: 'community scheme': 'Community Scheme' } + hotwater_appliance_to_fuel = { + 'gas range cooker': 'Natural Gas', + 'oil range cooker': 'Oil' + } + self.heating_energy_source = list({ fuel for key, fuel in heating_fuel_mapping.items() if self.main_heating.get(key, False) }) @@ -1216,8 +1222,7 @@ class Property: if self.hotwater["extra_features"] == "plus solar": self.hot_water_energy_source = self.heating_energy_source + " + Solar Thermal" return - - else: + elif self.hotwater["system_type"] is not None: fuel = system_type_modification[self.hotwater["system_type"]] if self.hotwater["extra_features"] == "plus solar": @@ -1232,6 +1237,8 @@ class Property: self.hot_water_energy_source = assumptions.DESCRIPTIONS_TO_FUEL_TYPES[secondary_heating]["fuel"] else: raise Exception("Investiage me") + else: + self.hot_water_energy_source = hotwater_appliance_to_fuel[self.hotwater["appliance"]] def is_ashp_valid(self, measures): diff --git a/backend/tests/test_integration.py b/backend/tests/test_integration.py index 45bc7325..e8473bb0 100644 --- a/backend/tests/test_integration.py +++ b/backend/tests/test_integration.py @@ -89,7 +89,8 @@ costs_by_floor_area = costs_by_floor_area.groupby("current-energy-efficiency")[ ["lighting-cost-current_scaled", "heating-cost-current_scaled", "hot-water-cost-current_scaled"] ].mean().reset_index() -sample_epc_data = epc_data.drop_duplicates("UPRN").sample(1000).reset_index(drop=True) +sample_epc_data = epc_data[pd.to_datetime(epc_data["LODGEMENT_DATE"]) >= "2015-01-01"].drop_duplicates("UPRN").sample( + 1000).reset_index(drop=True) # Load the input properties input_properties = [] @@ -173,6 +174,8 @@ for p in input_properties: p.set_features(cleaned=cleaned, kwh_client=kwh_client, kwh_predictions=mocked_kwh_predictions) for p in input_properties ] +for p in input_properties: + p.set_features(cleaned=cleaned, kwh_client=kwh_client, kwh_predictions=mocked_kwh_predictions) # Run the recommendations recommendations = {} diff --git a/etl/epc_clean/epc_attributes/HotWaterAttributes.py b/etl/epc_clean/epc_attributes/HotWaterAttributes.py index 1ea743fc..d1124e08 100644 --- a/etl/epc_clean/epc_attributes/HotWaterAttributes.py +++ b/etl/epc_clean/epc_attributes/HotWaterAttributes.py @@ -20,6 +20,7 @@ class HotWaterAttributes(Definitions): 'solid fuel range cooker', 'room heaters', # Generic/unspecified category 'electric multipoint', + 'single-point gas', ] # SYSTEM_TYPES refer to the larger system within which the heater operates. @@ -29,6 +30,7 @@ class HotWaterAttributes(Definitions): # The hot water is provided by a secondary (or supplementary) heating system in the building 'from second main heating system', # Same as 'from secondary system' 'community scheme', # The hot water is provided by a community heating system + "water heater", ] # THERMOSTAT_CHARACTERISTICS refer to features related to temperature control in the system. diff --git a/etl/epc_clean/tests/test_data/test_hot_water_attributes_cases.py b/etl/epc_clean/tests/test_data/test_hot_water_attributes_cases.py index ae5348be..18b97232 100644 --- a/etl/epc_clean/tests/test_data/test_hot_water_attributes_cases.py +++ b/etl/epc_clean/tests/test_data/test_hot_water_attributes_cases.py @@ -222,6 +222,11 @@ hotwater_cases = [ {'original_description': 'Electric multipoint', 'heater_type': 'electric multipoint', 'system_type': None, 'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None, 'extra_features': None, 'chp_systems': None, - 'distribution_system': None, 'no_system_present': None, 'appliance': None, 'assumed': False} + 'distribution_system': None, 'no_system_present': None, 'appliance': None, 'assumed': False}, + {'original_description': 'Single-point gas water heater, standard tariff', + 'heater_type': 'single-point gas', 'system_type': "water heater", 'thermostat_characteristics': None, + 'heating_scope': None, 'energy_recovery': None, 'tariff_type': 'standard tariff', 'extra_features': None, + 'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'appliance': None + } ]