From b9f64722cef0c9fe540f20e66eeefe6414e4be89 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 9 Jul 2024 15:52:16 +0100 Subject: [PATCH] integrating scoring heat and hot water models and adjusting days_to for the cost models --- backend/Property.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/Property.py b/backend/Property.py index 188564e4..433bebe7 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -2,8 +2,10 @@ import os import ast from itertools import groupby import pandas as pd +from datetime import datetime, timedelta from etl.epc.Dataset import TrainingDataset +from etl.epc.Record import EPCRecord from etl.epc.settings import LATEST_FIELD, MANDATORY_FIXED_FEATURES from etl.epc_clean.epc_attributes.all_cleaners import all_cleaner_map from etl.solar.SolarPhotoSupply import SolarPhotoSupply @@ -291,6 +293,7 @@ class Property: if r[0]["phase"] is not None ] ) + simulation_lodgment_date = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d") for phase in phases: property_recommendations_by_phase = [ @@ -323,6 +326,10 @@ class Property: 0 ].copy() + recommendation_record["days_to_ending"] = EPCRecord._calculate_days_to( + lodgement_date=simulation_lodgment_date, + ) + for rec in property_recommendations_by_phase: # We simulate the impact of the recommendation at this current phase, and all of the prior phases @@ -355,6 +362,13 @@ class Property: phase_epc_transformation[k] = v simulation_epc = self.epc_record.prepared_epc.copy() + # Insert static values + simulation_epc["lodgement_date"] = simulation_lodgment_date + # Insert today's costs, unadjusted (i.e. in line with what we expect the EPC would say today) + simulation_epc["heating-cost-current"] = round(self.energy_cost_estimates["unadjusted"]["heating"]) + simulation_epc["lighting-cost-current"] = round(self.energy_cost_estimates["unadjusted"]["lighting"]) + simulation_epc["hot-water-cost-current"] = round(self.energy_cost_estimates["unadjusted"]["hot_water"]) + # Replace the understores with hyphens simulation_epc = {k.replace("_", "-"): v for k, v in simulation_epc.items()} simulation_epc.update(phase_epc_transformation)