Skip to content

Commit

Permalink
fix: temp fix remove schedules (#70)
Browse files Browse the repository at this point in the history
* fix: temp fix remove schedules

* feat: added new test case
  • Loading branch information
TfedUD authored Nov 16, 2023
1 parent ab31e95 commit 405aba5
Show file tree
Hide file tree
Showing 7 changed files with 50,301 additions and 2,558 deletions.
137 changes: 137 additions & 0 deletions Untitled-1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"from honeybee.model import Model\n",
"from honeybee_doe2.properties.activitydescription import DayScheduleDoe, DayScheduleType, WeekScheduleDoe\n",
"\n",
"model = Model.from_file('tests\\\\assets\\\\revit-sample-with-program-type.hbjson')\n",
"\n",
"schedules = [sch for sch in model.properties.energy.schedules]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8\n"
]
}
],
"source": [
"print(len(schedules))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"True\n",
"True\n",
"True\n",
"True\n",
"True\n",
"True\n",
"True\n"
]
}
],
"source": [
"for sch in schedules:\n",
" if sch.is_single_week:\n",
" print(True)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ScheduleRuleset: ApartmentMidRise APT_DHW_SCH [default day: ApartmentMidRise APT_DHW_SCH_Default] [0 rules]\n"
]
}
],
"source": [
"print(schedules[0])"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'str' object has no attribute 'value'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"File \u001b[1;32md:\\__A1_LBT_DEV\\honeybee-doe2\\.env\\lib\\site-packages\\IPython\\core\\formatters.py:708\u001b[0m, in \u001b[0;36mPlainTextFormatter.__call__\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 701\u001b[0m stream \u001b[39m=\u001b[39m StringIO()\n\u001b[0;32m 702\u001b[0m printer \u001b[39m=\u001b[39m pretty\u001b[39m.\u001b[39mRepresentationPrinter(stream, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mverbose,\n\u001b[0;32m 703\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mmax_width, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mnewline,\n\u001b[0;32m 704\u001b[0m max_seq_length\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mmax_seq_length,\n\u001b[0;32m 705\u001b[0m singleton_pprinters\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39msingleton_printers,\n\u001b[0;32m 706\u001b[0m type_pprinters\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtype_printers,\n\u001b[0;32m 707\u001b[0m deferred_pprinters\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mdeferred_printers)\n\u001b[1;32m--> 708\u001b[0m printer\u001b[39m.\u001b[39;49mpretty(obj)\n\u001b[0;32m 709\u001b[0m printer\u001b[39m.\u001b[39mflush()\n\u001b[0;32m 710\u001b[0m \u001b[39mreturn\u001b[39;00m stream\u001b[39m.\u001b[39mgetvalue()\n",
"File \u001b[1;32md:\\__A1_LBT_DEV\\honeybee-doe2\\.env\\lib\\site-packages\\IPython\\lib\\pretty.py:410\u001b[0m, in \u001b[0;36mRepresentationPrinter.pretty\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 407\u001b[0m \u001b[39mreturn\u001b[39;00m meth(obj, \u001b[39mself\u001b[39m, cycle)\n\u001b[0;32m 408\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mcls\u001b[39m \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mobject\u001b[39m \\\n\u001b[0;32m 409\u001b[0m \u001b[39mand\u001b[39;00m \u001b[39mcallable\u001b[39m(\u001b[39mcls\u001b[39m\u001b[39m.\u001b[39m\u001b[39m__dict__\u001b[39m\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39m__repr__\u001b[39m\u001b[39m'\u001b[39m)):\n\u001b[1;32m--> 410\u001b[0m \u001b[39mreturn\u001b[39;00m _repr_pprint(obj, \u001b[39mself\u001b[39;49m, cycle)\n\u001b[0;32m 412\u001b[0m \u001b[39mreturn\u001b[39;00m _default_pprint(obj, \u001b[39mself\u001b[39m, cycle)\n\u001b[0;32m 413\u001b[0m \u001b[39mfinally\u001b[39;00m:\n",
"File \u001b[1;32md:\\__A1_LBT_DEV\\honeybee-doe2\\.env\\lib\\site-packages\\IPython\\lib\\pretty.py:778\u001b[0m, in \u001b[0;36m_repr_pprint\u001b[1;34m(obj, p, cycle)\u001b[0m\n\u001b[0;32m 776\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"A pprint that just redirects to the normal repr function.\"\"\"\u001b[39;00m\n\u001b[0;32m 777\u001b[0m \u001b[39m# Find newlines and replace them with p.break_()\u001b[39;00m\n\u001b[1;32m--> 778\u001b[0m output \u001b[39m=\u001b[39m \u001b[39mrepr\u001b[39;49m(obj)\n\u001b[0;32m 779\u001b[0m lines \u001b[39m=\u001b[39m output\u001b[39m.\u001b[39msplitlines()\n\u001b[0;32m 780\u001b[0m \u001b[39mwith\u001b[39;00m p\u001b[39m.\u001b[39mgroup():\n",
"File \u001b[1;32md:\\__A1_LBT_DEV\\honeybee-doe2\\honeybee_doe2\\properties\\activitydescription.py:223\u001b[0m, in \u001b[0;36mWeekScheduleDoe.__repr__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 222\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__repr__\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[1;32m--> 223\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mto_inp()\n",
"File \u001b[1;32md:\\__A1_LBT_DEV\\honeybee-doe2\\honeybee_doe2\\properties\\activitydescription.py:195\u001b[0m, in \u001b[0;36mWeekScheduleDoe.to_inp\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 193\u001b[0m obj_lines \u001b[39m=\u001b[39m []\n\u001b[0;32m 194\u001b[0m obj_lines\u001b[39m.\u001b[39mappend(\u001b[39mf\u001b[39m\u001b[39m'\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mname\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m = WEEK-SCHEDULE-PD\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[1;32m--> 195\u001b[0m obj_lines\u001b[39m.\u001b[39mappend(\u001b[39mf\u001b[39m\u001b[39m'\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m TYPE = \u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstype\u001b[39m.\u001b[39mvalue\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m)\n\u001b[0;32m 196\u001b[0m obj_lines\u001b[39m.\u001b[39mappend(\u001b[39mf\u001b[39m\u001b[39m'\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m DAY-SCHEDULES = ( \u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mday_schedules[\u001b[39m0\u001b[39m]\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m, $ Monday\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[0;32m 197\u001b[0m obj_lines\u001b[39m.\u001b[39mappend(\u001b[39mf\u001b[39m\u001b[39m'\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m \u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mday_schedules[\u001b[39m1\u001b[39m]\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m, $ Tuesday\u001b[39m\u001b[39m'\u001b[39m)\n",
"\u001b[1;31mAttributeError\u001b[0m: 'str' object has no attribute 'value'"
]
}
],
"source": [
"WeekScheduleDoe.from_schedule_ruleset(stype =DayScheduleType.FRACTION, schedule_ruleset=schedules[0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.5 ('.env': venv)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "64102ec5d521a84aea631c694a658e8415259261399b7e615bab718acc979667"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
175 changes: 91 additions & 84 deletions honeybee_doe2/properties/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,90 +125,97 @@ def _get_fixed_shades(obj):
else:
return None

@property
def week_scheduels(self):
return self._get_week_scheduels(self.host)

@staticmethod
def _get_week_scheduels(obj):

translated_schedules = []
for room in obj.rooms:

if room.properties.energy.lighting is not None and room.properties.energy.lighting.schedule.is_single_week:
translated_schedules.append(
WeekScheduleDoe.from_schedule_ruleset(
schedule_ruleset=room.properties.energy.lighting.schedule,
stype=DayScheduleType.FRACTION))

if room.properties.energy.people is not None and room.properties.energy.people.occupancy_schedule.is_single_week:
translated_schedules.append(
WeekScheduleDoe.from_schedule_ruleset(
schedule_ruleset=room.properties.energy.people.occupancy_schedule,
stype=DayScheduleType.FRACTION))

if room.properties.energy.electric_equipment is not None and room.properties.energy.electric_equipment.schedule.is_single_week:
translated_schedules.append(
WeekScheduleDoe.from_schedule_ruleset(
schedule_ruleset=room.properties.energy.electric_equipment.schedule,
stype=DayScheduleType.FRACTION))

if room.properties.energy.infiltration is not None and room.properties.energy.infiltration.schedule.is_single_week:
translated_schedules.append(
WeekScheduleDoe.from_schedule_ruleset(
schedule_ruleset=room.properties.energy.infiltration.schedule,
stype=DayScheduleType.MULTIPLIER)
)

if len(translated_schedules) > 0:
return '\n'.join(
set([schedule.to_inp() for schedule in translated_schedules]))
elif len(translated_schedules) == 0:
return '\n'

@property
def day_scheduels(self):
return self._get_day_scheduels(self.host)

@staticmethod
def _get_day_scheduels(obj):

translated_schedules = []
for room in obj.rooms:

if room.properties.energy.lighting is not None:
for sch in room.properties.energy.lighting.schedule.day_schedules:
if room.properties.energy.lighting.schedule.is_single_week:
translated_schedules.append(
DayScheduleDoe.from_day_schedule(
day_schedule=sch, stype=DayScheduleType.FRACTION))

if room.properties.energy.people is not None:
for sch in room.properties.energy.people.occupancy_schedule.day_schedules:
if room.properties.energy.people.occupancy_schedule.is_single_week:
translated_schedules.append(
DayScheduleDoe.from_day_schedule(
day_schedule=sch, stype=DayScheduleType.FRACTION))

if room.properties.energy.electric_equipment is not None:
for sch in room.properties.energy.electric_equipment.schedule.day_schedules:
if room.properties.energy.electric_equipment.schedule.is_single_week:
translated_schedules.append(
DayScheduleDoe.from_day_schedule(
day_schedule=sch, stype=DayScheduleType.FRACTION))

if room.properties.energy.infiltration is not None:
for sch in room.properties.energy.infiltration.schedule.day_schedules:
if room.properties.energy.infiltration.schedule.is_single_week:
translated_schedules.append(
DayScheduleDoe.from_day_schedule(
day_schedule=sch, stype=DayScheduleType.MULTIPLIER))

if len(translated_schedules) > 0:
return '\n'.join(
set([schedule.to_inp() for schedule in translated_schedules]))
elif len(translated_schedules) == 0:
return '\n'
# @property
# def week_scheduels(self):
# return self._get_week_scheduels(self.host)

# @staticmethod
# def _get_week_scheduels(obj):

# translated_schedules = []
# for room in obj.rooms:

# if room.properties.energy.lighting is not None and room.properties.energy.lighting.schedule.is_single_week:
# translated_schedules.append(
# WeekScheduleDoe.from_schedule_ruleset(
# schedule_ruleset=room.properties.energy.lighting.schedule,
# stype=DayScheduleType.FRACTION))
# else:
# None

# if room.properties.energy.people is not None and room.properties.energy.people.occupancy_schedule.is_single_week:
# translated_schedules.append(
# WeekScheduleDoe.from_schedule_ruleset(
# schedule_ruleset=room.properties.energy.people.occupancy_schedule,
# stype=DayScheduleType.FRACTION))
# else:
# None

# if room.properties.energy.electric_equipment is not None and room.properties.energy.electric_equipment.schedule.is_single_week:
# translated_schedules.append(
# WeekScheduleDoe.from_schedule_ruleset(
# schedule_ruleset=room.properties.energy.electric_equipment.schedule,
# stype=DayScheduleType.FRACTION))
# else:
# None
# if room.properties.energy.infiltration is not None and room.properties.energy.infiltration.schedule.is_single_week:
# translated_schedules.append(
# WeekScheduleDoe.from_schedule_ruleset(
# schedule_ruleset=room.properties.energy.infiltration.schedule,
# stype=DayScheduleType.MULTIPLIER)
# )
# else:
# None

# if len(translated_schedules) > 0:
# return '\n'.join(
# set([schedule.to_inp() for schedule in translated_schedules]))
# elif len(translated_schedules) == 0:
# return '\n'

# @property
# def day_scheduels(self):
# return self._get_day_scheduels(self.host)

# @staticmethod
# def _get_day_scheduels(obj):

# translated_schedules = []
# for room in obj.rooms:

# if room.properties.energy.lighting is not None:
# for sch in room.properties.energy.lighting.schedule.day_schedules:
# if room.properties.energy.lighting.schedule.is_single_week:
# translated_schedules.append(
# DayScheduleDoe.from_day_schedule(
# day_schedule=sch, stype=DayScheduleType.FRACTION))

# if room.properties.energy.people is not None:
# for sch in room.properties.energy.people.occupancy_schedule.day_schedules:
# if room.properties.energy.people.occupancy_schedule.is_single_week:
# translated_schedules.append(
# DayScheduleDoe.from_day_schedule(
# day_schedule=sch, stype=DayScheduleType.FRACTION))

# if room.properties.energy.electric_equipment is not None:
# for sch in room.properties.energy.electric_equipment.schedule.day_schedules:
# if room.properties.energy.electric_equipment.schedule.is_single_week:
# translated_schedules.append(
# DayScheduleDoe.from_day_schedule(
# day_schedule=sch, stype=DayScheduleType.FRACTION))

# if room.properties.energy.infiltration is not None:
# for sch in room.properties.energy.infiltration.schedule.day_schedules:
# if room.properties.energy.infiltration.schedule.is_single_week:
# translated_schedules.append(
# DayScheduleDoe.from_day_schedule(
# day_schedule=sch, stype=DayScheduleType.MULTIPLIER))

# if len(translated_schedules) > 0:
# return '\n'.join(
# set([schedule.to_inp() for schedule in translated_schedules]))
# elif len(translated_schedules) == 0:
# return '\n'

def __str__(self):
return "Model Doe2 Properties: [host: {}]".format(self.host.display_name)
Expand Down
4 changes: 2 additions & 2 deletions honeybee_doe2/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def model_to_inp(hb_model, hvac_mapping='story'):
comp_data.to_inp(),
sb_data.to_inp(),
fb.daySch,
hb_model.properties.doe2.day_scheduels,
# hb_model.properties.doe2.day_scheduels,
fb.weekSch,
hb_model.properties.doe2.week_scheduels,
# hb_model.properties.doe2.week_scheduels,
fb.mats_layers,
hb_model.properties.doe2.mats_cons_layers,
fb.glzCode,
Expand Down
Loading

0 comments on commit 405aba5

Please sign in to comment.