mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
fixing missing bills calcs for properties without recs
This commit is contained in:
parent
5696b03b8c
commit
7275dc8e91
2 changed files with 25 additions and 16 deletions
|
|
@ -133,8 +133,8 @@ def extract_portfolio_aggregation_data(
|
|||
[r["energy_cost_savings"] for r in default_recommendations]
|
||||
)
|
||||
|
||||
pre_retrofit_energy_consumption = p.current_adjusted_energy
|
||||
post_retrofit_energy_consumption = p.current_adjusted_energy - sum(
|
||||
pre_retrofit_energy_consumption = p.current_energy_consumption
|
||||
post_retrofit_energy_consumption = p.current_energy_consumption - sum(
|
||||
[r["kwh_savings"] for r in default_recommendations]
|
||||
)
|
||||
|
||||
|
|
@ -724,8 +724,9 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
# We now insert kwh estimates and costs into the recommendations
|
||||
# TODO: We should join the methodology which maps the heating and hot water descriptions to the fuel types in
|
||||
# Recommendations, but also the Property class
|
||||
for property_id in tqdm(recommendations.keys()):
|
||||
property_recommendations = recommendations[property_id]
|
||||
logger.info("Calculating tenant savings - kwh and bills")
|
||||
for property_id in tqdm([p.id for p in input_properties]):
|
||||
property_recommendations = recommendations.get(property_id, [])
|
||||
property_instance = [p for p in input_properties if p.id == property_id][0]
|
||||
|
||||
property_current_energy_bill = Recommendations.calculate_recommendation_tenant_savings(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from recommendations.HotwaterRecommendations import HotwaterRecommendations
|
|||
from recommendations.SecondaryHeating import SecondaryHeating
|
||||
from backend.ml_models.AnnualBillSavings import AnnualBillSavings
|
||||
from backend.apis.GoogleSolarApi import GoogleSolarApi
|
||||
import backend.app.assumptions as assumptions
|
||||
|
||||
ASHP_COP = 3
|
||||
DESCRIPTIONS_TO_FUEL_TYPES = {
|
||||
|
|
@ -40,6 +41,8 @@ DESCRIPTIONS_TO_FUEL_TYPES = {
|
|||
"Electric instantaneous at point of use": {"fuel": "Electricity", "cop": 1},
|
||||
"Boiler and radiators, oil": {"fuel": "Oil", "cop": 0.9},
|
||||
"Electric storage heaters, Electric storage heaters": {"fuel": "Electricity", "cop": 1},
|
||||
"Boiler and radiators, electric": {"fuel": "Electricity", "cop": 0.9},
|
||||
"Gas boiler/circulator, no cylinder thermostat": {"fuel": "Natural Gas", "cop": 0.9},
|
||||
}
|
||||
STARTING_DUMMY_ID_VALUE = -9999
|
||||
|
||||
|
|
@ -594,14 +597,15 @@ class Recommendations:
|
|||
{
|
||||
"phase": r["phase"],
|
||||
"recommendation_id": r["recommendation_id"],
|
||||
"lighting_kwh_savings": r["kwh_savings"] * GoogleSolarApi.SOLAR_CONSUMPTION_PROPORTION,
|
||||
"lighting_kwh_savings": r["kwh_savings"]
|
||||
} for recs in property_recommendations for r in recs if r["type"] == "low_energy_lighting"
|
||||
], columns=["phase", "recommendation_id", "lighting_kwh_savings"])
|
||||
|
||||
solar_recommendations = pd.DataFrame([
|
||||
{
|
||||
"phase": r["phase"],
|
||||
"recommendation_id": r["recommendation_id"],
|
||||
"solar_kwh_savings": r["initial_ac_kwh_per_year"] * GoogleSolarApi.SOLAR_CONSUMPTION_PROPORTION,
|
||||
"solar_kwh_savings": r["initial_ac_kwh_per_year"] * assumptions.SOLAR_CONSUMPTION_PROPORTION,
|
||||
} for recs in property_recommendations for r in recs if r["type"] == "solar_pv"
|
||||
], columns=["phase", "recommendation_id", "solar_kwh_savings"])
|
||||
|
||||
|
|
@ -673,17 +677,21 @@ class Recommendations:
|
|||
fuel_mapping, how="left", on="id"
|
||||
).sort_values(["phase", "recommendation_id"], ascending=True).reset_index(drop=True)
|
||||
|
||||
kwh_impact_table["heating_fuel_type"] = np.where(
|
||||
kwh_impact_table["id"] == STARTING_DUMMY_ID_VALUE,
|
||||
property_instance.heating_energy_source,
|
||||
kwh_impact_table["heating_fuel_type"]
|
||||
)
|
||||
if (pd.isnull(kwh_impact_table["heating_fuel_type"]).sum() or
|
||||
pd.isnull(kwh_impact_table["hotwater_fuel_type"]).sum()):
|
||||
raise Exception("Fuel type is missing")
|
||||
|
||||
kwh_impact_table["hotwater_fuel_type"] = np.where(
|
||||
kwh_impact_table["id"] == STARTING_DUMMY_ID_VALUE,
|
||||
property_instance.hot_water_energy_source,
|
||||
kwh_impact_table["hotwater_fuel_type"]
|
||||
)
|
||||
# kwh_impact_table["heating_fuel_type"] = np.where(
|
||||
# kwh_impact_table["id"] == STARTING_DUMMY_ID_VALUE,
|
||||
# property_instance.heating_energy_source,
|
||||
# kwh_impact_table["heating_fuel_type"]
|
||||
# )
|
||||
#
|
||||
# kwh_impact_table["hotwater_fuel_type"] = np.where(
|
||||
# kwh_impact_table["id"] == STARTING_DUMMY_ID_VALUE,
|
||||
# property_instance.hot_water_energy_source,
|
||||
# kwh_impact_table["hotwater_fuel_type"]
|
||||
# )
|
||||
|
||||
# We now calculate the fuel cost
|
||||
for k in ["heating", "hotwater"]:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue