mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Merge pull request #677 from Hestia-Homes/main
don't say ventilation is already installed if cwi installed
This commit is contained in:
commit
ac97bee4ae
4 changed files with 88 additions and 6 deletions
|
|
@ -0,0 +1,81 @@
|
||||||
|
# 1) Need to get all already installed measures
|
||||||
|
# 2) get the unique uprns for these properties
|
||||||
|
# 3) Create a re-fresh SAL for these properties
|
||||||
|
# 4) re-trigger EPC C w/o EWI/IWI + the EPC B scenario
|
||||||
|
|
||||||
|
from backend.app.db.models.recommendations import InstalledMeasure
|
||||||
|
from backend.app.db.connection import db_session
|
||||||
|
from etl.customers.cambridge.surveys import current_epc
|
||||||
|
|
||||||
|
# Get all installed measures from the installedMeasure table
|
||||||
|
with db_session() as session:
|
||||||
|
# We need installed measures, where the measure type is ewi or iwi
|
||||||
|
installed_measures = session.query(InstalledMeasure).filter(
|
||||||
|
InstalledMeasure.measure_type.in_(["external_wall_insulation", "internal_wall_insulation"])
|
||||||
|
).all()
|
||||||
|
# Get the uprns
|
||||||
|
installed_uprns = [x.uprn for x in installed_measures]
|
||||||
|
|
||||||
|
installed_uprns = list(set(installed_uprns))
|
||||||
|
|
||||||
|
# This is 21425 properties.
|
||||||
|
# We then create a portfolio of properties we need to re-run
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
sal = pd.read_excel(
|
||||||
|
"/Users/khalimconn-kowlessar/Documents/hestia/Customers/Peabody/Nov 2025 Consulting Project/Final SAL/20260113 - "
|
||||||
|
"final asset list.xlsx",
|
||||||
|
sheet_name="Standardised Asset List"
|
||||||
|
)
|
||||||
|
|
||||||
|
needing_retry = sal[sal["epc_os_uprn"].isin(installed_uprns)]
|
||||||
|
|
||||||
|
# Store
|
||||||
|
needing_retry.to_excel(
|
||||||
|
"/Users/khalimconn-kowlessar/Documents/hestia/Customers/Peabody/Nov 2025 Consulting Project/Final "
|
||||||
|
"SAL/properties_needing_retry_20260115.xlsx",
|
||||||
|
sheet_name="Standardised Asset List",
|
||||||
|
index=False
|
||||||
|
)
|
||||||
|
|
||||||
|
#### Testing
|
||||||
|
with_ewi = pd.read_excel(
|
||||||
|
"/Users/khalimconn-kowlessar/Documents/hestia/Customers/Peabody/Nov 2025 Consulting Project/Final SAL/EPC C - no "
|
||||||
|
"solid floor, ashp 3.0 - 20250113 final.xlsx"
|
||||||
|
)
|
||||||
|
without_ewi = pd.read_excel(
|
||||||
|
"/Users/khalimconn-kowlessar/Documents/hestia/Customers/Peabody/Nov 2025 Consulting Project/Final SAL/EPC C - no "
|
||||||
|
"solid floor, no EWI or IWI, ashp 3.0 - 20250113 final.xlsx"
|
||||||
|
)
|
||||||
|
|
||||||
|
comparison = with_ewi.merge(
|
||||||
|
without_ewi,
|
||||||
|
left_on="uprn",
|
||||||
|
right_on="uprn",
|
||||||
|
suffixes=("_with_ewi", "_without_ewi")
|
||||||
|
)
|
||||||
|
|
||||||
|
with_ewi = comparison[comparison["total_retrofit_cost_with_ewi"] > 0]
|
||||||
|
with_ewi["current_epc_rating_with_ewi"].value_counts()
|
||||||
|
with_ewi["current_epc_rating_with_ewi"].value_counts()
|
||||||
|
|
||||||
|
without_ewi = comparison[comparison["total_retrofit_cost_without_ewi"] > 0]
|
||||||
|
with_ewi = comparison[comparison["total_retrofit_cost_with_ewi"] > 0]
|
||||||
|
|
||||||
|
with_ewi[with_ewi["current_epc_rating_with_ewi"] == "Epc.C"]["uprn"]
|
||||||
|
|
||||||
|
to_fix = with_ewi[with_ewi["current_epc_rating_with_ewi"] == "Epc.C"]
|
||||||
|
to_fix = to_fix[["uprn", "address_with_ewi", "postcode_with_ewi", "property_type_with_ewi"]].rename(
|
||||||
|
columns={
|
||||||
|
"address_with_ewi": "address",
|
||||||
|
"postcode_with_ewi": "postcode",
|
||||||
|
"property_type_with_ewi": "property_type"
|
||||||
|
}
|
||||||
|
).merge(
|
||||||
|
sal[["epc_os_uprn", "landlord_built_form"]],
|
||||||
|
left_on="uprn",
|
||||||
|
right_on="epc_os_uprn",
|
||||||
|
how="left"
|
||||||
|
).drop(columns=["epc_os_uprn"])
|
||||||
|
|
||||||
|
to_fix = to_fix.to_dict("records")
|
||||||
|
|
@ -39,7 +39,7 @@ class VentilationRecommendations(Definitions):
|
||||||
|
|
||||||
parts = self.mechanical_ventilation_materials.copy()
|
parts = self.mechanical_ventilation_materials.copy()
|
||||||
|
|
||||||
already_installed = "cavity_wall_insulation" in self.property.already_installed
|
already_installed = "mechanical_ventilation" in self.property.already_installed
|
||||||
|
|
||||||
# TODO: We now have multiple ventilation options - we default to selecting the cheapest option
|
# TODO: We now have multiple ventilation options - we default to selecting the cheapest option
|
||||||
part = min(parts, key=lambda x: x['total_cost'])
|
part = min(parts, key=lambda x: x['total_cost'])
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,8 @@ def calculate_gain(
|
||||||
else epc_to_sap_lower_bound(body.goal_value)
|
else epc_to_sap_lower_bound(body.goal_value)
|
||||||
)
|
)
|
||||||
|
|
||||||
if target_sap == current_sap:
|
if target_sap <= current_sap:
|
||||||
|
# We've already met or exceeded the target EPC
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
gain = CostOptimiser.calculate_sap_gain_with_slack(
|
gain = CostOptimiser.calculate_sap_gain_with_slack(
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ from collections import defaultdict
|
||||||
# SCENARIOS = [389]
|
# SCENARIOS = [389]
|
||||||
PORTFOLIO_ID = 435 # Peabody
|
PORTFOLIO_ID = 435 # Peabody
|
||||||
SCENARIOS = [
|
SCENARIOS = [
|
||||||
# 908,
|
908,
|
||||||
# 909,
|
909,
|
||||||
910,
|
910,
|
||||||
]
|
]
|
||||||
scenario_names = {
|
scenario_names = {
|
||||||
# 908: "EPC C - no solid floor, ashp 3.0",
|
908: "EPC C - no solid floor, ashp 3.0",
|
||||||
# 909: "EPC C - no solid floor, no EWI or IWI, ashp 3.0",
|
909: "EPC C - no solid floor, no EWI or IWI, ashp 3.0",
|
||||||
910: "EPC B - no solid floor, no EWI, ashp 3.0"
|
910: "EPC B - no solid floor, no EWI, ashp 3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue