constrain solar api to allow max 70% roof coverage

This commit is contained in:
Khalim Conn-Kowlessar 2024-10-07 12:56:26 +01:00
parent f67668eb41
commit 4b1dab4abe

View file

@ -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,