From 47ebf866ee141c8ed91a7191b5bb75ef49246950 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 3 Apr 2024 20:02:37 +0100 Subject: [PATCH] fixed sample in slides --- backend/app/plan/router.py | 1 - etl/customers/gla_croydon_demo/slides.py | 35 +++++++++++---------- recommendations/HeatingRecommender.py | 39 ++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 4868749d..50b8a837 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -389,7 +389,6 @@ async def trigger_plan(body: PlanTriggerRequest): # Commit final changes session.commit() - except IntegrityError: logger.error("Database integrity error occurred", exc_info=True) session.rollback() diff --git a/etl/customers/gla_croydon_demo/slides.py b/etl/customers/gla_croydon_demo/slides.py index e6c4b5b8..cbd1f7e4 100644 --- a/etl/customers/gla_croydon_demo/slides.py +++ b/etl/customers/gla_croydon_demo/slides.py @@ -28,20 +28,22 @@ SAP_TARGET_2 = 100 CUSTOMER_KEY = "gla-demo" # Sample UPRNS -archetype_1_sample = ['100020618076', '100020619814', '100020581792', '100020671205', '100020585305', '100020606853', - '100020625813', '100020618042', '200001188304', '200001187196', '100020603026', '100020604138', - '100020615039', '200001188299', '100020618060', '200001192253'] +archetype_1_sample = ['100020604138', '200001192253', '100020581792', '100020576940', '200001187196', '100020618060', + '100020625813', '100020578756', '100020618076', '200001187197', '100020619814', '100020617489', + '100020588913'] -archetype_2_sample = ['100020616325', '100020665634', '100020665654', '100020665638', '100020587936', '100020587905', - '100020665645', '100020625597', '100022907528', '100020665630', '100020624348', '10001008257', - '100020666735', '100020698027', '100020624351', '100020665656', '100020666716', '100020665632', - '100020666715', '100020645639', '200001191309', '100020625451', '100020624347', '100020665658', - '100020585002', '100022917303', '100020665650', '100020667737', '100020620659', '100022904981', - '100020642337', '100020657902', '100020615603', '100020626800', '100020665647', '100020665643'] +archetype_2_sample = ['100020585002', '100020615603', '100020665652', '100020626800', '100020624347', '100020624348', + '100020576459', '10001007455', '100020666716', '100020609610', '100020625451', '100020625597', + '100020624351', '100020665634', '100020624350', '100020665640', '100020665632', '100022917303', + '100020665656', '10014055968', '100020630285', '100020665638', '100020616325', '100020637405', + '100020698027', '100020657902', '100020688226', '100020653786', '100020642337', '100020665643'] -archetype_3_sample = ['100020607980', '200001193193', '100020581690', '100020665611'] -archetype_4_sample = ['100020631683', '100020607667', '100020660228', '100020605116', '200001187539', '100020582907', - '100020610165', '100020650607', '100020655500', '100020598277', '100020642537'] +archetype_3_sample = ['100020594652', '100020697787', '100020577523', '100020633162', '100020601138', '100020595611', + '100020597485', '100020614883', '100020605342', '100020654671', '100020575611', '100020607980', + '200001185785', '100020616446', '100020692380'] + +archetype_4_sample = ['100020596436', '100020610165', '200001187539', '100020655500', '100020582907', '100020598277', + '100020650607', '100020605116', '100020650603'] def scenario_1(): @@ -182,10 +184,11 @@ def make_sample(): asset_list = pd.DataFrame(asset_list) # From the asset list, we deduce how many properties we need - archetype_1_sample_size = 16 - archetype_2_sample_size = 36 - archetype_3_sample_size = 4 - archetype_4_sample_size = 11 + # Need to figure out the sizes + archetype_1_sample_size = 13 + archetype_2_sample_size = 30 + archetype_3_sample_size = 15 + archetype_4_sample_size = 9 # We take the sample and we'll keep the uprns static archetype_1_sample = asset_list[ diff --git a/recommendations/HeatingRecommender.py b/recommendations/HeatingRecommender.py index 8b20c0cd..9d2e99e3 100644 --- a/recommendations/HeatingRecommender.py +++ b/recommendations/HeatingRecommender.py @@ -4,6 +4,7 @@ from recommendations.Costs import Costs from recommendations.recommendation_utils import check_simulation_difference from backend.Property import Property from etl.epc_clean.epc_attributes.MainheatAttributes import MainHeatAttributes +from etl.epc_clean.epc_attributes.HotWaterAttributes import HotWaterAttributes from recommendations.HeatingControlRecommender import HeatingControlRecommender @@ -35,7 +36,14 @@ class HeatingRecommender: return # if the property has mains heating with boiler and radiators, we recommend optimal heating controls - if self.property.main_heating["clean_description"] in ["Boiler and radiators, mains gas"]: + has_boiler = self.property.main_heating["clean_description"] in ["Boiler and radiators, mains gas"] + + # We also check that the property doesn't have a heating system, but it has access to the mains gas + no_heating_has_mains = self.property.main_heating["clean_description"] in [ + 'No system present, electric heaters assumed' + ] and self.property.data["mains-gas-flag"] + + if has_boiler or no_heating_has_mains: self.recommend_boiler_upgrades(phase=phase) return @@ -254,12 +262,37 @@ class HeatingRecommender: ) # If heating and hot water come from the mains, we need a combi boiler, otherwise we need a regular boiler - is_combi = self.property.hotwater["clean_description"] in ["From main system"] + hotwater_from_mains = self.property.hotwater["clean_description"] in ["From main system"] + access_to_mains_no_system = self.property.main_heating["clean_description"] in [ + 'No system present, electric heaters assumed' + ] and self.property.data["mains-gas-flag"] + is_combi = hotwater_from_mains or access_to_mains_no_system if is_combi: description = "Upgrade to a low carbon combi boiler" else: description = "Upgrade to a low carbon boiler" + simulation_config = {"mainheat_energy_eff_ending": "Good"} + if access_to_mains_no_system: + # Installation of a boiler improves the hot water system so we need to reflect this in + # the outcome of the recommendation + heating_ending_config = MainHeatAttributes("Boiler and radiators, mains gas").process() + hotwater_ending_config = HotWaterAttributes("From main system").process() + + heating_simulation_config = check_simulation_difference( + new_config=heating_ending_config, old_config=self.property.main_heating + ) + hotwater_simulation_config = check_simulation_difference( + new_config=hotwater_ending_config, old_config=self.property.hotwater + ) + + simulation_config = { + **simulation_config, + **heating_simulation_config, + **hotwater_simulation_config, + "hot_water_energy_eff_ending": "Good" + } + self.recommendations.append( { "phase": recommendation_phase, @@ -271,7 +304,7 @@ class HeatingRecommender: "starting_u_value": None, "new_u_value": None, "sap_points": None, - "simulation_config": {"mainheat_energy_eff_ending": "Good"}, + "simulation_config": simulation_config, **self.costs.low_carbon_boiler(is_combi=is_combi, size=f"{boiler_size}kw") } )