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,11 @@
1
+ """honeybee-radiance library."""
2
+
3
+ from honeybee.logutil import get_logger
4
+
5
+ # use the same logger settings across honeybee extensions
6
+ # this does NOT mean that the logs will be written to the same file but they will have
7
+ # the same formatting, level, etc.
8
+ logger = get_logger(name=__name__)
9
+
10
+ # load all functions that extends honeybee core library
11
+ import honeybee_radiance._extend_honeybee
@@ -0,0 +1,4 @@
1
+ from honeybee_radiance.cli import radiance
2
+
3
+ if __name__ == '__main__':
4
+ radiance()
@@ -0,0 +1,93 @@
1
+ # coding=utf-8
2
+ from honeybee.properties import ModelProperties, RoomProperties, FaceProperties, \
3
+ ShadeProperties, ApertureProperties, DoorProperties, ShadeMeshProperties
4
+ import honeybee.writer.door as door_writer
5
+ import honeybee.writer.aperture as aperture_writer
6
+ import honeybee.writer.shade as shade_writer
7
+ import honeybee.writer.shademesh as shademesh_writer
8
+ import honeybee.writer.face as face_writer
9
+ import honeybee.writer.room as room_writer
10
+ import honeybee.writer.model as model_writer
11
+
12
+ from .properties.model import ModelRadianceProperties
13
+ from .properties.room import RoomRadianceProperties
14
+ from .properties.face import FaceRadianceProperties
15
+ from .properties.shade import ShadeRadianceProperties
16
+ from .properties.shademesh import ShadeMeshRadianceProperties
17
+ from .properties.aperture import ApertureRadianceProperties
18
+ from .properties.door import DoorRadianceProperties
19
+ from .writer import model_to_rad_folder, model_to_rad, room_to_rad, face_to_rad, \
20
+ shade_to_rad, shade_mesh_to_rad, aperture_to_rad, door_to_rad
21
+
22
+
23
+ # set a hidden radiance attribute on each core geometry Property class to None
24
+ # define methods to produce radiance property instances on each Property instance
25
+ ModelProperties._radiance = None
26
+ RoomProperties._radiance = None
27
+ FaceProperties._radiance = None
28
+ ShadeProperties._radiance = None
29
+ ApertureProperties._radiance = None
30
+ DoorProperties._radiance = None
31
+ ShadeMeshProperties._radiance = None
32
+
33
+
34
+ def model_radiance_properties(self):
35
+ if self._radiance is None:
36
+ self._radiance = ModelRadianceProperties(self.host)
37
+ return self._radiance
38
+
39
+
40
+ def room_radiance_properties(self):
41
+ if self._radiance is None:
42
+ self._radiance = RoomRadianceProperties(self.host)
43
+ return self._radiance
44
+
45
+
46
+ def face_radiance_properties(self):
47
+ if self._radiance is None:
48
+ self._radiance = FaceRadianceProperties(self.host)
49
+ return self._radiance
50
+
51
+
52
+ def shade_radiance_properties(self):
53
+ if self._radiance is None:
54
+ self._radiance = ShadeRadianceProperties(self.host)
55
+ return self._radiance
56
+
57
+
58
+ def aperture_radiance_properties(self):
59
+ if self._radiance is None:
60
+ self._radiance = ApertureRadianceProperties(self.host)
61
+ return self._radiance
62
+
63
+
64
+ def door_radiance_properties(self):
65
+ if self._radiance is None:
66
+ self._radiance = DoorRadianceProperties(self.host)
67
+ return self._radiance
68
+
69
+
70
+ def shade_mesh_radiance_properties(self):
71
+ if self._radiance is None:
72
+ self._radiance = ShadeMeshRadianceProperties(self.host)
73
+ return self._radiance
74
+
75
+
76
+ # add radiance property methods to the Properties classes
77
+ ModelProperties.radiance = property(model_radiance_properties)
78
+ RoomProperties.radiance = property(room_radiance_properties)
79
+ FaceProperties.radiance = property(face_radiance_properties)
80
+ ShadeProperties.radiance = property(shade_radiance_properties)
81
+ ApertureProperties.radiance = property(aperture_radiance_properties)
82
+ DoorProperties.radiance = property(door_radiance_properties)
83
+ ShadeMeshProperties.radiance = property(shade_mesh_radiance_properties)
84
+
85
+ # add energy writer to rad
86
+ model_writer.rad_folder = model_to_rad_folder
87
+ model_writer.rad = model_to_rad
88
+ room_writer.rad = room_to_rad
89
+ face_writer.rad = face_to_rad
90
+ shade_writer.rad = shade_to_rad
91
+ aperture_writer.rad = aperture_to_rad
92
+ door_writer.rad = door_to_rad
93
+ shademesh_writer.rad = shade_mesh_to_rad
@@ -0,0 +1,88 @@
1
+ """honeybee-radiance commands which will be added to honeybee command line interface."""
2
+ import click
3
+ import sys
4
+ import logging
5
+ import json
6
+
7
+ from honeybee.cli import main
8
+ from ..config import folders
9
+ from .setconfig import set_config
10
+ from .edit import edit
11
+ from .translate import translate
12
+ from .lib import lib
13
+ from .sky import sky
14
+ from .grid import grid
15
+ from .view import view
16
+ from .sunpath import sunpath
17
+ from .octree import octree
18
+ from .raytrace import raytrace
19
+ from .rpict import rpict
20
+ from .dc import dc
21
+ from .viewfactor import view_factor
22
+ from .postprocess import post_process
23
+ from .mtx import mtxop
24
+ from .multiphase import multi_phase
25
+ from .glare import dcglare
26
+ from .schedule import schedule
27
+ from .study import study
28
+ from .modifier import modifier
29
+
30
+
31
+ _logger = logging.getLogger(__name__)
32
+
33
+
34
+ # command group for all radiance extension commands.
35
+ @click.group(help='honeybee radiance commands.')
36
+ @click.version_option()
37
+ def radiance():
38
+ pass
39
+
40
+
41
+ @radiance.command('config')
42
+ @click.option('--output-file', help='Optional file to output the JSON string of '
43
+ 'the config object. By default, it will be printed out to stdout',
44
+ type=click.File('w'), default='-', show_default=True)
45
+ def config(output_file):
46
+ """Get a JSON object with all configuration information"""
47
+ try:
48
+ config_dict = {
49
+ 'radiance_path': folders.radiance_path,
50
+ 'radbin_path': folders.radbin_path,
51
+ 'radlib_path': folders.radlib_path,
52
+ 'radiance_version': folders.radiance_version_str,
53
+ 'standards_data_folder': folders.standards_data_folder,
54
+ 'modifier_lib': folders.modifier_lib,
55
+ 'modifierset_lib': folders.modifierset_lib
56
+ }
57
+ output_file.write(json.dumps(config_dict, indent=4))
58
+ except Exception as e:
59
+ _logger.exception('Failed to retrieve configurations.\n{}'.format(e))
60
+ sys.exit(1)
61
+ else:
62
+ sys.exit(0)
63
+
64
+
65
+ # add sub-commands to radiance
66
+ radiance.add_command(set_config, name='set-config')
67
+ radiance.add_command(edit)
68
+ radiance.add_command(translate)
69
+ radiance.add_command(lib)
70
+ radiance.add_command(sky)
71
+ radiance.add_command(grid)
72
+ radiance.add_command(view)
73
+ radiance.add_command(sunpath)
74
+ radiance.add_command(octree)
75
+ radiance.add_command(raytrace)
76
+ radiance.add_command(rpict)
77
+ radiance.add_command(dc)
78
+ radiance.add_command(view_factor)
79
+ radiance.add_command(post_process, name='post-process')
80
+ radiance.add_command(mtxop)
81
+ radiance.add_command(multi_phase)
82
+ radiance.add_command(dcglare)
83
+ radiance.add_command(schedule)
84
+ radiance.add_command(study)
85
+ radiance.add_command(modifier)
86
+
87
+ # add radiance sub-commands to honeybee CLI
88
+ main.add_command(radiance)
@@ -0,0 +1,400 @@
1
+ """honeybee radiance daylight coefficient / contribution commands."""
2
+ import click
3
+ import sys
4
+ import os
5
+ import logging
6
+
7
+ from honeybee_radiance.config import folders
8
+ from honeybee_radiance_command.rcontrib import Rcontrib, RcontribOptions
9
+ from honeybee_radiance_command._command_util import run_command
10
+ from honeybee_radiance_command.rfluxmtx import Rfluxmtx, RfluxmtxOptions
11
+ from honeybee_radiance.reader import sensor_count_from_file
12
+
13
+
14
+ _logger = logging.getLogger(__name__)
15
+
16
+
17
+ @click.group(help='Commands to run daylight contribution/ coefficient calculations in Radiance.')
18
+ def dc():
19
+ pass
20
+
21
+
22
+ @dc.command('scontrib')
23
+ @click.argument(
24
+ 'octree', type=click.Path(exists=True, file_okay=True)
25
+ )
26
+ @click.argument(
27
+ 'sensor-grid', type=click.Path(exists=True, file_okay=True)
28
+ )
29
+ @click.argument(
30
+ 'modifiers', type=click.Path(exists=True, file_okay=True)
31
+ )
32
+ @click.option(
33
+ '--sensor-count', type=click.INT, show_default=True,
34
+ help='Number of sensors in sensor grid file. Number of sensors will be parsed form'
35
+ ' the sensor file if not provided.'
36
+ )
37
+ @click.option(
38
+ '--rad-params', show_default=True, help='Radiance parameters.'
39
+ )
40
+ @click.option(
41
+ '--rad-params-locked', show_default=True, help='Protected Radiance parameters. '
42
+ 'These values will overwrite user input rad parameters.'
43
+ )
44
+ @click.option(
45
+ '--output', '-o', show_default=True, help='Path to output file (.mtx or .dc). If a relative path'
46
+ ' is provided it should be relative to project folder.'
47
+ )
48
+ @click.option(
49
+ '--coeff/--value', is_flag=True, default=True, help='Switch between daylight '
50
+ ' coefficient and values. Default is coeff for calculating coefficient.'
51
+ )
52
+ @click.option(
53
+ '--conversion', help='conversion as a string which will be passed to rmtxop -c. '
54
+ 'This option is useful to post-process the results from 3 RGB components into one '
55
+ 'as part of this command.'
56
+ )
57
+ @click.option(
58
+ '--multiply-by', help='A value to multiply by all the results. This input is '
59
+ 'helpful to adjust the values for runs with different timesteps if required. '
60
+ 'This value will be multiplied by the values provided by conversion input.',
61
+ type=click.FLOAT, default=1
62
+ )
63
+ @click.option(
64
+ '--output-format', help='Output type for converted results. Valid inputs are a, f '
65
+ 'and d for ASCII, float or double. If conversion is not provided you can change the '
66
+ 'output type using rad-params options.', type=click.Choice(['a', 'f', 'd']),
67
+ default='a', show_default=True, show_choices=True
68
+ )
69
+ @click.option(
70
+ '--order-by-sensor/--order-by-datetime', is_flag=True, default=True,
71
+ show_default=True, help='An option to change how results are ordered in each row. '
72
+ 'By default each row are the results for a sensor during all the sun-up hours. '
73
+ 'You can change that by using --order-by-datetime flag to get the results for a '
74
+ 'single datetime in each row.'
75
+ )
76
+ @click.option(
77
+ '--keep-header/--remove-header', ' /-h-', is_flag=True, default=True,
78
+ help='A flag to keep or remove the header from the output file.'
79
+ )
80
+ @click.option(
81
+ '--dry-run', is_flag=True, default=False, show_default=True,
82
+ help='A flag to show the command without running it.'
83
+ )
84
+ def rcontrib_command_with_postprocess(
85
+ octree, sensor_grid, modifiers, sensor_count, rad_params, rad_params_locked,
86
+ output, coeff, conversion, multiply_by, output_format, order_by_sensor,
87
+ keep_header, dry_run
88
+ ):
89
+ """Run rcontrib command for an input octree and a sensor grid.
90
+
91
+ \b
92
+ Args:
93
+ octree: Path to octree file.
94
+ sensor-grid: Path to sensor grid file.
95
+ modifiers: Path to modifiers file.
96
+ """
97
+ try:
98
+ # first check to be sure there are sun-up hours; if so, write a blank file
99
+ if os.path.getsize(modifiers) == 0:
100
+ if output is not None:
101
+ with open(output, 'w') as wf:
102
+ wf.write('')
103
+ return
104
+
105
+ options = RcontribOptions()
106
+ # parse input radiance parameters
107
+ if rad_params:
108
+ options.update_from_string(rad_params.strip())
109
+ # overwrite input values with protected ones
110
+ if rad_params_locked:
111
+ options.update_from_string(rad_params_locked.strip())
112
+
113
+ if not sensor_count:
114
+ sensor_count = sensor_count_from_file(sensor_grid)
115
+
116
+ if coeff:
117
+ options.update_from_string('-aa 0.0 -V- -y {}'.format(sensor_count))
118
+ else:
119
+ options.update_from_string('-aa 0.0 -V+ -y {}'.format(sensor_count))
120
+
121
+ modifiers = os.path.relpath(modifiers)
122
+ if modifiers.startswith('..'):
123
+ pass
124
+ else:
125
+ modifiers = f'./{modifiers}'
126
+ cmd = 'rcontrib {options} -M {modifiers} {octree} < {sensor_grid}'.format(
127
+ options=options.to_radiance(),
128
+ modifiers=modifiers, octree=octree, sensor_grid=sensor_grid)
129
+ cmd = cmd.replace("\\", "/")
130
+
131
+ if conversion and conversion.strip():
132
+ if multiply_by != 1:
133
+ conversion = ' '.join(str(c * multiply_by) for c in conversion.split())
134
+ # pass the values to rmtxop
135
+ cmd = '{command} | rmtxop -f{output_format} - -c {conversion}'.format(
136
+ command=cmd, output_format=output_format, conversion=conversion
137
+ )
138
+ elif multiply_by != 1:
139
+ conversion = '{mult} {mult} {mult}'.format(mult=multiply_by)
140
+ cmd = '{command} | rmtxop -f{output_format} - -c {conversion}'.format(
141
+ command=cmd, output_format=output_format, conversion=conversion
142
+ )
143
+
144
+ if order_by_sensor is not True:
145
+ cmd = cmd + ' -t '
146
+ if not keep_header:
147
+ cmd = cmd + ' | getinfo - '
148
+ if output:
149
+ cmd = '{command} > {output}'.format(command=cmd, output=output)
150
+
151
+ if dry_run:
152
+ click.echo(cmd)
153
+ else:
154
+ # rcontrib.run(env=env)
155
+ run_command(cmd, env=folders.env)
156
+ except Exception:
157
+ _logger.exception('Failed to run ray-tracing command.')
158
+ sys.exit(1)
159
+ else:
160
+ sys.exit(0)
161
+
162
+
163
+ @dc.command('scoeff')
164
+ @click.argument(
165
+ 'octree', type=click.Path(exists=True, file_okay=True)
166
+ )
167
+ @click.argument(
168
+ 'sensor-grid', type=click.Path(exists=True, file_okay=True)
169
+ )
170
+ @click.argument(
171
+ 'sky-dome', type=click.Path(exists=True, file_okay=True)
172
+ )
173
+ @click.argument(
174
+ 'sky-mtx', type=click.Path(exists=True, file_okay=True)
175
+ )
176
+ @click.option(
177
+ '--sensor-count', type=click.INT, show_default=True,
178
+ help='Number of sensors in sensor grid file. Number of sensors will be parsed form'
179
+ ' the sensor file if not provided.'
180
+ )
181
+ @click.option(
182
+ '--rad-params', show_default=True, help='Radiance parameters.'
183
+ )
184
+ @click.option(
185
+ '--rad-params-locked', show_default=True, help='Protected Radiance parameters. '
186
+ 'These values will overwrite user input rad parameters.'
187
+ )
188
+ @click.option(
189
+ '--output', '-o', show_default=True, help='Path to output file (.mtx or .dc). If a relative path'
190
+ ' is provided it should be relative to project folder.'
191
+ )
192
+ @click.option(
193
+ '--conversion', help='conversion as a string which will be passed to rmtxop -c. '
194
+ 'This option is useful to post-process the results from 3 RGB components into one '
195
+ 'as part of this command.'
196
+ )
197
+ @click.option(
198
+ '--multiply-by', help='A value to multiply by all the results. This input is '
199
+ 'helpful to adjust the values for runs with different timesteps if required. '
200
+ 'This value will be multiplied by the values provided by converstion input.',
201
+ type=click.FLOAT, default=1
202
+ )
203
+ @click.option(
204
+ '--output-format', help='Output type for converted results. Valid inputs are a, f '
205
+ 'and d for ASCII, float or double.', type=click.Choice(['a', 'f', 'd']), default='f',
206
+ show_default=True, show_choices=True
207
+ )
208
+ @click.option(
209
+ '--order-by-sensor/--order-by-datetime', is_flag=True, default=True,
210
+ show_default=True, help='An option to change how results are ordered in each row. '
211
+ 'By default each row are the results for a sensor during all the sun-up hours. '
212
+ 'You can change that by using --order-by-datetime flag to get the results for a '
213
+ 'single datetime in each row.'
214
+ )
215
+ @click.option(
216
+ '--keep-header/--remove-header', ' /-h-', is_flag=True, default=True,
217
+ help='A flag to keep or remove the header from the output file.'
218
+ )
219
+ @click.option(
220
+ '--dry-run', is_flag=True, default=False, show_default=True,
221
+ help='A flag to show the command without running it.'
222
+ )
223
+ def rfluxmtx_command_with_postprocess(
224
+ octree, sensor_grid, sky_dome, sky_mtx, sensor_count, rad_params, rad_params_locked,
225
+ output, conversion, multiply_by, output_format, order_by_sensor, keep_header, dry_run
226
+ ):
227
+ """Run rfluxmtx command and pass the results to rmtxop.
228
+
229
+ octree: Path to octree file.
230
+
231
+ sensor-grid: Path to sensor grid file.
232
+
233
+ sky-dome: Path to sky dome for coefficient calculation.
234
+
235
+ sky-mtx: Path to sky matrix.
236
+
237
+ """
238
+ try:
239
+ # first check to be sure there are sun-up hours; if so, write a blank file
240
+ if os.path.getsize(sky_mtx) == 0:
241
+ if output is not None:
242
+ with open(output, 'w') as wf:
243
+ wf.write('')
244
+ return
245
+
246
+ options = RfluxmtxOptions()
247
+ # parse input radiance parameters
248
+ if rad_params:
249
+ options.update_from_string(rad_params.strip())
250
+ # overwrite input values with protected ones
251
+ if rad_params_locked:
252
+ options.update_from_string(rad_params_locked.strip())
253
+
254
+ if not sensor_count:
255
+ sensor_count = sensor_count_from_file(sensor_grid)
256
+
257
+ options.update_from_string('-aa 0.0 -faf -y {}'.format(sensor_count))
258
+
259
+ # create command.
260
+ cmd_template = 'rfluxmtx {rad_params} - "{sky_dome}" -i """{octree}""" < ' \
261
+ '"{sensors}" | rmtxop -f{output_format} - "{sky_mtx}"'
262
+
263
+ if conversion and conversion.strip():
264
+ if multiply_by != 1:
265
+ conversion = ' '.join(str(c * multiply_by) for c in conversion.split())
266
+ cmd_template = cmd_template + ' -c %s' % conversion
267
+ elif multiply_by != 1:
268
+ conversion = '{mult} {mult} {mult}'.format(mult=multiply_by)
269
+ cmd_template = cmd_template + ' -c %s' % conversion
270
+
271
+ if not order_by_sensor:
272
+ cmd_template = cmd_template + ' -t '
273
+
274
+ if not keep_header:
275
+ cmd_template = cmd_template + ' | getinfo - '
276
+ if output:
277
+ cmd_template = cmd_template + ' > "{output}"'.format(output=output)
278
+
279
+ cmd = cmd_template.format(
280
+ rad_params=options.to_radiance(), sky_dome=sky_dome, octree=octree,
281
+ sensors=sensor_grid, output_format=output_format, sky_mtx=sky_mtx
282
+ )
283
+
284
+ if dry_run:
285
+ click.echo(cmd)
286
+ else:
287
+ run_command(cmd, env=folders.env)
288
+ except Exception:
289
+ _logger.exception('Failed to run rfluxmtx command.')
290
+ sys.exit(1)
291
+ else:
292
+ sys.exit(0)
293
+
294
+
295
+ @dc.command('coeff')
296
+ @click.argument(
297
+ 'octree', type=click.Path(exists=True, file_okay=True)
298
+ )
299
+ @click.argument(
300
+ 'sensor-grid', type=click.Path(exists=True, file_okay=True)
301
+ )
302
+ @click.argument(
303
+ 'sky-dome', type=click.Path(exists=True, file_okay=True)
304
+ )
305
+ @click.option(
306
+ '--sensor-count', type=click.INT, show_default=True,
307
+ help='Number of sensors in sensor grid file. Number of sensors will be parsed form'
308
+ ' the sensor file if not provided.'
309
+ )
310
+ @click.option(
311
+ '--rad-params', show_default=True, help='Radiance parameters.'
312
+ )
313
+ @click.option(
314
+ '--rad-params-locked', show_default=True, help='Protected Radiance parameters. '
315
+ 'These values will overwrite user input rad parameters.'
316
+ )
317
+ @click.option(
318
+ '--output', '-o', show_default=True, help='Path to output file (.mtx or .dc). If a relative path'
319
+ ' is provided it should be relative to project folder.'
320
+ )
321
+ @click.option(
322
+ '--conversion', help='conversion as a string which will be passed to rmtxop -c. '
323
+ 'This option is useful to post-process the results from 3 RGB components into one '
324
+ 'as part of this command.'
325
+ )
326
+ @click.option(
327
+ '--input-format', help='Format type for input. Valid inputs are a, f and d for '
328
+ 'ASCII, float or double.', type=click.Choice(['a', 'f', 'd']), default='a',
329
+ show_default=True, show_choices=True
330
+ )
331
+ @click.option(
332
+ '--output-format', help='Output type for converted results. Valid inputs are a, f '
333
+ 'and d for ASCII, float or double.', type=click.Choice(['a', 'f', 'd']), default='f',
334
+ show_default=True, show_choices=True
335
+ )
336
+ @click.option(
337
+ '--keep-header/--remove-header', ' /-h-', is_flag=True, default=True,
338
+ help='A flag to keep or remove the header from the output file.'
339
+ )
340
+ @click.option(
341
+ '--dry-run', is_flag=True, default=False, show_default=True,
342
+ help='A flag to show the command without running it.'
343
+ )
344
+ def rfluxmtx_command_without_postprocess(
345
+ octree, sensor_grid, sky_dome, sensor_count, rad_params, rad_params_locked, output,
346
+ conversion, input_format, output_format, keep_header, dry_run
347
+ ):
348
+ """Run rfluxmtx command without sky matrix.
349
+
350
+ This command calculates the coefficient matrix for a sensor grid and sky dome. There
351
+ is no postprocessing, i.e., no sky matrix.
352
+
353
+ \b
354
+ Args:
355
+ octree: Path to octree file.
356
+ sensor-grid: Path to sensor grid file.
357
+ sky-dome: Path to sky dome for coefficient calculation.
358
+ """
359
+ try:
360
+ options = RfluxmtxOptions()
361
+ options.fio = input_format + output_format
362
+ # parse input radiance parameters
363
+ if rad_params:
364
+ options.update_from_string(rad_params.strip())
365
+ # overwrite input values with protected ones
366
+ if rad_params_locked:
367
+ options.update_from_string(rad_params_locked.strip())
368
+
369
+ if not sensor_count:
370
+ sensor_count = sensor_count_from_file(sensor_grid)
371
+
372
+ options.update_from_string('-aa 0.0 -y {}'.format(sensor_count))
373
+
374
+ # create command.
375
+ cmd_template = 'rfluxmtx {rad_params} - "{sky_dome}" -i """{octree}""" < ' \
376
+ '"{sensors}"'
377
+
378
+ if conversion and conversion.strip():
379
+ conversion = ' '.join(str(c ) for c in conversion.split())
380
+ cmd_template = cmd_template + ' | rmtxop - -c %s' % conversion
381
+
382
+ if not keep_header:
383
+ cmd_template = cmd_template + ' | getinfo - '
384
+ if output:
385
+ cmd_template = cmd_template + ' > "{output}"'.format(output=output)
386
+
387
+ cmd = cmd_template.format(
388
+ rad_params=options.to_radiance(), sky_dome=sky_dome, octree=octree,
389
+ sensors=sensor_grid
390
+ )
391
+
392
+ if dry_run:
393
+ click.echo(cmd)
394
+ else:
395
+ run_command(cmd, env=folders.env)
396
+ except Exception:
397
+ _logger.exception('Failed to run rfluxmtx command.')
398
+ sys.exit(1)
399
+ else:
400
+ sys.exit(0)