diff --git a/city_model_structure/energy_system.py b/city_model_structure/energy_system.py index 6df539d6..eb2deb71 100644 --- a/city_model_structure/energy_system.py +++ b/city_model_structure/energy_system.py @@ -9,14 +9,14 @@ from city_model_structure.energy_systems.heat_pump import HeatPump class EnergySystem(CityObject): - """ + """ EnergySystem(CityObject) class """ - def __init__(self, name, lod, surfaces, city_lower_corner): - super().__init__(name, lod, surfaces, city_lower_corner) - self._heat_pump = None - @property - def heat_pump(self) -> HeatPump: - return self._heat_pump + def __init__(self, name, lod, surfaces, city_lower_corner): + super().__init__(name, lod, surfaces, city_lower_corner) + self._heat_pump = None + @property + def heat_pump(self) -> HeatPump: + return self._heat_pump diff --git a/imports/energy_systems/xlsx_heat_pump_parameters.py b/imports/energy_systems/xlsx_heat_pump_parameters.py index b26a2d7a..7d37874f 100644 --- a/imports/energy_systems/xlsx_heat_pump_parameters.py +++ b/imports/energy_systems/xlsx_heat_pump_parameters.py @@ -5,22 +5,58 @@ Copyright © 2020 Project Author Peter Yefi peteryefi@gmail.com Contributor Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ +import pandas as pd +from typing import Dict + class XlsxHeatPumpParameters: - """ + """ XlsxHeatPumpParameters class """ - def __init__(self, city, base_path): - self._city = city - self._base_path = (base_path / 'heat_pumps/Air source.xlsx') - def _read_file(self): - """ + def __init__(self, city, base_path): + self._city = city + self._base_path = (base_path / 'heat_pumps/Air source.xlsx') + + def _read_file(self) -> Dict: + """ reads xlsx file containing the heat pump information + into a dictionary + :return : Dict """ + xl_file = pd.ExcelFile(self._base_path) + heat_pump_dfs = {sheet_name: xl_file.parse(sheet_name) + for sheet_name in xl_file.sheet_names} - def enrich_city(self): - """ + cooling_data = {} + heating_data = {} + + for sheet, dataframe in heat_pump_dfs.items(): + if sheet == "Summary": + continue + # Remove nan rows and columns and extract cooling and heating data + # for each sheet + df = heat_pump_dfs[sheet].dropna(axis=1, how='all') + cooling_df = df.iloc[4:34, 0:8] + heating_df = df.iloc[4:29, 8:20] + + # extract the data into dictionaries each sheet is a key entry in the + # dictionary + cooling_data[sheet] = {} + heating_data[sheet] = {} + i = 0 + # for each sheet extract data for twout/Ta.RU temperatures. Thus, the twout + # temp is the key for the values of pf,pa,qw data + while i < 25: + cooling_data[sheet][cooling_df.iloc[i][0]] = cooling_df.iloc[i + 1:i + 4, 2:8].values.tolist() + heating_data[sheet][heating_df.iloc[i][0]] = cooling_df.iloc[i + 1:i + 4, 2:8].values.tolist() + i = i + 5 + # extract the last cooling data + cooling_data[sheet][cooling_df.iloc[i][0]] = cooling_df.iloc[i + 1:i + 4, 2:8] + return {"cooling": cooling_data, "heating": heating_data} + + def enrich_city(self): + """ Enriches the city with information from file """ - return self._city + return self._city