2021-05-26 18:17:23 -04:00
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
Schedules retrieve the specific usage schedules module for the given standard
|
2021-05-26 18:17:23 -04:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
|
|
contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
"""
|
|
|
|
import pandas as pd
|
2021-06-01 18:31:50 -04:00
|
|
|
from imports.schedules.helpers.schedules_helper import SchedulesHelper
|
2021-09-01 12:14:48 -04:00
|
|
|
from city_model_structure.attributes.schedule import Schedule
|
|
|
|
import helpers.constants as cte
|
2021-05-26 18:17:23 -04:00
|
|
|
|
|
|
|
|
|
|
|
class ComnetSchedules:
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
2021-09-01 12:14:48 -04:00
|
|
|
Comnet based schedules
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
2021-05-26 18:17:23 -04:00
|
|
|
def __init__(self, city, base_path):
|
|
|
|
self._city = city
|
|
|
|
self._comnet_schedules_path = base_path / 'comnet_archetypes.xlsx'
|
|
|
|
xls = pd.ExcelFile(self._comnet_schedules_path)
|
|
|
|
for building in city.buildings:
|
|
|
|
for usage_zone in building.usage_zones:
|
2021-09-01 12:14:48 -04:00
|
|
|
schedules = []
|
2021-05-26 18:17:23 -04:00
|
|
|
usage_schedules = pd.read_excel(xls,
|
|
|
|
sheet_name=SchedulesHelper.comnet_from_usage(usage_zone.usage),
|
|
|
|
skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA")
|
|
|
|
number_of_schedule_types = 13
|
|
|
|
schedules_per_schedule_type = 3
|
|
|
|
day_types = dict({'week_day': 0, 'saturday': 1, 'sunday': 2})
|
|
|
|
for schedule_types in range(0, number_of_schedule_types):
|
|
|
|
name = ''
|
2021-09-01 12:14:48 -04:00
|
|
|
data_type = ''
|
2021-05-26 18:17:23 -04:00
|
|
|
for schedule_day in range(0, schedules_per_schedule_type):
|
2021-09-01 12:14:48 -04:00
|
|
|
schedule = Schedule()
|
|
|
|
schedule.time_step = cte.HOUR
|
|
|
|
schedule.time_range = cte.DAY
|
2021-05-26 18:17:23 -04:00
|
|
|
row_cells = usage_schedules.iloc[schedules_per_schedule_type*schedule_types + schedule_day]
|
|
|
|
if schedule_day == day_types['week_day']:
|
|
|
|
name = row_cells[0]
|
2021-09-01 12:14:48 -04:00
|
|
|
data_type = row_cells[1]
|
|
|
|
schedule.day_types = [cte.MONDAY, cte.TUESDAY, cte.WEDNESDAY, cte.THURSDAY, cte.FRIDAY]
|
|
|
|
elif schedule_day == day_types['saturday']:
|
|
|
|
schedule.day_types = [cte.SATURDAY]
|
|
|
|
else:
|
|
|
|
schedule.day_types = [cte.SUNDAY]
|
|
|
|
schedule.type = name
|
|
|
|
schedule.data_type = SchedulesHelper.data_type_from_comnet(data_type)
|
2021-09-01 17:59:28 -04:00
|
|
|
if schedule.data_type == cte.TEMPERATURE:
|
|
|
|
values = []
|
|
|
|
for cell in row_cells[schedules_per_schedule_type:].to_numpy():
|
|
|
|
values.append((float(cell) - 32.) * 5 / 9)
|
|
|
|
schedule.values = values
|
|
|
|
else:
|
|
|
|
schedule.values = row_cells[schedules_per_schedule_type:].to_numpy()
|
2021-09-01 12:14:48 -04:00
|
|
|
schedules.append(schedule)
|
2021-05-26 18:17:23 -04:00
|
|
|
usage_zone.schedules = schedules
|