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,219 @@
1
+ """honeybee radiance ray-tracing command commands."""
2
+ import click
3
+ import sys
4
+ import logging
5
+ import os
6
+
7
+ from honeybee_radiance.config import folders
8
+ from honeybee_radiance_command.rtrace import Rtrace, RtraceOptions
9
+ from honeybee_radiance_command.rcalc import Rcalc
10
+
11
+ _logger = logging.getLogger(__name__)
12
+
13
+
14
+ @click.group(help='Commands to run ray-tracing in Radiance.')
15
+ def raytrace():
16
+ pass
17
+
18
+
19
+ @raytrace.command('rtrace')
20
+ @click.argument(
21
+ 'octree', type=click.Path(exists=True, file_okay=True, resolve_path=True)
22
+ )
23
+ @click.argument(
24
+ 'sensor-grid', type=click.Path(exists=True, file_okay=True, resolve_path=True)
25
+ )
26
+ @click.option(
27
+ '--rad-params', show_default=True, help='Radiance parameters.'
28
+ )
29
+ @click.option(
30
+ '--rad-params-locked', show_default=True, help='Protected Radiance parameters. '
31
+ 'These values will overwrite user input rad parameters.'
32
+ )
33
+ @click.option(
34
+ '--output', '-o', show_default=True, help='Path to output file. If a relative path'
35
+ ' is provided it should be relative to project folder.'
36
+ )
37
+ @click.option(
38
+ '--dry-run', is_flag=True, default=False, show_default=True,
39
+ help='A flag to show the command without running it.'
40
+ )
41
+ def rtrace_command(
42
+ octree, sensor_grid, rad_params, rad_params_locked, output, dry_run):
43
+ """Run rtrace command for an input octree and a sensor grid.
44
+
45
+ \b
46
+ Args:
47
+ octree: Path to octree file.
48
+ sensor_grid: Path to sensor grid file.
49
+ """
50
+ try:
51
+ options = RtraceOptions()
52
+ # parse input radiance parameters
53
+ if rad_params:
54
+ options.update_from_string(rad_params.strip())
55
+ # overwrite input values with protected ones
56
+ if rad_params_locked:
57
+ options.update_from_string(rad_params_locked.strip())
58
+
59
+ # create command.
60
+ rtrace = Rtrace(
61
+ options=options, output=output, octree=octree, sensors=sensor_grid
62
+ )
63
+
64
+ if dry_run:
65
+ click.echo(rtrace)
66
+ else:
67
+ env = None
68
+ if folders.env != {}:
69
+ env = folders.env
70
+ env = dict(os.environ, **env) if env else None
71
+ rtrace.run(env=env)
72
+ except Exception:
73
+ _logger.exception('Failed to run ray-tracing command.')
74
+ sys.exit(1)
75
+ else:
76
+ sys.exit(0)
77
+
78
+
79
+ @raytrace.command('daylight-factor')
80
+ @click.argument(
81
+ 'octree', type=click.Path(exists=True, file_okay=True, resolve_path=True)
82
+ )
83
+ @click.argument(
84
+ 'sensor-grid', type=click.Path(exists=True, file_okay=True, resolve_path=True)
85
+ )
86
+ @click.option(
87
+ '--rad-params', show_default=True, help='Radiance parameters.'
88
+ )
89
+ @click.option(
90
+ '--rad-params-locked', show_default=True, help='Protected Radiance parameters. '
91
+ 'These values will overwrite user input rad parameters.'
92
+ )
93
+ @click.option(
94
+ '--sky-illum', '-i', default=100000, show_default=True, help='Sky illuminance value'
95
+ '. The post-processed results will be divided by this number.'
96
+ )
97
+ @click.option(
98
+ '--output', '-o', show_default=True, help='Path to output file. If a relative path'
99
+ ' is provided it should be relative to project folder.'
100
+ )
101
+ @click.option(
102
+ '--dry-run', is_flag=True, default=False, show_default=True,
103
+ help='A flag to show the command without running it.'
104
+ )
105
+ def rtrace_with_df_post_process(
106
+ octree, sensor_grid, rad_params, rad_params_locked, sky_illum, output, dry_run):
107
+ """Run rtrace command with rcalc post-processing for daylight factor studies.
108
+
109
+ \b
110
+ Args:
111
+ octree: Path to octree file.
112
+ sensor_grid: Path to sensor grid file.
113
+ """
114
+ try:
115
+ options = RtraceOptions()
116
+ # parse input radiance parameters
117
+ if rad_params:
118
+ options.update_from_string(rad_params.strip())
119
+ # overwrite input values with protected ones
120
+ if rad_params_locked:
121
+ options.update_from_string(rad_params_locked.strip())
122
+
123
+ # create command.
124
+ rtrace = Rtrace(options=options, octree=octree, sensors=sensor_grid)
125
+
126
+ # add rcalc post-procing
127
+ rcalc = Rcalc(output=output)
128
+ rcalc.options.e = '$1=(0.265*$1+0.67*$2+0.065*$3)*17900/{}'.format(sky_illum)
129
+ rtrace.pipe_to = rcalc
130
+
131
+ if dry_run:
132
+ click.echo(rtrace)
133
+ else:
134
+ env = None
135
+ if folders.env != {}:
136
+ env = folders.env
137
+ env = dict(os.environ, **env) if env else None
138
+ rtrace.run(env=env)
139
+ except Exception:
140
+ _logger.exception('Failed to run daylight-factor ray-tracing.')
141
+ sys.exit(1)
142
+ else:
143
+ sys.exit(0)
144
+
145
+
146
+ @raytrace.command('point-in-time')
147
+ @click.argument(
148
+ 'octree', type=click.Path(exists=True, file_okay=True, resolve_path=True)
149
+ )
150
+ @click.argument(
151
+ 'sensor-grid', type=click.Path(exists=True, file_okay=True, resolve_path=True)
152
+ )
153
+ @click.option(
154
+ '--rad-params', show_default=True, help='Radiance parameters.'
155
+ )
156
+ @click.option(
157
+ '--rad-params-locked', show_default=True, help='Protected Radiance parameters. '
158
+ 'These values will overwrite user input rad parameters.'
159
+ )
160
+ @click.option(
161
+ '--metric', '-m', default='illuminance', show_default=True,
162
+ help='Text for the type of metric to be output from the calculation. Choose from: '
163
+ 'illuminance, irradiance, luminance, radiance.'
164
+ )
165
+ @click.option(
166
+ '--output', '-o', show_default=True, help='Path to output file. If a relative path'
167
+ ' is provided it should be relative to project folder.'
168
+ )
169
+ @click.option(
170
+ '--dry-run', is_flag=True, default=False, show_default=True,
171
+ help='A flag to show the command without running it.'
172
+ )
173
+ def rtrace_with_pit_post_process(
174
+ octree, sensor_grid, rad_params, rad_params_locked, metric, output, dry_run):
175
+ """Run rtrace command with rcalc post-processing for point-in-time studies.
176
+
177
+ \b
178
+ Args:
179
+ octree: Path to octree file.
180
+ sensor_grid: Path to sensor grid file.
181
+ """
182
+ try:
183
+ options = RtraceOptions()
184
+ # parse input radiance parameters
185
+ if rad_params:
186
+ options.update_from_string(rad_params.strip())
187
+ # overwrite input values with protected ones
188
+ if rad_params_locked:
189
+ options.update_from_string(rad_params_locked.strip())
190
+ # overwrite the -I attribute depending on the metric to be calculated
191
+ if metric in ('illuminance', 'irradiance'):
192
+ options.I = True
193
+ elif metric in ('luminance', 'radiance'):
194
+ options.I = False
195
+ else:
196
+ raise ValueError('Metric "{}" is not recognized.'.format(metric))
197
+
198
+ # create command.
199
+ rtrace = Rtrace(options=options, octree=octree, sensors=sensor_grid)
200
+
201
+ # add rcalc post-procing
202
+ rcalc = Rcalc(output=output)
203
+ rcalc.options.e = '$1=(0.265*$1+0.67*$2+0.065*$3)*179' if metric in \
204
+ ('illuminance', 'luminance') else '$1=(0.265*$1+0.67*$2+0.065*$3)'
205
+ rtrace.pipe_to = rcalc
206
+
207
+ if dry_run:
208
+ click.echo(rtrace)
209
+ else:
210
+ env = None
211
+ if folders.env != {}:
212
+ env = folders.env
213
+ env = dict(os.environ, **env) if env else None
214
+ rtrace.run(env=env)
215
+ except Exception:
216
+ _logger.exception('Failed to run point-in-time ray-tracing.')
217
+ sys.exit(1)
218
+ else:
219
+ sys.exit(0)
@@ -0,0 +1,125 @@
1
+ """honeybee radiance rpict command."""
2
+ import click
3
+ import sys
4
+ import logging
5
+ import os
6
+ import shutil
7
+
8
+ from honeybee_radiance.config import folders
9
+ from honeybee_radiance_command.rpict import Rpict, RpictOptions
10
+
11
+
12
+ _logger = logging.getLogger(__name__)
13
+
14
+
15
+ @click.group(help='Commands to run rpict in Radiance.')
16
+ def rpict():
17
+ pass
18
+
19
+
20
+ @rpict.command('rpict')
21
+ @click.argument(
22
+ 'octree', type=click.Path(exists=True, file_okay=True, resolve_path=True)
23
+ )
24
+ @click.argument(
25
+ 'view', type=click.Path(exists=True, file_okay=True, resolve_path=True)
26
+ )
27
+ @click.option(
28
+ '--rad-params', help='Radiance parameters.'
29
+ )
30
+ @click.option(
31
+ '--rad-params-locked', help='Protected Radiance parameters. These values will '
32
+ 'overwrite user input rad parameters.'
33
+ )
34
+ @click.option(
35
+ '--metric', '-m', default='luminance', show_default=True,
36
+ help='Text for the type of metric to be output from the calculation. Choose from: '
37
+ 'illuminance, irradiance, luminance, radiance.'
38
+ )
39
+ @click.option(
40
+ '--resolution', '-r', default=None, type=int, show_default=True,
41
+ help='An integer for the maximum dimension of the image in pixels (either '
42
+ 'width/height depending on the input view angle and type). This will '
43
+ 'overwrite the -x and -y option in any input radiance parameters if specified. '
44
+ 'The default value for Radiance is 512 pixels.'
45
+ )
46
+ @click.option(
47
+ '--scale-factor', '-s', default=1, type=float, show_default=True,
48
+ help='A number that will be multiplied by the input resolution to scale the '
49
+ 'dimensions of the output image. This is useful in workflows if one plans to '
50
+ 're-scale the image after the ray tracing calculation to improve anti-aliasing.'
51
+ )
52
+ @click.option(
53
+ '--output', '-o', help='Path to output file. If a relative path is provided it '
54
+ 'should be relative to project folder.'
55
+ )
56
+ @click.option(
57
+ '--dry-run', is_flag=True, default=False, show_default=True,
58
+ help='A flag to show the command without running it.'
59
+ )
60
+ def rpict_command(
61
+ octree, view, rad_params, rad_params_locked, metric, resolution, scale_factor,
62
+ output, dry_run):
63
+ """Run rpict command for an input octree and a view file.
64
+
65
+ Note that, if an ambient cache file (.amb) is found next to the view file,
66
+ and it is determined to be valid (with a non-zero size) it will be
67
+ automatically used within the rpict command.
68
+
69
+ \b
70
+ Args:
71
+ octree: Path to octree file.
72
+ view: Path to view file.
73
+
74
+ """
75
+ try:
76
+ options = RpictOptions()
77
+ # parse input radiance parameters
78
+ if rad_params:
79
+ options.update_from_string(rad_params.strip())
80
+ # overwrite input values with protected ones
81
+ if rad_params_locked:
82
+ options.update_from_string(rad_params_locked.strip())
83
+ # overwrite the -i attribute depending on the metric to be calculated
84
+ if metric in ('illuminance', 'irradiance'):
85
+ options.i = True
86
+ elif metric in ('luminance', 'radiance'):
87
+ options.i = False
88
+ else:
89
+ raise ValueError('Metric "{}" is not recognized.'.format(metric))
90
+ # overwrite the -x and -y attribute depending on the input resolution
91
+ if resolution:
92
+ options.x = int(resolution * scale_factor)
93
+ options.y = int(resolution * scale_factor)
94
+ # sense wether there is an ambient cache file next to the view
95
+ for base_file in os.listdir(os.path.dirname(view)):
96
+ if base_file.endswith('.amb'):
97
+ full_amb_path = os.path.join(os.path.dirname(view), base_file)
98
+ if os.stat(full_amb_path).st_size != 0:
99
+ options.af = os.path.join(os.path.dirname(view), base_file)
100
+ break
101
+
102
+ # write the metric type into the view name such that it's in the HDR header
103
+ metric_view = os.path.basename(view).replace('.vf', '_{}.vf'.format(metric))
104
+ full_metric_view = os.path.join(os.path.dirname(view), metric_view)
105
+ shutil.copyfile(view, full_metric_view)
106
+
107
+ # create command.
108
+ rpict = Rpict(
109
+ options=options, output=output, octree=octree, view=full_metric_view
110
+ )
111
+
112
+ if dry_run:
113
+ click.echo(rpict)
114
+ else:
115
+ env = None
116
+ if folders.env != {}:
117
+ env = folders.env
118
+ env = dict(os.environ, **env) if env else None
119
+ rpict.run(env=env)
120
+ os.remove(full_metric_view)
121
+ except Exception:
122
+ _logger.exception('Failed to run rpict command.')
123
+ sys.exit(1)
124
+ else:
125
+ sys.exit(0)
@@ -0,0 +1,56 @@
1
+ """honeybee radiance schedule command."""
2
+ import click
3
+ import sys
4
+ import logging
5
+ import os
6
+
7
+ from ladybug.epw import EPW
8
+
9
+
10
+ _logger = logging.getLogger(__name__)
11
+
12
+
13
+ @click.group(help='Commands to create and modify schedules.')
14
+ def schedule():
15
+ pass
16
+
17
+
18
+ @schedule.command('epw-to-daylight-hours')
19
+ @click.argument(
20
+ 'epw', type=click.Path(exists=True, dir_okay=False, resolve_path=True))
21
+ @click.option('--folder', '-f', help='Output folder.', default='.', show_default=True)
22
+ @click.option(
23
+ '--name', '-n', help='Output file name for schedule.',
24
+ type=click.STRING, default='daylight_hours', show_default=True
25
+ )
26
+ def epw_to_daylight_hours(epw, folder, name):
27
+ """Convert EPW to EN 17037 schedule as a CSV file.
28
+
29
+ This command generates a valid schedule for EN 17037, also known as daylight hours.
30
+ Rather than a typical occupancy schedule, the daylight hours is half the year with
31
+ the largest quantity of daylight. This is generated by sorting the EPW file by
32
+ diffuse horizontal illuminance.
33
+
34
+ \b
35
+ Args:
36
+ epw: Path to epw file.
37
+ """
38
+ try:
39
+ epw_data = EPW(epw)
40
+ diffuse_horizontal_illuminance = epw_data.diffuse_horizontal_illuminance
41
+ _illuminance, indices = diffuse_horizontal_illuminance.highest_values(4380)
42
+ values = ['1' if i in indices else '0' for i in range(8760)]
43
+
44
+ if not os.path.isdir(folder):
45
+ os.makedirs(folder)
46
+
47
+ # write csv
48
+ file_path = os.path.join(folder, '%s.csv' % name)
49
+ with open(file_path, 'w') as fp:
50
+ fp.write('\n'.join(values))
51
+
52
+ except Exception:
53
+ _logger.exception('Failed to generate daylight hours schedule.')
54
+ sys.exit(1)
55
+ else:
56
+ sys.exit(0)
@@ -0,0 +1,63 @@
1
+ """Commands to set honeybee-radiance configurations."""
2
+ import click
3
+ import sys
4
+ import logging
5
+ import json
6
+
7
+ from honeybee_radiance.config import folders
8
+
9
+ _logger = logging.getLogger(__name__)
10
+
11
+
12
+ @click.group(help='Commands to set honeybee-radiance configurations.')
13
+ def set_config():
14
+ pass
15
+
16
+
17
+ @set_config.command('radiance-path')
18
+ @click.argument('folder-path', required=False, type=click.Path(
19
+ exists=True, file_okay=False, dir_okay=True, resolve_path=True))
20
+ def radiance_path(folder_path):
21
+ """Set the radiance-path configuration variable.
22
+
23
+ \b
24
+ Args:
25
+ folder_path: Path to a folder to be set as the radiance-path.
26
+ If unspecified, the radiance-path will be set back to
27
+ the default.
28
+ """
29
+ _set_config_variable(folder_path, 'radiance_path')
30
+
31
+
32
+ @set_config.command('standards-data-folder')
33
+ @click.argument('folder-path', required=False, type=click.Path(
34
+ exists=True, file_okay=False, dir_okay=True, resolve_path=True))
35
+ def standards_data_folder(folder_path):
36
+ """Set the standards-data-folder configuration variable.
37
+
38
+ \b
39
+ Args:
40
+ folder_path: Path to a folder to be set as the standards-data-folder.
41
+ If unspecified, the standards-data-folder will be set back to
42
+ the default.
43
+ """
44
+ _set_config_variable(folder_path, 'standards_data_folder')
45
+
46
+
47
+ def _set_config_variable(folder_path, variable_name):
48
+ var_cli_name = variable_name.replace('_', '-')
49
+ try:
50
+ config_file = folders.config_file
51
+ with open(config_file) as inf:
52
+ data = json.load(inf)
53
+ data[variable_name] = folder_path if folder_path is not None else ''
54
+ with open(config_file, 'w') as fp:
55
+ json.dump(data, fp, indent=4)
56
+ msg_end = 'reset to default' if folder_path is None \
57
+ else 'set to: {}'.format(folder_path)
58
+ print('{} successfully {}.'.format(var_cli_name, msg_end))
59
+ except Exception as e:
60
+ _logger.exception('Failed to set {}.\n{}'.format(var_cli_name, e))
61
+ sys.exit(1)
62
+ else:
63
+ sys.exit(0)