dragonfly-radiance 0.3.284__tar.gz → 0.4.0__tar.gz
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 dragonfly-radiance might be problematic. Click here for more details.
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/PKG-INFO +1 -1
- dragonfly_radiance-0.4.0/dragonfly_radiance/cli/translate.py +334 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/model.py +117 -8
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/PKG-INFO +1 -1
- dragonfly_radiance-0.3.284/dragonfly_radiance/cli/translate.py +0 -77
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/CODE_OF_CONDUCT.md +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/CONTRIBUTING.md +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/LICENSE +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/MANIFEST.in +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/README.md +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dev-requirements.txt +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/__init__.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/__main__.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/_extend_dragonfly.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/cli/__init__.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/gridpar.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/__init__.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/building.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/context.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/room2d.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/story.py +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/SOURCES.txt +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/dependency_links.txt +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/entry_points.txt +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/requires.txt +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/top_level.txt +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/requirements.txt +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/setup.cfg +0 -0
- {dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/setup.py +0 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"""dragonfly radiance translation commands."""
|
|
2
|
+
import click
|
|
3
|
+
import sys
|
|
4
|
+
import os
|
|
5
|
+
import logging
|
|
6
|
+
import zipfile
|
|
7
|
+
|
|
8
|
+
from ladybug.futil import unzip_file
|
|
9
|
+
from ladybug.commandutil import process_content_to_output
|
|
10
|
+
from dragonfly.model import Model
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
_logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@click.group(help='Commands for translating Dragonfly files to/from Radiance.')
|
|
17
|
+
def translate():
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@translate.command('model-to-rad-folder')
|
|
22
|
+
@click.argument('model-file', type=click.Path(
|
|
23
|
+
exists=True, file_okay=True, dir_okay=False, resolve_path=True))
|
|
24
|
+
@click.option(
|
|
25
|
+
'--multiplier/--full-geometry', ' /-fg', help='Flag to note if the '
|
|
26
|
+
'multipliers on each Building story will be passed along to the '
|
|
27
|
+
'generated Honeybee Room objects or if full geometry objects should be '
|
|
28
|
+
'written for each story in the building.', default=True, show_default=True
|
|
29
|
+
)
|
|
30
|
+
@click.option(
|
|
31
|
+
'--plenum/--no-plenum', '-p/-np', help='Flag to indicate whether '
|
|
32
|
+
'ceiling/floor plenum depths assigned to Room2Ds should generate '
|
|
33
|
+
'distinct 3D Rooms in the translation.', default=True, show_default=True
|
|
34
|
+
)
|
|
35
|
+
@click.option(
|
|
36
|
+
'--no-ceil-adjacency/--ceil-adjacency', ' /-a', help='Flag to indicate '
|
|
37
|
+
'whether adjacencies should be solved between interior stories when '
|
|
38
|
+
'Room2Ds perfectly match one another in their floor plate. This ensures '
|
|
39
|
+
'that Surface boundary conditions are used instead of Adiabatic ones. '
|
|
40
|
+
'Note that this input has no effect when the object-per-model is Story.',
|
|
41
|
+
default=True, show_default=True
|
|
42
|
+
)
|
|
43
|
+
@click.option(
|
|
44
|
+
'--folder', help='Folder into which the model Radiance '
|
|
45
|
+
'folders will be written. If None, the files will be output in the '
|
|
46
|
+
'same location as the model_file.', default=None, show_default=True
|
|
47
|
+
)
|
|
48
|
+
@click.option(
|
|
49
|
+
'--grid', '-g', multiple=True, help='List of grids to be included in folder. By '
|
|
50
|
+
'default all the sensor grids will be exported. You can also use wildcards here. '
|
|
51
|
+
'For instance first_floor_* will select all the sensor grids that has an identifier '
|
|
52
|
+
'that starts with first_floor. To filter based on group_identifier use /. For '
|
|
53
|
+
'example daylight/* will select all the grids that belong to daylight group.')
|
|
54
|
+
@click.option(
|
|
55
|
+
'--view', '-v', multiple=True, help='List of views to be included in folder. By '
|
|
56
|
+
'default all the views will be exported. You can also use wildcards to filter '
|
|
57
|
+
'multiple views. For instance first_floor_* will select all the views that has an '
|
|
58
|
+
'identifier that starts with first_floor. To filter based on group_identifier use '
|
|
59
|
+
'/. For example daylight/* will select all the views that belong to daylight group.')
|
|
60
|
+
@click.option(
|
|
61
|
+
'--full-match/--no-full-match', help='Flag to note whether the grids and'
|
|
62
|
+
'views should be filtered by their identifiers as full matches. Setting '
|
|
63
|
+
'this to True indicates that wildcard symbols will not be used in the '
|
|
64
|
+
'filtering of grids and views.', default=False, show_default=True)
|
|
65
|
+
@click.option(
|
|
66
|
+
'--config-file', '-c', help='An optional config file path to modify the '
|
|
67
|
+
'default folder names. If None, folder.cfg in honeybee-radiance-folder '
|
|
68
|
+
'will be used.', default=None, show_default=True)
|
|
69
|
+
@click.option(
|
|
70
|
+
'--minimal/--maximal', '-min/-max', help='Flag to note whether the radiance strings '
|
|
71
|
+
'should be written in a minimal format (with spaces instead of line '
|
|
72
|
+
'breaks).', default=False, show_default=True)
|
|
73
|
+
@click.option(
|
|
74
|
+
'--no-grid-check/--grid-check', ' /-gc', help='Flag to note whether the '
|
|
75
|
+
'model should be checked for the presence of sensor grids. If the check '
|
|
76
|
+
'is set and the model has no grids, an explicit error will be raised.',
|
|
77
|
+
default=True, show_default=True)
|
|
78
|
+
@click.option(
|
|
79
|
+
'--no-view-check/--view-check', ' /-vc', help='Flag to note whether the '
|
|
80
|
+
'model should be checked for the presence of views. If the check '
|
|
81
|
+
'is set and the model has no views, an explicit error will be raised.',
|
|
82
|
+
default=True, show_default=True)
|
|
83
|
+
@click.option(
|
|
84
|
+
'--create-grids', '-cg', default=False, show_default=True, is_flag=True,
|
|
85
|
+
help='Flag to note whether sensor grids should be created if none exists. '
|
|
86
|
+
'This will only create sensor grids for rooms if there are no sensor grids '
|
|
87
|
+
'in the model.'
|
|
88
|
+
)
|
|
89
|
+
@click.option(
|
|
90
|
+
'--log-file', help='Optional log file to output the path of the radiance '
|
|
91
|
+
'folder generated from the model. By default this will be printed '
|
|
92
|
+
'to stdout', type=click.File('w'), default='-')
|
|
93
|
+
def model_to_rad_folder_cli(
|
|
94
|
+
model_file, multiplier, plenum, no_ceil_adjacency,
|
|
95
|
+
folder, view, grid, full_match, config_file, minimal,
|
|
96
|
+
no_grid_check, no_view_check, create_grids, log_file
|
|
97
|
+
):
|
|
98
|
+
"""Translate a Model file into a Radiance Folder.
|
|
99
|
+
|
|
100
|
+
\b
|
|
101
|
+
Args:
|
|
102
|
+
model_file: Full path to a Model JSON file (HBJSON) or a Model
|
|
103
|
+
pkl (HBpkl) file. This can also be a zipped version of a Radiance
|
|
104
|
+
folder, in which case this command will simply unzip the file
|
|
105
|
+
into the --folder and no other operations will be performed on it.
|
|
106
|
+
"""
|
|
107
|
+
try:
|
|
108
|
+
full_geometry = not multiplier
|
|
109
|
+
no_plenum = not plenum
|
|
110
|
+
ceil_adjacency = not no_ceil_adjacency
|
|
111
|
+
grid_check = not no_grid_check
|
|
112
|
+
view_check = not no_view_check
|
|
113
|
+
model_to_rad_folder(
|
|
114
|
+
model_file, full_geometry, no_plenum, ceil_adjacency,
|
|
115
|
+
folder, view, grid, full_match, config_file,
|
|
116
|
+
minimal, grid_check, view_check, create_grids, log_file)
|
|
117
|
+
except Exception as e:
|
|
118
|
+
_logger.exception('Model translation failed.\n{}'.format(e))
|
|
119
|
+
sys.exit(1)
|
|
120
|
+
else:
|
|
121
|
+
sys.exit(0)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def model_to_rad_folder(
|
|
125
|
+
model_file, full_geometry=False, no_plenum=False, ceil_adjacency=False,
|
|
126
|
+
folder=None, view=None, grid=None, full_match=False, config_file=None,
|
|
127
|
+
minimal=False, grid_check=False, view_check=False, create_grids=False, log_file=None,
|
|
128
|
+
multiplier=True, plenum=True, no_ceil_adjacency=True,
|
|
129
|
+
no_full_match=True, maximal=True, no_grid_check=False, no_view_check=False,
|
|
130
|
+
):
|
|
131
|
+
"""Translate a Model file into a Radiance Folder.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
model_file: Full path to a Model JSON file (HBJSON) or a Model
|
|
135
|
+
pkl (HBpkl) file. This can also be a zipped version of a Radiance
|
|
136
|
+
folder, in which case this command will simply unzip the file
|
|
137
|
+
into the --folder and no other operations will be performed on it.
|
|
138
|
+
folder: Folder into which the model Radiance folders will be written.
|
|
139
|
+
If None, the files will be output in the same location as the model_file.
|
|
140
|
+
view: List of grids to be included in folder. By default all the sensor
|
|
141
|
+
grids will be exported. You can also use wildcards here. For instance
|
|
142
|
+
first_floor_* will select all the sensor grids that has an identifier
|
|
143
|
+
that starts with first_floor. To filter based on group_identifier
|
|
144
|
+
use /. For example daylight/* will select all the grids that belong
|
|
145
|
+
to daylight group. (Default: None).
|
|
146
|
+
grid: List of views to be included in folder. By default all the views
|
|
147
|
+
will be exported. You can also use wildcards to filter multiple views.
|
|
148
|
+
For instance first_floor_* will select all the views that has an
|
|
149
|
+
identifier that starts with first_floor. To filter based on
|
|
150
|
+
group_identifier use /. For example daylight/* will select all the
|
|
151
|
+
views that belong to daylight group. (Default: None).
|
|
152
|
+
full_match: Boolean to note whether the grids and views should be
|
|
153
|
+
filtered by their identifiers as full matches. Setting this to
|
|
154
|
+
True indicates that wildcard symbols will not be used in the
|
|
155
|
+
filtering of grids and views. (Default: False).
|
|
156
|
+
config_file: An optional config file path to modify the default folder
|
|
157
|
+
names. If None, folder.cfg in honeybee-radiance-folder will be used.
|
|
158
|
+
minimal: Boolean to note whether the radiance strings should be written
|
|
159
|
+
in a minimal format (with spaces instead of line breaks). (Default: False).
|
|
160
|
+
grid_check: Boolean to note whether the model should be checked for the
|
|
161
|
+
presence of sensor grids. If the check is set and the model has no
|
|
162
|
+
grids, an explicit error will be raised. (Default: False).
|
|
163
|
+
view_check: Boolean to note whether the model should be checked for the
|
|
164
|
+
presence of views. If the check is set and the model has no views,
|
|
165
|
+
an explicit error will be raised. (Default: False).
|
|
166
|
+
log_file: Optional log file to output the path of the radiance folder
|
|
167
|
+
generated from the model. If None, it will be returned from this method.
|
|
168
|
+
"""
|
|
169
|
+
# set the default folder if it's not specified
|
|
170
|
+
if folder is None:
|
|
171
|
+
folder = os.path.dirname(os.path.abspath(model_file))
|
|
172
|
+
|
|
173
|
+
# first check to see if the model_file is a zipped radiance folder
|
|
174
|
+
if zipfile.is_zipfile(model_file):
|
|
175
|
+
unzip_file(model_file, folder)
|
|
176
|
+
if log_file is None:
|
|
177
|
+
return folder
|
|
178
|
+
else:
|
|
179
|
+
log_file.write(folder)
|
|
180
|
+
else:
|
|
181
|
+
# re-serialize the Dragonfly Model
|
|
182
|
+
model = Model.from_file(model_file)
|
|
183
|
+
|
|
184
|
+
# convert Dragonfly Model to Honeybee
|
|
185
|
+
multiplier = not full_geometry
|
|
186
|
+
hb_models = model.to_honeybee(
|
|
187
|
+
object_per_model='District', use_multiplier=multiplier,
|
|
188
|
+
exclude_plenums=no_plenum, solve_ceiling_adjacencies=ceil_adjacency)
|
|
189
|
+
model = hb_models[0]
|
|
190
|
+
|
|
191
|
+
if create_grids:
|
|
192
|
+
if not model.properties.radiance.has_sensor_grids:
|
|
193
|
+
sensor_grids = []
|
|
194
|
+
|
|
195
|
+
unit_conversion = {
|
|
196
|
+
'Meters': 1,
|
|
197
|
+
'Millimeters': 0.001,
|
|
198
|
+
'Centimeters': 0.01,
|
|
199
|
+
'Feet': 0.3048,
|
|
200
|
+
'Inches': 0.0254
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if model.units in ['Meters', 'Millimeters', 'Centimeters']:
|
|
204
|
+
grid_size = 0.5 / unit_conversion[model.units]
|
|
205
|
+
offset = 0.76 / unit_conversion[model.units]
|
|
206
|
+
wall_offset = 0.3 / unit_conversion[model.units]
|
|
207
|
+
else: # assume IP units
|
|
208
|
+
grid_size = 2 * 0.3048 / unit_conversion[model.units]
|
|
209
|
+
offset = 2.5 * 0.3048 / unit_conversion[model.units]
|
|
210
|
+
wall_offset = 1 * 0.3048 / unit_conversion[model.units]
|
|
211
|
+
|
|
212
|
+
for room in model.rooms:
|
|
213
|
+
sensor_grids.append(room.properties.radiance.generate_sensor_grid(
|
|
214
|
+
grid_size, offset=offset, wall_offset=wall_offset))
|
|
215
|
+
model.properties.radiance.sensor_grids = sensor_grids
|
|
216
|
+
|
|
217
|
+
if grid_check and len(model.properties.radiance.sensor_grids) == 0:
|
|
218
|
+
raise ValueError('Model contains no sensor grids. These are required.')
|
|
219
|
+
if view_check and len(model.properties.radiance.views) == 0:
|
|
220
|
+
raise ValueError('Model contains no views These are required.')
|
|
221
|
+
|
|
222
|
+
# translate the model to a radiance folder
|
|
223
|
+
rad_fold = model.to.rad_folder(
|
|
224
|
+
model, folder, config_file, minimal, views=view, grids=grid,
|
|
225
|
+
full_match=full_match
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
if log_file is None:
|
|
229
|
+
return rad_fold
|
|
230
|
+
else:
|
|
231
|
+
log_file.write(rad_fold)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
@translate.command('model-to-rad')
|
|
235
|
+
@click.argument('model-file', type=click.Path(
|
|
236
|
+
exists=True, file_okay=True, dir_okay=False, resolve_path=True))
|
|
237
|
+
@click.option('--multiplier/--full-geometry', ' /-fg', help='Flag to note if the '
|
|
238
|
+
'multipliers on each Building story will be passed along to the '
|
|
239
|
+
'generated Honeybee Room objects or if full geometry objects should be '
|
|
240
|
+
'written for each story in the building.', default=True, show_default=True)
|
|
241
|
+
@click.option('--plenum/--no-plenum', '-p/-np', help='Flag to indicate whether '
|
|
242
|
+
'ceiling/floor plenum depths assigned to Room2Ds should generate '
|
|
243
|
+
'distinct 3D Rooms in the translation.', default=True, show_default=True)
|
|
244
|
+
@click.option('--no-ceil-adjacency/--ceil-adjacency', ' /-a', help='Flag to indicate '
|
|
245
|
+
'whether adjacencies should be solved between interior stories when '
|
|
246
|
+
'Room2Ds perfectly match one another in their floor plate. This ensures '
|
|
247
|
+
'that Surface boundary conditions are used instead of Adiabatic ones. '
|
|
248
|
+
'Note that this input has no effect when the object-per-model is Story.',
|
|
249
|
+
default=True, show_default=True)
|
|
250
|
+
@click.option('--blk', help='Boolean to note whether the "blacked out" version '
|
|
251
|
+
'of the geometry should be output, which is useful for direct studies '
|
|
252
|
+
'and isolation studies of individual apertures.',
|
|
253
|
+
default=False, show_default=True)
|
|
254
|
+
@click.option('--minimal/--maximal', help='Flag to note whether the radiance strings '
|
|
255
|
+
'should be written in a minimal format (with spaces instead of line '
|
|
256
|
+
'breaks).', default=False, show_default=True)
|
|
257
|
+
@click.option('--output-file', '-f', help='Optional Rad file to output the Rad string '
|
|
258
|
+
'of the translation. By default this will be printed out to stdout',
|
|
259
|
+
type=click.File('w'), default='-', show_default=True)
|
|
260
|
+
def model_to_rad_cli(model_file, multiplier, plenum, no_ceil_adjacency,
|
|
261
|
+
blk, minimal, output_file):
|
|
262
|
+
"""Translate a Dragonfly Model file to a Radiance string.
|
|
263
|
+
|
|
264
|
+
The resulting string will include all geometry and all modifiers.
|
|
265
|
+
|
|
266
|
+
\b
|
|
267
|
+
Args:
|
|
268
|
+
model_file: Full path to a Dragonfly Model JSON or Pkl file.
|
|
269
|
+
"""
|
|
270
|
+
try:
|
|
271
|
+
full_geometry = not multiplier
|
|
272
|
+
no_plenum = not plenum
|
|
273
|
+
ceil_adjacency = not no_ceil_adjacency
|
|
274
|
+
model_to_rad(model_file, full_geometry, no_plenum, ceil_adjacency,
|
|
275
|
+
blk, minimal, output_file)
|
|
276
|
+
except Exception as e:
|
|
277
|
+
_logger.exception('Model translation failed.\n{}\n'.format(e))
|
|
278
|
+
sys.exit(1)
|
|
279
|
+
else:
|
|
280
|
+
sys.exit(0)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def model_to_rad(
|
|
284
|
+
model_file, full_geometry=False, no_plenum=False, ceil_adjacency=False,
|
|
285
|
+
blk=False, minimal=False, output_file=None,
|
|
286
|
+
multiplier=True, plenum=True, no_ceil_adjacency=True, maximal=True
|
|
287
|
+
):
|
|
288
|
+
"""Translate a Model file to a Radiance string.
|
|
289
|
+
|
|
290
|
+
The resulting strings will include all geometry (Rooms, Faces, Shades, Apertures,
|
|
291
|
+
Doors) and all modifiers. However, it does not include any states for dynamic
|
|
292
|
+
geometry and will only write the default state for each dynamic object. To
|
|
293
|
+
correctly account for dynamic objects, model-to-rad-folder should be used.
|
|
294
|
+
|
|
295
|
+
Args:
|
|
296
|
+
model_file: Full path to a Model JSON file (HBJSON) or a Model pkl (HBpkl) file.
|
|
297
|
+
full_geometry: Boolean to note if the multipliers on each Building story
|
|
298
|
+
will be passed along to the generated Honeybee Room objects or if
|
|
299
|
+
full geometry objects should be written for each story in the
|
|
300
|
+
building. (Default: False).
|
|
301
|
+
no_plenum: Boolean to indicate whether ceiling/floor plenum depths
|
|
302
|
+
assigned to Room2Ds should generate distinct 3D Rooms in the
|
|
303
|
+
translation. (Default: False).
|
|
304
|
+
ceil_adjacency: Boolean to indicate whether adjacencies should be solved
|
|
305
|
+
between interior stories when Room2Ds perfectly match one another
|
|
306
|
+
in their floor plate. This ensures that Surface boundary conditions
|
|
307
|
+
are used instead of Adiabatic ones. Note that this input has no
|
|
308
|
+
effect when the object-per-model is Story. (Default: False).
|
|
309
|
+
blk: Boolean to note whether the "blacked out" version of the geometry
|
|
310
|
+
should be output, which is useful for direct studies and isolation
|
|
311
|
+
studies of individual apertures.
|
|
312
|
+
minimal: Boolean to note whether the radiance strings should be written
|
|
313
|
+
in a minimal format (with spaces instead of line breaks).
|
|
314
|
+
output_file: Optional RAD file to output the RAD string of the translation.
|
|
315
|
+
If None, the string will be returned from this method. (Default: None).
|
|
316
|
+
"""
|
|
317
|
+
# re-serialize the Dragonfly Model
|
|
318
|
+
model = Model.from_file(model_file)
|
|
319
|
+
|
|
320
|
+
# convert Dragonfly Model to Honeybee
|
|
321
|
+
multiplier = not full_geometry
|
|
322
|
+
hb_models = model.to_honeybee(
|
|
323
|
+
object_per_model='District', use_multiplier=multiplier,
|
|
324
|
+
exclude_plenums=no_plenum, solve_ceiling_adjacencies=ceil_adjacency)
|
|
325
|
+
hb_model = hb_models[0]
|
|
326
|
+
|
|
327
|
+
# create the strings for modifiers and geometry
|
|
328
|
+
model_str, modifier_str = hb_model.to.rad(hb_model, blk, minimal)
|
|
329
|
+
rad_str_list = ['# ======== MODEL MODIFIERS ========', modifier_str,
|
|
330
|
+
'# ======== MODEL GEOMETRY ========', model_str]
|
|
331
|
+
rad_str = '\n\n'.join(rad_str_list)
|
|
332
|
+
|
|
333
|
+
# write out the rad string
|
|
334
|
+
return process_content_to_output(rad_str, output_file)
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/model.py
RENAMED
|
@@ -105,21 +105,70 @@ class ModelRadianceProperties(object):
|
|
|
105
105
|
"""
|
|
106
106
|
return generic_modifier_set_visible
|
|
107
107
|
|
|
108
|
-
def
|
|
108
|
+
def check_for_extension(self, raise_exception=True, detailed=False):
|
|
109
|
+
"""Check that the Model is valid for Radiance simulation.
|
|
110
|
+
|
|
111
|
+
This process includes all relevant dragonfly-core checks as well as checks
|
|
112
|
+
that apply only for Radiance.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
raise_exception: Boolean to note whether a ValueError should be raised
|
|
116
|
+
if any errors are found. If False, this method will simply
|
|
117
|
+
return a text string with all errors that were found. (Default: True).
|
|
118
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
119
|
+
dicts with error info or a string with a message. (Default: False).
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
A text string with all errors that were found or a list if detailed is True.
|
|
123
|
+
This string (or list) will be empty if no errors were found.
|
|
124
|
+
"""
|
|
125
|
+
# set up defaults to ensure the method runs correctly
|
|
126
|
+
detailed = False if raise_exception else detailed
|
|
127
|
+
msgs = []
|
|
128
|
+
tol = self.host.tolerance
|
|
129
|
+
ang_tol = self.host.angle_tolerance
|
|
130
|
+
|
|
131
|
+
# perform checks for duplicate identifiers, which might mess with other checks
|
|
132
|
+
msgs.append(self.host.check_all_duplicate_identifiers(False, detailed))
|
|
133
|
+
|
|
134
|
+
# perform checks for key dragonfly model schema rules
|
|
135
|
+
msgs.append(self.host.check_degenerate_room_2ds(tol, False, detailed))
|
|
136
|
+
msgs.append(self.host.check_self_intersecting_room_2ds(tol, False, detailed))
|
|
137
|
+
msgs.append(self.host.check_plenum_depths(tol, False, detailed))
|
|
138
|
+
msgs.append(self.host.check_window_parameters_valid(tol, False, detailed))
|
|
139
|
+
msgs.append(self.host.check_no_room2d_overlaps(tol, False, detailed))
|
|
140
|
+
msgs.append(self.host.check_collisions_between_stories(tol, False, detailed))
|
|
141
|
+
msgs.append(self.host.check_roofs_above_rooms(tol, False, detailed))
|
|
142
|
+
msgs.append(self.host.check_room2d_floor_heights_valid(False, detailed))
|
|
143
|
+
msgs.append(self.host.check_all_room3d(tol, ang_tol, False, detailed))
|
|
144
|
+
|
|
145
|
+
# output a final report of errors or raise an exception
|
|
146
|
+
full_msgs = [msg for msg in msgs if msg]
|
|
147
|
+
if detailed:
|
|
148
|
+
return [m for msg in full_msgs for m in msg]
|
|
149
|
+
full_msg = '\n'.join(full_msgs)
|
|
150
|
+
if raise_exception and len(full_msgs) != 0:
|
|
151
|
+
raise ValueError(full_msg)
|
|
152
|
+
return full_msg
|
|
153
|
+
|
|
154
|
+
def check_all(self, raise_exception=True, detailed=False):
|
|
109
155
|
"""Check all of the aspects of the Model radiance properties.
|
|
110
156
|
|
|
111
157
|
Args:
|
|
112
158
|
raise_exception: Boolean to note whether a ValueError should be raised
|
|
113
159
|
if any errors are found. If False, this method will simply
|
|
114
160
|
return a text string with all errors that were found.
|
|
161
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
162
|
+
dicts with error info or a string with a message. (Default: False).
|
|
115
163
|
|
|
116
164
|
Returns:
|
|
117
|
-
A text string with all errors that were found
|
|
118
|
-
|
|
165
|
+
A text string with all errors that were found or a list if detailed is True.
|
|
166
|
+
This string (or list) will be empty if no errors were found.
|
|
119
167
|
"""
|
|
168
|
+
# set up defaults to ensure the method runs correctly
|
|
169
|
+
detailed = False if raise_exception else detailed
|
|
120
170
|
msgs = []
|
|
121
|
-
# perform checks for
|
|
122
|
-
msgs.append(self.check_duplicate_modifier_set_identifiers(False))
|
|
171
|
+
# perform checks for specific radiance simulation rules
|
|
123
172
|
# output a final report of errors or raise an exception
|
|
124
173
|
full_msgs = [msg for msg in msgs if msg != '']
|
|
125
174
|
full_msg = '\n'.join(full_msgs)
|
|
@@ -127,10 +176,70 @@ class ModelRadianceProperties(object):
|
|
|
127
176
|
raise ValueError(full_msg)
|
|
128
177
|
return full_msg
|
|
129
178
|
|
|
130
|
-
def
|
|
131
|
-
"""Check that there are no duplicate
|
|
179
|
+
def check_all_duplicate_identifiers(self, raise_exception=True, detailed=False):
|
|
180
|
+
"""Check that there are no duplicate identifiers for any geometry objects.
|
|
181
|
+
|
|
182
|
+
This includes Rooms, Faces, Apertures, Doors, Shades, and ShadeMeshes.
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
raise_exception: Boolean to note whether a ValueError should be raised
|
|
186
|
+
if any Model errors are found. If False, this method will simply
|
|
187
|
+
return a text string with all errors that were found. (Default: True).
|
|
188
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
189
|
+
dicts with error info or a string with a message. (Default: False).
|
|
190
|
+
|
|
191
|
+
Returns:
|
|
192
|
+
A text string with all errors that were found or a list if detailed is True.
|
|
193
|
+
This string (or list) will be empty if no errors were found.
|
|
194
|
+
"""
|
|
195
|
+
# set up defaults to ensure the method runs correctly
|
|
196
|
+
detailed = False if raise_exception else detailed
|
|
197
|
+
msgs = []
|
|
198
|
+
# perform checks for duplicate identifiers
|
|
199
|
+
msgs.append(self.check_duplicate_modifier_identifiers(False, detailed))
|
|
200
|
+
msgs.append(self.check_duplicate_modifier_set_identifiers(False, detailed))
|
|
201
|
+
# output a final report of errors or raise an exception
|
|
202
|
+
full_msgs = [msg for msg in msgs if msg]
|
|
203
|
+
if detailed:
|
|
204
|
+
return [m for msg in full_msgs for m in msg]
|
|
205
|
+
full_msg = '\n'.join(full_msgs)
|
|
206
|
+
if raise_exception and len(full_msgs) != 0:
|
|
207
|
+
raise ValueError(full_msg)
|
|
208
|
+
return full_msg
|
|
209
|
+
|
|
210
|
+
def check_duplicate_modifier_identifiers(self, raise_exception=True, detailed=False):
|
|
211
|
+
"""Check that there are no duplicate Modifier identifiers in the model.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
raise_exception: Boolean to note whether a ValueError should be raised
|
|
215
|
+
if duplicate identifiers are found. (Default: True).
|
|
216
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
217
|
+
dicts with error info or a string with a message. (Default: False).
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
A string with the message or a list with a dictionary if detailed is True.
|
|
221
|
+
"""
|
|
222
|
+
return check_duplicate_identifiers(
|
|
223
|
+
self.modifiers, raise_exception, 'Radiance Modifier',
|
|
224
|
+
detailed, '010001', 'Radiance', error_type='Duplicate Modifier Identifier')
|
|
225
|
+
|
|
226
|
+
def check_duplicate_modifier_set_identifiers(
|
|
227
|
+
self, raise_exception=True, detailed=False):
|
|
228
|
+
"""Check that there are no duplicate ModifierSet identifiers in the model.
|
|
229
|
+
|
|
230
|
+
Args:
|
|
231
|
+
raise_exception: Boolean to note whether a ValueError should be raised
|
|
232
|
+
if duplicate identifiers are found. (Default: True).
|
|
233
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
234
|
+
dicts with error info or a string with a message. (Default: False).
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
A string with the message or a list with a dictionary if detailed is True.
|
|
238
|
+
"""
|
|
132
239
|
return check_duplicate_identifiers(
|
|
133
|
-
self.modifier_sets, raise_exception, 'ModifierSet'
|
|
240
|
+
self.modifier_sets, raise_exception, 'ModifierSet',
|
|
241
|
+
detailed, '010002', 'Radiance',
|
|
242
|
+
error_type='Duplicate ModifierSet Identifier')
|
|
134
243
|
|
|
135
244
|
def apply_properties_from_dict(self, data):
|
|
136
245
|
"""Apply the radiance properties of a dictionary to the host Model of this object.
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"""dragonfly radiance translation commands."""
|
|
2
|
-
import click
|
|
3
|
-
import sys
|
|
4
|
-
import logging
|
|
5
|
-
|
|
6
|
-
from dragonfly.model import Model
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
_logger = logging.getLogger(__name__)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@click.group(help='Commands for translating Dragonfly files to/from Radiance.')
|
|
13
|
-
def translate():
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@translate.command('model-to-rad')
|
|
18
|
-
@click.argument('model-file', type=click.Path(
|
|
19
|
-
exists=True, file_okay=True, dir_okay=False, resolve_path=True))
|
|
20
|
-
@click.option('--multiplier/--full-geometry', ' /-fg', help='Flag to note if the '
|
|
21
|
-
'multipliers on each Building story will be passed along to the '
|
|
22
|
-
'generated Honeybee Room objects or if full geometry objects should be '
|
|
23
|
-
'written for each story in the building.', default=True, show_default=True)
|
|
24
|
-
@click.option('--plenum/--no-plenum', '-p/-np', help='Flag to indicate whether '
|
|
25
|
-
'ceiling/floor plenum depths assigned to Room2Ds should generate '
|
|
26
|
-
'distinct 3D Rooms in the translation.', default=True, show_default=True)
|
|
27
|
-
@click.option('--no-ceil-adjacency/--ceil-adjacency', ' /-a', help='Flag to indicate '
|
|
28
|
-
'whether adjacencies should be solved between interior stories when '
|
|
29
|
-
'Room2Ds perfectly match one another in their floor plate. This ensures '
|
|
30
|
-
'that Surface boundary conditions are used instead of Adiabatic ones. '
|
|
31
|
-
'Note that this input has no effect when the object-per-model is Story.',
|
|
32
|
-
default=True, show_default=True)
|
|
33
|
-
@click.option('--blk', help='Boolean to note whether the "blacked out" version '
|
|
34
|
-
'of the geometry should be output, which is useful for direct studies '
|
|
35
|
-
'and isolation studies of individual apertures.',
|
|
36
|
-
default=False, show_default=True)
|
|
37
|
-
@click.option('--minimal/--maximal', help='Flag to note whether the radiance strings '
|
|
38
|
-
'should be written in a minimal format (with spaces instead of line '
|
|
39
|
-
'breaks).', default=False, show_default=True)
|
|
40
|
-
@click.option('--output-file', '-f', help='Optional Rad file to output the Rad string '
|
|
41
|
-
'of the translation. By default this will be printed out to stdout',
|
|
42
|
-
type=click.File('w'), default='-', show_default=True)
|
|
43
|
-
def model_to_rad(model_file, multiplier, plenum, no_ceil_adjacency,
|
|
44
|
-
blk, minimal, output_file):
|
|
45
|
-
"""Translate a Dragonfly Model file to a Radiance string.
|
|
46
|
-
|
|
47
|
-
The resulting string will include all geometry and all modifiers.
|
|
48
|
-
|
|
49
|
-
\b
|
|
50
|
-
Args:
|
|
51
|
-
model_file: Full path to a Dragonfly Model JSON or Pkl file.
|
|
52
|
-
"""
|
|
53
|
-
try:
|
|
54
|
-
# re-serialize the Dragonfly Model
|
|
55
|
-
model = Model.from_file(model_file)
|
|
56
|
-
|
|
57
|
-
# convert Dragonfly Model to Honeybee
|
|
58
|
-
no_plenum = not plenum
|
|
59
|
-
ceil_adjacency = not no_ceil_adjacency
|
|
60
|
-
hb_models = model.to_honeybee(
|
|
61
|
-
object_per_model='District', use_multiplier=multiplier,
|
|
62
|
-
exclude_plenums=no_plenum, solve_ceiling_adjacencies=ceil_adjacency)
|
|
63
|
-
hb_model = hb_models[0]
|
|
64
|
-
|
|
65
|
-
# create the strings for modifiers and geometry
|
|
66
|
-
model_str, modifier_str = hb_model.to.rad(hb_model, blk, minimal)
|
|
67
|
-
rad_str_list = ['# ======== MODEL MODIFIERS ========', modifier_str,
|
|
68
|
-
'# ======== MODEL GEOMETRY ========', model_str]
|
|
69
|
-
rad_str = '\n\n'.join(rad_str_list)
|
|
70
|
-
|
|
71
|
-
# write out the Rad file
|
|
72
|
-
output_file.write(rad_str)
|
|
73
|
-
except Exception as e:
|
|
74
|
-
_logger.exception('Model translation failed.\n{}\n'.format(e))
|
|
75
|
-
sys.exit(1)
|
|
76
|
-
else:
|
|
77
|
-
sys.exit(0)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/_extend_dragonfly.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/__init__.py
RENAMED
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/building.py
RENAMED
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/context.py
RENAMED
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/room2d.py
RENAMED
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance/properties/story.py
RENAMED
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/requires.txt
RENAMED
|
File without changes
|
{dragonfly_radiance-0.3.284 → dragonfly_radiance-0.4.0}/dragonfly_radiance.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|