city_retrofit/imports/schedules/DOE_IDF.py

65 lines
2.4 KiB
Python
Raw Normal View History

2021-08-19 21:55:19 -04:00
import pandas as pd
from imports.schedules.helpers.schedules_helper import SchedulesHelper
import parseidf
class IdfParser:
_OCCUPANCY_SCHEDULE= ("BLDG_OCC_SCH_wo_SB","Occupancy")
_Activity_Schedule= "ACTIVITY_SCH"
_Electrical_Equipent_Schedule= "BLDG_EQUIP_SCH"
_Lighting_Schedule="BLDG_LIGHT_SCH"
_Infiltration_Ventilation_Schedule="INFIL_QUARTER_ON_SCH"
def __init__(self, city, base_path, type):
self._city = city
self._idf_schedules_path = base_path / 'ASHRAE901_OfficeSmall_STD2019_Buffalo.idf'
with open(self._idf_schedules_path, 'r') as f:
idf = parseidf.parse(f.read())
for building in city.buildings:
schedules = dict()
for usage_zone in building.usage_zones:
usage_schedules = pd.Datafram(idf['SCHEDULE:COMPACT'])
Small_Office_Occupancy = []
Small_Office_OccupancyActivity = []
Small_Office_ElectricalEquipment = []
Small_Office_Lighting = []
Small_Office_Infiltration = []
for i in usage_schedules:
if i[1] == self._Occupancy_Schedule:
return Small_Office_Occupancy.append(i)
elif i[1] == 'ACTIVITY_SCH':
Small_Office_OccupancyActivity.append(i)
elif i[1] == 'BLDG_EQUIP_SCH':
Small_Office_ElectricalEquipment.append(i)
elif i[1] == 'BLDG_LIGHT_SCH':
Small_Office_Lighting.append(i)
elif i[1] == 'INFIL_QUARTER_ON_SCH':
Small_Office_Infiltration.append(i)
else:
print("The schedule name is not standard")
'''
# 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
'''