Skip to content

Commit

Permalink
fix(subprocess): Update components for Rhino 8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Nov 8, 2023
1 parent 23317c9 commit 8a7777b
Show file tree
Hide file tree
Showing 44 changed files with 314 additions and 288 deletions.
Binary file modified honeybee_grasshopper_energy/icon/HB Annual Loads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Binary file modified honeybee_grasshopper_energy/icon/HB Peak Loads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_energy/icon/HB Read Custom Result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_energy/icon/HB Read Environment Matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_energy/icon/HB Read Face Result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_energy/icon/HB Read HVAC Sizing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_energy/icon/HB Read Room Energy Result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified honeybee_grasshopper_energy/icon/HB Read Tabular Data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 42 additions & 42 deletions honeybee_grasshopper_energy/json/HB_Annual_Loads.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions honeybee_grasshopper_energy/json/HB_Carbon_Emission_Intensity.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
{
"version": "1.7.0",
"nickname": "CEI",
"name": "HB Carbon Emission Intensity",
"subcategory": "6 :: Result",
"version": "1.7.1",
"description": "Get information about carbon emission intensity (CEI) from an EnergyPlus SQL file.\n_\nThe location and year (or input emissions of electricity intensity) will be used\nto compute carbon intensity for both electricity and district heating/cooling.\nFixed numbers will be used to convert the following on-site fuel sources:\n_\n* Natural Gas -- 277.358 kg/MWh\n* Propane -- 323.897 kg/MWh\n* Fuel Oil -- 294.962 kg/MWh\n-",
"code": "\nimport os\nimport subprocess\nimport json\n\ntry:\n from ladybug.location import Location\nexcept ImportError as e:\n raise ImportError('\\nFailed to import location:\\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.emissions import future_electricity_emissions, \\\n emissions_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, give_warning\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, elec_emiss):\n results = emissions_from_sql(sql_files, elec_emiss)\n return results['carbon_intensity'], results['total_floor_area'], \\\n results['end_uses'], results['sources']\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, elec_emiss):\n from collections import OrderedDict\n cmds = [folders.python_exe_path, '-m', 'honeybee_energy', 'result',\n 'carbon-emission-intensity']\n cmds.extend(sql_files)\n cmds.extend(['--electricity-emissions', str(elec_emiss)])\n custom_env = os.environ.copy()\n custom_env['PYTHONHOME'] = ''\n process = subprocess.Popen(cmds, stdout=subprocess.PIPE, env=custom_env)\n stdout = process.communicate()\n results = json.loads(stdout[0], object_pairs_hook=OrderedDict)\n return results['carbon_intensity'], results['total_floor_area'], \\\n results['end_uses'], results['sources']\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 # process the location and year or the electricity intensity\n if isinstance(_loc_kgMWh, Location):\n yr = 2030 if _year_ is None else int(_year_)\n elec_emiss = future_electricity_emissions(_loc_kgMWh, yr)\n if elec_emiss is None:\n msg = 'Location must be inside the USA in order to be used for carbon ' \\\n 'emissions estimation.\\nPlug in a number for carbon intensity in ' \\\n 'kg CO2/MWH for locations outside the USA.'\n print(msg)\n raise ValueError(msg)\n else:\n try:\n elec_emiss = float(_loc_kgMWh)\n except TypeError:\n msg = 'Expected location object or number for _loccation. ' \\\n 'Got {}.'.format(type(_loc_kgMWh))\n raise ValueError(msg)\n\n # get the results\n get_results = get_results_windows if os.name == 'nt' else get_results_mac\n cei, gross_floor, end_use_pairs, sources = get_results(_sql, elec_emiss)\n\n # create separate lists for end use values and labels\n cei_end_use = end_use_pairs.values()\n end_uses = [use.replace('_', ' ').title() for use in end_use_pairs.keys()]\n\n # give a warning if the sources include district heating or cooling\n if 'district_heat' in sources:\n msg = 'District heating was found in the results and so carbon emissions ' \\\n 'cannot be accurately estimated.\\nTry using a different HVAC or SHW system.'\n print(msg)\n give_warning(ghenv.Component, msg)\n if 'district_cool' in sources:\n msg = 'District cooling was found in the results and so carbon emissions ' \\\n 'cannot be accurately estimated.\\nTry using a different HVAC system.'\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"outputs": [
[
{
"access": "None",
"name": "cei",
"description": "A number for the total annual carbon emission intensity (CEI). This is\nthe sum of all operational carbon emissions divided by the gross\nfloor area (including both conditioned and unconditioned spaces).\nUnits are kg CO2/m2.",
"access": "None",
"type": null,
"description": "A number for the total annual carbon emission intensity (CEI). This is\nthe sum of all operational carbon emissions divided by the gross\nfloor area (including both conditioned and unconditioned spaces).\nUnits are kg CO2/m2.",
"default": null
},
{
"access": "None",
"name": "cei_end_use",
"description": "The carbon emission intensity broken down by each end use. These\nvalues coorespond to the end_uses output below. Values are in kg CO2/m2 .",
"access": "None",
"type": null,
"description": "The carbon emission intensity broken down by each end use. These\nvalues coorespond to the end_uses output below. Values are in kg CO2/m2 .",
"default": null
},
{
"access": "None",
"name": "end_uses",
"description": "A list of text for each of the end uses in the simulation (Heating,\nCooling, etc.). Thes outputs coorespond to the eui_end_use\noutput above.",
"access": "None",
"type": null,
"description": "A list of text for each of the end uses in the simulation (Heating,\nCooling, etc.). Thes outputs coorespond to the eui_end_use\noutput above.",
"default": null
},
{
"access": "None",
"name": "gross_floor",
"description": "The total gross floor area of the energy model. This can be used\nto compute the total energy use from the intensity values above or\nit can be used to help with other result post-processing. The value\nwill be in m2 if ip_ is False or None and ft2 if True.",
"access": "None",
"type": null,
"description": "The total gross floor area of the energy model. This can be used\nto compute the total energy use from the intensity values above or\nit can be used to help with other result post-processing. The value\nwill be in m2 if ip_ is False or None and ft2 if True.",
"default": null
}
]
],
"category": "HB-Energy",
"nickname": "CEI",
"inputs": [
{
"access": "list",
"name": "_sql",
"description": "The file path of the SQL result file that has been generated from\nan energy simulation. This can also be a list of EnergyPlus files\nin which case EUI will be computed across all files. Lastly, it can\nbe a directory or list of directories containing results, in which\ncase, EUI will be calculated form all files ending in .sql.",
"access": "list",
"type": "string",
"description": "The file path of the SQL result file that has been generated from\nan energy simulation. This can also be a list of EnergyPlus files\nin which case EUI will be computed across all files. Lastly, it can\nbe a directory or list of directories containing results, in which\ncase, EUI will be calculated form all files ending in .sql.",
"default": null
},
{
"access": "item",
"name": "_loc_kgMWh",
"description": "A ladybug Location object in the USA, which will be used to determine the\nsubregion of the electrical grid. Alternatively, it can be A number\nfor the electric grid carbon emissions in kg CO2/MWh. The following\nrules of thumb may be used as a guide:\n_\n* 800 kg/MWh - an inefficient coal or oil-dominated grid (West Virgina in 2020)\n* 400 kg/MWh - the average US (energy mixed) grid around 2020\n* 200-400 kg/MWh - for grids in transition to renewables\n* 100-200 kg/MWh - for grids with majority renewable/nuclear composition\n* 0-100 kg/MWh - for grids with renewables and storage",
"access": "item",
"type": "System.Object",
"description": "A ladybug Location object in the USA, which will be used to determine the\nsubregion of the electrical grid. Alternatively, it can be A number\nfor the electric grid carbon emissions in kg CO2/MWh. The following\nrules of thumb may be used as a guide:\n_\n* 800 kg/MWh - an inefficient coal or oil-dominated grid (West Virgina in 2020)\n* 400 kg/MWh - the average US (energy mixed) grid around 2020\n* 200-400 kg/MWh - for grids in transition to renewables\n* 100-200 kg/MWh - for grids with majority renewable/nuclear composition\n* 0-100 kg/MWh - for grids with renewables and storage",
"default": null
},
{
"access": "item",
"name": "_year_",
"description": "An integer for the future year for which carbon emissions will\nbe estimated. Values must be an even number and be between 2020\nand 2050. (Default: 2030).",
"access": "item",
"type": "int",
"description": "An integer for the future year for which carbon emissions will\nbe estimated. Values must be an even number and be between 2020\nand 2050. (Default: 2030).",
"default": null
}
],
"subcategory": "6 :: Result",
"code": "\nimport os\nimport subprocess\nimport json\n\ntry:\n from ladybug.location import Location\nexcept ImportError as e:\n raise ImportError('\\nFailed to import location:\\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.emissions import future_electricity_emissions, \\\n emissions_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, give_warning\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, elec_emiss):\n results = emissions_from_sql(sql_files, elec_emiss)\n return results['carbon_intensity'], results['total_floor_area'], \\\n results['end_uses'], results['sources']\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, elec_emiss):\n from collections import OrderedDict\n cmds = [folders.python_exe_path, '-m', 'honeybee_energy', 'result',\n 'carbon-emission-intensity']\n cmds.extend(sql_files)\n cmds.extend(['--electricity-emissions', str(elec_emiss)])\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['carbon_intensity'], results['total_floor_area'], \\\n results['end_uses'], results['sources']\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 # process the location and year or the electricity intensity\n if isinstance(_loc_kgMWh, Location):\n yr = 2030 if _year_ is None else int(_year_)\n elec_emiss = future_electricity_emissions(_loc_kgMWh, yr)\n if elec_emiss is None:\n msg = 'Location must be inside the USA in order to be used for carbon ' \\\n 'emissions estimation.\\nPlug in a number for carbon intensity in ' \\\n 'kg CO2/MWH for locations outside the USA.'\n print(msg)\n raise ValueError(msg)\n else:\n try:\n elec_emiss = float(_loc_kgMWh)\n except TypeError:\n msg = 'Expected location object or number for _loccation. ' \\\n 'Got {}.'.format(type(_loc_kgMWh))\n raise ValueError(msg)\n\n # get the results\n get_results = get_results_windows if os.name == 'nt' else get_results_mac\n cei, gross_floor, end_use_pairs, sources = get_results(_sql, elec_emiss)\n\n # create separate lists for end use values and labels\n cei_end_use = end_use_pairs.values()\n end_uses = [use.replace('_', ' ').title() for use in end_use_pairs.keys()]\n\n # give a warning if the sources include district heating or cooling\n if 'district_heat' in sources:\n msg = 'District heating was found in the results and so carbon emissions ' \\\n 'cannot be accurately estimated.\\nTry using a different HVAC or SHW system.'\n print(msg)\n give_warning(ghenv.Component, msg)\n if 'district_cool' in sources:\n msg = 'District cooling was found in the results and so carbon emissions ' \\\n 'cannot be accurately estimated.\\nTry using a different HVAC system.'\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"category": "HB-Energy",
"name": "HB Carbon Emission Intensity",
"description": "Get information about carbon emission intensity (CEI) from an EnergyPlus SQL file.\n_\nThe location and year (or input emissions of electricity intensity) will be used\nto compute carbon intensity for both electricity and district heating/cooling.\nFixed numbers will be used to convert the following on-site fuel sources:\n_\n* Natural Gas -- 277.358 kg/MWh\n* Propane -- 323.897 kg/MWh\n* Fuel Oil -- 294.962 kg/MWh\n-"
]
}
Loading

0 comments on commit 8a7777b

Please sign in to comment.