2021-10-18 11:37:20 -04:00
|
|
|
"""
|
|
|
|
XlsxHeatPumpParameters import the heat pump information
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2021-10-19 13:17:11 -04:00
|
|
|
Copyright © 2020 Project Author Peter Yefi peteryefi@gmail.com
|
2021-10-18 11:37:20 -04:00
|
|
|
Contributor Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
"""
|
|
|
|
|
2021-10-20 09:00:59 -04:00
|
|
|
import pandas as pd
|
|
|
|
from typing import Dict
|
2021-10-21 09:50:02 -04:00
|
|
|
from typing import List
|
|
|
|
from city_model_structure.energy_systems.heat_pump import HeatPump
|
|
|
|
from city_model_structure.energy_system import EnergySystem
|
2021-10-20 09:00:59 -04:00
|
|
|
|
2021-10-18 11:37:20 -04:00
|
|
|
|
|
|
|
class XlsxHeatPumpParameters:
|
2021-10-20 09:00:59 -04:00
|
|
|
"""
|
2021-10-18 11:37:20 -04:00
|
|
|
XlsxHeatPumpParameters class
|
|
|
|
"""
|
|
|
|
|
2021-10-20 09:00:59 -04:00
|
|
|
def __init__(self, city, base_path):
|
|
|
|
self._city = city
|
|
|
|
self._base_path = (base_path / 'heat_pumps/Air source.xlsx')
|
|
|
|
|
|
|
|
def _read_file(self) -> Dict:
|
|
|
|
"""
|
2021-10-18 11:37:20 -04:00
|
|
|
reads xlsx file containing the heat pump information
|
2021-10-20 09:00:59 -04:00
|
|
|
into a dictionary
|
|
|
|
:return : Dict
|
2021-10-18 11:37:20 -04:00
|
|
|
"""
|
2021-10-20 09:00:59 -04:00
|
|
|
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}
|
2021-10-18 11:37:20 -04:00
|
|
|
|
2021-10-20 09:00:59 -04:00
|
|
|
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()
|
2021-10-21 09:50:02 -04:00
|
|
|
heating_data[sheet][heating_df.iloc[i][0]] = heating_df.iloc[i + 1:i + 4, 2:8].values.tolist()
|
2021-10-20 09:00:59 -04:00
|
|
|
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):
|
|
|
|
"""
|
2021-10-18 11:37:20 -04:00
|
|
|
Enriches the city with information from file
|
|
|
|
"""
|
2021-10-21 09:50:02 -04:00
|
|
|
heap_pump_data = self._read_file()
|
|
|
|
for (k_cool, v_cool), (k_heat, v_heat) in \
|
|
|
|
zip(heap_pump_data["cooling"].items(), heap_pump_data["heating"].items()):
|
|
|
|
heat_pump = HeatPump()
|
|
|
|
heat_pump.model = k_cool
|
|
|
|
h_data = self._extract_heat_pump_data(v_heat)
|
|
|
|
c_data = self._extract_heat_pump_data(v_cool)
|
|
|
|
heat_pump.cooling_pf = c_data[0]
|
|
|
|
heat_pump.cooling_pa = c_data[1]
|
|
|
|
heat_pump.cooling_qw = c_data[2]
|
|
|
|
heat_pump.heating_pf = h_data[0]
|
|
|
|
heat_pump.heating_pa = h_data[1]
|
|
|
|
heat_pump.heating_qw = h_data[2]
|
|
|
|
energy_system = EnergySystem('{} capacity heat pump'.format(heat_pump.model), 0, [], None)
|
|
|
|
energy_system.heat_pump = heat_pump
|
|
|
|
self._city.add_city_object(energy_system)
|
2021-10-20 09:00:59 -04:00
|
|
|
return self._city
|
2021-10-21 09:50:02 -04:00
|
|
|
|
|
|
|
def _extract_heat_pump_data(self, heat_pump_capacity_data) -> [List, List, List]:
|
|
|
|
"""
|
|
|
|
Fetches a list of metric based data for heat pump for various temperature,
|
|
|
|
eg. cooling capacity data for 12 capacity heat pump
|
|
|
|
for 6,7,8,9,10 and 11 degree celsius
|
|
|
|
:param heat_pump_capacity_data: the heat pump capacity data from the
|
|
|
|
which the metric specific data is fetched: {List}
|
|
|
|
:return: List
|
|
|
|
"""
|
|
|
|
pf_data = []
|
|
|
|
pa_data = []
|
|
|
|
qw_data = []
|
|
|
|
for _, metric_data in heat_pump_capacity_data.items():
|
|
|
|
pf_data.append(metric_data[0])
|
|
|
|
pa_data.append(metric_data[1])
|
|
|
|
qw_data.append(metric_data[2])
|
|
|
|
return [pf_data, pa_data, qw_data]
|