diff --git a/backend/onboarders/parity.py b/backend/onboarders/parity.py index cb9b4f7f..f2f940ba 100644 --- a/backend/onboarders/parity.py +++ b/backend/onboarders/parity.py @@ -296,13 +296,6 @@ roof_aggs = data[["Roof Construction", "Roof Insulation"]].drop_duplicates().to_ # Thatched # Sloping - {'Roof Construction': 'PitchedWithSlopingCeiling', 'Roof Insulation': 'AsBuilt'}, - {'Roof Construction': 'PitchedWithSlopingCeiling', 'Roof Insulation': 'mm150'}, - {'Roof Construction': 'PitchedWithSlopingCeiling', 'Roof Insulation': 'mm100'}, - {'Roof Construction': 'PitchedWithSlopingCeiling', 'Roof Insulation': nan}, - {'Roof Construction': 'PitchedWithSlopingCeiling', 'Roof Insulation': 'mm50'}, - {'Roof Construction': 'PitchedWithSlopingCeiling', 'Roof Insulation': 'NoInsulation'}, - {'Roof Construction': 'PitchedWithSlopingCeiling', 'Roof Insulation': 'Unknown'}, # Sloping ceiling: # With measured insulation @@ -391,6 +384,25 @@ roof_mapping = { ('PitchedThatched', 'mm300'): EpcRoofDescriptions.thatched_with_additional_insulation, ('PitchedThatched', 'Unknown'): EpcRoofDescriptions.thatched, # efficiency classified based on age + # Sloping: + # Limited (12 very poor, 25-50 poor) + ('PitchedWithSlopingCeiling', 'mm12'): EpcRoofDescriptions.sloping_pitched_limited_insulation, + ('PitchedWithSlopingCeiling', 'mm25'): EpcRoofDescriptions.sloping_pitched_limited_insulation, + ('PitchedWithSlopingCeiling', 'mm50'): EpcRoofDescriptions.sloping_pitched_limited_insulation, + # Insulated 75mm+ (75 - 125 average, 150 - 250 good, 270+ very good) + ('PitchedWithSlopingCeiling', 'mm75'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm100'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm150'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm200'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm250'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm270'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm300'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm350'): EpcRoofDescriptions.sloping_pitched_insulated, + ('PitchedWithSlopingCeiling', 'mm400'): EpcRoofDescriptions.sloping_pitched_insulated, + # As built/unknown + ('PitchedWithSlopingCeiling', 'AsBuilt'): None, # To be classified + ('PitchedWithSlopingCeiling', nan): None, # To be classified + ('PitchedWithSlopingCeiling', 'Unknown'): None, # } @@ -404,6 +416,8 @@ def classify_flat_roof(age_band: EpcConstructionAgeBand) -> EpcRoofDescriptions: 1976–1982 → Flat, limited insulation 1967–1975 → Flat, limited insulation 1950–1966 and earlier → Flat, no insulation + :param age_band: Input age band + :return: EpcRoofDescriptions """ year = age_band.start_year() @@ -417,17 +431,31 @@ def classify_flat_roof(age_band: EpcConstructionAgeBand) -> EpcRoofDescriptions: return EpcRoofDescriptions.flat_no_insulation -def classify_thatched_roof(age_band: EpcConstructionAgeBand): - raise NotImplementedError("Thatched roof classification not implemented yet") +def classify_sloping_ceiling_roof(age_band: EpcConstructionAgeBand) -> EpcRoofDescriptions: + """ + For a sloping ceiling, as built roof, these are the breakdowns: + 2023 onwards → Sloping pitched, insulated + 2003–2022 → Sloping pitched, insulated + 1983–2002 → Sloping pitched, insulated + 1976–1982 → Sloping pitched, limited insulation + 1967–1975 and earlier → Sloping pitched, no insulation + :param age_band: Input age band + :return: EpcRoofDescriptions + """ + year = age_band.start_year() + if year >= 1983: + return EpcRoofDescriptions.sloping_pitched_insulated -def classify_sloping_ceiling_roof(age_band: EpcConstructionAgeBand): - raise NotImplementedError("Sloping ceiling roof classification not implemented yet") + if year >= 1976: + return EpcRoofDescriptions.sloping_pitched_limited_insulation + + return EpcRoofDescriptions.sloping_pitched_no_insulation AS_BUILT_ROOF_CLASSIFIERS = { + # Only need to apply this to flat and sloping ceiling roofs "Flat": classify_flat_roof, - "PitchedThatched": classify_thatched_roof, "PitchedWithSlopingCeiling": classify_sloping_ceiling_roof, }