mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-22 08:48:38 +00:00
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Map a Landlord-Override construction-age-band value to a fabric Simulation
|
|
Overlay.
|
|
|
|
A construction-age-band value is the RdSAP England-&-Wales letter code (A..M)
|
|
the calculator's U-value cascades key on (`SapBuildingPart.construction_age_band`,
|
|
read via `.strip().upper()` against the letter-code bands). The overlay targets
|
|
the override's building part and sets the band; an unrecognised code produces no
|
|
overlay. Re-dating a part re-derives its construction-default U-values, so this
|
|
is the highest-leverage fabric override.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from datatypes.epc.domain.epc_property_data import BuildingPartIdentifier
|
|
from domain.modelling.simulation import BuildingPartOverlay, EpcSimulation
|
|
|
|
# RdSAP England-&-Wales construction age bands (letter codes A..M).
|
|
_VALID_AGE_BANDS: frozenset[str] = frozenset("ABCDEFGHIJKLM")
|
|
|
|
|
|
def age_band_overlay_for(
|
|
age_band_value: str, building_part: int
|
|
) -> Optional[EpcSimulation]:
|
|
band = age_band_value.strip().upper()
|
|
if band not in _VALID_AGE_BANDS:
|
|
return None
|
|
|
|
identifier = (
|
|
BuildingPartIdentifier.MAIN
|
|
if building_part == 0
|
|
else BuildingPartIdentifier.extension(building_part)
|
|
)
|
|
return EpcSimulation(
|
|
building_parts={
|
|
identifier: BuildingPartOverlay(construction_age_band=band)
|
|
}
|
|
)
|