honeybee-radiance 1.66.190__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.

Potentially problematic release.


This version of honeybee-radiance might be problematic. Click here for more details.

Files changed (152) hide show
  1. honeybee_radiance/__init__.py +11 -0
  2. honeybee_radiance/__main__.py +4 -0
  3. honeybee_radiance/_extend_honeybee.py +93 -0
  4. honeybee_radiance/cli/__init__.py +88 -0
  5. honeybee_radiance/cli/dc.py +400 -0
  6. honeybee_radiance/cli/edit.py +529 -0
  7. honeybee_radiance/cli/glare.py +118 -0
  8. honeybee_radiance/cli/grid.py +859 -0
  9. honeybee_radiance/cli/lib.py +458 -0
  10. honeybee_radiance/cli/modifier.py +133 -0
  11. honeybee_radiance/cli/mtx.py +226 -0
  12. honeybee_radiance/cli/multiphase.py +1034 -0
  13. honeybee_radiance/cli/octree.py +640 -0
  14. honeybee_radiance/cli/postprocess.py +1186 -0
  15. honeybee_radiance/cli/raytrace.py +219 -0
  16. honeybee_radiance/cli/rpict.py +125 -0
  17. honeybee_radiance/cli/schedule.py +56 -0
  18. honeybee_radiance/cli/setconfig.py +63 -0
  19. honeybee_radiance/cli/sky.py +545 -0
  20. honeybee_radiance/cli/study.py +66 -0
  21. honeybee_radiance/cli/sunpath.py +331 -0
  22. honeybee_radiance/cli/threephase.py +255 -0
  23. honeybee_radiance/cli/translate.py +400 -0
  24. honeybee_radiance/cli/util.py +121 -0
  25. honeybee_radiance/cli/view.py +261 -0
  26. honeybee_radiance/cli/viewfactor.py +347 -0
  27. honeybee_radiance/config.json +6 -0
  28. honeybee_radiance/config.py +427 -0
  29. honeybee_radiance/dictutil.py +50 -0
  30. honeybee_radiance/dynamic/__init__.py +5 -0
  31. honeybee_radiance/dynamic/group.py +479 -0
  32. honeybee_radiance/dynamic/multiphase.py +557 -0
  33. honeybee_radiance/dynamic/state.py +718 -0
  34. honeybee_radiance/dynamic/stategeo.py +352 -0
  35. honeybee_radiance/geometry/__init__.py +13 -0
  36. honeybee_radiance/geometry/bubble.py +42 -0
  37. honeybee_radiance/geometry/cone.py +215 -0
  38. honeybee_radiance/geometry/cup.py +54 -0
  39. honeybee_radiance/geometry/cylinder.py +197 -0
  40. honeybee_radiance/geometry/geometrybase.py +37 -0
  41. honeybee_radiance/geometry/instance.py +40 -0
  42. honeybee_radiance/geometry/mesh.py +38 -0
  43. honeybee_radiance/geometry/polygon.py +174 -0
  44. honeybee_radiance/geometry/ring.py +214 -0
  45. honeybee_radiance/geometry/source.py +182 -0
  46. honeybee_radiance/geometry/sphere.py +178 -0
  47. honeybee_radiance/geometry/tube.py +46 -0
  48. honeybee_radiance/lib/__init__.py +1 -0
  49. honeybee_radiance/lib/_loadmodifiers.py +72 -0
  50. honeybee_radiance/lib/_loadmodifiersets.py +69 -0
  51. honeybee_radiance/lib/modifiers.py +58 -0
  52. honeybee_radiance/lib/modifiersets.py +63 -0
  53. honeybee_radiance/lightpath.py +204 -0
  54. honeybee_radiance/lightsource/__init__.py +1 -0
  55. honeybee_radiance/lightsource/_gendaylit.py +479 -0
  56. honeybee_radiance/lightsource/dictutil.py +49 -0
  57. honeybee_radiance/lightsource/ground.py +160 -0
  58. honeybee_radiance/lightsource/sky/__init__.py +7 -0
  59. honeybee_radiance/lightsource/sky/_skybase.py +177 -0
  60. honeybee_radiance/lightsource/sky/certainirradiance.py +232 -0
  61. honeybee_radiance/lightsource/sky/cie.py +378 -0
  62. honeybee_radiance/lightsource/sky/climatebased.py +501 -0
  63. honeybee_radiance/lightsource/sky/hemisphere.py +160 -0
  64. honeybee_radiance/lightsource/sky/skydome.py +113 -0
  65. honeybee_radiance/lightsource/sky/skymatrix.py +163 -0
  66. honeybee_radiance/lightsource/sky/strutil.py +34 -0
  67. honeybee_radiance/lightsource/sky/sunmatrix.py +212 -0
  68. honeybee_radiance/lightsource/sunpath.py +247 -0
  69. honeybee_radiance/modifier/__init__.py +3 -0
  70. honeybee_radiance/modifier/material/__init__.py +30 -0
  71. honeybee_radiance/modifier/material/absdf.py +477 -0
  72. honeybee_radiance/modifier/material/antimatter.py +54 -0
  73. honeybee_radiance/modifier/material/ashik2.py +51 -0
  74. honeybee_radiance/modifier/material/brtdfunc.py +81 -0
  75. honeybee_radiance/modifier/material/bsdf.py +292 -0
  76. honeybee_radiance/modifier/material/dielectric.py +53 -0
  77. honeybee_radiance/modifier/material/glass.py +431 -0
  78. honeybee_radiance/modifier/material/glow.py +246 -0
  79. honeybee_radiance/modifier/material/illum.py +51 -0
  80. honeybee_radiance/modifier/material/interface.py +49 -0
  81. honeybee_radiance/modifier/material/light.py +206 -0
  82. honeybee_radiance/modifier/material/materialbase.py +36 -0
  83. honeybee_radiance/modifier/material/metal.py +167 -0
  84. honeybee_radiance/modifier/material/metal2.py +41 -0
  85. honeybee_radiance/modifier/material/metdata.py +41 -0
  86. honeybee_radiance/modifier/material/metfunc.py +41 -0
  87. honeybee_radiance/modifier/material/mirror.py +340 -0
  88. honeybee_radiance/modifier/material/mist.py +86 -0
  89. honeybee_radiance/modifier/material/plasdata.py +58 -0
  90. honeybee_radiance/modifier/material/plasfunc.py +59 -0
  91. honeybee_radiance/modifier/material/plastic.py +354 -0
  92. honeybee_radiance/modifier/material/plastic2.py +58 -0
  93. honeybee_radiance/modifier/material/prism1.py +57 -0
  94. honeybee_radiance/modifier/material/prism2.py +48 -0
  95. honeybee_radiance/modifier/material/spotlight.py +50 -0
  96. honeybee_radiance/modifier/material/trans.py +518 -0
  97. honeybee_radiance/modifier/material/trans2.py +49 -0
  98. honeybee_radiance/modifier/material/transdata.py +50 -0
  99. honeybee_radiance/modifier/material/transfunc.py +53 -0
  100. honeybee_radiance/modifier/mixture/__init__.py +6 -0
  101. honeybee_radiance/modifier/mixture/mixdata.py +49 -0
  102. honeybee_radiance/modifier/mixture/mixfunc.py +54 -0
  103. honeybee_radiance/modifier/mixture/mixpict.py +52 -0
  104. honeybee_radiance/modifier/mixture/mixtext.py +66 -0
  105. honeybee_radiance/modifier/mixture/mixturebase.py +28 -0
  106. honeybee_radiance/modifier/modifierbase.py +40 -0
  107. honeybee_radiance/modifier/pattern/__init__.py +9 -0
  108. honeybee_radiance/modifier/pattern/brightdata.py +49 -0
  109. honeybee_radiance/modifier/pattern/brightfunc.py +47 -0
  110. honeybee_radiance/modifier/pattern/brighttext.py +81 -0
  111. honeybee_radiance/modifier/pattern/colordata.py +56 -0
  112. honeybee_radiance/modifier/pattern/colorfunc.py +47 -0
  113. honeybee_radiance/modifier/pattern/colorpict.py +54 -0
  114. honeybee_radiance/modifier/pattern/colortext.py +73 -0
  115. honeybee_radiance/modifier/pattern/patternbase.py +34 -0
  116. honeybee_radiance/modifier/texture/__init__.py +4 -0
  117. honeybee_radiance/modifier/texture/texdata.py +29 -0
  118. honeybee_radiance/modifier/texture/texfunc.py +26 -0
  119. honeybee_radiance/modifier/texture/texturebase.py +27 -0
  120. honeybee_radiance/modifierset.py +1091 -0
  121. honeybee_radiance/mutil.py +60 -0
  122. honeybee_radiance/postprocess/__init__.py +1 -0
  123. honeybee_radiance/postprocess/annual.py +108 -0
  124. honeybee_radiance/postprocess/annualdaylight.py +425 -0
  125. honeybee_radiance/postprocess/annualglare.py +201 -0
  126. honeybee_radiance/postprocess/annualirradiance.py +187 -0
  127. honeybee_radiance/postprocess/electriclight.py +119 -0
  128. honeybee_radiance/postprocess/en17037.py +261 -0
  129. honeybee_radiance/postprocess/leed.py +304 -0
  130. honeybee_radiance/postprocess/solartracking.py +90 -0
  131. honeybee_radiance/primitive.py +554 -0
  132. honeybee_radiance/properties/__init__.py +1 -0
  133. honeybee_radiance/properties/_base.py +390 -0
  134. honeybee_radiance/properties/aperture.py +197 -0
  135. honeybee_radiance/properties/door.py +198 -0
  136. honeybee_radiance/properties/face.py +123 -0
  137. honeybee_radiance/properties/model.py +1291 -0
  138. honeybee_radiance/properties/room.py +490 -0
  139. honeybee_radiance/properties/shade.py +186 -0
  140. honeybee_radiance/properties/shademesh.py +116 -0
  141. honeybee_radiance/putil.py +44 -0
  142. honeybee_radiance/reader.py +214 -0
  143. honeybee_radiance/sensor.py +166 -0
  144. honeybee_radiance/sensorgrid.py +1008 -0
  145. honeybee_radiance/view.py +1101 -0
  146. honeybee_radiance/writer.py +951 -0
  147. honeybee_radiance-1.66.190.dist-info/METADATA +89 -0
  148. honeybee_radiance-1.66.190.dist-info/RECORD +152 -0
  149. honeybee_radiance-1.66.190.dist-info/WHEEL +5 -0
  150. honeybee_radiance-1.66.190.dist-info/entry_points.txt +2 -0
  151. honeybee_radiance-1.66.190.dist-info/licenses/LICENSE +661 -0
  152. honeybee_radiance-1.66.190.dist-info/top_level.txt +1 -0
