hub/factories/occupancy_feeders/demo_occupancy_parameters.py

40 lines
1.5 KiB
Python
Raw Normal View History

2020-10-22 11:02:41 -04:00
"""
PhysicsFactory retrieve the specific physics module for the given region
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
contributors Pilar Monsalvete pilar_monsalvete@yahoo.es
2020-10-22 11:02:41 -04:00
"""
import pandas as pd
2020-10-29 08:16:48 -04:00
from factories.occupancy_feeders.helpers.occupancy_helper import OccupancyHelper
2020-10-22 11:02:41 -04:00
class DemoOccupancyParameters:
def __init__(self, city, base_path):
self._city = city
self._demo_schedules_path = base_path / 'demo_schedules.xlsx'
print('schedules: ', self._demo_schedules_path)
2020-10-22 11:02:41 -04:00
xls = pd.ExcelFile(self._demo_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()
2020-10-22 11:02:41 -04:00
occupancy = pd.read_excel(xls, sheet_name=OccupancyHelper.pluto_occupancy_function(building.function),
2020-10-27 09:31:57 -04:00
skiprows=[0, 1, 2, 3], nrows=39, usecols="A:AA")
# todo: should we safe the data type? How?
2020-10-27 09:31:57 -04:00
for index in range(0, 13):
data = pd.DataFrame()
columns_names = []
name = ''
data_type = ''
for i in range(0, 3):
2020-10-27 09:31:57 -04:00
row = occupancy.iloc[3*index + i]
if i == 0:
name = row[0]
data_type = row[1]
columns_names.append(row[2])
data1 = row[3:]
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