mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
refactoring simialtion_epcs
This commit is contained in:
parent
9a62184ab5
commit
a2834a180e
1 changed files with 38 additions and 59 deletions
|
|
@ -376,72 +376,51 @@ class Property:
|
|||
)
|
||||
self.recommendations_scoring_data.append(scoring_dict)
|
||||
|
||||
# We also use the representative recommendations to produce transformed EPCs
|
||||
represenative_recs_to_this_phase = [
|
||||
r for r in property_representative_recommendations
|
||||
if r["phase"] <= phase
|
||||
]
|
||||
simulation_epc = self.epc_record.prepared_epc.copy()
|
||||
# Insert static values
|
||||
simulation_epc["lodgement_date"] = simulation_lodgment_date
|
||||
simulation_epc = {k.replace("_", "-"): v for k, v in simulation_epc.items()}
|
||||
|
||||
# TODO: This is placeholder, but it's to handle the case of having both internal and external wall
|
||||
# insulation as options. This will cause the process below to fall over, so we take just
|
||||
# external wall insulation in epc_transformations, if we have both
|
||||
types = [
|
||||
x["type"] for x in represenative_recs_to_this_phase
|
||||
]
|
||||
if "external_wall_insulation" in types and "internal_wall_insulation" in types:
|
||||
types = [x["type"] for x in previous_phase_representatives]
|
||||
if "external_wall_insulation" in types and "internal_wall_insulation" in types:
|
||||
raise Exception("We shouldn't have this in the representative recommendations")
|
||||
epc_transformations = [
|
||||
x["description_simulation"] for x in represenative_recs_to_this_phase if
|
||||
x["type"] != "internal_wall_insulation"
|
||||
]
|
||||
else:
|
||||
epc_transformations = [
|
||||
x["description_simulation"] for x in represenative_recs_to_this_phase
|
||||
x["description_simulation"] for x in previous_phase_representatives
|
||||
]
|
||||
|
||||
# It is possible that we could have two simulations applied to the same descriptions
|
||||
# We extract these out
|
||||
phase_epc_transformation = {}
|
||||
for config in epc_transformations:
|
||||
for k, v in config.items():
|
||||
if k in phase_epc_transformation:
|
||||
if "-energy-eff" in k:
|
||||
# We take the highest value
|
||||
if phase_epc_transformation[k] == "Very Good":
|
||||
# It is possible that we could have two simulations applied to the same descriptions
|
||||
# We extract these out
|
||||
phase_epc_transformation = {}
|
||||
for config in epc_transformations:
|
||||
for k, v in config.items():
|
||||
if k in phase_epc_transformation:
|
||||
if "-energy-eff" in k:
|
||||
# We take the highest value
|
||||
if phase_epc_transformation[k] == "Very Good":
|
||||
continue
|
||||
elif phase_epc_transformation[k] == "Good":
|
||||
if v == "Very Good":
|
||||
phase_epc_transformation[k] = v
|
||||
elif phase_epc_transformation[k] == "Average":
|
||||
if v in ["Good", "Very Good"]:
|
||||
phase_epc_transformation[k] = v
|
||||
elif phase_epc_transformation[k] == "Poor":
|
||||
if v in ["Average", "Good", "Very Good"]:
|
||||
phase_epc_transformation[k] = v
|
||||
else:
|
||||
phase_epc_transformation[k] = v
|
||||
|
||||
continue
|
||||
elif phase_epc_transformation[k] == "Good":
|
||||
if v == "Very Good":
|
||||
phase_epc_transformation[k] = v
|
||||
elif phase_epc_transformation[k] == "Average":
|
||||
if v in ["Good", "Very Good"]:
|
||||
phase_epc_transformation[k] = v
|
||||
elif phase_epc_transformation[k] == "Poor":
|
||||
if v in ["Average", "Good", "Very Good"]:
|
||||
phase_epc_transformation[k] = v
|
||||
else:
|
||||
phase_epc_transformation[k] = v
|
||||
|
||||
continue
|
||||
if phase_epc_transformation[k] == v:
|
||||
continue
|
||||
|
||||
if phase_epc_transformation[k] == v:
|
||||
continue
|
||||
|
||||
raise NotImplementedError(
|
||||
"Already have this key in the phase_epc_transformation - implement me"
|
||||
)
|
||||
phase_epc_transformation[k] = v
|
||||
|
||||
simulation_epc = self.epc_record.prepared_epc.copy()
|
||||
# Insert static values
|
||||
simulation_epc["lodgement_date"] = simulation_lodgment_date
|
||||
|
||||
# Replace the understores with hyphens
|
||||
simulation_epc = {k.replace("_", "-"): v for k, v in simulation_epc.items()}
|
||||
# Add in today's costs (unadjusted
|
||||
simulation_epc["heating-cost-current"] = int(self.energy_cost_estimates["unadjusted"]["heating"])
|
||||
simulation_epc["hot-water-cost-current"] = int(self.energy_cost_estimates["unadjusted"]["hot_water"])
|
||||
simulation_epc["lighting-cost-current"] = int(self.energy_cost_estimates["unadjusted"]["lighting"])
|
||||
simulation_epc.update(phase_epc_transformation)
|
||||
self.simulation_epcs[phase] = simulation_epc
|
||||
raise NotImplementedError(
|
||||
"Already have this key in the phase_epc_transformation - implement me"
|
||||
)
|
||||
phase_epc_transformation[k] = v
|
||||
simulation_epc.update(phase_epc_transformation)
|
||||
self.simulation_epcs[rec["recommendation_id"]] = simulation_epc
|
||||
|
||||
def update_simulation_epcs(self, impact_summary):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue