extended outputs

This commit is contained in:
Khalim Conn-Kowlessar 2024-04-15 23:52:10 +01:00
parent d6fa81939d
commit cc6277c191

View file

@ -115,6 +115,9 @@ def extract_portfolio_aggregation_data(
pre_retrofit_energy_bill = p.current_energy_bill
post_retrofit_energy_bill = p.expected_energy_bill
pre_retrofit_energy_consumption = p.current_adjusted_energy
post_retrofit_energy_consumption = p.expected_adjusted_energy
cost = sum([r["total"] for r in default_recommendations])
sap_point_improvement = sum([r["sap_points"] for r in default_recommendations])
@ -125,6 +128,8 @@ def extract_portfolio_aggregation_data(
"post_retrofit_co2": post_retrofit_co2,
"pre_retrofit_energy_bill": pre_retrofit_energy_bill,
"post_retrofit_energy_bill": post_retrofit_energy_bill,
"pre_retrofit_energy_consumption": pre_retrofit_energy_consumption,
"post_retrofit_energy_consumption": post_retrofit_energy_consumption,
"cost": cost,
"sap_point_improvement": sap_point_improvement
})
@ -138,6 +143,9 @@ def extract_portfolio_aggregation_data(
total_carbon_saved = agg_data["pre_retrofit_co2"].sum() - agg_data["post_retrofit_co2"].sum()
total_sap_points = agg_data["sap_point_improvement"].sum()
def format_money(amount):
return f"£{amount:,.0f}"
aggregation_data = {
"epc_breakdown_pre_retrofit": json.dumps(
reformat_epc_data(agg_data["pre_retrofit_epc"].value_counts().to_dict())
@ -147,15 +155,18 @@ def extract_portfolio_aggregation_data(
),
"number_of_properties": n_units,
"n_units_to_retrofit": n_units_to_retrofit,
"co2_per_unit_pre_retrofit": agg_data["pre_retrofit_co2"].mean(),
"co2_per_unit_post_retrofit": agg_data["post_retrofit_co2"].mean(),
"energy_bill_per_unit_pre_retrofit": agg_data["pre_retrofit_energy_bill"].mean(),
"energy_bill_per_unit_post_retrofit": agg_data["post_retrofit_energy_bill"].mean(),
"valuation_improvement_per_unit": valuation_improvment_per_unit,
"total_cost": agg_data["cost"].sum(),
"cost_per_unit": agg_data["cost"].mean(),
"cost_per_co2_saved": agg_data["cost"].sum() / total_carbon_saved,
"cost_per_sap_point": agg_data["cost"].sum() / total_sap_points
"co2_per_unit_pre_retrofit": str(round(agg_data["pre_retrofit_co2"].mean(), 2)) + "t",
"co2_per_unit_post_retrofit": str(round(agg_data["post_retrofit_co2"].mean(), 2)) + "t",
"energy_bill_per_unit_pre_retrofit": format_money(agg_data["pre_retrofit_energy_bill"].mean()),
"energy_bill_per_unit_post_retrofit": format_money(agg_data["post_retrofit_energy_bill"].mean()),
"energy_consumption_per_unit_pre_retrofit": str(
round(agg_data["pre_retrofit_energy_consumption"].mean())) + "kWh",
"energy_consumption_per_unit_post_retrofit": str(
round(agg_data["post_retrofit_energy_consumption"].mean())) + "kWh",
"valuation_improvement_per_unit": format_money(valuation_improvment_per_unit),
"cost_per_unit": format_money(agg_data["cost"].mean()),
"cost_per_co2_saved": format_money(agg_data["cost"].sum() / total_carbon_saved),
"cost_per_sap_point": format_money(agg_data["cost"].sum() / total_sap_points)
}
return aggregation_data