diff --git a/backend/Property.py b/backend/Property.py index 45c0b406..3dbcc2b8 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -8,6 +8,7 @@ import pandas as pd from etl.epc.DataProcessor import DataProcessor from etl.epc.settings import POTENTIAL_COLUMNS, EFFICIENCY_FEATURES, BUILT_FORM_REMAP from etl.epc_clean.epc_attributes.all_cleaners import all_cleaner_map +from etl.solar.SolarPhotoSupply import SolarPhotoSupply from utils.logger import setup_logger from utils.s3 import read_dataframe_from_s3_parquet from BaseUtility import Definitions @@ -849,37 +850,19 @@ class Property(Definitions): "Need to set insulation floor area and pitched roof area before setting solar pv roof area" ) - # TODO: Create a class for the solar etl process and make this one of the functions, which applies a different - # method depending on the data type - def classify_floor_area(new_area, thresholds): - for i, threshold in enumerate(thresholds): - if new_area <= threshold: - return i # Returns the decile index (0 to 9) - return len(thresholds) - - floor_area_decile = classify_floor_area( - self.floor_area, floor_area_decile_thresholds["floor_area_decile_thresholds"].values + photo_supply_matched = SolarPhotoSupply.filter_photo_supply_lookup( + photo_supply_lookup=photo_supply_lookup, + floor_area_decile_thresholds=floor_area_decile_thresholds, + tenure=self.data["tenure"], + built_form=self.data["built-form"], + property_type=self.data["property-type"], + construction_age_band=self.construction_age_band, + is_flat=self.roof["is_flat"], + is_pitched=self.roof["is_pitched"], + is_roof_room=self.roof["is_roof_room"], + floor_area=self.floor_area ) - # Given the photo_supply_lookup, we esimate the percentage of the roof that is suitable for solar panels - - # TODO: Move this to the ETL process, since we need to know that tenure should be lower - tenure = self.data["tenure"].lower() - photo_supply_matched = photo_supply_lookup[ - (photo_supply_lookup["tenure"] == tenure) & - (photo_supply_lookup["built_form"] == self.data["built-form"]) & - (photo_supply_lookup["property_type"] == self.data["property-type"]) & - (photo_supply_lookup["construction_age_band"] == self.construction_age_band) & - (photo_supply_lookup["is_flat"] == self.roof["is_flat"]) & - (photo_supply_lookup["is_pitched"] == self.roof["is_pitched"]) & - (photo_supply_lookup["is_roof_room"] == self.roof["is_roof_room"]) - ] - - if floor_area_decile in photo_supply_matched["floor_area_decile"].values: - photo_supply_matched = photo_supply_matched[ - photo_supply_matched["floor_area_decile"] == floor_area_decile - ] - percentage_of_roof = photo_supply_matched["photo_supply_median"].mean() percentage_of_roof = percentage_of_roof / 100