41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
"""
|
|
Schedules retrieve the specific usage schedules module for the given standard
|
|
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
|
|
from imports.schedules_feeders.helpers.schedules_helper import SchedulesHelper
|
|
|
|
|
|
class ComnetSchedules:
|
|
|
|
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:
|
|
schedules = dict()
|
|
for usage_zone in building.usage_zones:
|
|
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")
|
|
# todo: should we save the data type? How?
|
|
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):
|
|
data = pd.DataFrame()
|
|
columns_names = []
|
|
name = ''
|
|
for schedule_day in range(0, schedules_per_schedule_type):
|
|
row_cells = usage_schedules.iloc[schedules_per_schedule_type*schedule_types + schedule_day]
|
|
if schedule_day == day_types['week_day']:
|
|
name = row_cells[0]
|
|
columns_names.append(row_cells[2])
|
|
data1 = row_cells[schedules_per_schedule_type:]
|
|
data = pd.concat([data, data1], axis=1)
|
|
data.columns = columns_names
|
|
schedules[name] = data
|
|
usage_zone.schedules = schedules
|