diff --git a/recommendations/RoofRecommendations.py b/recommendations/RoofRecommendations.py index a1f8c67c..615289de 100644 --- a/recommendations/RoofRecommendations.py +++ b/recommendations/RoofRecommendations.py @@ -87,6 +87,17 @@ class RoofRecommendations: return (self.insulation_thickness > self.MINIMUM_LOFT_ISULATION_MM) and self.property.roof["is_pitched"] + def is_room_roof_insulated(self): + + """ + Check if the room roof is already insulated + """ + + return ( + self.property.roof["is_roof_room"] and + self.property.roof["insulation_thickness"] in ["average", "above_average"] + ) + def recommend(self, phase): if self.property.roof["has_dwelling_above"]: @@ -105,8 +116,8 @@ class RoofRecommendations: if (self.insulation_thickness >= self.MINIMUM_FLAT_ROOF_ISULATION_MM) and self.property.roof["is_flat"]: return - if self.property.roof["is_roof_room"]: - raise ValueError("Update convert_thickness_to_numeric for room roof and implement") + if self.is_room_roof_insulated(): + return # If we have a u-value already, need to implement this if u_value: @@ -118,7 +129,17 @@ class RoofRecommendations: return raise NotImplementedError("Implement me") - u_value = get_roof_u_value(**{**self.property.roof, "age_band": self.property.age_band}) + u_value = get_roof_u_value( + insulation_thickness=self.property.roof["insulation_thickness"], + has_dwelling_above=self.property.roof["has_dwelling_above"], + is_loft=self.property.roof["is_loft"], + is_roof_room=self.property.roof["is_roof_room"], + is_thatched=self.property.roof["is_thatched"], + age_band=self.property.age_band, + is_flat=self.property.roof["is_flat"], + is_pitched=self.property.roof["is_pitched"], + is_at_rafters=self.property.roof["is_at_rafters"], + ) self.estimated_u_value = u_value if (u_value <= self.BUILDING_REGULATIONS_PART_L_MAX_U_VALUE) and ( diff --git a/recommendations/recommendation_utils.py b/recommendations/recommendation_utils.py index 9b5e22d1..4980f30a 100644 --- a/recommendations/recommendation_utils.py +++ b/recommendations/recommendation_utils.py @@ -207,6 +207,17 @@ def get_wall_u_value( def get_u_value_from_s9(thickness, s9, is_loft, is_roof_room, is_thatched): """Get the U-value from table S9 based on the insulation thickness.""" + + if is_roof_room: + # We re-map the thickness + thickness_map = { + "below average": 50, + "average": 100, + "above average": 270, + "none": 0, + } + thickness = thickness_map[thickness] + if thickness in ["below average", "average", "above average", "none", None] or ( not is_loft and not is_roof_room ): @@ -676,7 +687,7 @@ def estimate_windows( property_type, built_form, construction_age_band, floor_area, number_habitable_rooms ): # If there is an extension, that will boost the number of habitable rooms - + # Base window count based on habitable rooms window_count = number_habitable_rooms