2020-10-22 11:02:41 -04:00
|
|
|
"""
|
2020-12-15 14:57:46 -05:00
|
|
|
Schedules retrieve the specific usage schedules module for the given standard
|
2020-10-22 11:02:41 -04:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2020-11-02 13:41:42 -05:00
|
|
|
contributors Pilar Monsalvete pilar_monsalvete@yahoo.es
|
2020-10-22 11:02:41 -04:00
|
|
|
"""
|
|
|
|
import pandas as pd
|
2020-12-15 14:57:46 -05:00
|
|
|
from factories.occupancy_feeders.helpers.schedules_helper import SchedulesHelper
|
2020-10-22 11:02:41 -04:00
|
|
|
|
|
|
|
|
2020-12-15 14:57:46 -05:00
|
|
|
class ComnetSchedules:
|
2020-10-22 11:02:41 -04:00
|
|
|
|
|
|
|
def __init__(self, city, base_path):
|
|
|
|
self._city = city
|
2020-12-15 14:57:46 -05:00
|
|
|
self._comnet_schedules_path = base_path / 'comnet_archetypes.xlsx'
|
|
|
|
xls = pd.ExcelFile(self._comnet_schedules_path)
|
2020-10-27 12:53:29 -04:00
|
|
|
# todo: review for more than one usage_zones per building
|
2020-10-22 11:02:41 -04:00
|
|
|
for building in city.buildings:
|
2020-10-27 09:31:57 -04:00
|
|
|
schedules = dict()
|
2021-01-07 18:12:13 -05:00
|
|
|
usage_schedules = pd.read_excel(xls, sheet_name=SchedulesHelper.comnet_pluto_schedules_function(building.function)
|
|
|
|
, skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA")
|
2020-11-06 05:32:19 -05:00
|
|
|
# todo: should we save the data type? How?
|
2020-12-14 19:11:56 -05:00
|
|
|
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):
|
2020-11-02 13:41:42 -05:00
|
|
|
data = pd.DataFrame()
|
|
|
|
columns_names = []
|
|
|
|
name = ''
|
2020-12-14 19:11:56 -05:00
|
|
|
for schedule_day in range(0, schedules_per_schedule_type):
|
2020-12-15 14:57:46 -05:00
|
|
|
row_cells = usage_schedules.iloc[schedules_per_schedule_type*schedule_types + schedule_day]
|
2020-12-14 19:11:56 -05:00
|
|
|
if schedule_day == day_types['week_day']:
|
|
|
|
name = row_cells[0]
|
|
|
|
columns_names.append(row_cells[2])
|
|
|
|
data1 = row_cells[schedules_per_schedule_type:]
|
2020-11-02 13:41:42 -05:00
|
|
|
data = pd.concat([data, data1], axis=1)
|
|
|
|
data.columns = columns_names
|
2020-10-27 09:31:57 -04:00
|
|
|
schedules[name] = data
|
2020-10-27 12:53:29 -04:00
|
|
|
building.usage_zones[0].schedules = schedules
|