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,431 @@
1
+ """Radiance Glass Material.
2
+
3
+ http://radsite.lbl.gov/radiance/refer/ray.html#Glass
4
+ """
5
+ from __future__ import division
6
+ import math
7
+
8
+ from .materialbase import Material
9
+
10
+ import honeybee.typing as typing
11
+ from ladybug.rootfinding import secant
12
+
13
+
14
+ class Glass(Material):
15
+ """Radiance glass material.
16
+
17
+ Args:
18
+ identifier: Text string for a unique Material ID. Must not contain spaces
19
+ or special characters. This will be used to identify the object across
20
+ a model and in the exported Radiance files.
21
+ r_transmissivity: Transmissivity for red. The value should be between 0 and 1
22
+ (Default: 0).
23
+ g_transmissivity: Transmissivity for green. The value should be between 0
24
+ and 1 (Default: 0).
25
+ b_transmissivity: Transmissivity for blue. The value should be between 0 and
26
+ 1 (Default: 0).
27
+ refraction_index: Index of refraction. Typical values are 1.52 for float
28
+ glass and 1.4 for ETFE. If None, Radiance will default to using 1.52
29
+ for glass (Default: None).
30
+ modifier: Material modifier (Default: None).
31
+ dependencies: A list of primitives that this primitive depends on. This
32
+ argument is only useful for defining advanced primitives where the
33
+ primitive is defined based on other primitives. (Default: [])
34
+
35
+ Properties:
36
+ * identifier
37
+ * display_name
38
+ * r_transmissivity
39
+ * g_transmissivity
40
+ * b_transmissivity
41
+ * refraction_index
42
+ * average_transmissivity
43
+ * average_transmittance
44
+ * values
45
+ * modifier
46
+ * dependencies
47
+ * is_modifier
48
+ * is_material
49
+
50
+ Usage:
51
+
52
+ .. code-block:: python
53
+
54
+ glass_material = Glass("generic_glass", .65, .65, .65)
55
+ print(glass_material)
56
+ """
57
+ __slots__ = ('_r_transmissivity', '_g_transmissivity', '_b_transmissivity',
58
+ '_refraction_index')
59
+
60
+ def __init__(self, identifier, r_transmissivity=0.0, g_transmissivity=0.0,
61
+ b_transmissivity=0.0, refraction_index=None, modifier=None,
62
+ dependencies=None):
63
+ """Create glass material."""
64
+ Material.__init__(self, identifier, modifier=modifier,
65
+ dependencies=dependencies)
66
+ self.r_transmissivity = r_transmissivity
67
+ self.g_transmissivity = g_transmissivity
68
+ self.b_transmissivity = b_transmissivity
69
+ self.refraction_index = refraction_index
70
+ self._update_values()
71
+
72
+ def _update_values(self):
73
+ """Populate dictionary values."""
74
+ if self.refraction_index:
75
+ self._values[2] = [
76
+ self.r_transmissivity, self.g_transmissivity, self.b_transmissivity,
77
+ self.refraction_index
78
+ ]
79
+ else:
80
+ self._values[2] = [
81
+ self.r_transmissivity, self.g_transmissivity, self.b_transmissivity
82
+ ]
83
+
84
+ @property
85
+ def r_transmissivity(self):
86
+ """Get or set the transmissivity for red channel.
87
+
88
+ The value should be between 0 and 1 (Default: 0).
89
+ """
90
+ return self._r_transmissivity
91
+
92
+ @r_transmissivity.setter
93
+ def r_transmissivity(self, transmissivity):
94
+ self._r_transmissivity = \
95
+ typing.float_in_range(transmissivity, 0, 1, 'red transmissivity')
96
+
97
+ @property
98
+ def g_transmissivity(self):
99
+ """Get or set the transmissivity for green channel.
100
+
101
+ The value should be between 0 and 1 (Default: 0).
102
+ """
103
+ return self._g_transmissivity
104
+
105
+ @g_transmissivity.setter
106
+ def g_transmissivity(self, transmissivity):
107
+ self._g_transmissivity = \
108
+ typing.float_in_range(transmissivity, 0, 1, 'green transmissivity')
109
+
110
+ @property
111
+ def b_transmissivity(self):
112
+ """get or set the transmissivity for blue channel.
113
+
114
+ The value should be between 0 and 1 (Default: 0).
115
+ """
116
+ return self._b_transmissivity
117
+
118
+ @b_transmissivity.setter
119
+ def b_transmissivity(self, transmissivity):
120
+ self._b_transmissivity = \
121
+ typing.float_in_range(transmissivity, 0, 1, 'blue transmissivity')
122
+
123
+ @property
124
+ def refraction_index(self):
125
+ """Get or set the index of refraction.
126
+
127
+ Typical values are 1.52 for float glass and 1.4 for ETFE. If None, Radiance
128
+ will default to using 1.52 for glass.
129
+ """
130
+ return self._refraction_index
131
+
132
+ @refraction_index.setter
133
+ def refraction_index(self, value):
134
+ self._refraction_index = \
135
+ typing.float_in_range(value, 1, input_name='refraction index') \
136
+ if value is not None else None
137
+
138
+ @property
139
+ def r_transmittance(self):
140
+ """Get or set the transmittance for red channel."""
141
+ return self.transmittance_from_transmissivity(self.r_transmissivity)
142
+
143
+ @r_transmittance.setter
144
+ def r_transmittance(self, value):
145
+ self.r_transmissivity = self.transmissivity_from_transmittance(value)
146
+
147
+ @property
148
+ def g_transmittance(self):
149
+ """Get or set the transmittance for green channel."""
150
+ return self.transmittance_from_transmissivity(self.g_transmissivity)
151
+
152
+ @g_transmittance.setter
153
+ def g_transmittance(self, value):
154
+ self.g_transmissivity = self.transmissivity_from_transmittance(value)
155
+
156
+ @property
157
+ def b_transmittance(self):
158
+ """Get or set the transmittance for blue channel."""
159
+ return self.transmittance_from_transmissivity(self.b_transmissivity)
160
+
161
+ @b_transmittance.setter
162
+ def b_transmittance(self, value):
163
+ self.b_transmissivity = self.transmissivity_from_transmittance(value)
164
+
165
+ @property
166
+ def average_transmissivity(self):
167
+ """Get the average transmissivity.
168
+
169
+ The value is calculated by multiplying the r, g, b values by v-lambda.
170
+ """
171
+ return 0.265 * self.r_transmissivity + \
172
+ 0.670 * self.g_transmissivity + 0.065 * self.b_transmissivity
173
+
174
+ @property
175
+ def average_transmittance(self):
176
+ """Get the average transmittance.
177
+
178
+ The value is calculated by multiplying the r, g, b values by v-lambda.
179
+ """
180
+ return self.transmittance_from_transmissivity(self.average_transmissivity)
181
+
182
+ @classmethod
183
+ def from_transmittance(cls, identifier, r_transmittance=0.0, g_transmittance=0.0,
184
+ b_transmittance=0.0, refraction_index=None, modifier=None,
185
+ dependencies=None):
186
+ """Create glass material from transmittance values.
187
+
188
+ Radiance uses transmissivity values while glass manufactures provide the value
189
+ for transmittance. This method does the conversion from transmittance to
190
+ transmissivity.
191
+
192
+ Args:
193
+ identifier: Text string for a unique Material ID. Must not contain spaces
194
+ or special characters. This will be used to identify the object across
195
+ a model and in the exported Radiance files.
196
+ r_transmittance: Transmittance for red. The value should be between 0 and 1
197
+ (Default: 0).
198
+ g_transmittance: Transmittance for green. The value should be between 0 and 1
199
+ (Default: 0).
200
+ b_transmittance: Transmittance for blue. The value should be between 0 and 1
201
+ (Default: 0).
202
+ refraction_index: Index of refraction. Typical values are 1.52 for float
203
+ glass and 1.4 for ETFE. If None, Radiance will default to using 1.52
204
+ for glass (Default: None).
205
+ modifier: Material modifier (Default: None).
206
+ dependencies: A list of primitives that this primitive depends on. This
207
+ argument is only useful for defining advanced primitives where the
208
+ primitive is defined based on other primitives. (Default: [])
209
+
210
+ Usage:
211
+
212
+ .. code-block:: python
213
+
214
+ glass_material = Glass.from_transmittance("generic_glass", .60, .60, .60)
215
+ print(glass_material)
216
+ """
217
+ rt = cls.transmissivity_from_transmittance(r_transmittance)
218
+ gt = cls.transmissivity_from_transmittance(g_transmittance)
219
+ bt = cls.transmissivity_from_transmittance(b_transmittance)
220
+ return cls(identifier, rt, gt, bt, refraction_index, modifier,
221
+ dependencies=dependencies)
222
+
223
+ @classmethod
224
+ def from_single_transmissivity(cls, identifier, rgb_transmissivity=0,
225
+ refraction_index=None, modifier=None,
226
+ dependencies=None):
227
+ """Create glass material with single transmissivity value.
228
+
229
+ Args:
230
+ identifier: Text string for a unique Material ID. Must not contain spaces
231
+ or special characters. This will be used to identify the object across
232
+ a model and in the exported Radiance files.
233
+ rgb_transmissivity: Transmissivity for red, green and blue. The value should
234
+ be between 0 and 1 (Default: 0).
235
+ refraction_index: Index of refraction. Typical values are 1.52 for float
236
+ glass and 1.4 for ETFE. If None, Radiance will default to using 1.52
237
+ for glass (Default: None).
238
+ modifier: Material modifier (Default: None).
239
+ dependencies: A list of primitives that this primitive depends on. This
240
+ argument is only useful for defining advanced primitives where the
241
+ primitive is defined based on other primitives. (Default: [])
242
+
243
+ Usage:
244
+
245
+ .. code-block:: python
246
+
247
+ glassMaterial = Glass.from_single_transmissivity("generic glass", .65)
248
+ print(glassMaterial)
249
+ """
250
+ return cls(
251
+ identifier, r_transmissivity=rgb_transmissivity,
252
+ g_transmissivity=rgb_transmissivity, b_transmissivity=rgb_transmissivity,
253
+ refraction_index=refraction_index,
254
+ modifier=modifier, dependencies=dependencies)
255
+
256
+ @classmethod
257
+ def from_single_transmittance(cls, identifier, rgb_transmittance=0,
258
+ refraction_index=None, modifier=None,
259
+ dependencies=None):
260
+ """Create glass material with single transmittance value.
261
+
262
+ Args:
263
+ identifier: Text string for a unique Material ID. Must not contain spaces
264
+ or special characters. This will be used to identify the object across
265
+ a model and in the exported Radiance files.
266
+ rgb_transmittance: Transmittance for red, green and blue. The value should
267
+ be between 0 and 1 (Default: 0).
268
+ refraction_index: Index of refraction. Typical values are 1.52 for float
269
+ glass and 1.4 for ETFE. If None, Radiance will default to using 1.52
270
+ for glass (Default: None).
271
+ modifier: Material modifier (Default: None).
272
+ dependencies: A list of primitives that this primitive depends on. This
273
+ argument is only useful for defining advanced primitives where the
274
+ primitive is defined based on other primitives. (Default: [])
275
+
276
+ Usage:
277
+
278
+ .. code-block:: python
279
+
280
+ glassMaterial = Glass.from_single_transmittance("generic glass", .65)
281
+ print(glassMaterial)
282
+ """
283
+ rgb_transmissivity = cls.transmissivity_from_transmittance(rgb_transmittance)
284
+ return cls(
285
+ identifier,
286
+ r_transmissivity=rgb_transmissivity, g_transmissivity=rgb_transmissivity,
287
+ b_transmissivity=rgb_transmissivity, refraction_index=refraction_index,
288
+ modifier=modifier, dependencies=dependencies)
289
+
290
+ @classmethod
291
+ def from_primitive_dict(cls, primitive_dict):
292
+ """Initialize Glass from a primitive dict.
293
+
294
+ Args:
295
+ data: A dictionary in the format below.
296
+
297
+ .. code-block:: python
298
+
299
+ {
300
+ "modifier": {}, # primitive modifier (Default: None)
301
+ "type": "glass", # primitive type
302
+ "identifier": "", # primitive identifier
303
+ "display_name": "", # primitive display name
304
+ "values": [] , # values
305
+ "dependencies": []
306
+ }
307
+ """
308
+ cls._dict_type_check(cls.__name__, primitive_dict)
309
+ modifier, dependencies = cls.filter_dict_input(primitive_dict)
310
+ values = primitive_dict['values'][2]
311
+ refraction_index = values[3] if len(values) == 4 else None
312
+ cls_ = cls(
313
+ identifier=primitive_dict['identifier'],
314
+ r_transmissivity=values[0],
315
+ g_transmissivity=values[1],
316
+ b_transmissivity=values[2],
317
+ refraction_index=refraction_index,
318
+ modifier=modifier,
319
+ dependencies=dependencies)
320
+ if 'display_name' in primitive_dict and \
321
+ primitive_dict['display_name'] is not None:
322
+ cls_.display_name = primitive_dict['display_name']
323
+
324
+ # update the values from values dictionary.
325
+ # this might look redundant but it is to ensure any strange input like inputs in
326
+ # strings line are updated and will be the same as input in cases that user uses
327
+ # from_string classmethod
328
+ cls_.values = primitive_dict['values']
329
+ return cls_
330
+
331
+ @classmethod
332
+ def from_dict(cls, data):
333
+ """Initialize Glass from a dictionary.
334
+
335
+ Args:
336
+ data: A dictionary in the format below.
337
+
338
+ .. code-block:: python
339
+
340
+ {
341
+ "type": "Glass",
342
+ "identifier": "", # Material identifier
343
+ "display_name": "", # Material display name
344
+ "r_transmissivity": float, # Transmissivity for red
345
+ "g_transmissivity": float, # Transmissivity for green
346
+ "b_transmissivity": float, # Transmissivity for blue
347
+ "refraction_index": float, # Index of refraction
348
+ "modifier": {}, # material modifier (Default: None)
349
+ "dependencies": []
350
+ }
351
+ """
352
+ cls._dict_type_check(cls.__name__, data)
353
+ modifier, dependencies = cls.filter_dict_input(data)
354
+
355
+ new_obj = cls(identifier=data["identifier"],
356
+ r_transmissivity=data["r_transmissivity"],
357
+ g_transmissivity=data["g_transmissivity"],
358
+ b_transmissivity=data["b_transmissivity"],
359
+ refraction_index=data["refraction_index"],
360
+ modifier=modifier,
361
+ dependencies=dependencies)
362
+ if 'display_name' in data and data['display_name'] is not None:
363
+ new_obj.display_name = data['display_name']
364
+ return new_obj
365
+
366
+ def to_dict(self):
367
+ """Translate this object to a dictionary."""
368
+ base = {
369
+ 'modifier': self.modifier.to_dict(),
370
+ 'type': 'Glass',
371
+ 'identifier': self.identifier,
372
+ 'r_transmissivity': self.r_transmissivity,
373
+ 'g_transmissivity': self.g_transmissivity,
374
+ 'b_transmissivity': self.b_transmissivity,
375
+ 'refraction_index': self.refraction_index,
376
+ 'dependencies': [dp.to_dict() for dp in self.dependencies]
377
+ }
378
+ if self._display_name is not None:
379
+ base['display_name'] = self.display_name
380
+ return base
381
+
382
+ @staticmethod
383
+ def transmissivity_from_transmittance(transmittance):
384
+ """Calculate transmissivity based on transmittance value.
385
+
386
+ Transmissivity is the amount of light not absorbed in one traversal of
387
+ the material.
388
+
389
+ Transmittance (the value usually measured) is the total light transmitted
390
+ through the material pane including multiple reflections inside of the
391
+ glass pane.
392
+ """
393
+ transmittance = float(transmittance)
394
+ return Glass._transmissivity_from_transmittance(transmittance)
395
+
396
+ @staticmethod
397
+ def transmittance_from_transmissivity(transmissivity):
398
+ """Calculate transmittance based on transmissivity value.
399
+
400
+ Transmittance (the value usually measured) is the total light transmitted
401
+ through the material pane including multiple reflections inside of the
402
+ glass pane.
403
+
404
+ Transmissivity is the amount of light not absorbed in one traversal of
405
+ the material.
406
+ """
407
+ transmissivity = float(transmissivity)
408
+ if transmissivity == 0:
409
+ return 0
410
+
411
+ def fn(x):
412
+ return Glass._transmissivity_from_transmittance(x) - transmissivity
413
+ return secant(0.01, 1, fn, 0.01)
414
+
415
+ @staticmethod
416
+ def _transmissivity_from_transmittance(transmittance):
417
+ """Get transmissivity from a transmittance value"""
418
+ try:
419
+ tms = (math.sqrt(0.8402528435 + 0.0072522239 * (transmittance ** 2)) -
420
+ 0.9166530661) / 0.0036261119 / transmittance
421
+ return tms if tms > 0 else 0
422
+ except ZeroDivisionError:
423
+ return 0
424
+
425
+ def __copy__(self):
426
+ mod, depend = self._dup_mod_and_depend()
427
+ new_obj = self.__class__(
428
+ self.identifier, self.r_transmissivity, self.g_transmissivity,
429
+ self.b_transmissivity, self.refraction_index, mod, depend)
430
+ new_obj._display_name = self._display_name
431
+ return new_obj
@@ -0,0 +1,246 @@
1
+ """Radiance Glow Material.
2
+
3
+ http://radsite.lbl.gov/radiance/refer/ray.html#Glow
4
+ """
5
+ from __future__ import division
6
+
7
+ from .materialbase import Material
8
+ import honeybee.typing as typing
9
+
10
+
11
+ class Glow(Material):
12
+ """Create glow material.
13
+
14
+ Args:
15
+ identifier: Text string for a unique Material ID. Must not contain spaces
16
+ or special characters. This will be used to identify the object across
17
+ a model and in the exported Radiance files.
18
+ r_emittance: A positive value for the Red channel of the glow (default: 0).
19
+ g_emittance: A positive value for the Green channel of the glow (default: 0).
20
+ b_emittance: A positive value for the Blue channel of the glow (default: 0).
21
+ max_radius: Maximum radius for shadow testing (default: 0). If maxrad is
22
+ zero, then the surface will never be tested for shadow, although it may
23
+ participate in an interreflection calculation. If maxrad is negative,
24
+ then the surface will never contribute to scene illumination. Glow
25
+ sources will never illuminate objects on the other side of an illum
26
+ surface. This provides a convenient way to illuminate local light fixture
27
+ geometry without overlighting nearby objects.
28
+ modifier: Material modifier (Default: None).
29
+ dependencies: A list of primitives that this primitive depends on. This
30
+ argument is only useful for defining advanced primitives where the
31
+ primitive is defined based on other primitives. (Default: [])
32
+
33
+ Properties:
34
+ * identifier
35
+ * display_name
36
+ * r_emittance
37
+ * g_emittance
38
+ * b_emittance
39
+ * max_radius
40
+ * values
41
+ * modifier
42
+ * dependencies
43
+ * is_modifier
44
+ * is_material
45
+ """
46
+
47
+ __slots__ = ('_r_emittance', '_g_emittance', '_b_emittance', '_max_radius')
48
+
49
+ def __init__(self, identifier, r_emittance=0.0, g_emittance=0.0, b_emittance=0.0,
50
+ max_radius=0.0, modifier=None, dependencies=None):
51
+ """Init Glow material."""
52
+ Material.__init__(self, identifier, modifier=modifier,
53
+ dependencies=dependencies)
54
+ self.r_emittance = r_emittance
55
+ self.g_emittance = g_emittance
56
+ self.b_emittance = b_emittance
57
+ self.max_radius = max_radius
58
+ self._update_values()
59
+
60
+ def _update_values(self):
61
+ "update value dictionaries."
62
+ self._values[2] = [
63
+ self.r_emittance, self.g_emittance, self.b_emittance, self.max_radius
64
+ ]
65
+
66
+ @property
67
+ def r_emittance(self):
68
+ """Get or set a positive value for the Red channel of the glow.
69
+
70
+ The value must be positive (Default: 0).
71
+ """
72
+ return self._r_emittance
73
+
74
+ @r_emittance.setter
75
+ def r_emittance(self, value):
76
+ self._r_emittance = typing.float_positive(value)
77
+
78
+ @property
79
+ def g_emittance(self):
80
+ """Get or set a positive value for the Green channel of the glow.
81
+
82
+ The value must be positive (Default: 0).
83
+ """
84
+ return self._g_emittance
85
+
86
+ @g_emittance.setter
87
+ def g_emittance(self, value):
88
+ self._g_emittance = typing.float_positive(value)
89
+
90
+ @property
91
+ def b_emittance(self):
92
+ """Get or set a positive value for the Blue channel of the glow.
93
+
94
+ The value must be positive (Default: 0).
95
+ """
96
+ return self._b_emittance
97
+
98
+ @b_emittance.setter
99
+ def b_emittance(self, value):
100
+ self._b_emittance = typing.float_positive(value)
101
+
102
+ @property
103
+ def max_radius(self):
104
+ """Get or set the maximum radius for shadow testing. (Default: 0).
105
+
106
+ If maxrad is zero, then the surface will never be tested for shadow, although
107
+ it may participate in an interreflection calculation. If maxrad is negative, then
108
+ the surface will never contribute to scene illumination. Glow sources will
109
+ never illuminate objects on the other side of an illum surface. This
110
+ provides a convenient way to illuminate local light fixture geometry without
111
+ overlighting nearby objects.
112
+ """
113
+ return self._max_radius
114
+
115
+ @max_radius.setter
116
+ def max_radius(self, value):
117
+ self._max_radius = float(value)
118
+
119
+ @classmethod
120
+ def from_single_value(cls, identifier, rgb=0, max_radius=0, modifier=None,
121
+ dependencies=None):
122
+ """Create glow material with single value.
123
+
124
+ Args:
125
+ identifier: Text string for a unique Material ID. Must not contain spaces
126
+ or special characters. This will be used to identify the object across
127
+ a model and in the exported Radiance files.
128
+ rgb: Input for r_emittance, g_emittance and b_emittance. The value should be
129
+ between 0 and 1 (Default: 0).
130
+ modifier: Material modifier (Default: None).
131
+ max_radius: Maximum radius for shadow testing (default: 0). If maxrad is zero,
132
+ then the surface will never be tested for shadow, although it may
133
+ participate in an interreflection calculation. If maxrad is negative, then
134
+ the surface will never contribute to scene illumination. Glow sources will
135
+ never illuminate objects on the other side of an illum surface. This
136
+ provides a convenient way to illuminate local light fixture geometry without
137
+ overlighting nearby objects.
138
+ dependencies: A list of primitives that this primitive depends on. This
139
+ argument is only useful for defining advanced primitives where the
140
+ primitive is defined based on other primitives. (Default: [])
141
+
142
+ Usage:
143
+
144
+ .. code-block:: python
145
+
146
+ sample_glow = Glow.from_single_value("sample_glow", 100)
147
+ print(sample_glow)
148
+ """
149
+ return cls(identifier, r_emittance=rgb, g_emittance=rgb, b_emittance=rgb,
150
+ max_radius=max_radius, modifier=modifier, dependencies=dependencies)
151
+
152
+ @classmethod
153
+ def from_primitive_dict(cls, primitive_dict):
154
+ """Initialize Glow from a primitive dict.
155
+
156
+ Args:
157
+ data: A dictionary in the format below.
158
+
159
+ .. code-block:: python
160
+
161
+ {
162
+ "modifier": {} # primitive modifier (Default: None)
163
+ "type": "glow", # primitive type
164
+ "identifier": "", # primitive identifier
165
+ "display_name": "", # primitive display name
166
+ "values": [], # values
167
+ "dependencies": []
168
+ }
169
+ """
170
+ cls._dict_type_check(cls.__name__, primitive_dict)
171
+ modifier, dependencies = cls.filter_dict_input(primitive_dict)
172
+ values = primitive_dict['values'][2]
173
+
174
+ cls_ = cls(
175
+ identifier=primitive_dict["identifier"],
176
+ r_emittance=values[0],
177
+ g_emittance=values[1],
178
+ b_emittance=values[2],
179
+ max_radius=values[3],
180
+ modifier=modifier,
181
+ dependencies=dependencies
182
+ )
183
+ if 'display_name' in primitive_dict and primitive_dict['display_name'] is not None:
184
+ cls_.display_name = primitive_dict['display_name']
185
+
186
+ # this might look redundant but it is NOT. see glass for explanation.
187
+ cls_.values = primitive_dict['values']
188
+ return cls_
189
+
190
+ @classmethod
191
+ def from_dict(cls, data):
192
+ """Initialize Glow from a dictionary.
193
+
194
+ Args:
195
+ data: A dictionary in the format below.
196
+
197
+ .. code-block:: python
198
+
199
+ {
200
+ "type": "Glow", # primitive type
201
+ "identifier": "", # Material identifier
202
+ "display_name": "", # Material display name
203
+ "r_emittance": float, # A positive value for the Red channel of the glow
204
+ "g_emittance": float, # A positive value for the Green channel of the glow
205
+ "b_emittance": float, # A positive value for the Blue channel of the glow
206
+ "max_radius": float, # Maximum radius for shadow testing
207
+ "modifier": {} # primitive modifier (Default: None)
208
+ "dependencies: []
209
+ }
210
+ """
211
+ cls._dict_type_check(cls.__name__, data)
212
+ modifier, dependencies = cls.filter_dict_input(data)
213
+
214
+ new_obj = cls(identifier=data['identifier'],
215
+ r_emittance=data['r_emittance'],
216
+ g_emittance=data['g_emittance'],
217
+ b_emittance=data['b_emittance'],
218
+ max_radius=data['max_radius'],
219
+ modifier=modifier,
220
+ dependencies=dependencies)
221
+ if 'display_name' in data and data['display_name'] is not None:
222
+ new_obj.display_name = data['display_name']
223
+ return new_obj
224
+
225
+ def to_dict(self):
226
+ """Translate this object to a dictionary."""
227
+ base = {
228
+ 'modifier': self.modifier.to_dict(),
229
+ 'type': 'Glow',
230
+ 'identifier': self.identifier,
231
+ 'r_emittance': self.r_emittance,
232
+ 'g_emittance': self.g_emittance,
233
+ 'b_emittance': self.b_emittance,
234
+ 'max_radius': self.max_radius,
235
+ 'dependencies': [dp.to_dict() for dp in self.dependencies]
236
+ }
237
+ if self._display_name is not None:
238
+ base['display_name'] = self.display_name
239
+ return base
240
+
241
+ def __copy__(self):
242
+ mod, depend = self._dup_mod_and_depend()
243
+ new_obj = self.__class__(self.identifier, self.r_emittance, self.g_emittance,
244
+ self.b_emittance, self.max_radius, mod, depend)
245
+ new_obj._display_name = self._display_name
246
+ return new_obj