small fixes for multiple heating systems

This commit is contained in:
Khalim Conn-Kowlessar 2025-08-09 18:43:10 +01:00
parent 8dcb9c11d8
commit 25f4c7f246
2 changed files with 25 additions and 10 deletions

View file

@ -383,7 +383,9 @@ class Funding:
return 'Non Condensing LPG Boiler'
if mainheating["has_boiler"] and (
main_fuel["fuel_type"] in ["dual fuel appliance mineral and wood", "manufactured smokeless fuel"]
main_fuel["fuel_type"] in [
"dual fuel appliance mineral and wood", "manufactured smokeless fuel", "dual fuel mineral wood"
]
) and (mainheat_energy_eff in ["Average", "Very Poor", "Poor"]):
return 'Solid Fossil Boiler'
@ -395,7 +397,9 @@ class Funding:
if mainheating["has_community_scheme"] and mainheat_energy_eff in ["Good", "Very Good"]:
return 'DHS CHP'
if mainheating["has_community_scheme"] and mainheat_energy_eff in ["Average", "Very Poor", "Poor"]:
if mainheating["has_community_scheme"] and (
mainheat_energy_eff in ["Average", "Very Poor", "Poor"] or pd.isnull(mainheat_energy_eff)
):
return 'DHS non-CHP'
if mainheating["has_electric_storage_heaters"] and mainheat_energy_eff == "Very Poor":
@ -414,13 +418,18 @@ class Funding:
if mainheating["has_room_heaters"] and main_fuel["fuel_type"] == "mains gas":
return 'Gas Room Heaters'
if mainheating["has_room_heaters"] and main_fuel["fuel_type"] in [
"dual fuel appliance mineral and wood", "manufactured smokeless fuel"
]:
if mainheating["has_room_heaters"] and (
main_fuel["fuel_type"] in [
"dual fuel appliance mineral and wood", "manufactured smokeless fuel", "dual fuel mineral wood", "oil",
'smokeless coal'
] or mainheating["has_coal"]
):
return 'Solid Fossil Room Heaters'
# Handle the case of no heating system - electric heaters assumed
if mainheating["has_no_system_present"] or mainheating["has_portable_electric_heaters"]:
if mainheating["has_no_system_present"] or mainheating["has_portable_electric_heaters"] or (
mainheating["has_warm_air"] and mainheating["has_electric"] and not mainheating["has_electricaire"]
):
return 'Electric Room Heaters'
if not any(mainheating.values()):
@ -455,6 +464,7 @@ class Funding:
main_fuel: dict,
mainheat_energy_eff: str,
filtered_pps_matrix: pd.DataFrame,
pre_heating_system: str,
current_wall_uvalue: float = None,
is_partial: bool = False,
existing_li_thickness: float = None,
@ -536,7 +546,6 @@ class Funding:
return pps.squeeze()["Cost Savings"]
if measure_type == "solar_pv":
pre_heating_system = self._map_to_pre_main_heating(mainheating, main_fuel, mainheat_energy_eff)
solar_pps_df = filtered_pps_matrix[
(filtered_pps_matrix["Measure_Type"] == "Solar_PV") &
(filtered_pps_matrix["Pre_Main_Heating_Source"] == pre_heating_system)
@ -544,7 +553,6 @@ class Funding:
return solar_pps_df.squeeze()["Cost Savings"]
if measure_type == "air_source_heat_pump":
pre_heating_system = self._map_to_pre_main_heating(mainheating, main_fuel, mainheat_energy_eff)
pps = filtered_pps_matrix[
(filtered_pps_matrix["Pre_Main_Heating_Source"] == pre_heating_system) &
(filtered_pps_matrix["Post_Main_Heating_Source"] == "Air to Water ASHP") &
@ -795,6 +803,8 @@ class Funding:
(self.partial_project_scores_matrix["Starting Band"] == self.starting_sap_band)
].copy()
pre_heating_system = self._map_to_pre_main_heating(mainheating, main_fuel, mainheat_energy_eff)
if self.tenure == "Private":
# ECO4 PRS
self.eco4_prs_eligibility(starting_sap, ending_sap, measure_types, has_solar, solar_eligible)
@ -806,6 +816,9 @@ class Funding:
self.eco4_funding = self.full_project_abs * (
self.private_cavity_abs_rate if is_cavity else self.private_solid_abs_rate)
if self.gbis_eligible:
raise NotImplementedError("FIX ME")
elif self.tenure == "Social":
# ECO4 Social
self.eco4_sh_eligibility(
@ -836,6 +849,7 @@ class Funding:
is_partial=is_partial,
existing_li_thickness=existing_li_thickness,
filtered_pps_matrix=filtered_pps_matrix,
pre_heating_system=pre_heating_system
)
project_uplifts.append(pps * uplifts[i])
total_uplift = sum(project_uplifts)
@ -854,7 +868,8 @@ class Funding:
current_wall_uvalue=current_wall_uvalue,
is_partial=is_partial,
existing_li_thickness=existing_li_thickness,
filtered_pps_matrix=filtered_pps_matrix
filtered_pps_matrix=filtered_pps_matrix,
pre_heating_system=pre_heating_system
)

View file

@ -1019,7 +1019,7 @@ for _, x in tqdm(epc_df.iterrows(), total=len(epc_df)):
# inputs
mainheat_energy_eff = x["MAINHEAT_ENERGY_EFF"]
heating_cleaner = MainHeatAttributes(description=x["MAINHEAT_DESCRIPTION"])
fuel_cleaner = MainFuelAttributes(description=x["MAIN_FUEL"])
fuel_cleaner = MainFuelAttributes(description="" if pd.isnull(x["MAIN_FUEL"]) else x["MAIN_FUEL"])
h = heating_cleaner.process()
f = fuel_cleaner.process()