honeybee-core 1.64.12__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.
- honeybee/__init__.py +23 -0
- honeybee/__main__.py +4 -0
- honeybee/_base.py +331 -0
- honeybee/_basewithshade.py +310 -0
- honeybee/_lockable.py +99 -0
- honeybee/altnumber.py +47 -0
- honeybee/aperture.py +997 -0
- honeybee/boundarycondition.py +358 -0
- honeybee/checkdup.py +173 -0
- honeybee/cli/__init__.py +118 -0
- honeybee/cli/compare.py +132 -0
- honeybee/cli/create.py +265 -0
- honeybee/cli/edit.py +559 -0
- honeybee/cli/lib.py +103 -0
- honeybee/cli/setconfig.py +43 -0
- honeybee/cli/validate.py +224 -0
- honeybee/colorobj.py +363 -0
- honeybee/config.json +5 -0
- honeybee/config.py +347 -0
- honeybee/dictutil.py +54 -0
- honeybee/door.py +746 -0
- honeybee/extensionutil.py +208 -0
- honeybee/face.py +2360 -0
- honeybee/facetype.py +153 -0
- honeybee/logutil.py +79 -0
- honeybee/model.py +4272 -0
- honeybee/orientation.py +132 -0
- honeybee/properties.py +845 -0
- honeybee/room.py +3485 -0
- honeybee/search.py +107 -0
- honeybee/shade.py +514 -0
- honeybee/shademesh.py +362 -0
- honeybee/typing.py +498 -0
- honeybee/units.py +88 -0
- honeybee/writer/__init__.py +7 -0
- honeybee/writer/aperture.py +6 -0
- honeybee/writer/door.py +6 -0
- honeybee/writer/face.py +6 -0
- honeybee/writer/model.py +6 -0
- honeybee/writer/room.py +6 -0
- honeybee/writer/shade.py +6 -0
- honeybee/writer/shademesh.py +6 -0
- honeybee_core-1.64.12.dist-info/METADATA +94 -0
- honeybee_core-1.64.12.dist-info/RECORD +48 -0
- honeybee_core-1.64.12.dist-info/WHEEL +5 -0
- honeybee_core-1.64.12.dist-info/entry_points.txt +2 -0
- honeybee_core-1.64.12.dist-info/licenses/LICENSE +661 -0
- honeybee_core-1.64.12.dist-info/top_level.txt +1 -0
honeybee/properties.py
ADDED
|
@@ -0,0 +1,845 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
"""Extension properties for Model, Room, Face, Shade, Aperture, Door.
|
|
3
|
+
|
|
4
|
+
These objects hold all attributes assigned by extensions like honeybee-radiance
|
|
5
|
+
and honeybee-energy. Note that these Property objects are not intended to exist
|
|
6
|
+
on their own but should have a host object.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class _Properties(object):
|
|
11
|
+
"""Base class for all Properties classes.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
host: A honeybee-core geometry object that hosts these properties
|
|
15
|
+
(ie. Model, Room, Face, Shade, Aperture, Door).
|
|
16
|
+
"""
|
|
17
|
+
_exclude = set(
|
|
18
|
+
('host', 'move', 'rotate', 'rotate_xy', 'reflect', 'scale', 'is_equivalent',
|
|
19
|
+
'add_prefix', 'reset_to_default', 'to_dict', 'apply_properties_from_dict',
|
|
20
|
+
'ToString'))
|
|
21
|
+
|
|
22
|
+
def __init__(self, host):
|
|
23
|
+
"""Initialize properties."""
|
|
24
|
+
self._host = host
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def host(self):
|
|
28
|
+
"""Get the object hosting these properties."""
|
|
29
|
+
return self._host
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def _extension_attributes(self):
|
|
33
|
+
return (atr for atr in dir(self) if not atr.startswith('_')
|
|
34
|
+
and atr not in self._exclude)
|
|
35
|
+
|
|
36
|
+
def move(self, moving_vec):
|
|
37
|
+
"""Apply a move transform to extension attributes.
|
|
38
|
+
|
|
39
|
+
This is useful in cases where extension attributes possess geometric data
|
|
40
|
+
that should be moved alongside the host object. For example, dynamic
|
|
41
|
+
geometry within the honeybee-radiance state of an aperture should be
|
|
42
|
+
moved if the host aperture is moved.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
moving_vec: A ladybug_geometry Vector3D with the direction and distance
|
|
46
|
+
to move the face.
|
|
47
|
+
"""
|
|
48
|
+
for atr in self._extension_attributes:
|
|
49
|
+
var = getattr(self, atr)
|
|
50
|
+
if not hasattr(var, 'move'):
|
|
51
|
+
continue
|
|
52
|
+
try:
|
|
53
|
+
var.move(moving_vec)
|
|
54
|
+
except Exception as e:
|
|
55
|
+
import traceback
|
|
56
|
+
traceback.print_exc()
|
|
57
|
+
raise Exception('Failed to move {}: {}'.format(var, e))
|
|
58
|
+
|
|
59
|
+
def rotate(self, axis, angle, origin):
|
|
60
|
+
"""Apply a rotation transform to extension attributes.
|
|
61
|
+
|
|
62
|
+
This is useful in cases where extension attributes possess geometric data
|
|
63
|
+
that should be rotated alongside the host object. For example, dynamic
|
|
64
|
+
geometry within the honeybee-radiance state of an aperture should be
|
|
65
|
+
rotated if the host aperture is rotated.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
axis: A ladybug_geometry Vector3D axis representing the axis of rotation.
|
|
69
|
+
angle: An angle for rotation in degrees.
|
|
70
|
+
origin: A ladybug_geometry Point3D for the origin around which the
|
|
71
|
+
object will be rotated.
|
|
72
|
+
"""
|
|
73
|
+
for atr in self._extension_attributes:
|
|
74
|
+
var = getattr(self, atr)
|
|
75
|
+
if not hasattr(var, 'rotate'):
|
|
76
|
+
continue
|
|
77
|
+
try:
|
|
78
|
+
var.rotate(axis, angle, origin)
|
|
79
|
+
except Exception as e:
|
|
80
|
+
import traceback
|
|
81
|
+
traceback.print_exc()
|
|
82
|
+
raise Exception('Failed to rotate {}: {}'.format(var, e))
|
|
83
|
+
|
|
84
|
+
def rotate_xy(self, angle, origin):
|
|
85
|
+
"""Apply a rotation in the XY plane to extension attributes.
|
|
86
|
+
|
|
87
|
+
This is useful in cases where extension attributes possess geometric data
|
|
88
|
+
that should be rotated alongside the host object. For example, dynamic
|
|
89
|
+
geometry within the honeybee-radiance state of an aperture should be
|
|
90
|
+
rotated if the host aperture is rotated.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
angle: An angle in degrees.
|
|
94
|
+
origin: A ladybug_geometry Point3D for the origin around which the
|
|
95
|
+
object will be rotated.
|
|
96
|
+
"""
|
|
97
|
+
for atr in self._extension_attributes:
|
|
98
|
+
var = getattr(self, atr)
|
|
99
|
+
if not hasattr(var, 'rotate_xy'):
|
|
100
|
+
continue
|
|
101
|
+
try:
|
|
102
|
+
var.rotate_xy(angle, origin)
|
|
103
|
+
except Exception as e:
|
|
104
|
+
import traceback
|
|
105
|
+
traceback.print_exc()
|
|
106
|
+
raise Exception('Failed to rotate {}: {}'.format(var, e))
|
|
107
|
+
|
|
108
|
+
def reflect(self, plane):
|
|
109
|
+
"""Apply a reflection transform to extension attributes.
|
|
110
|
+
|
|
111
|
+
This is useful in cases where extension attributes possess geometric data
|
|
112
|
+
that should be reflected alongside the host object. For example, dynamic
|
|
113
|
+
geometry within the honeybee-radiance state of an aperture should be
|
|
114
|
+
reflected if the host aperture is reflected.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
plane: A ladybug_geometry Plane across which the object will
|
|
118
|
+
be reflected.
|
|
119
|
+
"""
|
|
120
|
+
for atr in self._extension_attributes:
|
|
121
|
+
var = getattr(self, atr)
|
|
122
|
+
if not hasattr(var, 'reflect'):
|
|
123
|
+
continue
|
|
124
|
+
try:
|
|
125
|
+
var.reflect(plane)
|
|
126
|
+
except Exception as e:
|
|
127
|
+
import traceback
|
|
128
|
+
traceback.print_exc()
|
|
129
|
+
raise Exception('Failed to reflect {}: {}'.format(var, e))
|
|
130
|
+
|
|
131
|
+
def scale(self, factor, origin=None):
|
|
132
|
+
"""Apply a scale transform to extension attributes.
|
|
133
|
+
|
|
134
|
+
This is useful in cases where extension attributes possess geometric data
|
|
135
|
+
that should be scaled alongside the host object. For example, dynamic
|
|
136
|
+
geometry within the honeybee-radiance state of an aperture should be
|
|
137
|
+
scaled if the host aperture is scaled.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
factor: A number representing how much the object should be scaled.
|
|
141
|
+
origin: A ladybug_geometry Point3D representing the origin from which
|
|
142
|
+
to scale. If None, it will be scaled from the World origin (0, 0, 0).
|
|
143
|
+
"""
|
|
144
|
+
for atr in self._extension_attributes:
|
|
145
|
+
var = getattr(self, atr)
|
|
146
|
+
if not hasattr(var, 'scale'):
|
|
147
|
+
continue
|
|
148
|
+
try:
|
|
149
|
+
var.scale(factor, origin)
|
|
150
|
+
except Exception as e:
|
|
151
|
+
import traceback
|
|
152
|
+
traceback.print_exc()
|
|
153
|
+
raise Exception('Failed to scale {}: {}'.format(var, e))
|
|
154
|
+
|
|
155
|
+
def is_equivalent(self, other_properties):
|
|
156
|
+
"""Get a dictionary noting the equivalency of these properties to other ones.
|
|
157
|
+
|
|
158
|
+
The keys of this dictionary will note the name of each extension (eg.
|
|
159
|
+
energy, radiance) and the values will be a boolean for whether the
|
|
160
|
+
extension properties are equivalent or not.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
other_properties: Properties of another object for which equivalency
|
|
164
|
+
will be tested.
|
|
165
|
+
"""
|
|
166
|
+
eq_dict = {}
|
|
167
|
+
for atr in self._extension_attributes:
|
|
168
|
+
var = getattr(self, atr)
|
|
169
|
+
if not hasattr(var, 'is_equivalent'):
|
|
170
|
+
continue
|
|
171
|
+
other_var = getattr(other_properties, atr)
|
|
172
|
+
try:
|
|
173
|
+
eq_dict[atr] = var.is_equivalent(other_var)
|
|
174
|
+
except Exception as e:
|
|
175
|
+
import traceback
|
|
176
|
+
traceback.print_exc()
|
|
177
|
+
raise Exception('Failed test is_equivalent for {}: {}'.format(var, e))
|
|
178
|
+
return eq_dict
|
|
179
|
+
|
|
180
|
+
def _update_by_sync(self, change, existing_prop, updated_prop):
|
|
181
|
+
"""Update properties using change instructions and existing/updated objects."""
|
|
182
|
+
for atr in self._extension_attributes:
|
|
183
|
+
up_atr = 'update_{}'.format(atr)
|
|
184
|
+
if up_atr in change:
|
|
185
|
+
var = getattr(updated_prop, atr) if change[up_atr] \
|
|
186
|
+
else getattr(existing_prop, atr)
|
|
187
|
+
if not hasattr(var, 'duplicate'):
|
|
188
|
+
continue
|
|
189
|
+
try:
|
|
190
|
+
setattr(self, '_' + atr, var.duplicate(self.host))
|
|
191
|
+
except Exception as e:
|
|
192
|
+
import traceback
|
|
193
|
+
traceback.print_exc()
|
|
194
|
+
raise Exception('Failed to duplicate {}: {}'.format(var, e))
|
|
195
|
+
|
|
196
|
+
def _duplicate_extension_attr(self, original_properties):
|
|
197
|
+
"""Duplicate the attributes added by extensions.
|
|
198
|
+
|
|
199
|
+
This method should be called within the duplicate or __copy__ methods of
|
|
200
|
+
each honeybee-core geometry object after the core object has been duplicated.
|
|
201
|
+
This method only needs to be called on the new (duplicated) core object and
|
|
202
|
+
the extension properties of the original core object should be passed to
|
|
203
|
+
this method as the original_properties.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
original_properties: The properties object of the original core
|
|
207
|
+
object from which the duplicate was derived.
|
|
208
|
+
"""
|
|
209
|
+
for atr in self._extension_attributes:
|
|
210
|
+
var = getattr(original_properties, atr)
|
|
211
|
+
if not hasattr(var, 'duplicate'):
|
|
212
|
+
continue
|
|
213
|
+
try:
|
|
214
|
+
setattr(self, '_' + atr, var.duplicate(self.host))
|
|
215
|
+
except Exception as e:
|
|
216
|
+
import traceback
|
|
217
|
+
traceback.print_exc()
|
|
218
|
+
raise Exception('Failed to duplicate {}: {}'.format(var, e))
|
|
219
|
+
|
|
220
|
+
def _add_prefix_extension_attr(self, prefix):
|
|
221
|
+
"""Change the name extension attributes unique to this object by adding a prefix.
|
|
222
|
+
|
|
223
|
+
This is particularly useful in workflows where you duplicate and edit
|
|
224
|
+
a starting object and then want to combine it with the original object
|
|
225
|
+
into one Model (like making a model of repeated rooms).
|
|
226
|
+
|
|
227
|
+
Notably, this method only adds the prefix to extension attributes that must
|
|
228
|
+
be unique to the object and does not add the prefix to attributes that are
|
|
229
|
+
shared across several objects.
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
prefix: Text that will be inserted at the start of the extension attributes'
|
|
233
|
+
name. It is recommended that this name be short to avoid maxing
|
|
234
|
+
out the 100 allowable characters for honeybee names.
|
|
235
|
+
"""
|
|
236
|
+
for atr in self._extension_attributes:
|
|
237
|
+
var = getattr(self, atr)
|
|
238
|
+
if not hasattr(var, 'add_prefix'):
|
|
239
|
+
continue
|
|
240
|
+
try:
|
|
241
|
+
var.add_prefix(prefix)
|
|
242
|
+
except Exception as e:
|
|
243
|
+
import traceback
|
|
244
|
+
traceback.print_exc()
|
|
245
|
+
raise Exception('Failed to add prefix to {}: {}'.format(var, e))
|
|
246
|
+
|
|
247
|
+
def _reset_extension_attr_to_default(self):
|
|
248
|
+
"""Reset all extension attributes for the object to be default.
|
|
249
|
+
|
|
250
|
+
This is useful in cases where properties that are hard-assigned to a specific
|
|
251
|
+
object might be illegal in combination with other properties and so they
|
|
252
|
+
should be reset upon the setting of the other properties. For example,
|
|
253
|
+
setting a Face type to AirBoundary typically makes certain types of energy
|
|
254
|
+
and radiance properties illegal. So calling this function whenever setting
|
|
255
|
+
Face type to AirBoundary will reset the extension attributes to the legal
|
|
256
|
+
default values.
|
|
257
|
+
"""
|
|
258
|
+
for atr in self._extension_attributes:
|
|
259
|
+
var = getattr(self, atr)
|
|
260
|
+
if not hasattr(var, 'reset_to_default'):
|
|
261
|
+
continue
|
|
262
|
+
try:
|
|
263
|
+
var.reset_to_default()
|
|
264
|
+
except Exception as e:
|
|
265
|
+
import traceback
|
|
266
|
+
traceback.print_exc()
|
|
267
|
+
raise Exception('Failed to reset_to_default for {}: {}'.format(var, e))
|
|
268
|
+
|
|
269
|
+
def _add_extension_attr_to_dict(self, base, abridged, include):
|
|
270
|
+
"""Add attributes for extensions to the base dictionary.
|
|
271
|
+
|
|
272
|
+
This method should be called within the to_dict method of each honeybee-core
|
|
273
|
+
geometry object.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
base: The dictionary of the core object without any extension attributes.
|
|
277
|
+
This method will add extension attributes to this dictionary. For
|
|
278
|
+
example, energy properties will appear under base['properties']['energy'].
|
|
279
|
+
abridged: Boolean to note whether the attributes of the extensions should
|
|
280
|
+
be abridged (True) or full (False). For example, if a Room's energy
|
|
281
|
+
properties are abridged, the program_type attribute under the energy
|
|
282
|
+
properties dictionary will just be the identifier of the program_type. If
|
|
283
|
+
it is full (not abridged), the program_type will be a complete
|
|
284
|
+
dictionary following the ProgramType schema. Abridged dictionaries
|
|
285
|
+
should be used within the Model.to_dict but full dictionaries should
|
|
286
|
+
be used within the to_dict methods of individual objects.
|
|
287
|
+
include: List of properties to filter keys that must be included in
|
|
288
|
+
output dictionary. For example ['energy'] will include 'energy' key if
|
|
289
|
+
available in properties to_dict. By default all the keys will be
|
|
290
|
+
included. To exclude all the keys from extensions use an empty list.
|
|
291
|
+
"""
|
|
292
|
+
attr = include if include is not None else self._extension_attributes
|
|
293
|
+
for atr in attr:
|
|
294
|
+
var = getattr(self, atr)
|
|
295
|
+
if not hasattr(var, 'to_dict'):
|
|
296
|
+
continue
|
|
297
|
+
try:
|
|
298
|
+
base.update(var.to_dict(abridged))
|
|
299
|
+
except Exception as e:
|
|
300
|
+
import traceback
|
|
301
|
+
traceback.print_exc()
|
|
302
|
+
raise Exception('Failed to convert {} to a dict: {}'.format(var, e))
|
|
303
|
+
return base
|
|
304
|
+
|
|
305
|
+
def _load_extension_attr_from_dict(self, property_dict):
|
|
306
|
+
"""Get attributes for extensions from a dictionary of the properties.
|
|
307
|
+
|
|
308
|
+
This method should be called within the from_dict method of each honeybee-core
|
|
309
|
+
geometry object. Specifically, this method should be called on the core
|
|
310
|
+
object after it has been created from a dictionary but lacks any of the
|
|
311
|
+
extension attributes in the dictionary.
|
|
312
|
+
|
|
313
|
+
Args:
|
|
314
|
+
property_dict: A dictionary of properties for the object (ie.
|
|
315
|
+
FaceProperties, RoomProperties). These will be used to load
|
|
316
|
+
attributes from the dictionary and assign them to the object on
|
|
317
|
+
which this method is called.
|
|
318
|
+
"""
|
|
319
|
+
for atr in self._extension_attributes:
|
|
320
|
+
var = getattr(self, atr)
|
|
321
|
+
if not hasattr(var, 'from_dict'):
|
|
322
|
+
continue
|
|
323
|
+
try:
|
|
324
|
+
setattr(self, '_' + atr, var.__class__.from_dict(
|
|
325
|
+
property_dict[atr], self.host))
|
|
326
|
+
except KeyError:
|
|
327
|
+
pass # the property_dict possesses no properties for that extension
|
|
328
|
+
|
|
329
|
+
def ToString(self):
|
|
330
|
+
"""Overwrite .NET ToString method."""
|
|
331
|
+
return self.__repr__()
|
|
332
|
+
|
|
333
|
+
def __repr__(self):
|
|
334
|
+
"""Properties representation."""
|
|
335
|
+
return 'BaseProperties'
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
class ModelProperties(_Properties):
|
|
339
|
+
"""Honeybee Model Properties.
|
|
340
|
+
|
|
341
|
+
This class will be extended by extensions.
|
|
342
|
+
|
|
343
|
+
Usage:
|
|
344
|
+
|
|
345
|
+
.. code-block:: python
|
|
346
|
+
|
|
347
|
+
model = Model('New Elementary School', list_of_rooms)
|
|
348
|
+
model.properties -> ModelProperties
|
|
349
|
+
model.properties.radiance -> ModelRadianceProperties
|
|
350
|
+
model.properties.energy -> ModelEnergyProperties
|
|
351
|
+
"""
|
|
352
|
+
|
|
353
|
+
def to_dict(self, include=None):
|
|
354
|
+
"""Convert properties to dictionary.
|
|
355
|
+
|
|
356
|
+
Args:
|
|
357
|
+
include: A list of keys to be included in dictionary.
|
|
358
|
+
If None all the available keys will be included.
|
|
359
|
+
"""
|
|
360
|
+
base = {'type': 'ModelProperties'}
|
|
361
|
+
attr = include if include is not None else self._extension_attributes
|
|
362
|
+
for atr in attr:
|
|
363
|
+
var = getattr(self, atr)
|
|
364
|
+
if not hasattr(var, 'to_dict'):
|
|
365
|
+
continue
|
|
366
|
+
try:
|
|
367
|
+
base.update(var.to_dict()) # no abridged dictionary for model
|
|
368
|
+
except Exception as e:
|
|
369
|
+
import traceback
|
|
370
|
+
traceback.print_exc()
|
|
371
|
+
raise Exception('Failed to convert {} to a dict: {}'.format(var, e))
|
|
372
|
+
return base
|
|
373
|
+
|
|
374
|
+
def apply_properties_from_dict(self, data):
|
|
375
|
+
"""Apply extension properties from a Model dictionary to the host Model.
|
|
376
|
+
|
|
377
|
+
Args:
|
|
378
|
+
data: A dictionary representation of an entire honeybee-core Model.
|
|
379
|
+
"""
|
|
380
|
+
for atr in self._extension_attributes:
|
|
381
|
+
if atr not in data['properties'] or data['properties'][atr] is None:
|
|
382
|
+
continue
|
|
383
|
+
var = getattr(self, atr)
|
|
384
|
+
if var and not hasattr(var, 'apply_properties_from_dict'):
|
|
385
|
+
continue
|
|
386
|
+
try:
|
|
387
|
+
var.apply_properties_from_dict(data)
|
|
388
|
+
except Exception as e:
|
|
389
|
+
import traceback
|
|
390
|
+
traceback.print_exc()
|
|
391
|
+
raise Exception(
|
|
392
|
+
'Failed to apply {} properties to the Model: {}'.format(atr, e))
|
|
393
|
+
|
|
394
|
+
def _check_for_extension(self, extension_name, detailed=False):
|
|
395
|
+
"""Check the validity of the model for a specific extension.
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
399
|
+
dicts with error info or a string with a message. (Default: False).
|
|
400
|
+
extension_name: Text for the name of the extension to be checked.
|
|
401
|
+
This value should always be lowercase to match the name of the
|
|
402
|
+
extension package. Some common honeybee extension names that can
|
|
403
|
+
be input here if they are installed include:
|
|
404
|
+
|
|
405
|
+
* radiance
|
|
406
|
+
* energy
|
|
407
|
+
* doe2
|
|
408
|
+
* ies
|
|
409
|
+
* idaice
|
|
410
|
+
"""
|
|
411
|
+
msgs = []
|
|
412
|
+
for atr in self._extension_attributes:
|
|
413
|
+
if extension_name == atr:
|
|
414
|
+
check_msg = None
|
|
415
|
+
try:
|
|
416
|
+
var = getattr(self, atr)
|
|
417
|
+
except AttributeError as e:
|
|
418
|
+
raise ImportError(
|
|
419
|
+
'Extension for {} is not installed or has not been set up '
|
|
420
|
+
'for model validation.\n{}'.format(var, e))
|
|
421
|
+
if not hasattr(var, 'check_for_extension'):
|
|
422
|
+
raise NotImplementedError(
|
|
423
|
+
'Extension for {} does not have validation routines.'.format(var))
|
|
424
|
+
try:
|
|
425
|
+
check_msg = var.check_for_extension(
|
|
426
|
+
raise_exception=False, detailed=detailed)
|
|
427
|
+
if detailed and check_msg is not None:
|
|
428
|
+
msgs.append(check_msg)
|
|
429
|
+
elif check_msg != '':
|
|
430
|
+
f_msg = 'Attributes for {} are invalid.\n{}'.format(atr, check_msg)
|
|
431
|
+
msgs.append(f_msg)
|
|
432
|
+
except Exception as e:
|
|
433
|
+
import traceback
|
|
434
|
+
traceback.print_exc()
|
|
435
|
+
raise Exception('Failed to check_for_extension '
|
|
436
|
+
'for {}: {}'.format(var, e))
|
|
437
|
+
return msgs
|
|
438
|
+
|
|
439
|
+
def _check_all_extension_attr(self, detailed=False, all_ext_checks=False):
|
|
440
|
+
"""Check the attributes of all extensions.
|
|
441
|
+
|
|
442
|
+
This method should be called within the check_all method of the Model object
|
|
443
|
+
to ensure that the check_all functions of any extension model properties
|
|
444
|
+
are also called.
|
|
445
|
+
|
|
446
|
+
Args:
|
|
447
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
448
|
+
dicts with error info or a string with a message. (Default: False).
|
|
449
|
+
"""
|
|
450
|
+
msgs = []
|
|
451
|
+
for atr in self._extension_attributes:
|
|
452
|
+
# get the extension attributes
|
|
453
|
+
check_msg = None
|
|
454
|
+
var = getattr(self, atr)
|
|
455
|
+
# use the check_generic function if it is available
|
|
456
|
+
if not all_ext_checks and hasattr(var, 'check_generic'):
|
|
457
|
+
try:
|
|
458
|
+
check_msg = var.check_generic(
|
|
459
|
+
raise_exception=False, detailed=detailed)
|
|
460
|
+
if detailed and check_msg is not None:
|
|
461
|
+
msgs.append(check_msg)
|
|
462
|
+
elif check_msg != '':
|
|
463
|
+
f_msg = \
|
|
464
|
+
'Attributes for {} are invalid.\n{}'.format(atr, check_msg)
|
|
465
|
+
msgs.append(f_msg)
|
|
466
|
+
except Exception as e:
|
|
467
|
+
import traceback
|
|
468
|
+
traceback.print_exc()
|
|
469
|
+
raise Exception('Failed to check_generic for {}: {}'.format(var, e))
|
|
470
|
+
elif hasattr(var, 'check_all'): # use the check_all function
|
|
471
|
+
try:
|
|
472
|
+
try:
|
|
473
|
+
check_msg = var.check_all(
|
|
474
|
+
raise_exception=False, detailed=detailed)
|
|
475
|
+
except TypeError: # no option available for detailed error message
|
|
476
|
+
check_msg = var.check_all(raise_exception=False)
|
|
477
|
+
if detailed and check_msg is not None:
|
|
478
|
+
msgs.append(check_msg)
|
|
479
|
+
elif check_msg != '':
|
|
480
|
+
f_msg = \
|
|
481
|
+
'Attributes for {} are invalid.\n{}'.format(atr, check_msg)
|
|
482
|
+
msgs.append(f_msg)
|
|
483
|
+
except Exception as e:
|
|
484
|
+
import traceback
|
|
485
|
+
traceback.print_exc()
|
|
486
|
+
raise Exception('Failed to check_all for {}: {}'.format(var, e))
|
|
487
|
+
return msgs
|
|
488
|
+
|
|
489
|
+
def _check_func_from_code(self, error_code):
|
|
490
|
+
"""Get a check function for a specific error code that exists in an extension.
|
|
491
|
+
|
|
492
|
+
Args:
|
|
493
|
+
error_code: Text for the error code for which the check will be performed.
|
|
494
|
+
This can be the value under the "code" key in the dictionary of
|
|
495
|
+
the validation error whenever the detailed option is used.
|
|
496
|
+
"""
|
|
497
|
+
for atr in self._extension_attributes:
|
|
498
|
+
var = getattr(self, atr)
|
|
499
|
+
if hasattr(var, 'ERROR_MAP'):
|
|
500
|
+
err_map = getattr(var, 'ERROR_MAP')
|
|
501
|
+
try:
|
|
502
|
+
check_func = err_map[error_code]
|
|
503
|
+
check_func = getattr(var, check_func)
|
|
504
|
+
return check_func
|
|
505
|
+
except KeyError: # not the correct extension for the code
|
|
506
|
+
pass
|
|
507
|
+
|
|
508
|
+
def __repr__(self):
|
|
509
|
+
"""Properties representation."""
|
|
510
|
+
return 'ModelProperties: {}'.format(self.host.display_name)
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
class RoomProperties(_Properties):
|
|
514
|
+
"""Honeybee Room Properties.
|
|
515
|
+
|
|
516
|
+
This class will be extended by extensions.
|
|
517
|
+
|
|
518
|
+
Usage:
|
|
519
|
+
|
|
520
|
+
.. code-block:: python
|
|
521
|
+
|
|
522
|
+
room = Room('Bedroom', geometry)
|
|
523
|
+
room.properties -> RoomProperties
|
|
524
|
+
room.properties.radiance -> RoomRadianceProperties
|
|
525
|
+
room.properties.energy -> RoomEnergyProperties
|
|
526
|
+
"""
|
|
527
|
+
|
|
528
|
+
def to_dict(self, abridged=False, include=None):
|
|
529
|
+
"""Convert properties to dictionary.
|
|
530
|
+
|
|
531
|
+
Args:
|
|
532
|
+
abridged: Boolean to note whether the full dictionary describing the
|
|
533
|
+
object should be returned (False) or just an abridged version (True).
|
|
534
|
+
Default: False.
|
|
535
|
+
include: A list of keys to be included in dictionary.
|
|
536
|
+
If None all the available keys will be included.
|
|
537
|
+
"""
|
|
538
|
+
base = {'type': 'RoomProperties'} if not abridged else \
|
|
539
|
+
{'type': 'RoomPropertiesAbridged'}
|
|
540
|
+
|
|
541
|
+
base = self._add_extension_attr_to_dict(base, abridged, include)
|
|
542
|
+
return base
|
|
543
|
+
|
|
544
|
+
def add_prefix(self, prefix):
|
|
545
|
+
"""Change the identifier extension attributes unique to this object by adding a prefix.
|
|
546
|
+
|
|
547
|
+
Notably, this method only adds the prefix to extension attributes that must
|
|
548
|
+
be unique to the Room (eg. single-room HVAC systems) and does not add the
|
|
549
|
+
prefix to attributes that are shared across several Rooms (eg. ConstructionSets).
|
|
550
|
+
|
|
551
|
+
Args:
|
|
552
|
+
prefix: Text that will be inserted at the start of extension attribute identifiers.
|
|
553
|
+
"""
|
|
554
|
+
self._add_prefix_extension_attr(prefix)
|
|
555
|
+
|
|
556
|
+
def reset_to_default(self):
|
|
557
|
+
"""Reset the extension properties assigned at the level of this Room to default.
|
|
558
|
+
|
|
559
|
+
This typically means erasing any ConstructionSets or ModifierSets assigned
|
|
560
|
+
to this Room among other properties.
|
|
561
|
+
"""
|
|
562
|
+
self._reset_extension_attr_to_default()
|
|
563
|
+
|
|
564
|
+
def __repr__(self):
|
|
565
|
+
"""Properties representation."""
|
|
566
|
+
return 'RoomProperties: {}'.format(self.host.display_name)
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
class FaceProperties(_Properties):
|
|
570
|
+
"""Honeybee Face Properties.
|
|
571
|
+
|
|
572
|
+
This class will be extended by extensions.
|
|
573
|
+
|
|
574
|
+
Usage:
|
|
575
|
+
|
|
576
|
+
.. code-block:: python
|
|
577
|
+
|
|
578
|
+
face = Face('South Bedroom Wall', geometry)
|
|
579
|
+
face.properties -> FaceProperties
|
|
580
|
+
face.properties.radiance -> FaceRadianceProperties
|
|
581
|
+
face.properties.energy -> FaceEnergyProperties
|
|
582
|
+
"""
|
|
583
|
+
|
|
584
|
+
def to_dict(self, abridged=False, include=None):
|
|
585
|
+
"""Convert properties to dictionary.
|
|
586
|
+
|
|
587
|
+
Args:
|
|
588
|
+
abridged: Boolean to note whether the full dictionary describing the
|
|
589
|
+
object should be returned (False) or just an abridged version (True).
|
|
590
|
+
Default: False.
|
|
591
|
+
include: A list of keys to be included in dictionary besides Face type
|
|
592
|
+
and boundary_condition. If None all the available keys will be included.
|
|
593
|
+
"""
|
|
594
|
+
base = {'type': 'FaceProperties'} if not abridged else \
|
|
595
|
+
{'type': 'FacePropertiesAbridged'}
|
|
596
|
+
base = self._add_extension_attr_to_dict(base, abridged, include)
|
|
597
|
+
return base
|
|
598
|
+
|
|
599
|
+
def add_prefix(self, prefix):
|
|
600
|
+
"""Change the identifier extension attributes unique to this object by adding a prefix.
|
|
601
|
+
|
|
602
|
+
Notably, this method only adds the prefix to extension attributes that must
|
|
603
|
+
be unique to the Face and does not add the prefix to attributes that are
|
|
604
|
+
shared across several Faces.
|
|
605
|
+
|
|
606
|
+
Args:
|
|
607
|
+
prefix: Text that will be inserted at the start of extension attribute identifiers.
|
|
608
|
+
"""
|
|
609
|
+
self._add_prefix_extension_attr(prefix)
|
|
610
|
+
|
|
611
|
+
def reset_to_default(self):
|
|
612
|
+
"""Reset the extension properties assigned at the level of this Face to default.
|
|
613
|
+
|
|
614
|
+
This typically means erasing any Constructions or Modifiers assigned to this
|
|
615
|
+
Face (having them instead assigned by ConstructionSets and ModifierSets).
|
|
616
|
+
"""
|
|
617
|
+
self._reset_extension_attr_to_default()
|
|
618
|
+
|
|
619
|
+
def __repr__(self):
|
|
620
|
+
"""Properties representation."""
|
|
621
|
+
return 'FaceProperties: {}'.format(self.host.display_name)
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
class ApertureProperties(_Properties):
|
|
625
|
+
"""Honeybee Aperture Properties.
|
|
626
|
+
|
|
627
|
+
This class will be extended by extensions.
|
|
628
|
+
|
|
629
|
+
Usage:
|
|
630
|
+
|
|
631
|
+
.. code-block:: python
|
|
632
|
+
|
|
633
|
+
aperture = Aperture('Window to My Soul', geometry)
|
|
634
|
+
aperture.properties -> ApertureProperties
|
|
635
|
+
aperture.properties.radiance -> ApertureRadianceProperties
|
|
636
|
+
aperture.properties.energy -> ApertureEnergyProperties
|
|
637
|
+
"""
|
|
638
|
+
|
|
639
|
+
def to_dict(self, abridged=False, include=None):
|
|
640
|
+
"""Convert properties to dictionary.
|
|
641
|
+
|
|
642
|
+
Args:
|
|
643
|
+
abridged: Boolean to note whether the full dictionary describing the
|
|
644
|
+
object should be returned (False) or just an abridged version (True).
|
|
645
|
+
Default: False.
|
|
646
|
+
include: A list of keys to be included in dictionary.
|
|
647
|
+
If None all the available keys will be included.
|
|
648
|
+
"""
|
|
649
|
+
base = {'type': 'ApertureProperties'} if not abridged else \
|
|
650
|
+
{'type': 'AperturePropertiesAbridged'}
|
|
651
|
+
|
|
652
|
+
base = self._add_extension_attr_to_dict(base, abridged, include)
|
|
653
|
+
return base
|
|
654
|
+
|
|
655
|
+
def add_prefix(self, prefix):
|
|
656
|
+
"""Change the identifier extension attributes unique to this object by adding a prefix.
|
|
657
|
+
|
|
658
|
+
Notably, this method only adds the prefix to extension attributes that must
|
|
659
|
+
be unique to the Aperture and does not add the prefix to attributes that are
|
|
660
|
+
shared across several Apertures.
|
|
661
|
+
|
|
662
|
+
Args:
|
|
663
|
+
prefix: Text that will be inserted at the start of extension attribute identifiers.
|
|
664
|
+
"""
|
|
665
|
+
self._add_prefix_extension_attr(prefix)
|
|
666
|
+
|
|
667
|
+
def reset_to_default(self):
|
|
668
|
+
"""Reset the extension properties assigned to this Aperture to default.
|
|
669
|
+
|
|
670
|
+
This typically means erasing any Constructions or Modifiers assigned to this
|
|
671
|
+
Aperture (having them instead assigned by ConstructionSets and ModifierSets).
|
|
672
|
+
"""
|
|
673
|
+
self._reset_extension_attr_to_default()
|
|
674
|
+
|
|
675
|
+
def __repr__(self):
|
|
676
|
+
"""Properties representation."""
|
|
677
|
+
return 'ApertureProperties: {}'.format(self.host.display_name)
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
class DoorProperties(_Properties):
|
|
681
|
+
"""Honeybee Door Properties.
|
|
682
|
+
|
|
683
|
+
This class will be extended by extensions.
|
|
684
|
+
|
|
685
|
+
Usage:
|
|
686
|
+
|
|
687
|
+
.. code-block:: python
|
|
688
|
+
|
|
689
|
+
door = Door('Front Door', geometry)
|
|
690
|
+
door.properties -> DoorProperties
|
|
691
|
+
door.properties.radiance -> DoorRadianceProperties
|
|
692
|
+
door.properties.energy -> DoorEnergyProperties
|
|
693
|
+
"""
|
|
694
|
+
|
|
695
|
+
def to_dict(self, abridged=False, include=None):
|
|
696
|
+
"""Convert properties to dictionary.
|
|
697
|
+
|
|
698
|
+
Args:
|
|
699
|
+
abridged: Boolean to note whether the full dictionary describing the
|
|
700
|
+
object should be returned (False) or just an abridged version (True).
|
|
701
|
+
Default: False.
|
|
702
|
+
include: A list of keys to be included in dictionary.
|
|
703
|
+
If None all the available keys will be included.
|
|
704
|
+
"""
|
|
705
|
+
base = {'type': 'DoorProperties'} if not abridged else \
|
|
706
|
+
{'type': 'DoorPropertiesAbridged'}
|
|
707
|
+
|
|
708
|
+
base = self._add_extension_attr_to_dict(base, abridged, include)
|
|
709
|
+
return base
|
|
710
|
+
|
|
711
|
+
def add_prefix(self, prefix):
|
|
712
|
+
"""Change the identifier extension attributes unique to this object by adding a prefix.
|
|
713
|
+
|
|
714
|
+
Notably, this method only adds the prefix to extension attributes that must
|
|
715
|
+
be unique to the Door and does not add the prefix to attributes that are
|
|
716
|
+
shared across several Doors.
|
|
717
|
+
|
|
718
|
+
Args:
|
|
719
|
+
prefix: Text that will be inserted at the start of extension attribute identifiers.
|
|
720
|
+
"""
|
|
721
|
+
self._add_prefix_extension_attr(prefix)
|
|
722
|
+
|
|
723
|
+
def reset_to_default(self):
|
|
724
|
+
"""Reset the extension properties assigned to this Door to default.
|
|
725
|
+
|
|
726
|
+
This typically means erasing any Constructions or Modifiers assigned to this
|
|
727
|
+
Door (having them instead assigned by ConstructionSets and ModifierSets).
|
|
728
|
+
"""
|
|
729
|
+
self._reset_extension_attr_to_default()
|
|
730
|
+
|
|
731
|
+
def __repr__(self):
|
|
732
|
+
"""Properties representation."""
|
|
733
|
+
return 'DoorProperties: {}'.format(self.host.display_name)
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
class ShadeProperties(_Properties):
|
|
737
|
+
"""Honeybee Shade Properties.
|
|
738
|
+
|
|
739
|
+
This class will be extended by extensions.
|
|
740
|
+
|
|
741
|
+
Usage:
|
|
742
|
+
|
|
743
|
+
.. code-block:: python
|
|
744
|
+
|
|
745
|
+
shade = Shade('Deep Overhang', geometry)
|
|
746
|
+
shade.properties -> ShadeProperties
|
|
747
|
+
shade.properties.radiance -> ShadeRadianceProperties
|
|
748
|
+
shade.properties.energy -> ShadeEnergyProperties
|
|
749
|
+
"""
|
|
750
|
+
|
|
751
|
+
def to_dict(self, abridged=False, include=None):
|
|
752
|
+
"""Convert properties to dictionary.
|
|
753
|
+
|
|
754
|
+
Args:
|
|
755
|
+
abridged: Boolean to note whether the full dictionary describing the
|
|
756
|
+
object should be returned (False) or just an abridged version (True).
|
|
757
|
+
Default: False.
|
|
758
|
+
include: A list of keys to be included in dictionary.
|
|
759
|
+
If None all the available keys will be included.
|
|
760
|
+
"""
|
|
761
|
+
base = {'type': 'ShadeProperties'} if not abridged else \
|
|
762
|
+
{'type': 'ShadePropertiesAbridged'}
|
|
763
|
+
|
|
764
|
+
base = self._add_extension_attr_to_dict(base, abridged, include)
|
|
765
|
+
return base
|
|
766
|
+
|
|
767
|
+
def add_prefix(self, prefix):
|
|
768
|
+
"""Change the identifier extension attributes unique to this object by adding a prefix.
|
|
769
|
+
|
|
770
|
+
Notably, this method only adds the prefix to extension attributes that must
|
|
771
|
+
be unique to the Shade and does not add the prefix to attributes that are
|
|
772
|
+
shared across several Shades.
|
|
773
|
+
|
|
774
|
+
Args:
|
|
775
|
+
prefix: Text that will be inserted at the start of extension attribute identifiers.
|
|
776
|
+
"""
|
|
777
|
+
self._add_prefix_extension_attr(prefix)
|
|
778
|
+
|
|
779
|
+
def reset_to_default(self):
|
|
780
|
+
"""Reset the extension properties assigned at the level of this Shade to default.
|
|
781
|
+
|
|
782
|
+
This typically means erasing any Constructions or Modifiers assigned to this
|
|
783
|
+
Shade (having them instead assigned by ConstructionSets and ModifierSets).
|
|
784
|
+
"""
|
|
785
|
+
self._reset_extension_attr_to_default()
|
|
786
|
+
|
|
787
|
+
def __repr__(self):
|
|
788
|
+
"""Properties representation."""
|
|
789
|
+
return 'ShadeProperties: {}'.format(self.host.display_name)
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
class ShadeMeshProperties(_Properties):
|
|
793
|
+
"""Honeybee ShadeMesh Properties.
|
|
794
|
+
|
|
795
|
+
This class will be extended by extensions.
|
|
796
|
+
|
|
797
|
+
Usage:
|
|
798
|
+
|
|
799
|
+
.. code-block:: python
|
|
800
|
+
|
|
801
|
+
shade = ShadeMesh('Hilly Terrain', geometry)
|
|
802
|
+
shade.properties -> ShadeMeshProperties
|
|
803
|
+
shade.properties.radiance -> ShadeMeshRadianceProperties
|
|
804
|
+
shade.properties.energy -> ShadeMeshEnergyProperties
|
|
805
|
+
"""
|
|
806
|
+
|
|
807
|
+
def to_dict(self, abridged=False, include=None):
|
|
808
|
+
"""Convert properties to dictionary.
|
|
809
|
+
|
|
810
|
+
Args:
|
|
811
|
+
abridged: Boolean to note whether the full dictionary describing the
|
|
812
|
+
object should be returned (False) or just an abridged version (True).
|
|
813
|
+
Default: False.
|
|
814
|
+
include: A list of keys to be included in dictionary.
|
|
815
|
+
If None all the available keys will be included.
|
|
816
|
+
"""
|
|
817
|
+
base = {'type': 'ShadeMeshProperties'} if not abridged else \
|
|
818
|
+
{'type': 'ShadeMeshPropertiesAbridged'}
|
|
819
|
+
|
|
820
|
+
base = self._add_extension_attr_to_dict(base, abridged, include)
|
|
821
|
+
return base
|
|
822
|
+
|
|
823
|
+
def add_prefix(self, prefix):
|
|
824
|
+
"""Change the identifier extension attributes unique to this object by adding a prefix.
|
|
825
|
+
|
|
826
|
+
Notably, this method only adds the prefix to extension attributes that must
|
|
827
|
+
be unique to the ShadeMesh and does not add the prefix to attributes that are
|
|
828
|
+
shared across several ShadeMeshes (eg. modifier).
|
|
829
|
+
|
|
830
|
+
Args:
|
|
831
|
+
prefix: Text that will be inserted at the start of extension attribute identifiers.
|
|
832
|
+
"""
|
|
833
|
+
self._add_prefix_extension_attr(prefix)
|
|
834
|
+
|
|
835
|
+
def reset_to_default(self):
|
|
836
|
+
"""Reset the extension properties assigned to this ShadeMesh to default.
|
|
837
|
+
|
|
838
|
+
This typically means erasing any Constructions or Modifiers assigned to this
|
|
839
|
+
ShadeMesh.
|
|
840
|
+
"""
|
|
841
|
+
self._reset_extension_attr_to_default()
|
|
842
|
+
|
|
843
|
+
def __repr__(self):
|
|
844
|
+
"""Properties representation."""
|
|
845
|
+
return 'ShadeMeshProperties: {}'.format(self.host.display_name)
|