From 69981192089e6256df5f4918c6ec244037be4c05 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 21 May 2024 12:10:38 +0100 Subject: [PATCH] added solar to mds --- backend/apis/GoogleSolarApi.py | 6 ++-- recommendations/Mds.py | 5 +-- recommendations/SolarPvRecommendations.py | 40 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/backend/apis/GoogleSolarApi.py b/backend/apis/GoogleSolarApi.py index 86324c58..205a3560 100644 --- a/backend/apis/GoogleSolarApi.py +++ b/backend/apis/GoogleSolarApi.py @@ -11,12 +11,14 @@ EPC_AUTH_TOKEN = os.getenv("EPC_AUTH_TOKEN") # This is for 6 Laura Close, Tintagel, PL34 0EB (same property that Cotswolrd energy used) uprn = 100040099104 +# This is for 353A, Hermitage Lane, ME16 9NT (one of the e.on properties) +uprn = 200000964454 cleaning_data = read_dataframe_from_s3_parquet( bucket_name="retrofit-data-dev", file_key="sap_change_model/cleaning_dataset.parquet", ) -searcher = SearchEpc(address1="6 Laura Close", postcode="PL34 0EB", uprn=uprn, auth_token=EPC_AUTH_TOKEN, os_api_key="") +searcher = SearchEpc(address1="", postcode="", uprn=uprn, auth_token=EPC_AUTH_TOKEN, os_api_key="") searcher.find_property(skip_os=True) @@ -80,7 +82,7 @@ solar_potential["panelWidthMeters"] solar_potential["wholeRoofStats"] -# Copy of response for testing: +# Copy of response for testing - 6 Laura Close, Tintagel, PL34 0EB # {'name': 'buildings/ChIJ2yC6t4KEa0gRh2TIssogI7k', 'center': {'latitude': 50.667375, 'longitude': -4.7416833}, # 'imageryDate': {'year': 2021, 'month': 7, 'day': 19}, 'regionCode': 'GB', 'solarPotential': {'maxArrayPanelsCount': # 39, 'maxArrayAreaMeters2': 76.578636, 'maxSunshineHoursPerYear': 1172.0627, 'carbonOffsetFactorKgPerMwh': diff --git a/recommendations/Mds.py b/recommendations/Mds.py index ca6ee3db..ecc8c852 100644 --- a/recommendations/Mds.py +++ b/recommendations/Mds.py @@ -123,8 +123,9 @@ class Mds: self.heating_recommender.recommend(phase=0) if "solar_pv" in measure_config_list: - raise Exception("check me out 14") - self.solar_recommender.recommend(phase=0) + recs = self.solar_recommender.mds_recommend(phase=0, solar_pv_percentage=0.5) + recs = self.insert_recommendation_id(recs, measures, "solar_pv") + mds_recommendations.append(recs) if "double_glazing" in measure_config_list: raise Exception("check me out 15") diff --git a/recommendations/SolarPvRecommendations.py b/recommendations/SolarPvRecommendations.py index 58d4b123..14161da3 100644 --- a/recommendations/SolarPvRecommendations.py +++ b/recommendations/SolarPvRecommendations.py @@ -35,6 +35,46 @@ class SolarPvRecommendations: return trimmed_list + def mds_recommend(self, phase=None, solar_pv_percentage=0.5): + # For specific usage within the mds report + + solar_pv_roof_area = self.property.get_solar_pv_roof_area(solar_pv_percentage) + + number_solar_panels = np.floor(solar_pv_roof_area / self.SOLAR_PANEL_AREA) + solar_panel_wattage = number_solar_panels * self.SOLAR_PANEL_WATTAGE + + solar_panel_wattage = np.clip( + a=solar_panel_wattage, a_min=self.MIN_SYSTEM_WATTAGE, a_max=self.MAX_SYSTEM_WATTAGE + ) + + # We now have a property which is potentially suitable for solar PV + roof_coverage_percent = round(solar_pv_percentage * 100) + # Given the wattage, we estimate the cost of the solar PV system. This is based on the MCS database + # of solar PV installations + cost_result = self.costs.solar_pv(wattage=solar_panel_wattage, has_battery=False) + kw = np.floor(solar_panel_wattage / 100) / 10 + + description = (f"Install a {kw} kilowatt-peak (kWp) solar photovoltaic (PV) p" + f"anel system on {round(roof_coverage_percent)}% the roof.") + + return [ + { + "phase": phase, + "parts": [], + "type": "solar_pv", + "description": description, + "starting_u_value": None, + "new_u_value": None, + "sap_points": None, + "already_installed": False, + **cost_result, + # This is required for simulating the SAP impact. solar_pv_percentage is between 0 & 1 so we scale + # back up here + "photo_supply": roof_coverage_percent, + "has_battery": False + } + ] + def recommend(self, phase): """ We check if a property is potentially suitable for solar PV based on the following criteria: