mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
fix(16d): predicted_lighting_kwh handles None bulb counts
EPC bulb-count fields are Optional[int]; 1k-cert sanity-check from slice 16h hit None + None TypeError. Coerce to 0 before sum.
This commit is contained in:
parent
700ff4640c
commit
e8b6f19a3a
1 changed files with 10 additions and 6 deletions
|
|
@ -120,19 +120,23 @@ def predicted_hot_water_kwh(
|
||||||
|
|
||||||
def predicted_lighting_kwh(
|
def predicted_lighting_kwh(
|
||||||
total_floor_area_m2: Optional[float],
|
total_floor_area_m2: Optional[float],
|
||||||
cfl_count: int,
|
cfl_count: Optional[int],
|
||||||
led_count: int,
|
led_count: Optional[int],
|
||||||
incandescent_count: int,
|
incandescent_count: Optional[int],
|
||||||
) -> float:
|
) -> float:
|
||||||
"""Annual lighting kWh (SAP10.2 Section L simplified).
|
"""Annual lighting kWh (SAP10.2 Section L simplified).
|
||||||
|
|
||||||
Base demand ~ 9.3 * TFA kWh/yr; reduced by low-energy bulb share. LED
|
Base demand ~ 9.3 * TFA kWh/yr; reduced by low-energy bulb share. LED
|
||||||
bulbs cut consumption by ~50%, CFL by ~40%, incandescent by 0%.
|
bulbs cut consumption by ~50%, CFL by ~40%, incandescent by 0%.
|
||||||
|
Missing counts treated as zero.
|
||||||
"""
|
"""
|
||||||
if total_floor_area_m2 is None or total_floor_area_m2 <= 0:
|
if total_floor_area_m2 is None or total_floor_area_m2 <= 0:
|
||||||
return 0.0
|
return 0.0
|
||||||
total_bulbs = max(1, cfl_count + led_count + incandescent_count)
|
cfl = cfl_count or 0
|
||||||
led_share = led_count / total_bulbs
|
led = led_count or 0
|
||||||
cfl_share = cfl_count / total_bulbs
|
inc = incandescent_count or 0
|
||||||
|
total_bulbs = max(1, cfl + led + inc)
|
||||||
|
led_share = led / total_bulbs
|
||||||
|
cfl_share = cfl / total_bulbs
|
||||||
reduction = 0.5 * led_share + 0.4 * cfl_share
|
reduction = 0.5 * led_share + 0.4 * cfl_share
|
||||||
return 9.3 * total_floor_area_m2 * (1.0 - reduction)
|
return 9.3 * total_floor_area_m2 * (1.0 - reduction)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue