From 69d53c85f98c925bbae5732753b8cf511ade1ace Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 6 Feb 2024 21:46:02 +0000 Subject: [PATCH] updating how we simulate the impact of floor insultion --- .idea/Model.iml | 2 +- .idea/misc.xml | 2 +- backend/Property.py | 5 +- backend/app/utils.py | 4 +- etl/testing_data/retrofitted_properties.py | 55 ++++++++++++++++++++++ recommendations/SolarPvRecommendations.py | 6 +-- 6 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 etl/testing_data/retrofitted_properties.py diff --git a/.idea/Model.iml b/.idea/Model.iml index b0f9c00d..4413bb06 100644 --- a/.idea/Model.iml +++ b/.idea/Model.iml @@ -7,7 +7,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 1122b380..6f308057 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/backend/Property.py b/backend/Property.py index c9cad22f..6d534689 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -197,10 +197,11 @@ class Property: if len(recommendation["parts"]) > 1: raise NotImplementedError("Have more than 1 floor insulation part - handle this case") - recommendation_record["floor_thermal_transmittance_ending"] = recommendation["new_u_value"] + # recommendation_record["floor_thermal_transmittance_ending"] = recommendation["new_u_value"] # We don't really see above average for this in the training data recommendation_record["floor_insulation_thickness_ending"] = "average" - recommendation_record["floor_energy_eff_ending"] = "Good" + # This is rarely ever populated in the training data + # recommendation_record["floor_energy_eff_ending"] = "Good" else: if recommendation_record["floor_thermal_transmittance_ending"] is None: raise ValueError("We should not have a None value for the u value") diff --git a/backend/app/utils.py b/backend/app/utils.py index 6801da65..ba5509e1 100644 --- a/backend/app/utils.py +++ b/backend/app/utils.py @@ -75,8 +75,8 @@ def sap_to_epc(sap_points: int | float): :return: """ - if sap_points <= 0 or sap_points > 100: - raise ValueError("SAP points should be between 1 and 100.") + if sap_points <= 0: + raise ValueError("SAP points should be above 0.") if sap_points >= 92: return "A" diff --git a/etl/testing_data/retrofitted_properties.py b/etl/testing_data/retrofitted_properties.py new file mode 100644 index 00000000..dcd3d09b --- /dev/null +++ b/etl/testing_data/retrofitted_properties.py @@ -0,0 +1,55 @@ +""" +This script will create an input csv for the recommendation engine and upload it to S3, which can be used for +testing +""" +import pandas as pd +from utils.s3 import save_csv_to_s3 + +USER_ID = 8 +PORTFOLIO_ID = 62 + + +def app(): + """ + This portfolio contains propertyies that we have demo'd in pilots, or properties that were provided to us + as proprties that are being treated under funding scehemes and we have pre/post EPRs for + :return: + """ + + test_file = pd.DataFrame( + [ + # Pilot properties + {'address': '113 Tenby Road', 'postcode': 'B13 9LT', 'Notes': ''}, + {'address': '139 School Road', 'postcode': 'B28 8JF', 'Notes': ''}, + {'address': '77 Simmons Drive', 'postcode': 'B32 1SL', 'Notes': ''}, + {'address': 'Flat 2, 54 Wedgewood Road', 'postcode': 'B32 1LS', 'Notes': ''}, + # Warmfront ECO4 Properties + {'address': '73 Long Chaulden', 'postcode': 'HP1 2HX', 'Notes': ''}, + {'address': '8 Lindlings', 'postcode': 'HP1 2HA', 'Notes': ''}, + {'address': '44 Lindlings', 'postcode': 'HP1 2HE', 'Notes': ''}, + {'address': '46 Chaulden Terrace', 'postcode': 'HP1 2AN', 'Notes': ''}, + # Osmosis SHDF Properties + {'address': '4, Heather Shaw', 'postcode': 'BA14 7JS', 'Notes': ''}, + {'address': '16 Glastonbury Road', 'postcode': 'M32 9PE', 'Notes': ''}, + {'address': '31 Loddon Way', 'postcode': 'BA15 1HG', 'Notes': ''}, + {'address': '62 Pearmain Drive', 'postcode': 'NG3 3DJ', 'Notes': ''}, + ] + + ) + + # Store the data in s3 + filename = f"{USER_ID}/{PORTFOLIO_ID}/eco4_shdf_retrofits.csv" + save_csv_to_s3( + dataframe=test_file, + bucket_name="retrofit-plan-inputs-dev", + file_name=filename + ) + + body = { + "portfolio_id": str(PORTFOLIO_ID), + "housing_type": "Social", + "goal": "Increase EPC", + "goal_value": "A", + "trigger_file_path": filename + } + print(body) diff --git a/recommendations/SolarPvRecommendations.py b/recommendations/SolarPvRecommendations.py index 01cd4f17..230671f1 100644 --- a/recommendations/SolarPvRecommendations.py +++ b/recommendations/SolarPvRecommendations.py @@ -5,8 +5,8 @@ from recommendations.Costs import Costs class SolarPvRecommendations: # Approximate area of the solar panels SOLAR_PANEL_AREA = 1.6 - # Wattage per panel - SOLAR_PANEL_WATTAGE = 360 + # Wattage per panel - this is based on the average wattage of a solar panel being between 250w and 420w + SOLAR_PANEL_WATTAGE = 250 def __init__(self, property_instance): """ @@ -47,7 +47,7 @@ class SolarPvRecommendations: # of solar PV installations cost_result = self.costs.solar_pv(wattage=solar_panel_wattage) - kw = int(np.round(solar_panel_wattage / 1000)) + kw = np.floor(solar_panel_wattage / 100) / 10 self.recommendation = [ {