diff --git a/backend/apis/GoogleSolarApi.py b/backend/apis/GoogleSolarApi.py index 31ae39bd..a5c1e739 100644 --- a/backend/apis/GoogleSolarApi.py +++ b/backend/apis/GoogleSolarApi.py @@ -53,6 +53,10 @@ class GoogleSolarApi: # Max area of a roof space we allow panels for PERCENTAGE_OF_ROOF_LIMIT = 0.8 + # If the roof area that comes back from the solar API is more than 25% larger than the estiamted roof area + # that we calcualte based on the property dimensions, we will correct the roof area + ROOF_AREA_TOLERANCE = 1.25 + # Error Messages ENTITY_NOT_FOUND_ERROR = 'Requested entity was not found.' @@ -167,7 +171,6 @@ class GoogleSolarApi: if self.insights_data.get("error") == self.ENTITY_NOT_FOUND_ERROR: # We use default performance since in this case, we couldn't retrieve data. We don't store self.panel_performance = self.default_panel_performance(property_instance=property_instance) - return self.need_to_store = True @@ -182,7 +185,11 @@ class GoogleSolarApi: ): self.exclude_likely_duplicate_surfaces() + # TODO: We need to constrain the roof area, based on the floor area to be more conservative self.roof_area = self.insights_data["solarPotential"]["wholeRoofStats"]['areaMeters2'] + if self.roof_area > property_instance.roof_area * self.ROOF_AREA_TOLERANCE: + self.roof_area = property_instance.roof_area + self.floor_area = self.insights_data["solarPotential"]["wholeRoofStats"]['groundAreaMeters2'] self.panel_wattage = self.insights_data["solarPotential"]["panelCapacityWatts"] if self.panel_wattage != 400: @@ -279,8 +286,6 @@ class GoogleSolarApi: # minimum is 4 min_panels = self.MIN_BUILDING_PANELS if is_building else self.MIN_UNIT_PANELS - cost_instance = Costs(property_instance=property_instance) if property_instance is not None else None - # Remove any north facing roof segments panel_performance = [] for config in self.insights_data["solarPotential"].get("solarPanelConfigs", []): @@ -314,18 +319,12 @@ class GoogleSolarApi: if roi_summary["n_panels"].sum() < min_panels: continue - if cost_instance is None: - total_cost = Costs.solar_pv( - n_panels=roi_summary["n_panels"].sum(), - has_battery=False, - n_floors=3, # Assume the most amount of scaffolding - )["total"] - else: - total_cost = cost_instance.solar_pv( - n_panels=roi_summary["n_panels"].sum(), - has_battery=False, - n_floors=property_instance.number_of_floors, - )["total"] + total_cost = Costs.solar_pv( + n_panels=roi_summary["n_panels"].sum(), + has_battery=False, + # Assume the most amount of scaffolding + n_floors=3 if property_instance is None else property_instance.number_of_floors + )["total"] weighted_ratio = np.average( roi_summary["ratio"].values, weights=roi_summary["generated_dc_energy"].values