From 4b1dab4abe8478ff0c3da94c4beb9d0501239041 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 7 Oct 2024 12:56:26 +0100 Subject: [PATCH] constrain solar api to allow max 70% roof coverage --- recommendations/SolarPvRecommendations.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/recommendations/SolarPvRecommendations.py b/recommendations/SolarPvRecommendations.py index 08f077d2..2c93689d 100644 --- a/recommendations/SolarPvRecommendations.py +++ b/recommendations/SolarPvRecommendations.py @@ -17,6 +17,8 @@ class SolarPvRecommendations: MAX_SYSTEM_WATTAGE = 6000 MIN_SYSTEM_WATTAGE = 1000 + MAX_ROOF_AREA_PERCENTAGE = 0.7 + def __init__(self, property_instance): """ :param property_instance: Instance of the Property class, for the home associated to property_id @@ -189,15 +191,20 @@ class SolarPvRecommendations: ) else: # TODO: There may be some instances where we don't want to use the solar API so we should cover for them - panel_performance = self.property.solar_panel_configuration["panel_performance"] + panel_performance = self.property.solar_panel_configuration["panel_performance"].copy() + # We don't allow for more than 70% of the roof to be covered + panel_performance = panel_performance[ + panel_performance["panneled_roof_area"] / self.property.roof_area <= self.MAX_ROOF_AREA_PERCENTAGE + ] + roof_area = self.property.roof_area solar_configurations = panel_performance.head(3).reset_index(drop=True) # We combine each of these configurations with estimates with and without a battery for rank, recommendation_config in solar_configurations.iterrows(): roof_coverage_percent = round(recommendation_config["panneled_roof_area"] / roof_area * 100) - # We round up to the nearest 10 - roof_coverage_percent = np.ceil(roof_coverage_percent / 10) * 10 + # We round up to the nearest 5 + roof_coverage_percent = np.ceil(roof_coverage_percent / 5) * 5 for has_battery in [False, True]: cost_result = self.costs.solar_pv( has_battery=has_battery,