Idf parser and standardization is done (correct version)_need to be updated

This commit is contained in:
Soroush Samareh Abolhassani 2021-08-20 18:36:28 -04:00
parent 1d0dd11409
commit 665adae908
2 changed files with 94 additions and 16990 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,105 @@
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())
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"
for building in city.buildings:
schedules = dict()
for usage_zone in building.usage_zones:
usage_schedules = pd.Datafram(idf['SCHEDULE:COMPACT'])
def __init__(self, city, base_path):
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())
print(idf.keys()) # lists the object types in the idf file
print(idf['SCHEDULE:COMPACT']) # lists all the Output:Variable objects in the idf file
Holiday = []
Winterdesignday = []
Summerdesignday = []
Customday1 = []
Customday2 = []
Weekday = []
Weekend = []
dayType = []
compactKeywords = ['Weekdays', 'Weekends', 'Alldays', 'AllOtherDays', 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday', 'Holiday', 'Winterdesignday', 'Summerdesignday', 'Customday1',
'Customday2']
for val in idf['SCHEDULE:COMPACT']:
if val[1] == 'BLDG_LIGHT_SCH':
count = 0
for words in val:
dayType.append(words.title().split('For: ')[-1])
index = []
for count, word_dayType in enumerate(dayType):
if word_dayType in compactKeywords:
index.append(count)
index.append(len(dayType))
for i in range(len(index) - 1):
numberOfDaySch = list(dayType[index[i] + 1:index[i + 1]])
hourlyValues = list(range(24))
startHour = 0
for num in range(int(len(numberOfDaySch) / 2)):
untilTime = list(map(int, (numberOfDaySch[2 * num].split('Until: ')[-1]).split(":")[0:]))
endHour = int(untilTime[0] + untilTime[1] / 60)
value = float(numberOfDaySch[2 * num + 1])
for hour in range(startHour, endHour):
hourlyValues[hour] = value
print(hour, value)
startHour = endHour
if dayType[index[i]] == 'Weekdays':
Weekday.append(hourlyValues)
elif dayType[index[i]] == 'Weekends':
Weekend.append(hourlyValues)
elif dayType[index[i]] == 'Holiday':
Holiday.append(hourlyValues)
elif dayType[index[i]] == 'Winterdesignday':
Winterdesignday.append(hourlyValues)
elif dayType[index[i]] == 'Summerdesignday':
Summerdesignday.append(hourlyValues)
elif dayType[index[i]] == 'Customday1':
Customday1.append(hourlyValues)
elif dayType[index[i]] == 'Customday2':
Customday2.append(hourlyValues)
else:
print('its none of them')
idf_schedules = pd.DataFrame(
{'week_day': Weekday,
'Weekends': Weekend,
'Holiday': Holiday,
'Winterdesignday': Winterdesignday,
'Summerdesignday': Summerdesignday,
'Customday1': Customday1,
'Customday2': Customday2,
})
print(idf_schedules)
Small_Office_Occupancy = []
Small_Office_OccupancyActivity = []
Small_Office_ElectricalEquipment = []
Small_Office_Lighting = []
Small_Office_Infiltration = []
for building in city.buildings:
schedules = dict()
for usage_zone in building.usage_zones:
usage_schedules = idf_schedules
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 = 5
schedules_per_schedule_type = 6
idf_day_types = dict({'week_day': 0, 'Weekends': 1, 'Holiday': 2, 'Winterdesignday': 3, 'Summerdesignday': 4, 'Customday1': 5, 'Customday2': 6})
for schedule_types in range(0, number_of_schedule_types):
data = pd.DataFrame()
columns_names = []
name = ''
for schedule_day in range(0, len(idf_schedules)):
row_cells = usage_schedules.iloc[schedules_per_schedule_type*schedule_types + schedule_day]
if schedule_day == idf_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
'''
# 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
'''