integrating scoring heat and hot water models and adjusting days_to for the cost models

This commit is contained in:
Khalim Conn-Kowlessar 2024-07-09 15:52:16 +01:00
parent 4c79abe512
commit b9f64722ce

View file

@ -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)