Skip to content

Commit

Permalink
fix(result): Add missing OrderedDict dependency for Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed May 15, 2023
1 parent b433881 commit 8dd4ad8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
Binary file modified honeybee_grasshopper_energy/icon/HB End Use Intensity.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_End_Use_Intensity.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"nickname": "EUI",
"outputs": [
[
Expand Down Expand Up @@ -50,7 +50,7 @@
}
],
"subcategory": "6 :: Result",
"code": "\nimport os\nimport subprocess\nimport json\n\ntry:\n from ladybug.datatype.area import Area\n from ladybug.datatype.energyintensity import EnergyIntensity\n from ladybug.datatype.energy import Energy\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from honeybee.config import folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry:\n from honeybee_energy.result.eui import eui_from_sql\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\n# Use the SQLiteResult class to parse the result files directly on Windows.\ndef get_results_windows(sql_files):\n results = eui_from_sql(sql_files)\n return results['eui'], results['total_floor_area'], results['end_uses']\n\n\n# The SQLite3 module doesn't work in IronPython on Mac, so we must make a call\n# to the Honeybee CLI (which runs on CPython) to get the results.\ndef get_results_mac(sql_files):\n cmds = [folders.python_exe_path, '-m', 'honeybee_energy', 'result',\n 'energy-use-intensity']\n cmds.extend(sql_files)\n process = subprocess.Popen(cmds, stdout=subprocess.PIPE)\n stdout = process.communicate()\n results = json.loads(stdout[0], object_pairs_hook=OrderedDict)\n return results['eui'], results['total_floor_area'], results['end_uses']\n\n\nif all_required_inputs(ghenv.Component):\n # ensure that _sql is a list rather than a single string\n if isinstance(_sql, basestring):\n _sql = [_sql]\n\n # get the results\n get_results = get_results_windows if os.name == 'nt' else get_results_mac\n eui, gross_floor, end_use_pairs = get_results(_sql)\n\n # create separate lists for end use values and labels\n eui_end_use = end_use_pairs.values()\n end_uses = [use.replace('_', ' ').title() for use in end_use_pairs.keys()]\n\n # convert data to IP if requested\n if ip_:\n eui_typ, a_typ, e_typ = EnergyIntensity(), Area(), Energy()\n eui = round(eui_typ.to_ip([eui], 'kWh/m2')[0][0], 3)\n gross_floor = round(a_typ.to_ip([gross_floor], 'm2')[0][0], 3)\n eui_end_use = [round(eui_typ.to_ip([val], 'kWh/m2')[0][0], 3)\n for val in eui_end_use]\n",
"code": "\nimport os\nimport subprocess\nimport json\n\ntry:\n from ladybug.datatype.area import Area\n from ladybug.datatype.energyintensity import EnergyIntensity\n from ladybug.datatype.energy import Energy\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from honeybee.config import folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry:\n from honeybee_energy.result.eui import eui_from_sql\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\n# Use the SQLiteResult class to parse the result files directly on Windows.\ndef get_results_windows(sql_files):\n results = eui_from_sql(sql_files)\n return results['eui'], results['total_floor_area'], results['end_uses']\n\n\n# The SQLite3 module doesn't work in IronPython on Mac, so we must make a call\n# to the Honeybee CLI (which runs on CPython) to get the results.\ndef get_results_mac(sql_files):\n from collections import OrderedDict\n cmds = [folders.python_exe_path, '-m', 'honeybee_energy', 'result',\n 'energy-use-intensity']\n cmds.extend(sql_files)\n process = subprocess.Popen(cmds, stdout=subprocess.PIPE)\n stdout = process.communicate()\n results = json.loads(stdout[0], object_pairs_hook=OrderedDict)\n return results['eui'], results['total_floor_area'], results['end_uses']\n\n\nif all_required_inputs(ghenv.Component):\n # ensure that _sql is a list rather than a single string\n if isinstance(_sql, basestring):\n _sql = [_sql]\n\n # get the results\n get_results = get_results_windows if os.name == 'nt' else get_results_mac\n eui, gross_floor, end_use_pairs = get_results(_sql)\n\n # create separate lists for end use values and labels\n eui_end_use = end_use_pairs.values()\n end_uses = [use.replace('_', ' ').title() for use in end_use_pairs.keys()]\n\n # convert data to IP if requested\n if ip_:\n eui_typ, a_typ, e_typ = EnergyIntensity(), Area(), Energy()\n eui = round(eui_typ.to_ip([eui], 'kWh/m2')[0][0], 3)\n gross_floor = round(a_typ.to_ip([gross_floor], 'm2')[0][0], 3)\n eui_end_use = [round(eui_typ.to_ip([val], 'kWh/m2')[0][0], 3)\n for val in eui_end_use]\n",
"category": "HB-Energy",
"name": "HB End Use Intensity",
"description": "Get information about end use intensity from an EnergyPlus SQL file.\n-"
Expand Down
3 changes: 2 additions & 1 deletion honeybee_grasshopper_energy/src/HB End Use Intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

ghenv.Component.Name = 'HB End Use Intensity'
ghenv.Component.NickName = 'EUI'
ghenv.Component.Message = '1.6.0'
ghenv.Component.Message = '1.6.1'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '6 :: Result'
ghenv.Component.AdditionalHelpFromDocStrings = '1'
Expand Down Expand Up @@ -79,6 +79,7 @@ def get_results_windows(sql_files):
# The SQLite3 module doesn't work in IronPython on Mac, so we must make a call
# to the Honeybee CLI (which runs on CPython) to get the results.
def get_results_mac(sql_files):
from collections import OrderedDict
cmds = [folders.python_exe_path, '-m', 'honeybee_energy', 'result',
'energy-use-intensity']
cmds.extend(sql_files)
Expand Down
Binary file not shown.

0 comments on commit 8dd4ad8

Please sign in to comment.