city_retrofit/imports/schedules/comnet_schedules_parameters.py

57 lines
2.5 KiB
Python
Raw Normal View History

"""
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.helpers.schedules_helper import SchedulesHelper
from city_model_structure.attributes.schedule import Schedule
import helpers.constants as cte
class ComnetSchedules:
2021-08-27 12:51:30 -04:00
"""
Comnet based schedules
2021-08-27 12:51:30 -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:
schedules = []
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 = ''
data_type = ''
for schedule_day in range(0, schedules_per_schedule_type):
schedule = Schedule()
schedule.time_step = cte.HOUR
schedule.time_range = cte.DAY
row_cells = usage_schedules.iloc[schedules_per_schedule_type*schedule_types + schedule_day]
if schedule_day == day_types['week_day']:
name = row_cells[0]
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)
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()
schedules.append(schedule)
usage_zone.schedules = schedules