diff --git a/backend/ml_models/AnnualBillSavings.py b/backend/ml_models/AnnualBillSavings.py index 9be9d78a..99d67126 100644 --- a/backend/ml_models/AnnualBillSavings.py +++ b/backend/ml_models/AnnualBillSavings.py @@ -19,7 +19,8 @@ class AnnualBillSavings: PRICE_FACTOR = 0.09549999999999999 # Daily standard charge, based on average across England, Scotland and Wales, and includes VAT - DAILY_STANDARD_CHARGE = 0.3143 + DAILY_STANDARD_CHARGE_GAS = 0.3143 + DAILY_STANDARD_CHARGE_ELECTRICITY = 0.601 EPC_BANDS = ["G", "F", "E", "D", "C", "B", "A"] @@ -45,11 +46,12 @@ class AnnualBillSavings: def calculate_annual_bill(cls, kwh): """ This method will estimate the total annual bill for a property + It assumed gas & electricity are used :param kwh: The total kwh consumption :return: An estimate for annual bill """ - return cls.PRICE_FACTOR * kwh + cls.DAILY_STANDARD_CHARGE * 365 + return cls.PRICE_FACTOR * kwh + (cls.DAILY_STANDARD_CHARGE_GAS + cls.DAILY_STANDARD_CHARGE_ELECTRICITY * 365) @classmethod def adjust_energy_to_metered(cls, epc_energy_consumption, current_epc_rating): diff --git a/etl/customers/gla_croydon_demo/slides.py b/etl/customers/gla_croydon_demo/slides.py index cbd1f7e4..9f791bbd 100644 --- a/etl/customers/gla_croydon_demo/slides.py +++ b/etl/customers/gla_croydon_demo/slides.py @@ -112,6 +112,49 @@ def scenario_1(): recommendations_summary["total_bill_savings"] / recommendations_summary["current_energy_bill"] ) + ######################## + # Overview + ######################## + overview_totals = recommendations_summary.sum() + overview_means = recommendations_summary.mean() + + ######################## + # Measures + ######################## + measures_count = recommendations_df.groupby("type")["id"].count().reset_index() + wall_insulation_measures = measures_count[ + measures_count["type"].isin(["cavity_wall_insulation", "external_wall_insulation", "internal_wall_insulation"]) + ]["id"].sum() + ventilation_measures = measures_count[ + measures_count["type"].isin(["mechanical_ventilation"]) + ]["id"].sum() + roof_insulation_measures = measures_count[ + measures_count["type"].isin(["loft_insulation", "flat_roof_insulation"]) + ]["id"].sum() + floor_insulation_measures = measures_count[ + measures_count["type"].isin(["solid_floor_insulation", "suspended_floor_insulation"]) + ]["id"].sum() + windows = measures_count[ + measures_count["type"].isin(["windows_glazing"]) + ]["id"].sum() + heating = measures_count[ + measures_count["type"].isin(["heating"]) + ]["id"].sum() + heating_controls = measures_count[ + measures_count["type"].isin(["heating_control"]) + ]["id"].sum() + solar = measures_count[ + measures_count["type"].isin(["solar_pv"]) + ]["id"].sum() + other = measures_count[ + ~measures_count["type"].isin([ + "cavity_wall_insulation", "external_wall_insulation", "internal_wall_insulation", + "loft_insulation", "flat_roof_insulation", "solid_floor_insulation", + "suspended_floor_insulation", "windows_glazing", "heating", "heating_control", "solar_pv", + "mechanical_ventilation" + ]) + ]["id"].sum() + # Summary information by each archetype ######################## # Archetype 1 @@ -121,10 +164,54 @@ def scenario_1(): recommendations_summary["uprn"].astype(str).isin(archetype_1["uprn"].values) ] + arch_1_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_1["uprn"].values) + ] + arch_1_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value - arch_1_recommendation_min = recommendations_arch_1_summary.min() - arch_1_recommendation_max = recommendations_arch_1_summary.max() - arch_1_recommendation_means = recommendations_arch_1_summary.mean() + cols_to_keep = ["total_cost", "total_carbon", "total_bill_savings", "total_sap_points", "adjusted_heat_demand", + "energy_percent_change", "carbon_percent_change", "bills_percent_change"] + arch_1_recommendation_min = recommendations_arch_1_summary.min()[cols_to_keep] + arch_1_recommendation_max = recommendations_arch_1_summary.max()[cols_to_keep] + arch_1_recommendation_means = recommendations_arch_1_summary.mean()[cols_to_keep] + arch_1_totals = recommendations_arch_1_summary.sum()[cols_to_keep] + + annual_total_co2 = recommendations_arch_1_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_1_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_1_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_1["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_1_recommendation_means['total_cost'], 2)}: " + f"{arch_1_recommendation_min['total_cost']} - {arch_1_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_1_recommendation_means['total_sap_points'], 2)}: " + f"{arch_1_recommendation_min['total_sap_points']} - {arch_1_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_1_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_1_recommendation_min['adjusted_heat_demand']} - " + f"{arch_1_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_1_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_1_recommendation_min['energy_percent_change']} - " + f"{arch_1_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_1_recommendation_means['total_carbon'], 2)}: " + f"{arch_1_recommendation_min['total_carbon']} - {arch_1_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_1_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_1_recommendation_min['carbon_percent_change']} - " + f"{arch_1_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_1_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_1_recommendation_min['total_bill_savings']} - " + f"{arch_1_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_1_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_1_recommendation_min['bills_percent_change']} - " + f"{arch_1_recommendation_max['bills_percent_change']}") ######################## # Archetype 2 @@ -134,11 +221,53 @@ def scenario_1(): recommendations_summary["uprn"].astype(str).isin(archetype_2["uprn"].values) ] + arch_2_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_2["uprn"].values) + ] + arch_2_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value arch_2_recommendation_min = recommendations_arch_2_summary.min() arch_2_recommendation_max = recommendations_arch_2_summary.max() arch_2_recommendation_means = recommendations_arch_2_summary.mean().round(2) + total_cost = recommendations_arch_2_summary["total_cost"].sum() + annual_total_co2 = recommendations_arch_2_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_2_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_2_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_2["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_2_recommendation_means['total_cost'], 2)}: " + f"{arch_2_recommendation_min['total_cost']} - {arch_2_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_2_recommendation_means['total_sap_points'], 2)}: " + f"{arch_2_recommendation_min['total_sap_points']} - {arch_2_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_2_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_2_recommendation_min['adjusted_heat_demand']} - " + f"{arch_2_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_2_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_2_recommendation_min['energy_percent_change']} - " + f"{arch_2_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_2_recommendation_means['total_carbon'], 2)}: " + f"{arch_2_recommendation_min['total_carbon']} - {arch_2_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_2_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_2_recommendation_min['carbon_percent_change']} - " + f"{arch_2_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_2_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_2_recommendation_min['total_bill_savings']} - " + f"{arch_2_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_2_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_2_recommendation_min['bills_percent_change']} - " + f"{arch_2_recommendation_max['bills_percent_change']}") + ######################## # Archetype 3 ######################## @@ -147,11 +276,53 @@ def scenario_1(): recommendations_summary["uprn"].astype(str).isin(archetype_3["uprn"].values) ] + arch_3_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_3["uprn"].values) + ] + arch_3_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value arch_3_recommendation_min = recommendations_arch_3_summary.min() arch_3_recommendation_max = recommendations_arch_3_summary.max() arch_3_recommendation_means = recommendations_arch_3_summary.mean() + total_cost = recommendations_arch_3_summary["total_cost"].sum() + annual_total_co2 = recommendations_arch_3_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_3_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_3_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_3["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_3_recommendation_means['total_cost'], 2)}: " + f"{arch_3_recommendation_min['total_cost']} - {arch_3_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_3_recommendation_means['total_sap_points'], 2)}: " + f"{arch_3_recommendation_min['total_sap_points']} - {arch_3_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_3_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_3_recommendation_min['adjusted_heat_demand']} - " + f"{arch_3_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_3_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_3_recommendation_min['energy_percent_change']} - " + f"{arch_3_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_3_recommendation_means['total_carbon'], 2)}: " + f"{arch_3_recommendation_min['total_carbon']} - {arch_3_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_3_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_3_recommendation_min['carbon_percent_change']} - " + f"{arch_3_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_3_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_3_recommendation_min['total_bill_savings']} - " + f"{arch_3_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_3_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_3_recommendation_min['bills_percent_change']} - " + f"{arch_3_recommendation_max['bills_percent_change']}") + ######################## # Archetype 4 ######################## @@ -160,14 +331,52 @@ def scenario_1(): recommendations_summary["uprn"].astype(str).isin(archetype_4["uprn"].values) ] + arch_4_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_4["uprn"].values) + ] + arch_4_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value arch_4_recommendation_min = recommendations_arch_4_summary.min() arch_4_recommendation_max = recommendations_arch_4_summary.max() arch_4_recommendation_means = recommendations_arch_4_summary.mean() - property_details_df[ - property_details_df["uprn"].astype(str).isin(archetype_4["uprn"].values) - ]["total_floor_area"].mean() + total_cost = recommendations_arch_4_summary["total_cost"].sum() + annual_total_co2 = recommendations_arch_4_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_4_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_4_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_4["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_4_recommendation_means['total_cost'], 2)}: " + f"{arch_4_recommendation_min['total_cost']} - {arch_4_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_4_recommendation_means['total_sap_points'], 2)}: " + f"{arch_4_recommendation_min['total_sap_points']} - {arch_4_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_4_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_4_recommendation_min['adjusted_heat_demand']} - " + f"{arch_4_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_4_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_4_recommendation_min['energy_percent_change']} - " + f"{arch_4_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_4_recommendation_means['total_carbon'], 2)}: " + f"{arch_4_recommendation_min['total_carbon']} - {arch_4_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_4_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_4_recommendation_min['carbon_percent_change']} - " + f"{arch_4_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_4_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_4_recommendation_min['total_bill_savings']} - " + f"{arch_4_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_4_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_4_recommendation_min['bills_percent_change']} - " + f"{arch_4_recommendation_max['bills_percent_change']}") ######################## # Overview @@ -291,6 +500,38 @@ def scenario_2(): # Measures ######################## measures_count = recommendations_df.groupby("type")["id"].count().reset_index() + wall_insulation_measures = measures_count[ + measures_count["type"].isin(["cavity_wall_insulation", "external_wall_insulation", "internal_wall_insulation"]) + ]["id"].sum() + ventilation_measures = measures_count[ + measures_count["type"].isin(["mechanical_ventilation"]) + ]["id"].sum() + roof_insulation_measures = measures_count[ + measures_count["type"].isin(["loft_insulation", "flat_roof_insulation"]) + ]["id"].sum() + floor_insulation_measures = measures_count[ + measures_count["type"].isin(["solid_floor_insulation", "suspended_floor_insulation"]) + ]["id"].sum() + windows = measures_count[ + measures_count["type"].isin(["windows_glazing"]) + ]["id"].sum() + heating = measures_count[ + measures_count["type"].isin(["heating"]) + ]["id"].sum() + heating_controls = measures_count[ + measures_count["type"].isin(["heating_control"]) + ]["id"].sum() + solar = measures_count[ + measures_count["type"].isin(["solar_pv"]) + ]["id"].sum() + other = measures_count[ + ~measures_count["type"].isin([ + "cavity_wall_insulation", "external_wall_insulation", "internal_wall_insulation", + "loft_insulation", "flat_roof_insulation", "solid_floor_insulation", + "suspended_floor_insulation", "windows_glazing", "heating", "heating_control", "solar_pv", + "mechanical_ventilation" + ]) + ]["id"].sum() z = recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_3_sample)] @@ -305,11 +546,54 @@ def scenario_2(): recommendations_summary["uprn"].astype(str).isin(archetype_1["uprn"].values) ] + arch_1_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_1["uprn"].values) + ] + arch_1_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value arch_1_recommendation_min = recommendations_arch_1_summary.min() arch_1_recommendation_max = recommendations_arch_1_summary.max() arch_1_recommendation_means = recommendations_arch_1_summary.mean() + arch_1_totals = recommendations_arch_1_summary.sum() + + annual_total_co2 = recommendations_arch_1_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_1_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_1_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_1["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_1_recommendation_means['total_cost'], 2)}: " + f"{arch_1_recommendation_min['total_cost']} - {arch_1_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_1_recommendation_means['total_sap_points'], 2)}: " + f"{arch_1_recommendation_min['total_sap_points']} - {arch_1_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_1_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_1_recommendation_min['adjusted_heat_demand']} - " + f"{arch_1_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_1_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_1_recommendation_min['energy_percent_change']} - " + f"{arch_1_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_1_recommendation_means['total_carbon'], 2)}: " + f"{arch_1_recommendation_min['total_carbon']} - {arch_1_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_1_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_1_recommendation_min['carbon_percent_change']} - " + f"{arch_1_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_1_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_1_recommendation_min['total_bill_savings']} - " + f"{arch_1_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_1_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_1_recommendation_min['bills_percent_change']} - " + f"{arch_1_recommendation_max['bills_percent_change']}") + ######################## # Archetype 2 ######################## @@ -318,11 +602,53 @@ def scenario_2(): recommendations_summary["uprn"].astype(str).isin(archetype_2["uprn"].values) ] + arch_2_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_2["uprn"].values) + ] + arch_2_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value arch_2_recommendation_min = recommendations_arch_2_summary.min() arch_2_recommendation_max = recommendations_arch_2_summary.max() arch_2_recommendation_means = recommendations_arch_2_summary.mean().round(2) + total_cost = recommendations_arch_2_summary["total_cost"].sum() + annual_total_co2 = recommendations_arch_2_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_2_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_2_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_2["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_2_recommendation_means['total_cost'], 2)}: " + f"{arch_2_recommendation_min['total_cost']} - {arch_2_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_2_recommendation_means['total_sap_points'], 2)}: " + f"{arch_2_recommendation_min['total_sap_points']} - {arch_2_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_2_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_2_recommendation_min['adjusted_heat_demand']} - " + f"{arch_2_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_2_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_2_recommendation_min['energy_percent_change']} - " + f"{arch_2_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_2_recommendation_means['total_carbon'], 2)}: " + f"{arch_2_recommendation_min['total_carbon']} - {arch_2_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_2_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_2_recommendation_min['carbon_percent_change']} - " + f"{arch_2_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_2_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_2_recommendation_min['total_bill_savings']} - " + f"{arch_2_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_2_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_2_recommendation_min['bills_percent_change']} - " + f"{arch_2_recommendation_max['bills_percent_change']}") + ######################## # Archetype 3 ######################## @@ -331,11 +657,53 @@ def scenario_2(): recommendations_summary["uprn"].astype(str).isin(archetype_3["uprn"].values) ] + arch_3_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_3["uprn"].values) + ] + arch_3_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value arch_3_recommendation_min = recommendations_arch_3_summary.min() arch_3_recommendation_max = recommendations_arch_3_summary.max() arch_3_recommendation_means = recommendations_arch_3_summary.mean() + total_cost = recommendations_arch_3_summary["total_cost"].sum() + annual_total_co2 = recommendations_arch_3_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_3_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_3_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_3["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_3_recommendation_means['total_cost'], 2)}: " + f"{arch_3_recommendation_min['total_cost']} - {arch_3_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_3_recommendation_means['total_sap_points'], 2)}: " + f"{arch_3_recommendation_min['total_sap_points']} - {arch_3_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_3_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_3_recommendation_min['adjusted_heat_demand']} - " + f"{arch_3_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_3_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_3_recommendation_min['energy_percent_change']} - " + f"{arch_3_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_3_recommendation_means['total_carbon'], 2)}: " + f"{arch_3_recommendation_min['total_carbon']} - {arch_3_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_3_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_3_recommendation_min['carbon_percent_change']} - " + f"{arch_3_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_3_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_3_recommendation_min['total_bill_savings']} - " + f"{arch_3_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_3_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_3_recommendation_min['bills_percent_change']} - " + f"{arch_3_recommendation_max['bills_percent_change']}") + ######################## # Archetype 4 ######################## @@ -344,11 +712,49 @@ def scenario_2(): recommendations_summary["uprn"].astype(str).isin(archetype_4["uprn"].values) ] + arch_4_property_details = property_details_df[ + property_details_df["uprn"].astype(str).isin(archetype_4["uprn"].values) + ] + arch_4_property_details["co2_emissions"].sum() / property_details_df["co2_emissions"].sum() + # Take the mean, median and maximum of each value arch_4_recommendation_min = recommendations_arch_4_summary.min() arch_4_recommendation_max = recommendations_arch_4_summary.max() arch_4_recommendation_means = recommendations_arch_4_summary.mean() - property_details_df[ - property_details_df["uprn"].astype(str).isin(archetype_4["uprn"].values) - ]["total_floor_area"].mean() + total_cost = recommendations_arch_4_summary["total_cost"].sum() + annual_total_co2 = recommendations_arch_4_summary["total_carbon"].sum() + annual_total_bills = recommendations_arch_4_summary["total_bill_savings"].sum() + annual_total_energy_savings = recommendations_arch_4_summary["adjusted_heat_demand"].sum() + archetype_measures = \ + recommendations_df[recommendations_df["uprn"].astype(str).isin(archetype_4["uprn"].values)].groupby("type")[ + "id"].count().reset_index() + + cost_text = (f"{round(arch_4_recommendation_means['total_cost'], 2)}: " + f"{arch_4_recommendation_min['total_cost']} - {arch_4_recommendation_max['total_cost']}") + + sap_text = (f"{round(arch_4_recommendation_means['total_sap_points'], 2)}: " + f"{arch_4_recommendation_min['total_sap_points']} - {arch_4_recommendation_max['total_sap_points']}") + + energy_text = (f"{round(arch_4_recommendation_means['adjusted_heat_demand'], 2)}: " + f"{arch_4_recommendation_min['adjusted_heat_demand']} - " + f"{arch_4_recommendation_max['adjusted_heat_demand']}") + + energy_percent_text = (f"{round(arch_4_recommendation_means['energy_percent_change'], 2)}: " + f"{arch_4_recommendation_min['energy_percent_change']} - " + f"{arch_4_recommendation_max['energy_percent_change']}") + + carbon_text = (f"{round(arch_4_recommendation_means['total_carbon'], 2)}: " + f"{arch_4_recommendation_min['total_carbon']} - {arch_4_recommendation_max['total_carbon']}") + + carbon_percent_text = (f"{round(arch_4_recommendation_means['carbon_percent_change'], 2)}: " + f"{arch_4_recommendation_min['carbon_percent_change']} - " + f"{arch_4_recommendation_max['carbon_percent_change']}") + + bill_text = (f"{round(arch_4_recommendation_means['total_bill_savings'], 2)}: " + f"{arch_4_recommendation_min['total_bill_savings']} - " + f"{arch_4_recommendation_max['total_bill_savings']}") + + bill_percent_text = (f"{round(arch_4_recommendation_means['bills_percent_change'], 2)}: " + f"{arch_4_recommendation_min['bills_percent_change']} - " + f"{arch_4_recommendation_max['bills_percent_change']}") diff --git a/recommendations/HeatingRecommender.py b/recommendations/HeatingRecommender.py index 9d2e99e3..2c075820 100644 --- a/recommendations/HeatingRecommender.py +++ b/recommendations/HeatingRecommender.py @@ -186,9 +186,18 @@ class HeatingRecommender: # This upgrade will only take the heating system to average energy efficiency heating_simulation_config["mainheat_energy_eff_ending"] = "Average" + # If the property is off-gas and has no heating system in place, the number of heated rooms will actually + # be 0, so we use the number of rooms as the figure + number_heated_rooms = ( + self.property.data["number-heated-rooms"] if self.property.data["number-heated-rooms"] > 0 + else ( + self.property.number_of_rooms - 1 if self.property.number_of_rooms > 1 else + self.property.number_of_rooms + ) + ) # Upgrade to electric storage heaters costs = self.costs.high_heat_electric_storage_heaters( - number_heated_rooms=self.property.data["number-heated-rooms"] + number_heated_rooms=number_heated_rooms ) description = "Install high heat retention electric storage heaters" @@ -268,9 +277,9 @@ class HeatingRecommender: ] 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" + description = "Upgrade to a new combi boiler" else: - description = "Upgrade to a low carbon boiler" + description = "Upgrade to a new boiler" simulation_config = {"mainheat_energy_eff_ending": "Good"} if access_to_mains_no_system: