Skip to content

Commit

Permalink
fix(result): Update to respect changed E+ output name
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Dec 12, 2024
1 parent c4f43a6 commit 99eca4b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Binary file modified honeybee_grasshopper_energy/icon/HB Color Rooms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions honeybee_grasshopper_energy/json/HB_Color_Rooms.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.0",
"version": "1.8.1",
"nickname": "ColorRooms",
"outputs": [
[
Expand Down Expand Up @@ -113,7 +113,7 @@
}
],
"subcategory": "6 :: Result",
"code": "\n\ntry:\n from honeybee.model import Model\n from honeybee.room import Room\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry:\n from honeybee_energy.result.colorobj import ColorRoom\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_point3d\n from ladybug_{{cad}}.fromgeometry import from_face3ds_to_colored_mesh, \\\n from_polyface3d_to_wireframe\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.color import color_to_color\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\n from ladybug_{{cad}}.config import units_abbreviation\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\ndef split_solar_enclosure_data(data_to_split, rooms):\n \"\"\"Split solar enclosure data according to exterior aperture area.\"\"\"\n # figure out the ratios of exterior aperture area in each room\n enclosures = Room.group_by_air_boundary_adjacency(rooms)\n encl_ratios = {}\n for encl in enclosures:\n if len(encl) != 1:\n ap_areas = [rm.exterior_aperture_area for rm in encl]\n total_a = sum(ap_areas)\n if total_a != 0:\n rat_dict = {rm.identifier: ap / total_a\n for rm, ap in zip(encl, ap_areas)}\n else:\n rat_dict = {rm.identifier: 0 for rm in encl}\n encl_ratios[encl[0].identifier] = rat_dict\n encl_ratios = [x for _, x in sorted(zip(encl_ratios.keys(), encl_ratios.values()))]\n\n # create the list of split data collections\n split_data, enc_count = [], 0\n for dat in data_to_split:\n if 'Solar Enclosure' in dat.header.metadata['Zone']:\n rm_ratios = encl_ratios[enc_count]\n for rm_id, rm_rat in rm_ratios.items():\n new_data = dat.duplicate()\n new_data.header.metadata['Zone'] = rm_id.upper()\n new_data.values = [val * rm_rat for val in dat.values]\n split_data.append(new_data)\n enc_count += 1\n else:\n split_data.append(dat)\n return split_data\n\n\nif all_required_inputs(ghenv.Component):\n # extract any rooms from input Models\n rooms = []\n for hb_obj in _rooms_model:\n if isinstance(hb_obj, Model):\n rooms.extend(hb_obj.rooms)\n else:\n rooms.append(hb_obj)\n\n # apply analysis period to the data if connected\n if period_ is not None:\n _data = [coll.filter_by_analysis_period(period_) for coll in _data]\n\n # set default norm_by_floor value\n norm_by_flr_ = True if norm_by_flr_ is None else norm_by_flr_\n\n # sense if the conneccted data is for a solar enclosure and split the data if so\n space_based = False\n zone_solar = 'Zone Windows Total Transmitted Solar Radiation Energy'\n if 'type' in _data[0].header.metadata and _data[0].header.metadata['type'] == zone_solar:\n space_based = True\n if isinstance(_rooms_model[0], Model):\n _data = split_solar_enclosure_data(_data, rooms)\n\n # create the ColorRoom visualization object and output geometry\n color_obj = ColorRoom(_data, rooms, legend_par_, sim_step_, norm_by_flr_,\n units_abbreviation(), space_based=space_based)\n graphic = color_obj.graphic_container\n mesh = [from_face3ds_to_colored_mesh(flrs, col) for flrs, col in\n zip(color_obj.matched_floor_faces, graphic.value_colors)]\n wire_frame = []\n for room in rooms:\n wire_frame.extend(from_polyface3d_to_wireframe(room.geometry))\n legend = legend_objects(graphic.legend)\n title = text_objects(color_obj.title_text, graphic.lower_title_location,\n graphic.legend_parameters.text_height,\n graphic.legend_parameters.font)\n rooms = color_obj.matched_rooms\n colors = [color_to_color(col, 125) for col in graphic.value_colors]\n values = graphic.values\n vis_set = color_obj\n",
"code": "\n\ntry:\n from honeybee.model import Model\n from honeybee.room import Room\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry:\n from honeybee_energy.result.colorobj import ColorRoom\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_point3d\n from ladybug_{{cad}}.fromgeometry import from_face3ds_to_colored_mesh, \\\n from_polyface3d_to_wireframe\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.color import color_to_color\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\n from ladybug_{{cad}}.config import units_abbreviation\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\ndef split_solar_enclosure_data(data_to_split, rooms):\n \"\"\"Split solar enclosure data according to exterior aperture area.\"\"\"\n # figure out the ratios of exterior aperture area in each room\n enclosures = Room.group_by_air_boundary_adjacency(rooms)\n encl_ratios = {}\n for encl in enclosures:\n if len(encl) != 1:\n ap_areas = [rm.exterior_aperture_area for rm in encl]\n total_a = sum(ap_areas)\n if total_a != 0:\n rat_dict = {rm.identifier: ap / total_a\n for rm, ap in zip(encl, ap_areas)}\n else:\n rat_dict = {rm.identifier: 0 for rm in encl}\n encl_ratios[encl[0].identifier] = rat_dict\n encl_ratios = [x for _, x in sorted(zip(encl_ratios.keys(), encl_ratios.values()))]\n\n # create the list of split data collections\n split_data, enc_count = [], 0\n for dat in data_to_split:\n if 'Solar Enclosure' in dat.header.metadata['Zone']:\n rm_ratios = encl_ratios[enc_count]\n for rm_id, rm_rat in rm_ratios.items():\n new_data = dat.duplicate()\n new_data.header.metadata['Zone'] = rm_id.upper()\n new_data.values = [val * rm_rat for val in dat.values]\n split_data.append(new_data)\n enc_count += 1\n else:\n split_data.append(dat)\n return split_data\n\n\nif all_required_inputs(ghenv.Component):\n # extract any rooms from input Models\n rooms = []\n for hb_obj in _rooms_model:\n if isinstance(hb_obj, Model):\n rooms.extend(hb_obj.rooms)\n else:\n rooms.append(hb_obj)\n\n # apply analysis period to the data if connected\n if period_ is not None:\n _data = [coll.filter_by_analysis_period(period_) for coll in _data]\n\n # set default norm_by_floor value\n norm_by_flr_ = True if norm_by_flr_ is None else norm_by_flr_\n\n # sense if the conneccted data is for a solar enclosure and split the data if so\n space_based = False\n zone_solar = 'Windows Total Transmitted Solar Radiation Energy'\n if 'type' in _data[0].header.metadata and zone_solar in _data[0].header.metadata['type']:\n space_based = True\n if isinstance(_rooms_model[0], Model):\n _data = split_solar_enclosure_data(_data, rooms)\n\n # create the ColorRoom visualization object and output geometry\n color_obj = ColorRoom(_data, rooms, legend_par_, sim_step_, norm_by_flr_,\n units_abbreviation(), space_based=space_based)\n graphic = color_obj.graphic_container\n mesh = [from_face3ds_to_colored_mesh(flrs, col) for flrs, col in\n zip(color_obj.matched_floor_faces, graphic.value_colors)]\n wire_frame = []\n for room in rooms:\n wire_frame.extend(from_polyface3d_to_wireframe(room.geometry))\n legend = legend_objects(graphic.legend)\n title = text_objects(color_obj.title_text, graphic.lower_title_location,\n graphic.legend_parameters.text_height,\n graphic.legend_parameters.font)\n rooms = color_obj.matched_rooms\n colors = [color_to_color(col, 125) for col in graphic.value_colors]\n values = graphic.values\n vis_set = color_obj\n",
"category": "HB-Energy",
"name": "HB Color Rooms",
"description": "Visualize Room-level energy simulation results as colored Room geometry.\n-"
Expand Down
6 changes: 3 additions & 3 deletions honeybee_grasshopper_energy/src/HB Color Rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

ghenv.Component.Name = "HB Color Rooms"
ghenv.Component.NickName = 'ColorRooms'
ghenv.Component.Message = '1.8.0'
ghenv.Component.Message = '1.8.1'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '6 :: Result'
ghenv.Component.AdditionalHelpFromDocStrings = '2'
Expand Down Expand Up @@ -143,8 +143,8 @@ def split_solar_enclosure_data(data_to_split, rooms):

# sense if the conneccted data is for a solar enclosure and split the data if so
space_based = False
zone_solar = 'Zone Windows Total Transmitted Solar Radiation Energy'
if 'type' in _data[0].header.metadata and _data[0].header.metadata['type'] == zone_solar:
zone_solar = 'Windows Total Transmitted Solar Radiation Energy'
if 'type' in _data[0].header.metadata and zone_solar in _data[0].header.metadata['type']:
space_based = True
if isinstance(_rooms_model[0], Model):
_data = split_solar_enclosure_data(_data, rooms)
Expand Down
Binary file modified honeybee_grasshopper_energy/user_objects/HB Color Rooms.ghuser
Binary file not shown.

0 comments on commit 99eca4b

Please sign in to comment.