@@ -0,0 +1,427 @@
1
+ """Honeybee_radiance 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_radiance.config import folders
10
+ print(folders.radiance_path)
11
+ folders.radiance_path = "C:/Radiance/bin"
12
+ """
13
+ import ladybug.config as lb_config
14
+ import honeybee_standards
15
+
16
+ import os
17
+ import platform
18
+ import subprocess
19
+ import json
20
+ import re
21
+
22
+
23
+ class Folders(object):
24
+ """Honeybee_radiance folders.
25
+
26
+ Args:
27
+ config_file: The path to the config.json file from which folders are loaded.
28
+ If None, the config.json module included in this package will be used.
29
+ Default: None.
30
+ mute: If False, the paths to the various folders will be printed as they
31
+ are found. If True, no printing will occur upon initialization of this
32
+ class. Default: True.
33
+
34
+ Properties:
35
+ * radiance_path
36
+ * radbin_path
37
+ * radlib_path
38
+ * radiance_version
39
+ * radiance_version_str
40
+ * radiance_version_date
41
+ * standards_data_folder
42
+ * modifier_lib
43
+ * modifierset_lib
44
+ * defaults_file
45
+ * config_file
46
+ * mute
47
+ """
48
+
49
+ def __init__(self, config_file=None, mute=True):
50
+ self.mute = bool(mute) # set the mute value
51
+ self.config_file = config_file # load paths from the config JSON file
52
+
53
+ @property
54
+ def radiance_path(self):
55
+ """Get or set the path to Radiance installation folder.
56
+
57
+ This is the top level folder that contains both the "bin" and the "lib"
58
+ directories.
59
+ """
60
+ return self._radiance_path
61
+
62
+ @radiance_path.setter
63
+ def radiance_path(self, r_path):
64
+ exe_name = 'rad.exe' if os.name == 'nt' else 'rad'
65
+ if not r_path: # check the default installation location
66
+ r_path = self._find_radiance_folder()
67
+ else:
68
+ r_path = os.path.join(r_path, 'bin')
69
+ rad_exe_file = os.path.join(r_path, exe_name) if r_path is not None else None
70
+
71
+ if r_path: # check that the Radiance executable exists in the installation
72
+ assert os.path.isfile(rad_exe_file), \
73
+ '{} is not a valid path to a Radiance installation.'.format(r_path)
74
+
75
+ # set the radiance_path
76
+ self._radbin_path = r_path
77
+ if r_path:
78
+ self._radiance_path = os.path.split(r_path)[0]
79
+ radlib_path = os.path.join(self._radiance_path, 'lib')
80
+ if os.path.isdir(radlib_path):
81
+ self._radlib_path = radlib_path
82
+ elif os.environ.get('RAYPATH'):
83
+ self._radlib_path = os.environ.get('RAYPATH')
84
+ else:
85
+ self._radlib_path = None
86
+ if not self.mute:
87
+ print("Path to Radiance is set to: %s" % self._radiance_path)
88
+ else:
89
+ self._radiance_path = None
90
+ self._radlib_path = None
91
+ self._radiance_version = None
92
+ self._radiance_version_str = None
93
+ self._radiance_version_date = None
94
+
95
+ @property
96
+ def radbin_path(self):
97
+ """Get the path to Radiance bin folder.
98
+
99
+ This is the "bin" directory for Radiance installation (the one that
100
+ contains the executable files).
101
+ """
102
+ return self._radbin_path
103
+
104
+ @property
105
+ def radlib_path(self):
106
+ """Get the path to Radiance lib folder."""
107
+ return self._radlib_path
108
+
109
+ @property
110
+ def radiance_version(self):
111
+ """Get a tuple for the version of radiance (eg. (5, 3, '012cb17835')).
112
+
113
+ This will be None if the version could not be sensed or if no Radiance
114
+ installation was found.
115
+ """
116
+ if self._radbin_path and self._radiance_version_str is None:
117
+ self._radiance_version_from_cli()
118
+ return self._radiance_version
119
+
120
+ @property
121
+ def radiance_version_str(self):
122
+ """Get text for the full version of radiance (eg."RADIANCE 5.3 official release").
123
+
124
+ This will be None if the version could not be sensed or if no Radiance
125
+ installation was found.
126
+ """
127
+ if self._radbin_path and self._radiance_version_str is None:
128
+ self._radiance_version_from_cli()
129
+ return self._radiance_version_str
130
+
131
+ @property
132
+ def radiance_version_date(self):
133
+ """Get a tuple for the date of the radiance version (eg. (2020, 9, 3)).
134
+
135
+ This will be None if the version could not be sensed or if no Radiance
136
+ installation was found.
137
+ """
138
+ if self._radbin_path and self._radiance_version_str is None:
139
+ self._radiance_version_from_cli()
140
+ return self._radiance_version_date
141
+
142
+ @property
143
+ def standards_data_folder(self):
144
+ """Get or set the path to the folder standards loaded to honeybee_radiance.lib.
145
+
146
+ This folder must have the following sub-folders in order to be valid:
147
+ * modifiers - folder with RAD files for modifiers.
148
+ * modifiersets - folder with JSON files of abridged ModifierSets.
149
+ """
150
+ return self._standards_data_folder
151
+
152
+ @standards_data_folder.setter
153
+ def standards_data_folder(self, path):
154
+ if not path: # check the default locations of the template library
155
+ path = self._find_standards_data_folder()
156
+
157
+ # gather all of the sub folders underneath the master folder
158
+ self._modifier_lib, self._modifierset_lib = self._check_standards_folder(path)
159
+
160
+ # set the standards_data_folder
161
+ self._standards_data_folder = path
162
+ if path and not self.mute:
163
+ print('Path to the standards_data_folder is set to: '
164
+ '{}'.format(self._standards_data_folder))
165
+
166
+ @property
167
+ def modifier_lib(self):
168
+ """Get the path to the modifier library in the standards_data_folder."""
169
+ return self._modifier_lib
170
+
171
+ @property
172
+ def modifierset_lib(self):
173
+ """Get the path to the modifierset library in the standards_data_folder."""
174
+ return self._modifierset_lib
175
+
176
+ @property
177
+ def defaults_file(self):
178
+ """Get or set the JSON file where honeybee's defaults are loaded from."""
179
+ return self._defaults_file
180
+
181
+ @defaults_file.setter
182
+ def defaults_file(self, path):
183
+ if not path: # check the default location
184
+ path = self._find_defaults_file()
185
+ assert os.path.isfile(path), \
186
+ '{} is not a valid path to an defaults JSON file.'.format(path)
187
+ self._defaults_file = path
188
+ if not self.mute:
189
+ print("Path to defaults file is set to: %s" % self._defaults_file)
190
+
191
+ @property
192
+ def config_file(self):
193
+ """Get or set the path to the config.json file from which folders are loaded.
194
+
195
+ Setting this to None will result in using the config.json module included
196
+ in this package.
197
+ """
198
+ return self._config_file
199
+
200
+ @config_file.setter
201
+ def config_file(self, cfg):
202
+ if cfg is None:
203
+ cfg = os.path.join(os.path.dirname(__file__), 'config.json')
204
+ self._load_from_file(cfg)
205
+ self._config_file = cfg
206
+
207
+ @property
208
+ def env(self):
209
+ "Return Radiance environment as a dictionary."
210
+ env = {}
211
+ if self.radbin_path:
212
+ env['PATH'] = self.radbin_path.replace('\\', '/')
213
+ if self.radlib_path:
214
+ env['RAYPATH'] = self.radlib_path.replace('\\', '/')
215
+ return env
216
+
217
+ def _load_from_file(self, file_path):
218
+ """Set all of the the properties of this object from a config JSON file.
219
+
220
+ Args:
221
+ file_path: Path to a JSON file containing the file paths. A sample of this
222
+ JSON is the config.json file within this package.
223
+ """
224
+ # check the default file path
225
+ assert os.path.isfile(str(file_path)), \
226
+ ValueError('No file found at {}'.format(file_path))
227
+
228
+ # set the default paths to be all blank
229
+ default_path = {
230
+ "radiance_path": r'',
231
+ "standards_data_folder": r'',
232
+ "defaults_file": r''
233
+ }
234
+
235
+ with open(file_path, 'r') as cfg:
236
+ try:
237
+ paths = json.load(cfg)
238
+ except Exception as e:
239
+ print('Failed to load paths from {}.\n{}'.format(file_path, e))
240
+ else:
241
+ for key, p in paths.items():
242
+ if not key.startswith('__') and p.strip():
243
+ default_path[key] = p.strip()
244
+
245
+ # set path for radiance installations
246
+ self.radiance_path = default_path["radiance_path"]
247
+
248
+ # set path for the standards_data_folder and defaults_file
249
+ self.standards_data_folder = default_path["standards_data_folder"]
250
+ self.defaults_file = default_path["defaults_file"]
251
+
252
+ def _radiance_version_from_cli(self):
253
+ """Get the Radiance version properties by making a call to a Radiance command."""
254
+ # check mkpmap version since this avoids interference with Accelerad
255
+ # more information about this is here: https://discourse.ladybug.tools/t/
256
+ # is-it-possible-to-get-lbt-1-2-0-working-with-accelerad/13789/9
257
+ rad_exe = os.path.join(self.radbin_path, 'mkpmap.exe') if os.name == 'nt' \
258
+ else os.path.join(self.radbin_path, 'mkpmap')
259
+ if not os.path.isfile(rad_exe): # old Radiance without the mkpmap executable
260
+ rad_exe = os.path.join(self.radbin_path, 'rtrace.exe') if os.name == 'nt' \
261
+ else os.path.join(self.radbin_path, 'rtrace')
262
+ cmds = [rad_exe, '-version']
263
+ use_shell = True if os.name == 'nt' else False
264
+ process = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=use_shell)
265
+ stdout = process.communicate()
266
+ base_str = str(stdout[0]).replace("b'", '').replace(r"\r\n'", '')
267
+ self._radiance_version_str = base_str # set the version string
268
+ if 'NREL' in base_str: # parse using NREL's version conventions
269
+ try: # try to parse the version into a list of integers
270
+ ver_nums = base_str.split(' ')[1].split('.')
271
+ ver_array = []
272
+ for i in ver_nums:
273
+ val = int(i) if i.isnumeric() else i
274
+ ver_array.append(val)
275
+ self._radiance_version = tuple(ver_array)
276
+ except Exception:
277
+ pass # failed to parse the version into values; possibly a custom build
278
+ if self._radiance_version and self._radiance_version[:2] >= (5, 2):
279
+ try: # try to parse the date into a list of integers
280
+ date_pattern = re.compile(r'(\d*\-\d*\-\d*)')
281
+ ver_date = re.search(date_pattern, base_str)
282
+ self._radiance_version_date = \
283
+ tuple(int(v) for v in ver_date.group(0).split('-'))
284
+ except Exception:
285
+ pass # failed to parse the date into values; possibly a custom build
286
+ else:
287
+ try: # try to parse the date into a list of integers
288
+ date_pattern = re.compile(r'(\d*\.\d*\.\d*\))')
289
+ ver_date = re.search(date_pattern, base_str)
290
+ self._radiance_version_date = \
291
+ tuple(int(v) for v in
292
+ ver_date.group(0).replace(')', '').split('.'))
293
+ except Exception:
294
+ pass # failed to parse the date into values; possibly a custom build
295
+ else:
296
+ try: # try to parse the version into a list of integers
297
+ ver_nums = base_str.split('(')[-1].split(')')[0].split('.')
298
+ ver_array = []
299
+ for i in ver_nums:
300
+ val = int(i) if i.isnumeric() else i
301
+ ver_array.append(val)
302
+ self._radiance_version = tuple(ver_array)
303
+ except Exception:
304
+ pass # failed to parse the version into values; possibly a custom build
305
+ try: # try to parse the date into a list of integers
306
+ date_pattern = re.compile(r'(\d*\-\d*\-\d*)')
307
+ ver_date = re.search(date_pattern, base_str)
308
+ self._radiance_version_date = \
309
+ tuple(int(v) for v in ver_date.group(0).split('-'))
310
+ except Exception:
311
+ pass # failed to parse the date into values; possibly a custom build
312
+
313
+ @staticmethod
314
+ def _find_radiance_folder():
315
+ """Find the Radiance installation in its default location.
316
+
317
+ This method will first attempt to return the path of a standalone Radiance
318
+ installation.
319
+
320
+ Returns:
321
+ File directory and full path to executable in case of success.
322
+ None, None in case of failure.
323
+ """
324
+ # first check if there's a version installed in the ladybug_tools folder
325
+ lb_install = lb_config.folders.ladybug_tools_folder
326
+ rad_path = None
327
+ if os.path.isdir(lb_install):
328
+ test_path = os.path.join(lb_install, 'radiance')
329
+ rad_path = test_path if os.path.isdir(test_path) else None
330
+
331
+ # then check for the default location where standalone Radiance is installed
332
+ if rad_path is not None:
333
+ pass # we found a version of radiance in the ladybug_tools folder
334
+ elif os.name == 'nt': # search the C:/ drive on Windows
335
+ test_path = 'C:\\Radiance'
336
+ rad_path = test_path if os.path.isdir(test_path) else None
337
+ elif platform.system() == 'Darwin': # search usr/local and Applications on Mac
338
+ test_path = '/usr/local/radiance'
339
+ rad_path = test_path if os.path.isdir(test_path) else None
340
+ if rad_path is None:
341
+ test_path = '/Applications/radiance'
342
+ rad_path = test_path if os.path.isdir(test_path) else None
343
+ elif platform.system() == 'Linux': # search the usr/local folder
344
+ test_path = '/usr/local/radiance'
345
+ rad_path = test_path if os.path.isdir(test_path) else None
346
+
347
+ # check the environment variables
348
+ if not rad_path:
349
+ rad_bin_path = os.environ.get('BINPATH')
350
+ if rad_bin_path is not None:
351
+ return rad_bin_path
352
+
353
+ if not rad_path: # no Radiance installations were found
354
+ return None
355
+
356
+ # return the path to the executable
357
+ rad_path = os.path.join(rad_path, 'bin')
358
+ return rad_path
359
+
360
+ @staticmethod
361
+ def _find_standards_data_folder():
362
+ """Find the the user template library in its default location.
363
+
364
+ The %AppData%/ladybug_tools/standards folder will be checked first, which
365
+ can contain libraries that are not overwritten with the update of the
366
+ honeybee_radiance package. If this is not found, the ladybug_tools/resources/
367
+ standards/honeybee_standards folder will be checked next, If no such folder
368
+ is found, this method defaults to the lib/library/ folder within this package.
369
+ """
370
+ # first check if there's a user-defined folder in AppData
371
+ app_folder = os.getenv('APPDATA')
372
+ if app_folder is not None:
373
+ lib_folder = os.path.join(app_folder, 'ladybug_tools', 'standards')
374
+ if os.path.isdir(lib_folder):
375
+ return lib_folder
376
+
377
+ # first check the ladybug_tools installation folder were permanent lib is
378
+ lb_install = lb_config.folders.ladybug_tools_folder
379
+ if os.path.isdir(lb_install):
380
+ lib_folder = os.path.join(
381
+ lb_install, 'resources', 'standards', 'honeybee_standards')
382
+ if os.path.isdir(lib_folder):
383
+ try:
384
+ Folders._check_standards_folder(lib_folder)
385
+ return lib_folder
386
+ except AssertionError: # the folder is not valid
387
+ pass
388
+
389
+ # default to the library folder that installs with this Python package
390
+ return os.path.join(os.path.dirname(honeybee_standards.__file__))
391
+
392
+ @staticmethod
393
+ def _check_standards_folder(path):
394
+ """Check that a standards data sub-folders exist."""
395
+ if not path: # first check that a path exists
396
+ return [None] * 2
397
+
398
+ # gather all of the sub folders underneath the master folder
399
+ _modifier_lib = os.path.join(path, 'modifiers')
400
+ _modifierset_lib = os.path.join(path, 'modifiersets')
401
+
402
+ assert os.path.isdir(_modifier_lib), \
403
+ '{} lacks a "modifiers" folder.'.format(path)
404
+ assert os.path.isdir(_modifierset_lib), \
405
+ '{} lacks a "modifiersets" folder.'.format(path)
406
+
407
+ return _modifier_lib, _modifierset_lib
408
+
409
+ @staticmethod
410
+ def _find_defaults_file():
411
+ """Find the radiance default JSON in its default locations."""
412
+ # first check the ladybug_tools installation folder were permanent lib is
413
+ lb_install = lb_config.folders.ladybug_tools_folder
414
+ if os.path.isdir(lb_install):
415
+ def_file = os.path.join(
416
+ lb_install, 'resources', 'standards', 'honeybee_standards',
417
+ 'radiance_default.json')
418
+ if os.path.isfile(def_file):
419
+ return def_file
420
+
421
+ # default to the library folder that installs with this Python package
422
+ return os.path.join(
423
+ os.path.dirname(honeybee_standards.__file__), 'radiance_default.json')
424
+
425
+
426
+ """Object possesing all key folders within the configuration."""
427
+ folders = Folders(mute=True)
@@ -0,0 +1,50 @@
1
+ # coding=utf-8
2
+ """Utilities to convertint any dictionary to Python objects.
3
+
4
+ Note that importing this module will import almost all modules within the
5
+ library in order to be able to re-serialize almost any dictionary produced
6
+ from the library.
7
+ """
8
+ from honeybee_radiance.putil import dict_to_primitive
9
+ from honeybee_radiance.modifierset import ModifierSet
10
+ from honeybee_radiance.sensorgrid import SensorGrid
11
+ from honeybee_radiance.view import View
12
+ from honeybee_radiance.lightsource.dictutil import dict_to_light_source, \
13
+ LIGHT_SOURCE_TYPES
14
+
15
+
16
+ def dict_to_object(honeybee_radiance_dict, raise_exception=True):
17
+ """Re-serialize a dictionary of almost any object within honeybee_radiance.
18
+
19
+ This includes any Modifier, ModifierSet, LightSource, SensorGrid or View object.
20
+
21
+ Args:
22
+ honeybee_radiance_dict: A dictionary of any Honeybee radiance object. Note
23
+ that this should be a non-abridged dictionary to be valid.
24
+ raise_exception: Boolean to note whether an excpetion should be raised
25
+ if the object is not identified as a part of honeybee_radiance.
26
+ Default: True.
27
+
28
+ Returns:
29
+ A Python object derived from the input honeybee_radiance_dict.
30
+ """
31
+ try: # get the type key from the dictionary
32
+ obj_type = honeybee_radiance_dict['type']
33
+ except KeyError:
34
+ raise ValueError('Honeybee_radiance dictionary lacks required "type" key.')
35
+
36
+ if obj_type == 'ModifierSet':
37
+ return ModifierSet.from_dict(honeybee_radiance_dict)
38
+ elif obj_type == 'SensorGrid':
39
+ return SensorGrid.from_dict(honeybee_radiance_dict)
40
+ elif obj_type == 'View':
41
+ return View.from_dict(honeybee_radiance_dict)
42
+ elif obj_type in LIGHT_SOURCE_TYPES:
43
+ return dict_to_light_source(honeybee_radiance_dict)
44
+ else:
45
+ try:
46
+ return dict_to_primitive(honeybee_radiance_dict)
47
+ except (NotImplementedError, ValueError):
48
+ if raise_exception:
49
+ raise ValueError(
50
+ '{} is not a recognized honeybee radiance object'.format(obj_type))
@@ -0,0 +1,5 @@
1
+ """Objects for creating and exporting dynamic geometry."""
2
+
3
+ from .group import DynamicShadeGroup, DynamicSubFaceGroup
4
+ from .state import RadianceShadeState, RadianceSubFaceState
5
+ from .stategeo import StateGeometry