mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added additional test for solar
This commit is contained in:
parent
f0936bd1d4
commit
732f3eb356
1 changed files with 164 additions and 0 deletions
|
|
@ -243,3 +243,167 @@ class TestSolarPvRecommendations:
|
|||
|
||||
assert predictions_dict["sap_change_predictions"]["predictions"].tolist() == [65.9, 65.9]
|
||||
assert ending_epc["current-energy-efficiency"] == '65'
|
||||
|
||||
def test_model2(self):
|
||||
data[["uprn", "sap_ending"]]
|
||||
#
|
||||
|
||||
searcher = SearchEpc(
|
||||
address1="",
|
||||
postcode="",
|
||||
auth_token="a2Nvbm5rb3dsZXNzYXJAZ21haWwuY29tOjY5MGJiMWM0NmIyOGI5ZDUxYzAxMzQzYzNiZGNlZGJjZDNmODQwMzA=",
|
||||
os_api_key="",
|
||||
full_address="",
|
||||
uprn=100030952942,
|
||||
)
|
||||
searcher.find_property(False)
|
||||
|
||||
ending_epc = {
|
||||
'low-energy-fixed-light-count': '', 'address': '6 Kenmare Crescent',
|
||||
'uprn-source': 'Energy Assessor', 'floor-height': '2.49', 'heating-cost-potential': '464',
|
||||
'unheated-corridor-length': '', 'hot-water-cost-potential': '46',
|
||||
'construction-age-band': 'England and Wales: 1967-1975', 'potential-energy-rating': 'B',
|
||||
'mainheat-energy-eff': 'Good', 'windows-env-eff': 'Average', 'lighting-energy-eff': 'Very Good',
|
||||
'environment-impact-potential': '91', 'glazed-type': 'not defined', 'heating-cost-current': '535',
|
||||
'address3': '', 'mainheatcont-description': 'Programmer, room thermostat and TRVs',
|
||||
'sheating-energy-eff': 'N/A', 'property-type': 'Bungalow',
|
||||
'local-authority-label': 'West Lindsey', 'fixed-lighting-outlets-count': '9',
|
||||
'energy-tariff': 'Single', 'mechanical-ventilation': 'natural', 'hot-water-cost-current': '69',
|
||||
'county': 'Lincolnshire', 'postcode': 'DN21 1PR', 'solar-water-heating-flag': 'N',
|
||||
'constituency': 'E14000707', 'co2-emissions-potential': '0.7', 'number-heated-rooms': '3',
|
||||
'floor-description': 'Suspended, no insulation (assumed)', 'energy-consumption-potential': '56',
|
||||
'local-authority': 'E07000142', 'built-form': 'Semi-Detached', 'number-open-fireplaces': '0',
|
||||
'windows-description': 'Fully double glazed', 'glazed-area': 'Much More Than Typical',
|
||||
'inspection-date': '2022-08-24', 'mains-gas-flag': 'Y', 'co2-emiss-curr-per-floor-area': '18',
|
||||
'address1': '6 Kenmare Crescent', 'heat-loss-corridor': '', 'flat-storey-count': '',
|
||||
'constituency-label': 'Gainsborough', 'roof-energy-eff': 'Very Good', 'total-floor-area': '66.0',
|
||||
'building-reference-number': '10002845316', 'environment-impact-current': '85',
|
||||
'co2-emissions-current': '1.2', 'roof-description': 'Pitched, 300 mm loft insulation',
|
||||
'floor-energy-eff': 'N/A', 'number-habitable-rooms': '3', 'address2': '',
|
||||
'hot-water-env-eff': 'Good', 'posttown': 'GAINSBOROUGH', 'mainheatc-energy-eff': 'Good',
|
||||
'main-fuel': 'mains gas (not community)', 'lighting-env-eff': 'Very Good',
|
||||
'windows-energy-eff': 'Average', 'floor-env-eff': 'N/A', 'sheating-env-eff': 'N/A',
|
||||
'lighting-description': 'Low energy lighting in all fixed outlets', 'roof-env-eff': 'Very Good',
|
||||
'walls-energy-eff': 'Average', 'photo-supply': '40.0', 'lighting-cost-potential': '65',
|
||||
'mainheat-env-eff': 'Good', 'multi-glaze-proportion': '100', 'main-heating-controls': '',
|
||||
'lodgement-datetime': '2022-08-24 15:39:42', 'flat-top-storey': '', 'current-energy-rating': 'B',
|
||||
'secondheat-description': 'Room heaters, electric', 'walls-env-eff': 'Average',
|
||||
'transaction-type': 'ECO assessment', 'uprn': '100030952942', 'current-energy-efficiency': '87',
|
||||
'energy-consumption-current': '100', 'mainheat-description': 'Boiler and radiators, mains gas',
|
||||
'lighting-cost-current': '65', 'lodgement-date': '2022-08-24', 'extension-count': '0',
|
||||
'mainheatc-env-eff': 'Good',
|
||||
'lmk-key': 'e20be883431b1fed15db7fa1f52634fb7655d2b80c2fdad37df779f93ec4dafd',
|
||||
'wind-turbine-count': '0', 'tenure': 'Owner-occupied', 'floor-level': '',
|
||||
'potential-energy-efficiency': '91', 'hot-water-energy-eff': 'Good', 'low-energy-lighting': '100',
|
||||
'walls-description': 'Cavity wall, filled cavity', 'hotwater-description': 'From main system'
|
||||
}
|
||||
starting_epc = {
|
||||
'low-energy-fixed-light-count': '', 'address': '6 Kenmare Crescent', 'uprn-source': 'Energy Assessor',
|
||||
'floor-height': '2.49', 'heating-cost-potential': '464', 'unheated-corridor-length': '',
|
||||
'hot-water-cost-potential': '46', 'construction-age-band': 'England and Wales: 1967-1975',
|
||||
'potential-energy-rating': 'B', 'mainheat-energy-eff': 'Good', 'windows-env-eff': 'Average',
|
||||
'lighting-energy-eff': 'Very Good', 'environment-impact-potential': '85', 'glazed-type': 'not defined',
|
||||
'heating-cost-current': '535', 'address3': '',
|
||||
'mainheatcont-description': 'Programmer, room thermostat and TRVs', 'sheating-energy-eff': 'N/A',
|
||||
'property-type': 'Bungalow', 'local-authority-label': 'West Lindsey', 'fixed-lighting-outlets-count': '9',
|
||||
'energy-tariff': 'Single', 'mechanical-ventilation': 'natural', 'hot-water-cost-current': '69',
|
||||
'county': 'Lincolnshire', 'postcode': 'DN21 1PR', 'solar-water-heating-flag': 'N',
|
||||
'constituency': 'E14000707', 'co2-emissions-potential': '1.2', 'number-heated-rooms': '3',
|
||||
'floor-description': 'Suspended, no insulation (assumed)', 'energy-consumption-potential': '102',
|
||||
'local-authority': 'E07000142', 'built-form': 'Semi-Detached', 'number-open-fireplaces': '0',
|
||||
'windows-description': 'Fully double glazed', 'glazed-area': 'Much More Than Typical',
|
||||
'inspection-date': '2022-05-31', 'mains-gas-flag': 'Y', 'co2-emiss-curr-per-floor-area': '40',
|
||||
'address1': '6 Kenmare Crescent', 'heat-loss-corridor': '', 'flat-storey-count': '',
|
||||
'constituency-label': 'Gainsborough', 'roof-energy-eff': 'Very Good', 'total-floor-area': '66.0',
|
||||
'building-reference-number': '10002845316', 'environment-impact-current': '68',
|
||||
'co2-emissions-current': '2.6', 'roof-description': 'Pitched, 300 mm loft insulation',
|
||||
'floor-energy-eff': 'N/A', 'number-habitable-rooms': '3', 'address2': '', 'hot-water-env-eff': 'Good',
|
||||
'posttown': 'GAINSBOROUGH', 'mainheatc-energy-eff': 'Good', 'main-fuel': 'mains gas (not community)',
|
||||
'lighting-env-eff': 'Very Good', 'windows-energy-eff': 'Average', 'floor-env-eff': 'N/A',
|
||||
'sheating-env-eff': 'N/A', 'lighting-description': 'Low energy lighting in all fixed outlets',
|
||||
'roof-env-eff': 'Very Good', 'walls-energy-eff': 'Average', 'photo-supply': '0.0',
|
||||
'lighting-cost-potential': '65', 'mainheat-env-eff': 'Good', 'multi-glaze-proportion': '100',
|
||||
'main-heating-controls': '', 'lodgement-datetime': '2022-06-15 08:38:02', 'flat-top-storey': '',
|
||||
'current-energy-rating': 'D', 'secondheat-description': 'Room heaters, electric',
|
||||
'walls-env-eff': 'Average', 'transaction-type': 'ECO assessment', 'uprn': '100030952942',
|
||||
'current-energy-efficiency': '68', 'energy-consumption-current': '227',
|
||||
'mainheat-description': 'Boiler and radiators, mains gas', 'lighting-cost-current': '65',
|
||||
'lodgement-date': '2022-06-15', 'extension-count': '0', 'mainheatc-env-eff': 'Good',
|
||||
'lmk-key': 'ce181970b7077cb9b4626242bfb010b30a0e48541b5f22427e81f1adbeeec4f2', 'wind-turbine-count': '0',
|
||||
'tenure': 'Owner-occupied', 'floor-level': '', 'potential-energy-efficiency': '85',
|
||||
'hot-water-energy-eff': 'Good', 'low-energy-lighting': '100',
|
||||
'walls-description': 'Cavity wall, filled cavity', 'hotwater-description': 'From main system'
|
||||
}
|
||||
|
||||
cleaning_data = read_dataframe_from_s3_parquet(
|
||||
bucket_name="retrofit-data-dev", file_key="sap_change_model/cleaning_dataset.parquet",
|
||||
)
|
||||
|
||||
cleaned = read_from_s3(
|
||||
s3_file_name="cleaned_epc_data/cleaned.bson",
|
||||
bucket_name="retrofit-data-dev"
|
||||
)
|
||||
cleaned = msgpack.unpackb(cleaned, raw=False)
|
||||
|
||||
photo_supply_lookup, floor_area_decile_thresholds = SolarPhotoSupply.load(bucket="retrofit-data-dev")
|
||||
|
||||
epc = EPCRecord(
|
||||
epc_records={
|
||||
'original_epc': starting_epc,
|
||||
'full_sap_epc': {},
|
||||
'old_data': []
|
||||
},
|
||||
run_mode="newdata",
|
||||
cleaning_data=cleaning_data
|
||||
)
|
||||
|
||||
home = Property(
|
||||
id=0,
|
||||
address="",
|
||||
postcode="",
|
||||
epc_record=epc,
|
||||
already_installed={},
|
||||
non_invasive_recommendations={},
|
||||
)
|
||||
home.in_conservation_area = False
|
||||
home.is_listed = False
|
||||
home.is_heritage = False
|
||||
home.restricted_measures = True
|
||||
home.get_components(
|
||||
cleaned=cleaned,
|
||||
photo_supply_lookup=photo_supply_lookup,
|
||||
floor_area_decile_thresholds=floor_area_decile_thresholds
|
||||
)
|
||||
|
||||
recommender = SolarPvRecommendations(property_instance=home)
|
||||
recommender.recommend(phase=0)
|
||||
|
||||
coverage_40_percent = [x for x in recommender.recommendation if x["photo_supply"] == 40]
|
||||
assert len(coverage_40_percent) == 2
|
||||
|
||||
property_recommendations = Recommendations.insert_temp_recommendation_id([coverage_40_percent])
|
||||
|
||||
home.create_base_difference_epc_record(cleaned_lookup=cleaned)
|
||||
home.adjust_difference_record_with_recommendations(
|
||||
property_recommendations, []
|
||||
)
|
||||
|
||||
scoring_data = pd.DataFrame(home.recommendations_scoring_data).drop(
|
||||
columns=["rdsap_change", "heat_demand_change", "carbon_change", "sap_ending", "heat_demand_ending",
|
||||
"carbon_ending"]
|
||||
)
|
||||
|
||||
model_api = ModelApi(portfolio_id="ashp-test", timestamp=datetime.now().isoformat())
|
||||
model_api.MODEL_PREFIXES = ["sap_change_predictions"]
|
||||
|
||||
predictions_dict = model_api.predict_all(
|
||||
df=scoring_data,
|
||||
bucket="retrofit-data-dev",
|
||||
prediction_buckets={
|
||||
"sap_change_predictions": "retrofit-sap-predictions-dev",
|
||||
}
|
||||
)
|
||||
|
||||
assert predictions_dict["sap_change_predictions"]["predictions"].tolist() == [87.1, 87.1]
|
||||
assert ending_epc["current-energy-efficiency"] == '87'
|
||||
assert starting_epc["current-energy-efficiency"] == '68'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue