honeybee-energy 1.116.106__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. honeybee_energy/__init__.py +24 -0
  2. honeybee_energy/__main__.py +4 -0
  3. honeybee_energy/_extend_honeybee.py +145 -0
  4. honeybee_energy/altnumber.py +21 -0
  5. honeybee_energy/baseline/__init__.py +2 -0
  6. honeybee_energy/baseline/create.py +608 -0
  7. honeybee_energy/baseline/data/__init__.py +1 -0
  8. honeybee_energy/baseline/data/constructions.csv +64 -0
  9. honeybee_energy/baseline/data/fen_ratios.csv +15 -0
  10. honeybee_energy/baseline/data/lpd_building.csv +21 -0
  11. honeybee_energy/baseline/data/pci_2016.csv +22 -0
  12. honeybee_energy/baseline/data/pci_2019.csv +22 -0
  13. honeybee_energy/baseline/data/pci_2022.csv +22 -0
  14. honeybee_energy/baseline/data/shw.csv +21 -0
  15. honeybee_energy/baseline/pci.py +512 -0
  16. honeybee_energy/baseline/result.py +371 -0
  17. honeybee_energy/boundarycondition.py +128 -0
  18. honeybee_energy/cli/__init__.py +69 -0
  19. honeybee_energy/cli/baseline.py +475 -0
  20. honeybee_energy/cli/edit.py +327 -0
  21. honeybee_energy/cli/lib.py +1154 -0
  22. honeybee_energy/cli/result.py +810 -0
  23. honeybee_energy/cli/setconfig.py +124 -0
  24. honeybee_energy/cli/settings.py +569 -0
  25. honeybee_energy/cli/simulate.py +380 -0
  26. honeybee_energy/cli/translate.py +1714 -0
  27. honeybee_energy/cli/validate.py +224 -0
  28. honeybee_energy/config.json +11 -0
  29. honeybee_energy/config.py +842 -0
  30. honeybee_energy/construction/__init__.py +1 -0
  31. honeybee_energy/construction/_base.py +374 -0
  32. honeybee_energy/construction/air.py +325 -0
  33. honeybee_energy/construction/dictutil.py +89 -0
  34. honeybee_energy/construction/dynamic.py +607 -0
  35. honeybee_energy/construction/opaque.py +460 -0
  36. honeybee_energy/construction/shade.py +319 -0
  37. honeybee_energy/construction/window.py +1096 -0
  38. honeybee_energy/construction/windowshade.py +847 -0
  39. honeybee_energy/constructionset.py +1655 -0
  40. honeybee_energy/dictutil.py +56 -0
  41. honeybee_energy/generator/__init__.py +5 -0
  42. honeybee_energy/generator/loadcenter.py +204 -0
  43. honeybee_energy/generator/pv.py +535 -0
  44. honeybee_energy/hvac/__init__.py +21 -0
  45. honeybee_energy/hvac/_base.py +124 -0
  46. honeybee_energy/hvac/_template.py +270 -0
  47. honeybee_energy/hvac/allair/__init__.py +22 -0
  48. honeybee_energy/hvac/allair/_base.py +349 -0
  49. honeybee_energy/hvac/allair/furnace.py +168 -0
  50. honeybee_energy/hvac/allair/psz.py +131 -0
  51. honeybee_energy/hvac/allair/ptac.py +163 -0
  52. honeybee_energy/hvac/allair/pvav.py +109 -0
  53. honeybee_energy/hvac/allair/vav.py +128 -0
  54. honeybee_energy/hvac/detailed.py +337 -0
  55. honeybee_energy/hvac/doas/__init__.py +28 -0
  56. honeybee_energy/hvac/doas/_base.py +345 -0
  57. honeybee_energy/hvac/doas/fcu.py +127 -0
  58. honeybee_energy/hvac/doas/radiant.py +329 -0
  59. honeybee_energy/hvac/doas/vrf.py +81 -0
  60. honeybee_energy/hvac/doas/wshp.py +91 -0
  61. honeybee_energy/hvac/heatcool/__init__.py +23 -0
  62. honeybee_energy/hvac/heatcool/_base.py +177 -0
  63. honeybee_energy/hvac/heatcool/baseboard.py +61 -0
  64. honeybee_energy/hvac/heatcool/evapcool.py +72 -0
  65. honeybee_energy/hvac/heatcool/fcu.py +92 -0
  66. honeybee_energy/hvac/heatcool/gasunit.py +53 -0
  67. honeybee_energy/hvac/heatcool/radiant.py +269 -0
  68. honeybee_energy/hvac/heatcool/residential.py +77 -0
  69. honeybee_energy/hvac/heatcool/vrf.py +54 -0
  70. honeybee_energy/hvac/heatcool/windowac.py +70 -0
  71. honeybee_energy/hvac/heatcool/wshp.py +62 -0
  72. honeybee_energy/hvac/idealair.py +699 -0
  73. honeybee_energy/internalmass.py +310 -0
  74. honeybee_energy/lib/__init__.py +1 -0
  75. honeybee_energy/lib/_loadconstructions.py +194 -0
  76. honeybee_energy/lib/_loadconstructionsets.py +117 -0
  77. honeybee_energy/lib/_loadmaterials.py +83 -0
  78. honeybee_energy/lib/_loadprogramtypes.py +125 -0
  79. honeybee_energy/lib/_loadschedules.py +87 -0
  80. honeybee_energy/lib/_loadtypelimits.py +64 -0
  81. honeybee_energy/lib/constructions.py +207 -0
  82. honeybee_energy/lib/constructionsets.py +95 -0
  83. honeybee_energy/lib/materials.py +67 -0
  84. honeybee_energy/lib/programtypes.py +125 -0
  85. honeybee_energy/lib/schedules.py +61 -0
  86. honeybee_energy/lib/scheduletypelimits.py +31 -0
  87. honeybee_energy/load/__init__.py +1 -0
  88. honeybee_energy/load/_base.py +190 -0
  89. honeybee_energy/load/daylight.py +397 -0
  90. honeybee_energy/load/dictutil.py +47 -0
  91. honeybee_energy/load/equipment.py +771 -0
  92. honeybee_energy/load/hotwater.py +543 -0
  93. honeybee_energy/load/infiltration.py +460 -0
  94. honeybee_energy/load/lighting.py +480 -0
  95. honeybee_energy/load/people.py +497 -0
  96. honeybee_energy/load/process.py +472 -0
  97. honeybee_energy/load/setpoint.py +816 -0
  98. honeybee_energy/load/ventilation.py +550 -0
  99. honeybee_energy/material/__init__.py +1 -0
  100. honeybee_energy/material/_base.py +166 -0
  101. honeybee_energy/material/dictutil.py +59 -0
  102. honeybee_energy/material/frame.py +367 -0
  103. honeybee_energy/material/gas.py +1087 -0
  104. honeybee_energy/material/glazing.py +854 -0
  105. honeybee_energy/material/opaque.py +1351 -0
  106. honeybee_energy/material/shade.py +1360 -0
  107. honeybee_energy/measure.py +472 -0
  108. honeybee_energy/programtype.py +723 -0
  109. honeybee_energy/properties/__init__.py +1 -0
  110. honeybee_energy/properties/aperture.py +333 -0
  111. honeybee_energy/properties/door.py +342 -0
  112. honeybee_energy/properties/extension.py +244 -0
  113. honeybee_energy/properties/face.py +274 -0
  114. honeybee_energy/properties/model.py +2640 -0
  115. honeybee_energy/properties/room.py +1747 -0
  116. honeybee_energy/properties/shade.py +314 -0
  117. honeybee_energy/properties/shademesh.py +262 -0
  118. honeybee_energy/reader.py +48 -0
  119. honeybee_energy/result/__init__.py +1 -0
  120. honeybee_energy/result/colorobj.py +648 -0
  121. honeybee_energy/result/emissions.py +290 -0
  122. honeybee_energy/result/err.py +101 -0
  123. honeybee_energy/result/eui.py +100 -0
  124. honeybee_energy/result/generation.py +160 -0
  125. honeybee_energy/result/loadbalance.py +890 -0
  126. honeybee_energy/result/match.py +202 -0
  127. honeybee_energy/result/osw.py +90 -0
  128. honeybee_energy/result/rdd.py +59 -0
  129. honeybee_energy/result/zsz.py +190 -0
  130. honeybee_energy/run.py +1577 -0
  131. honeybee_energy/schedule/__init__.py +1 -0
  132. honeybee_energy/schedule/day.py +626 -0
  133. honeybee_energy/schedule/dictutil.py +59 -0
  134. honeybee_energy/schedule/fixedinterval.py +1012 -0
  135. honeybee_energy/schedule/rule.py +619 -0
  136. honeybee_energy/schedule/ruleset.py +1867 -0
  137. honeybee_energy/schedule/typelimit.py +310 -0
  138. honeybee_energy/shw.py +315 -0
  139. honeybee_energy/simulation/__init__.py +1 -0
  140. honeybee_energy/simulation/control.py +214 -0
  141. honeybee_energy/simulation/daylightsaving.py +185 -0
  142. honeybee_energy/simulation/dictutil.py +51 -0
  143. honeybee_energy/simulation/output.py +646 -0
  144. honeybee_energy/simulation/parameter.py +606 -0
  145. honeybee_energy/simulation/runperiod.py +443 -0
  146. honeybee_energy/simulation/shadowcalculation.py +295 -0
  147. honeybee_energy/simulation/sizing.py +546 -0
  148. honeybee_energy/ventcool/__init__.py +5 -0
  149. honeybee_energy/ventcool/_crack_data.py +91 -0
  150. honeybee_energy/ventcool/afn.py +289 -0
  151. honeybee_energy/ventcool/control.py +269 -0
  152. honeybee_energy/ventcool/crack.py +126 -0
  153. honeybee_energy/ventcool/fan.py +493 -0
  154. honeybee_energy/ventcool/opening.py +365 -0
  155. honeybee_energy/ventcool/simulation.py +314 -0
  156. honeybee_energy/writer.py +1078 -0
  157. honeybee_energy-1.116.106.dist-info/METADATA +113 -0
  158. honeybee_energy-1.116.106.dist-info/RECORD +162 -0
  159. honeybee_energy-1.116.106.dist-info/WHEEL +5 -0
  160. honeybee_energy-1.116.106.dist-info/entry_points.txt +2 -0
  161. honeybee_energy-1.116.106.dist-info/licenses/LICENSE +661 -0
  162. honeybee_energy-1.116.106.dist-info/top_level.txt +1 -0
@@ -0,0 +1,842 @@
1
+ """Honeybee_energy configurations.
2
+
3
+ Import this into every module where access configurations are needed.
4
+
5
+ Usage:
6
+
7
+ .. code-block:: python
8
+
9
+ from honeybee_energy.config import folders
10
+ print(folders.energyplus_path)
11
+ print(folders.openstudio_path)
12
+ folders.energyplus_path = "C:/EnergyPlusV9-0-1"
13
+ """
14
+ import ladybug.config as lb_config
15
+ import honeybee_standards
16
+
17
+ import os
18
+ import platform
19
+ import subprocess
20
+ import json
21
+ import pkgutil
22
+
23
+
24
+ class Folders(object):
25
+ """Honeybee_energy folders.
26
+
27
+ Args:
28
+ config_file: The path to the config.json file from which folders are loaded.
29
+ If None, the config.json module included in this package will be used.
30
+ Default: None.
31
+ mute: If False, the paths to the various folders will be printed as they
32
+ are found. If True, no printing will occur upon initialization of this
33
+ class. Default: True.
34
+
35
+ Properties:
36
+ * openstudio_path
37
+ * openstudio_exe
38
+ * openstudio_version
39
+ * openstudio_version_str
40
+ * openstudio_csharp_path
41
+ * openstudio_lib_path
42
+ * energyplus_path
43
+ * energyplus_exe
44
+ * energyplus_version
45
+ * energyplus_version_str
46
+ * energyplus_idd_path
47
+ * lbt_measures_path
48
+ * openstudio_results_measure_path
49
+ * view_data_measure_path
50
+ * inject_idf_measure_path
51
+ * efficiency_standard_measure_path
52
+ * honeybee_openstudio_gem_path
53
+ * honeybee_adapter_path
54
+ * ironbug_path
55
+ * ironbug_exe
56
+ * ironbug_version
57
+ * ironbug_version_str
58
+ * standards_data_folder
59
+ * construction_lib
60
+ * constructionset_lib
61
+ * schedule_lib
62
+ * programtype_lib
63
+ * defaults_file
64
+ * standards_extension_folders
65
+ * config_file
66
+ * mute
67
+ """
68
+
69
+ def __init__(self, config_file=None, mute=True):
70
+ self.mute = bool(mute) # set the mute value
71
+ self.config_file = config_file # load paths from the config JSON file
72
+
73
+ @property
74
+ def openstudio_path(self):
75
+ """Get or set the path to OpenStudio installation folder.
76
+
77
+ This is the "bin" directory for OpenStudio installation (the one that
78
+ contains the openstudio executable file).
79
+ """
80
+ return self._openstudio_path
81
+
82
+ @openstudio_path.setter
83
+ def openstudio_path(self, path):
84
+ if not path: # check the default installation location
85
+ path = self._find_openstudio_folder()
86
+ exe_name = 'openstudio.exe' if os.name == 'nt' else 'openstudio'
87
+ os_exe_file = os.path.join(path, exe_name) if path is not None else None
88
+
89
+ if path: # check that the OpenStudio executable exists in the path
90
+ assert os.path.isfile(os_exe_file), \
91
+ '{} is not a valid path to an openstudio installation.'.format(path)
92
+ # see if the CSharp folder is installed
93
+ csharp_path = os.path.join(os.path.dirname(path), 'CSharp', 'openstudio')
94
+ self._openstudio_csharp_path = csharp_path \
95
+ if os.path.isdir(csharp_path) else None
96
+ # see if the lib path is installed
97
+ lib_path = os.path.join(os.path.dirname(path), 'lib')
98
+ self._openstudio_lib_path = lib_path \
99
+ if os.path.isdir(lib_path) else None
100
+ else:
101
+ self._openstudio_csharp_path = None
102
+ self._openstudio_lib_path = None
103
+
104
+ # set the openstudio_path
105
+ self._openstudio_path = path
106
+ self._openstudio_exe = os_exe_file
107
+ self._openstudio_version = None
108
+ self._openstudio_version_str = None
109
+ if path and not self.mute:
110
+ print("Path to OpenStudio is set to: %s" % path)
111
+
112
+ @property
113
+ def openstudio_exe(self):
114
+ """Get the path to the executable openstudio file."""
115
+ return self._openstudio_exe
116
+
117
+ @property
118
+ def openstudio_version(self):
119
+ """Get a tuple for the version of openstudio (eg. (3, 0, 1)).
120
+
121
+ This will be None if the version could not be sensed or if no OpenStudio
122
+ installation was found.
123
+ """
124
+ if self._openstudio_exe and self._openstudio_version_str is None:
125
+ self._openstudio_version_from_cli()
126
+ return self._openstudio_version
127
+
128
+ @property
129
+ def openstudio_version_str(self):
130
+ """Get text for the full version of openstudio (eg. "3.0.1+09b7c8a554").
131
+
132
+ This will be None if the version could not be sensed or if no OpenStudio
133
+ installation was found.
134
+ """
135
+ if self._openstudio_exe and self._openstudio_version_str is None:
136
+ self._openstudio_version_from_cli()
137
+ return self._openstudio_version_str
138
+
139
+ @property
140
+ def openstudio_csharp_path(self):
141
+ """Get the path to the OpenStudio CSharp folder if it exists."""
142
+ if self._openstudio_csharp_path is None and self._ironbug_path is not None:
143
+ os_dll = os.path.join(self._ironbug_path, 'OpenStudio.dll')
144
+ if os.path.isfile(os_dll):
145
+ return self._ironbug_path
146
+ return self._openstudio_csharp_path
147
+
148
+ @property
149
+ def openstudio_lib_path(self):
150
+ """Get the path to the OpenStudio lib folder if it exists."""
151
+ return self._openstudio_lib_path
152
+
153
+ @property
154
+ def energyplus_path(self):
155
+ """Get or set the path to EnergyPlus installation folder."""
156
+ return self._energyplus_path
157
+
158
+ @energyplus_path.setter
159
+ def energyplus_path(self, path):
160
+ if not path: # check the default installation location
161
+ path = self._find_energyplus_folder()
162
+ exe_name = 'energyplus.exe' if os.name == 'nt' else 'energyplus'
163
+ ep_exe_file = os.path.join(path, exe_name) if path is not None else None
164
+
165
+ if path: # check that the Energyplus executable exists in the installation
166
+ assert os.path.isfile(ep_exe_file), \
167
+ '{} is not a valid path to an energyplus installation.'.format(path)
168
+
169
+ # set the energyplus_path
170
+ self._energyplus_path = path
171
+ self._energyplus_exe = ep_exe_file
172
+ self._energyplus_version = None
173
+ self._energyplus_version_str = None
174
+ self._energyplus_idd_path = None
175
+ if path and not self.mute:
176
+ print("Path to EnergyPlus is set to: %s" % self._energyplus_path)
177
+
178
+ @property
179
+ def energyplus_exe(self):
180
+ """Get the path to the executable energyplus file."""
181
+ return self._energyplus_exe
182
+
183
+ @property
184
+ def energyplus_version(self):
185
+ """Get a tuple for the version of energyplus (eg. (9, 3, 0)).
186
+
187
+ This will be None if the version could not be sensed or if no EnergyPlus
188
+ installation was found.
189
+ """
190
+ if self._energyplus_exe and self._energyplus_version_str is None:
191
+ self._energyplus_version_from_cli()
192
+ return self._energyplus_version
193
+
194
+ @property
195
+ def energyplus_version_str(self):
196
+ """Get text for the full version of energyplus (eg. "9.3.0-baff08990c").
197
+
198
+ This will be None if the version could not be sensed or if no EnergyPlus
199
+ installation was found.
200
+ """
201
+ if self._energyplus_exe and self._energyplus_version_str is None:
202
+ self._energyplus_version_from_cli()
203
+ return self._energyplus_version_str
204
+
205
+ @property
206
+ def energyplus_idd_path(self):
207
+ if self._energyplus_exe and self._energyplus_idd_path is None:
208
+ idd_path = os.path.join(self.energyplus_path, 'Energy+.idd')
209
+ if os.path.isfile(idd_path):
210
+ self._energyplus_idd_path = idd_path
211
+ return self._energyplus_idd_path
212
+
213
+ @property
214
+ def lbt_measures_path(self):
215
+ """Get or set the path to the the measures that ship with with Ladybug Tools.
216
+
217
+ This folder must have the following sub-folders in order to be valid:
218
+
219
+ * openstudio_results - Measure to display a clean energy use HTML report.
220
+ * view_data - Measure to color geometry with simulation results.
221
+ """
222
+ return self._lbt_measures_path
223
+
224
+ @lbt_measures_path.setter
225
+ def lbt_measures_path(self, path):
226
+ if not path: # check the default locations of the lbt_measures
227
+ path = self._find_lbt_measures_path()
228
+
229
+ # check that the library's sub-folders exist
230
+ self._openstudio_results_measure_path = None
231
+ self._view_data_measure_path = None
232
+ self._inject_idf_measure_path = None
233
+ self._efficiency_standard_measure_path = None
234
+ if path:
235
+ result_mea = os.path.join(path, 'openstudio_results')
236
+ view_mea = os.path.join(path, 'view_data')
237
+ idf_mea = os.path.join(path, 'inject_idf')
238
+ eff_mea = os.path.join(path, 'efficiency_standard')
239
+ if os.path.isdir(result_mea):
240
+ self._openstudio_results_measure_path = result_mea
241
+ if os.path.isdir(view_mea):
242
+ self._view_data_measure_path = view_mea
243
+ if os.path.isdir(idf_mea):
244
+ self._inject_idf_measure_path = idf_mea
245
+ if os.path.isdir(eff_mea):
246
+ self._efficiency_standard_measure_path = eff_mea
247
+
248
+ # set the lbt_measures_path
249
+ self._lbt_measures_path = path
250
+ if path and not self.mute:
251
+ print('Path to the lbt_measures is set to: '
252
+ '{}'.format(self._lbt_measures_path))
253
+
254
+ @property
255
+ def efficiency_standard_measure_path(self):
256
+ """Get the path to the measure that sets efficiencies of all HVAC equipment."""
257
+ return self._efficiency_standard_measure_path
258
+
259
+ @property
260
+ def openstudio_results_measure_path(self):
261
+ """Get the path to the measure that displays a clean energy use HTML report."""
262
+ return self._openstudio_results_measure_path
263
+
264
+ @property
265
+ def view_data_measure_path(self):
266
+ """Get the path to the measure that colors geometry with simulation results."""
267
+ return self._view_data_measure_path
268
+
269
+ @property
270
+ def inject_idf_measure_path(self):
271
+ """Get the path to the measure that injects IDF text."""
272
+ return self._inject_idf_measure_path
273
+
274
+ @property
275
+ def honeybee_openstudio_gem_path(self):
276
+ """Get or set the path to the honeybee_openstudio_gem.
277
+
278
+ This gem contains libraries and measures for translating between Honeybee
279
+ JSON schema and OpenStudio Model schema (OSM).
280
+ This folder must have the following sub-folders in order to be valid:
281
+
282
+ * honeybee - Ruby library with modules for model translation to OpenStudio.
283
+ * measures - folder with the actual measures that run the translation.
284
+ * files - folder containing the adapter and other supporting files.
285
+ """
286
+ return self._honeybee_openstudio_gem_path
287
+
288
+ @honeybee_openstudio_gem_path.setter
289
+ def honeybee_openstudio_gem_path(self, path):
290
+ if not path: # check the default locations of the honeybee_openstudio_gem
291
+ path = self._find_honeybee_openstudio_gem_path()
292
+
293
+ # check that the library's sub-folders exist
294
+ self._honeybee_adapter_path = None
295
+ if path:
296
+ assert os.path.isdir(os.path.join(path, 'measures')), \
297
+ '{} lacks a "measures" folder.'.format(path)
298
+ assert os.path.isdir(os.path.join(path, 'files')), \
299
+ '{} lacks a "files" folder.'.format(path)
300
+ adapter = os.path.join(path, 'files', 'honeybee_adapter.rb')
301
+ self._honeybee_adapter_path = adapter if os.path.isfile(adapter) else None
302
+
303
+ # set the honeybee_openstudio_gem_path
304
+ self._honeybee_openstudio_gem_path = path
305
+ if path and not self.mute:
306
+ print('Path to the honeybee_openstudio_gem is set to: '
307
+ '{}'.format(self._honeybee_openstudio_gem_path))
308
+
309
+ @property
310
+ def honeybee_adapter_path(self):
311
+ """Get the path to the honeybee adapter.
312
+
313
+ This adapter file is used to report the EnergyPlus simulation progress
314
+ when running simulations using the OpenStudio CLI.
315
+ """
316
+ return self._honeybee_adapter_path
317
+
318
+ @property
319
+ def ironbug_path(self):
320
+ """Get or set the path to an Ironbug installation folder."""
321
+ return self._ironbug_path
322
+
323
+ @ironbug_path.setter
324
+ def ironbug_path(self, path):
325
+ if not path: # check the default installation location
326
+ path = self._find_ironbug_path_folder()
327
+ exe_name = 'Ironbug.Console.exe' if os.name == 'nt' else 'Ironbug.Console'
328
+ ib_exe_file = os.path.join(path, exe_name) if path is not None else None
329
+
330
+ if path: # check that the Ironbug executable exists in the installation
331
+ assert os.path.isfile(ib_exe_file), \
332
+ '{} is not a valid path to an Ironbug installation.'.format(path)
333
+
334
+ # set the ironbug_path
335
+ self._ironbug_path = path
336
+ self._ironbug_exe = ib_exe_file
337
+ self._ironbug_version = None
338
+ self._ironbug_version_str = None
339
+ if path and not self.mute:
340
+ print("Path to IronBug is set to: %s" % self._ironbug_path)
341
+
342
+ @property
343
+ def ironbug_exe(self):
344
+ """Get the path to the executable Ironbug console file."""
345
+ return self._ironbug_exe
346
+
347
+ @property
348
+ def ironbug_version(self):
349
+ """Get a tuple for the version of Ironbug (eg. (1, 4, 3, 0)).
350
+
351
+ This will be None if the version could not be sensed or if no Ironbug
352
+ installation was found.
353
+ """
354
+ if self._ironbug_exe and self._ironbug_version_str is None:
355
+ self._ironbug_version_from_cli()
356
+ return self._ironbug_version
357
+
358
+ @property
359
+ def ironbug_version_str(self):
360
+ """Get text for the full version of Ironbug (eg. "v1.4.3.0 (Jan 17, 2023)").
361
+
362
+ This will be None if the version could not be sensed or if no Ironbug
363
+ installation was found.
364
+ """
365
+ if self._ironbug_exe and self._ironbug_version_str is None:
366
+ self._ironbug_version_from_cli()
367
+ return self._ironbug_version_str
368
+
369
+ @property
370
+ def standards_data_folder(self):
371
+ """Get or set the path to the library of standards loaded to honeybee_energy.lib.
372
+
373
+ This folder must have the following sub-folders in order to be valid:
374
+
375
+ * constructions - folder with IDF files for materials + constructions.
376
+ * constructionsets - folder with JSON files of abridged ConstructionSets.
377
+ * schedules - folder with IDF files for schedules.
378
+ * programtypes - folder with JSON files of abridged ProgramTypes.
379
+ """
380
+ return self._standards_data_folder
381
+
382
+ @standards_data_folder.setter
383
+ def standards_data_folder(self, path):
384
+ if not path: # check the default locations of the template library
385
+ path = self._find_standards_data_folder()
386
+
387
+ # gather all of the sub folders underneath the master folder
388
+ self._construction_lib, self._constructionset_lib, self._schedule_lib, \
389
+ self._programtype_lib = self._check_standards_folder(path)
390
+
391
+ # set the standards_data_folder
392
+ self._standards_data_folder = path
393
+ if path and not self.mute:
394
+ print('Path to the standards_data_folder is set to: '
395
+ '{}'.format(self._standards_data_folder))
396
+
397
+ @property
398
+ def standards_extension_folders(self):
399
+ """Get or set an array of paths to standards extensions loaded to the lib.
400
+
401
+ Each extension folder folder must have the following sub-folders:
402
+
403
+ * constructions - folder with honeybee JSON files for materials + constructions.
404
+ It should have the following 4 JSON files:
405
+ opaque_material, opaque_construction, window_material, window_construction.
406
+ * constructionsets - folder with honeybee JSON files of ConstructionSets.
407
+ * schedules - folder with honeybee JSON files for schedules.
408
+ * programtypes - folder with honeybee JSON files of ProgramTypes.
409
+ """
410
+ return tuple(self._standards_extension_folders)
411
+
412
+ @standards_extension_folders.setter
413
+ def standards_extension_folders(self, folders):
414
+ if not folders: # check the default locations
415
+ folders = self._find_standards_extension_folders()
416
+
417
+ # check that any extensions have the proper sub-folders
418
+ for path in folders:
419
+ self._check_standards_folder(path)
420
+ if not self.mute:
421
+ print('Standards extension folder found: {}'.format(path))
422
+
423
+ # set the standards_data_folder
424
+ self._standards_extension_folders = folders
425
+
426
+ @property
427
+ def construction_lib(self):
428
+ """Get the path to the construction library in the standards_data_folder."""
429
+ return self._construction_lib
430
+
431
+ @property
432
+ def constructionset_lib(self):
433
+ """Get the path to the constructionset library in the standards_data_folder."""
434
+ return self._constructionset_lib
435
+
436
+ @property
437
+ def schedule_lib(self):
438
+ """Get the path to the schedule library in the standards_data_folder."""
439
+ return self._schedule_lib
440
+
441
+ @property
442
+ def programtype_lib(self):
443
+ """Get the path to the programtype library in the standards_data_folder."""
444
+ return self._programtype_lib
445
+
446
+ @property
447
+ def defaults_file(self):
448
+ """Get the path to the JSON file where honeybee's defaults are loaded from."""
449
+ return self._defaults_file
450
+
451
+ @defaults_file.setter
452
+ def defaults_file(self, path):
453
+ if not path: # check the default location
454
+ path = self._find_defaults_file()
455
+ assert os.path.isfile(path), \
456
+ '{} is not a valid path to an defaults JSON file.'.format(path)
457
+ self._defaults_file = path
458
+ if not self.mute:
459
+ print("Path to defaults file is set to: %s" % self._defaults_file)
460
+
461
+ @property
462
+ def config_file(self):
463
+ """Get or set the path to the config.json file from which folders are loaded.
464
+
465
+ Setting this to None will result in using the config.json module included
466
+ in this package.
467
+ """
468
+ return self._config_file
469
+
470
+ @config_file.setter
471
+ def config_file(self, cfg):
472
+ if cfg is None:
473
+ cfg = os.path.join(os.path.dirname(__file__), 'config.json')
474
+ self._load_from_file(cfg)
475
+ self._config_file = cfg
476
+
477
+ def _load_from_file(self, file_path):
478
+ """Set all of the the properties of this object from a config JSON file.
479
+
480
+ Args:
481
+ file_path: Path to a JSON file containing the file paths. A sample of this
482
+ JSON is the config.json file within this package.
483
+ """
484
+ # check the default file path
485
+ assert os.path.isfile(str(file_path)), \
486
+ ValueError('No file found at {}'.format(file_path))
487
+
488
+ # set the default paths to be all blank
489
+ default_path = {
490
+ "energyplus_path": r'',
491
+ "openstudio_path": r'',
492
+ "lbt_measures_path": r'',
493
+ "honeybee_openstudio_gem_path": r'',
494
+ "ironbug_path": r'',
495
+ "standards_data_folder": r'',
496
+ "standards_extension_folders": [],
497
+ "defaults_file": r''
498
+ }
499
+
500
+ with open(file_path, 'r') as cfg:
501
+ try:
502
+ paths = json.load(cfg)
503
+ except Exception as e:
504
+ print('Failed to load paths from {}.\n{}'.format(file_path, e))
505
+ else:
506
+ for key, p in paths.items():
507
+ if isinstance(key, list) or not key.startswith('__'):
508
+ try:
509
+ default_path[key] = p.strip()
510
+ except AttributeError:
511
+ default_path[key] = p
512
+
513
+ # set paths for energyplus and openstudio installations
514
+ self.openstudio_path = default_path["openstudio_path"]
515
+ self.energyplus_path = default_path["energyplus_path"]
516
+
517
+ # set the paths for lbt_measures and the honeybee_openstudio_gem
518
+ self.lbt_measures_path = default_path["lbt_measures_path"]
519
+ self.honeybee_openstudio_gem_path = default_path["honeybee_openstudio_gem_path"]
520
+
521
+ # set the paths for ironbug
522
+ self.ironbug_path = default_path["ironbug_path"]
523
+
524
+ # set path for the standards_data_folder and defaults_file
525
+ self.standards_data_folder = default_path["standards_data_folder"]
526
+ self.defaults_file = default_path["defaults_file"]
527
+
528
+ # set path for the standards_extension_folders
529
+ self.standards_extension_folders = default_path["standards_extension_folders"]
530
+
531
+ def _find_lbt_measures_path(self):
532
+ """Find the lbt_measures_path in its default location.
533
+
534
+ The ladybug_tools/resources/measures folder will be checked for the
535
+ expected directories of measures.
536
+ """
537
+ # first, check the resources/measures folder in the ladybug_tools folder
538
+ lb_install = lb_config.folders.ladybug_tools_folder
539
+ if os.path.isdir(lb_install):
540
+ measure_path = os.path.join(lb_install, 'resources', 'measures')
541
+ if os.path.isdir(os.path.join(measure_path, 'openstudio_results')):
542
+ return measure_path
543
+ return None # No lbt_measures is installed
544
+
545
+ def _find_honeybee_openstudio_gem_path(self):
546
+ """Find the honeybee_openstudio_gem_path in its default location.
547
+
548
+ First, the ladybug_tools/resources/measures folder will be checked for a
549
+ honeybee_openstudio_gem directory.
550
+
551
+ If nothing is found there, the OpenStudio installation will be checked
552
+ to see if there is a compatible version of the measure installed that
553
+ is specific for that version of OpenStudio.
554
+ """
555
+ # first, check the resources/measures folder in the ladybug_tools folder
556
+ lb_install = lb_config.folders.ladybug_tools_folder
557
+ if os.path.isdir(lb_install):
558
+ measure_path = os.path.join(
559
+ lb_install, 'resources', 'measures', 'honeybee_openstudio_gem', 'lib')
560
+ if os.path.isdir(measure_path):
561
+ return measure_path
562
+
563
+ # then check if there's a version installed in the OpenStudio folder
564
+ if self.openstudio_path:
565
+ os_root = os.path.split(self.openstudio_path)[0]
566
+ measure_path = os.path.join(os_root, 'honeybee_openstudio_gem', 'lib')
567
+ if os.path.isdir(measure_path):
568
+ return measure_path
569
+
570
+ return None # No energy model measure is installed
571
+
572
+ def _find_ironbug_path_folder(self):
573
+ """Find the ironbug_path in its default location.
574
+
575
+ The ladybug_tools/grasshopper/ironbug folder will be checked for the
576
+ expected directories.
577
+ """
578
+ # first, check the grasshopper/ironbug folder in the ladybug_tools folder
579
+ lb_install = lb_config.folders.ladybug_tools_folder
580
+ if os.path.isdir(lb_install):
581
+ ib_path = os.path.join(lb_install, 'grasshopper', 'ironbug')
582
+ if os.path.isdir(ib_path):
583
+ return ib_path
584
+ return None # No ironbug is installed
585
+
586
+ def _find_energyplus_folder(self):
587
+ """Find the most recent EnergyPlus installation in its default location.
588
+
589
+ This method will first attempt to return the path of the EnergyPlus that
590
+ installs with OpenStudio and, if none are found, it will search for a
591
+ standalone installation of EnergyPlus.
592
+
593
+ Returns:
594
+ File directory and full path to executable in case of success.
595
+ None in case of failure.
596
+ """
597
+ def getversion(energyplus_path):
598
+ """Get digits for the version of EnergyPlus."""
599
+ try:
600
+ ver = ''.join(s for s in energyplus_path if (s.isdigit() or s == '-'))
601
+ return sum(int(d) * (10 ** i)
602
+ for i, d in enumerate(reversed(ver.split('-'))))
603
+ except ValueError: # folder starting with 'EnergyPlus' and no version
604
+ return 0
605
+
606
+ # first check for the EnergyPlus that comes with OpenStudio
607
+ ep_path, ep_folders = None, []
608
+ if self.openstudio_path is not None and os.path.isdir(os.path.join(
609
+ os.path.split(self.openstudio_path)[0], 'EnergyPlus')):
610
+ ep_path = os.path.join(os.path.split(self.openstudio_path)[0], 'EnergyPlus')
611
+
612
+ # then check the default location where standalone EnergyPlus is installed
613
+ elif os.name == 'nt': # search the C:/ drive on Windows
614
+ for f in os.listdir('C:\\'):
615
+ f_path = 'C:\\{}'.format(f)
616
+ if f.lower().startswith('energyplus') and os.path.isdir(f_path):
617
+ ep_folders.append(f_path)
618
+ elif platform.system() == 'Darwin': # search the Applications folder on Mac
619
+ for f in os.listdir('/Applications/'):
620
+ f_path = '/Applications/{}'.format(f)
621
+ if f.lower().startswith('energyplus') and os.path.isdir(f_path):
622
+ ep_folders.append(f_path)
623
+ elif platform.system() == 'Linux': # search the usr/local folder
624
+ for f in os.listdir('/usr/local/'):
625
+ f_path = '/usr/local/{}'.format(f)
626
+ if f.lower().startswith('energyplus') and os.path.isdir(f_path):
627
+ ep_folders.append(f_path)
628
+
629
+ if not ep_path and not ep_folders: # No EnergyPlus installations were found
630
+ return None
631
+ elif not ep_path: # get the most recent version of energyplus that was found
632
+ ep_path = sorted(ep_folders, key=getversion, reverse=True)[0]
633
+ return ep_path
634
+
635
+ def _openstudio_version_from_cli(self):
636
+ """Set this object's OpenStudio version by making a call to OpenStudio CLI."""
637
+ cmds = [self.openstudio_exe, 'openstudio_version']
638
+ use_shell = True if os.name == 'nt' else False
639
+ process = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=use_shell)
640
+ stdout = process.communicate()
641
+ try:
642
+ base_str = str(stdout[0]).replace("b'", '').replace(r"\r\n'", '')
643
+ self._openstudio_version_str = base_str
644
+ ver_nums = self._openstudio_version_str.split('+')[0].split('.')
645
+ ver_nums[-1] = ver_nums[-1].split('-')[0] \
646
+ if '-' in ver_nums[-1] else ver_nums[-1]
647
+ self._openstudio_version = tuple(int(i) for i in ver_nums)
648
+ except Exception:
649
+ pass # failed to parse the version into integers
650
+
651
+ def _energyplus_version_from_cli(self):
652
+ """Set this object's EnergyPlus version by making a call to EnergyPlus CLI."""
653
+ cmds = [self.energyplus_exe, '--version']
654
+ use_shell = True if os.name == 'nt' else False
655
+ process = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=use_shell)
656
+ stdout = process.communicate()
657
+ try:
658
+ base_str = str(stdout[0]).replace("b'", '').replace(r"\r\n'", '')
659
+ self._energyplus_version_str = base_str.split(',')[1].split(' ')[-1]
660
+ ver_nums = self._energyplus_version_str.split('-')[0].split('.')
661
+ self._energyplus_version = tuple(int(i) for i in ver_nums)
662
+ except Exception:
663
+ pass # failed to parse the version into integers
664
+
665
+ def _ironbug_version_from_cli(self):
666
+ """Set this object's Ironbug version by making a call to Ironbug CLI."""
667
+ cmds = [self.ironbug_exe, '--version']
668
+ use_shell = True if os.name == 'nt' else False
669
+ process = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=use_shell)
670
+ stdout = process.communicate()
671
+ base_str = str(stdout[0]).replace("b'", '')
672
+ base_str = base_str.replace("\r\n", '__').replace(r"\r\n", '__') \
673
+ if os.name == 'nt' else base_str.replace("\n", '__').replace(r"\n", '__')
674
+ try:
675
+ base_str = base_str.split('__')[-2]
676
+ self._ironbug_version_str = base_str
677
+ ver_nums = base_str.split(' ')[0].replace('v', '').split('.')
678
+ self._ironbug_version = tuple(int(i) for i in ver_nums)
679
+ except Exception:
680
+ pass # failed to parse the version into integers
681
+
682
+ @staticmethod
683
+ def _find_openstudio_folder():
684
+ """Find the most recent OpenStudio installation in its default location.
685
+
686
+ Returns:
687
+ File directory and full path to executable in case of success.
688
+ None in case of failure.
689
+ """
690
+ def getversion(openstudio_path):
691
+ """Get digits for the version of OpenStudio."""
692
+ try:
693
+ ver = ''.join(s for s in openstudio_path if (s.isdigit() or s == '.'))
694
+ return sum(int(d) * (10 ** i)
695
+ for i, d in enumerate(reversed(ver.split('.'))))
696
+ except ValueError: # folder starting with 'openstudio' and no version
697
+ return 0
698
+
699
+ # first check if there's a version installed in the ladybug_tools folder
700
+ lb_install = lb_config.folders.ladybug_tools_folder
701
+ os_folders = []
702
+ if os.path.isdir(lb_install):
703
+ for f in os.listdir(lb_install):
704
+ f_path = os.path.join(lb_install, f)
705
+ if f.lower().startswith('openstudio') and os.path.isdir(f_path):
706
+ os_folders.append(f_path)
707
+
708
+ # then check the default installation folders
709
+ if len(os_folders) != 0 and os.path.isdir(os.path.join(os_folders[0], 'bin')):
710
+ pass # we found a version of openstudio in the ladybug_tools folder
711
+ elif os.name == 'nt': # search the C:/ drive on Windows
712
+ for f in os.listdir('C:\\'):
713
+ f_path = 'C:\\{}'.format(f)
714
+ if f.lower().startswith('openstudio') and os.path.isdir(f_path):
715
+ os_folders.append(f_path)
716
+ elif platform.system() == 'Darwin': # search the Applications folder on Mac
717
+ for f in os.listdir('/Applications/'):
718
+ f_path = '/Applications/{}'.format(f)
719
+ if f.lower().startswith('openstudio') and os.path.isdir(f_path):
720
+ os_folders.append(f_path)
721
+ elif platform.system() == 'Linux': # search the usr/local folder
722
+ for f in os.listdir('/usr/local/'):
723
+ f_path = '/usr/local/{}'.format(f)
724
+ if f.lower().startswith('openstudio') and os.path.isdir(f_path):
725
+ os_folders.append(f_path)
726
+ else: # unknown operating system
727
+ os_folders = None
728
+
729
+ if not os_folders: # No Openstudio installations were found
730
+ return None
731
+
732
+ # get the most recent version of OpenStudio that was found
733
+ os_path = sorted(os_folders, key=getversion, reverse=True)[0]
734
+
735
+ return os.path.join(os_path, 'bin')
736
+
737
+ @staticmethod
738
+ def _find_standards_data_folder():
739
+ """Find the user template library in its default location.
740
+
741
+ The %AppData%/ladybug_tools/standards folder will be checked first, which
742
+ can contain libraries that are not overwritten with the update of the
743
+ honeybee_energy package. If this is not found, the ladybug_tools/resources/
744
+ standards/honeybee_standards folder will be checked next, If no such folder
745
+ is found, this method defaults to the lib/library/ folder within this package.
746
+ """
747
+ # first check if there's a user-defined folder in AppData
748
+ app_folder = os.getenv('APPDATA')
749
+ if app_folder is not None:
750
+ lib_folder = os.path.join(app_folder, 'ladybug_tools', 'standards')
751
+ if os.path.isdir(lib_folder):
752
+ return lib_folder
753
+
754
+ # then check the ladybug_tools installation folder were permanent lib is
755
+ lb_install = lb_config.folders.ladybug_tools_folder
756
+ if os.path.isdir(lb_install):
757
+ lib_folder = os.path.join(
758
+ lb_install, 'resources', 'standards', 'honeybee_standards')
759
+ if os.path.isdir(lib_folder):
760
+ try:
761
+ Folders._check_standards_folder(lib_folder)
762
+ return lib_folder
763
+ except AssertionError: # the folder is not valid
764
+ pass
765
+
766
+ # default to the library folder that installs with this Python package
767
+ return os.path.join(os.path.dirname(honeybee_standards.__file__))
768
+
769
+ @staticmethod
770
+ def _find_standards_extension_folders():
771
+ """Find the standards extension folders in their default locations.
772
+
773
+ Extension folders are expected to start with the words "honeybee_energy"
774
+ and end with the words "standards" (eg. honeybee_energy_cibse_standards).
775
+
776
+ The ladybug_tools/resources/standards folder will be checked first, which
777
+ can contain libraries that are not overwritten with the update of the
778
+ honeybee_energy package.
779
+ If no folders are found, this method will look for any Python packages
780
+ sitting next to honeybee_energy that follow the naming criteria above.
781
+ """
782
+ standards_extensions = []
783
+ # first check the ladybug_tools installation folder were permanent lib is
784
+ lb_install = lb_config.folders.ladybug_tools_folder
785
+ std_folder = os.path.join(lb_install, 'resources', 'standards')
786
+ if os.path.isdir(std_folder):
787
+ for folder in os.listdir(std_folder):
788
+ if folder.endswith('standards') and folder.startswith('honeybee_energy'):
789
+ lib_folder = os.path.join(std_folder, folder)
790
+ if os.path.isdir(lib_folder):
791
+ standards_extensions.append(lib_folder)
792
+ # then check next to the Python library
793
+ if len(standards_extensions) == 0:
794
+ for finder, name, ispkg in pkgutil.iter_modules():
795
+ if name.endswith('standards') and name.startswith('honeybee_energy'):
796
+ lib_folder = os.path.join(finder.path, name)
797
+ if os.path.isdir(lib_folder):
798
+ standards_extensions.append(lib_folder)
799
+ return standards_extensions
800
+
801
+ @staticmethod
802
+ def _check_standards_folder(path):
803
+ """Check that a standards data sub-folders exist."""
804
+ if not path: # first check that a path exists
805
+ return [None] * 4
806
+
807
+ # gather all of the sub folders underneath the master folder
808
+ _construction_lib = os.path.join(path, 'constructions')
809
+ _constructionset_lib = os.path.join(path, 'constructionsets')
810
+ _schedule_lib = os.path.join(path, 'schedules')
811
+ _programtype_lib = os.path.join(path, 'programtypes')
812
+
813
+ assert os.path.isdir(_construction_lib), \
814
+ '{} lacks a "constructions" folder.'.format(path)
815
+ assert os.path.isdir(_constructionset_lib), \
816
+ '{} lacks a "constructionsets" folder.'.format(path)
817
+ assert os.path.isdir(_schedule_lib), \
818
+ '{} lacks a "schedules" folder.'.format(path)
819
+ assert os.path.isdir(_programtype_lib), \
820
+ '{} lacks a "programtypes" folder.'.format(path)
821
+
822
+ return _construction_lib, _constructionset_lib, _schedule_lib, _programtype_lib
823
+
824
+ @staticmethod
825
+ def _find_defaults_file():
826
+ """Find the energy default JSON in its default locations."""
827
+ # first check the ladybug_tools installation folder were permanent lib is
828
+ lb_install = lb_config.folders.ladybug_tools_folder
829
+ if os.path.isdir(lb_install):
830
+ def_file = os.path.join(
831
+ lb_install, 'resources', 'standards', 'honeybee_standards',
832
+ 'energy_default.json')
833
+ if os.path.isfile(def_file):
834
+ return def_file
835
+
836
+ # default to the library folder that installs with this Python package
837
+ return os.path.join(
838
+ os.path.dirname(honeybee_standards.__file__), 'energy_default.json')
839
+
840
+
841
+ """Object possesing all key folders within the configuration."""
842
+ folders = Folders(mute=True)