Skip to content

Commit

Permalink
fix(cleanup): Fix No People bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-p-may committed Jan 23, 2023
1 parent 01801f6 commit 1932bd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions PHX/from_HBJSON/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
from honeybee_energy.load import people, equipment, infiltration
from honeybee_energy.schedule.ruleset import ScheduleRuleset
from honeybee_energy.lib.scheduletypelimits import schedule_type_limit_by_identifier
from honeybee_energy.properties.room import RoomEnergyProperties
except ImportError as e:
raise ImportError("\nFailed to import honeybee_energy:\n\t{}".format(e))

from honeybee_energy_ph.properties.hot_water.hw_system import SHWSystemPhProperties
from honeybee_energy_ph.properties.load.people import PeoplePhProperties
from PHX.model import project


HB_BC = Union[Outdoors, Ground, Adiabatic]


Expand Down Expand Up @@ -96,9 +97,16 @@ def merge_occupancies(_hb_rooms: List[room.Room]) -> people.People:
total_ph_bedrooms = 0.0
total_ph_people = 0.0
for room in _hb_rooms:
hb_ppl_obj = room.properties.energy.people # alias
total_ph_bedrooms += int(hb_ppl_obj.properties.ph.number_bedrooms)
total_ph_people += int(hb_ppl_obj.properties.ph.number_people)
hb_room_prop_energy: RoomEnergyProperties = room.properties.energy # type: ignore
hb_ppl_obj = hb_room_prop_energy.people

# -- Sometimes there is no 'People'
if hb_ppl_obj is None:
continue

hbph_people_prop_ph: PeoplePhProperties = hb_ppl_obj.properties.ph # type: ignore
total_ph_bedrooms += int(hbph_people_prop_ph.number_bedrooms)
total_ph_people += int(hbph_people_prop_ph.number_people)
total_hb_people += hb_ppl_obj.people_per_area * room.floor_area

# Build up the new object's attributes
Expand Down
2 changes: 1 addition & 1 deletion _testing_to_PHPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"/Users/em/Dropbox/bldgtyp-00/00_PH_Tools/PHX/tests/_source_hbjson/Default_Model_Single_Zone.hbjson"
)
SOURCE_FILE = pathlib.Path(
"/Users/em/Dropbox/bldgtyp-00/00_PH_Tools/PHX/sample/hbjson/Arapahoe_Cir_230111.hbjson"
"/Users/em/Dropbox/bldgtyp-00/00_PH_Tools/PHX/sample/hbjson/2303_Citylight.hbjson"
)

if __name__ == "__main__":
Expand Down

0 comments on commit 1932bd7

Please sign in to comment.