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.
- honeybee_radiance/__init__.py +11 -0
- honeybee_radiance/__main__.py +4 -0
- honeybee_radiance/_extend_honeybee.py +93 -0
- honeybee_radiance/cli/__init__.py +88 -0
- honeybee_radiance/cli/dc.py +400 -0
- honeybee_radiance/cli/edit.py +529 -0
- honeybee_radiance/cli/glare.py +118 -0
- honeybee_radiance/cli/grid.py +859 -0
- honeybee_radiance/cli/lib.py +458 -0
- honeybee_radiance/cli/modifier.py +133 -0
- honeybee_radiance/cli/mtx.py +226 -0
- honeybee_radiance/cli/multiphase.py +1034 -0
- honeybee_radiance/cli/octree.py +640 -0
- honeybee_radiance/cli/postprocess.py +1186 -0
- honeybee_radiance/cli/raytrace.py +219 -0
- honeybee_radiance/cli/rpict.py +125 -0
- honeybee_radiance/cli/schedule.py +56 -0
- honeybee_radiance/cli/setconfig.py +63 -0
- honeybee_radiance/cli/sky.py +545 -0
- honeybee_radiance/cli/study.py +66 -0
- honeybee_radiance/cli/sunpath.py +331 -0
- honeybee_radiance/cli/threephase.py +255 -0
- honeybee_radiance/cli/translate.py +400 -0
- honeybee_radiance/cli/util.py +121 -0
- honeybee_radiance/cli/view.py +261 -0
- honeybee_radiance/cli/viewfactor.py +347 -0
- honeybee_radiance/config.json +6 -0
- honeybee_radiance/config.py +427 -0
- honeybee_radiance/dictutil.py +50 -0
- honeybee_radiance/dynamic/__init__.py +5 -0
- honeybee_radiance/dynamic/group.py +479 -0
- honeybee_radiance/dynamic/multiphase.py +557 -0
- honeybee_radiance/dynamic/state.py +718 -0
- honeybee_radiance/dynamic/stategeo.py +352 -0
- honeybee_radiance/geometry/__init__.py +13 -0
- honeybee_radiance/geometry/bubble.py +42 -0
- honeybee_radiance/geometry/cone.py +215 -0
- honeybee_radiance/geometry/cup.py +54 -0
- honeybee_radiance/geometry/cylinder.py +197 -0
- honeybee_radiance/geometry/geometrybase.py +37 -0
- honeybee_radiance/geometry/instance.py +40 -0
- honeybee_radiance/geometry/mesh.py +38 -0
- honeybee_radiance/geometry/polygon.py +174 -0
- honeybee_radiance/geometry/ring.py +214 -0
- honeybee_radiance/geometry/source.py +182 -0
- honeybee_radiance/geometry/sphere.py +178 -0
- honeybee_radiance/geometry/tube.py +46 -0
- honeybee_radiance/lib/__init__.py +1 -0
- honeybee_radiance/lib/_loadmodifiers.py +72 -0
- honeybee_radiance/lib/_loadmodifiersets.py +69 -0
- honeybee_radiance/lib/modifiers.py +58 -0
- honeybee_radiance/lib/modifiersets.py +63 -0
- honeybee_radiance/lightpath.py +204 -0
- honeybee_radiance/lightsource/__init__.py +1 -0
- honeybee_radiance/lightsource/_gendaylit.py +479 -0
- honeybee_radiance/lightsource/dictutil.py +49 -0
- honeybee_radiance/lightsource/ground.py +160 -0
- honeybee_radiance/lightsource/sky/__init__.py +7 -0
- honeybee_radiance/lightsource/sky/_skybase.py +177 -0
- honeybee_radiance/lightsource/sky/certainirradiance.py +232 -0
- honeybee_radiance/lightsource/sky/cie.py +378 -0
- honeybee_radiance/lightsource/sky/climatebased.py +501 -0
- honeybee_radiance/lightsource/sky/hemisphere.py +160 -0
- honeybee_radiance/lightsource/sky/skydome.py +113 -0
- honeybee_radiance/lightsource/sky/skymatrix.py +163 -0
- honeybee_radiance/lightsource/sky/strutil.py +34 -0
- honeybee_radiance/lightsource/sky/sunmatrix.py +212 -0
- honeybee_radiance/lightsource/sunpath.py +247 -0
- honeybee_radiance/modifier/__init__.py +3 -0
- honeybee_radiance/modifier/material/__init__.py +30 -0
- honeybee_radiance/modifier/material/absdf.py +477 -0
- honeybee_radiance/modifier/material/antimatter.py +54 -0
- honeybee_radiance/modifier/material/ashik2.py +51 -0
- honeybee_radiance/modifier/material/brtdfunc.py +81 -0
- honeybee_radiance/modifier/material/bsdf.py +292 -0
- honeybee_radiance/modifier/material/dielectric.py +53 -0
- honeybee_radiance/modifier/material/glass.py +431 -0
- honeybee_radiance/modifier/material/glow.py +246 -0
- honeybee_radiance/modifier/material/illum.py +51 -0
- honeybee_radiance/modifier/material/interface.py +49 -0
- honeybee_radiance/modifier/material/light.py +206 -0
- honeybee_radiance/modifier/material/materialbase.py +36 -0
- honeybee_radiance/modifier/material/metal.py +167 -0
- honeybee_radiance/modifier/material/metal2.py +41 -0
- honeybee_radiance/modifier/material/metdata.py +41 -0
- honeybee_radiance/modifier/material/metfunc.py +41 -0
- honeybee_radiance/modifier/material/mirror.py +340 -0
- honeybee_radiance/modifier/material/mist.py +86 -0
- honeybee_radiance/modifier/material/plasdata.py +58 -0
- honeybee_radiance/modifier/material/plasfunc.py +59 -0
- honeybee_radiance/modifier/material/plastic.py +354 -0
- honeybee_radiance/modifier/material/plastic2.py +58 -0
- honeybee_radiance/modifier/material/prism1.py +57 -0
- honeybee_radiance/modifier/material/prism2.py +48 -0
- honeybee_radiance/modifier/material/spotlight.py +50 -0
- honeybee_radiance/modifier/material/trans.py +518 -0
- honeybee_radiance/modifier/material/trans2.py +49 -0
- honeybee_radiance/modifier/material/transdata.py +50 -0
- honeybee_radiance/modifier/material/transfunc.py +53 -0
- honeybee_radiance/modifier/mixture/__init__.py +6 -0
- honeybee_radiance/modifier/mixture/mixdata.py +49 -0
- honeybee_radiance/modifier/mixture/mixfunc.py +54 -0
- honeybee_radiance/modifier/mixture/mixpict.py +52 -0
- honeybee_radiance/modifier/mixture/mixtext.py +66 -0
- honeybee_radiance/modifier/mixture/mixturebase.py +28 -0
- honeybee_radiance/modifier/modifierbase.py +40 -0
- honeybee_radiance/modifier/pattern/__init__.py +9 -0
- honeybee_radiance/modifier/pattern/brightdata.py +49 -0
- honeybee_radiance/modifier/pattern/brightfunc.py +47 -0
- honeybee_radiance/modifier/pattern/brighttext.py +81 -0
- honeybee_radiance/modifier/pattern/colordata.py +56 -0
- honeybee_radiance/modifier/pattern/colorfunc.py +47 -0
- honeybee_radiance/modifier/pattern/colorpict.py +54 -0
- honeybee_radiance/modifier/pattern/colortext.py +73 -0
- honeybee_radiance/modifier/pattern/patternbase.py +34 -0
- honeybee_radiance/modifier/texture/__init__.py +4 -0
- honeybee_radiance/modifier/texture/texdata.py +29 -0
- honeybee_radiance/modifier/texture/texfunc.py +26 -0
- honeybee_radiance/modifier/texture/texturebase.py +27 -0
- honeybee_radiance/modifierset.py +1091 -0
- honeybee_radiance/mutil.py +60 -0
- honeybee_radiance/postprocess/__init__.py +1 -0
- honeybee_radiance/postprocess/annual.py +108 -0
- honeybee_radiance/postprocess/annualdaylight.py +425 -0
- honeybee_radiance/postprocess/annualglare.py +201 -0
- honeybee_radiance/postprocess/annualirradiance.py +187 -0
- honeybee_radiance/postprocess/electriclight.py +119 -0
- honeybee_radiance/postprocess/en17037.py +261 -0
- honeybee_radiance/postprocess/leed.py +304 -0
- honeybee_radiance/postprocess/solartracking.py +90 -0
- honeybee_radiance/primitive.py +554 -0
- honeybee_radiance/properties/__init__.py +1 -0
- honeybee_radiance/properties/_base.py +390 -0
- honeybee_radiance/properties/aperture.py +197 -0
- honeybee_radiance/properties/door.py +198 -0
- honeybee_radiance/properties/face.py +123 -0
- honeybee_radiance/properties/model.py +1291 -0
- honeybee_radiance/properties/room.py +490 -0
- honeybee_radiance/properties/shade.py +186 -0
- honeybee_radiance/properties/shademesh.py +116 -0
- honeybee_radiance/putil.py +44 -0
- honeybee_radiance/reader.py +214 -0
- honeybee_radiance/sensor.py +166 -0
- honeybee_radiance/sensorgrid.py +1008 -0
- honeybee_radiance/view.py +1101 -0
- honeybee_radiance/writer.py +951 -0
- honeybee_radiance-1.66.190.dist-info/METADATA +89 -0
- honeybee_radiance-1.66.190.dist-info/RECORD +152 -0
- honeybee_radiance-1.66.190.dist-info/WHEEL +5 -0
- honeybee_radiance-1.66.190.dist-info/entry_points.txt +2 -0
- honeybee_radiance-1.66.190.dist-info/licenses/LICENSE +661 -0
- honeybee_radiance-1.66.190.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"""Generate CIE standard sky."""
|
|
2
|
+
from __future__ import division
|
|
3
|
+
import argparse
|
|
4
|
+
import shlex
|
|
5
|
+
|
|
6
|
+
import ladybug.futil as futil
|
|
7
|
+
from ladybug.dt import DateTime
|
|
8
|
+
from ladybug.location import Location
|
|
9
|
+
from ladybug.sunpath import Sunpath
|
|
10
|
+
import honeybee.typing as typing
|
|
11
|
+
|
|
12
|
+
from ._skybase import _PointInTime
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CIE(_PointInTime):
|
|
16
|
+
"""CIE sky.
|
|
17
|
+
|
|
18
|
+
The output of CIE sky is similar to using Radiance's gensky command. For more
|
|
19
|
+
information see gensky documentation.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
altitude: Solar altitude. The altitude is measured in degrees above the horizon.
|
|
23
|
+
azimuth: Solar azimuth. The azimuth is measured in degrees east of North. East is
|
|
24
|
+
90, South is 180 and West is 270. Note that this input is different from
|
|
25
|
+
Radiance convention. In Radiance the azimuth degrees are measured in west of
|
|
26
|
+
South.
|
|
27
|
+
sky_type: An integer between 0..5 to indicate CIE Sky Type.
|
|
28
|
+
|
|
29
|
+
* 0 = Sunny with sun. Sunny sky with sun. In addition to the sky distribution
|
|
30
|
+
function, a source description of the sun is generated.
|
|
31
|
+
* 1 = Sunny without sun. Sunny sky without sun. The sky distribution will
|
|
32
|
+
correspond to a standard CIE clear day.
|
|
33
|
+
* 2 = Intermediate with sun. In addition to the sky distribution, a (somewhat
|
|
34
|
+
subdued) sun is generated.
|
|
35
|
+
* 3 = Intermediate without sun. The sky will correspond to a standard CIE
|
|
36
|
+
intermediate day.
|
|
37
|
+
* 4 = Cloudy sky. The sky distribution will correspond to a standard CIE
|
|
38
|
+
overcast day.
|
|
39
|
+
* 5 = Uniform cloudy sky. The sky distribution will be completely uniform.
|
|
40
|
+
|
|
41
|
+
ground_reflectance: Average ground reflectance (Default: 0.2).
|
|
42
|
+
|
|
43
|
+
Properties:
|
|
44
|
+
* altitude
|
|
45
|
+
* azimuth
|
|
46
|
+
* sky_type
|
|
47
|
+
* sky_type_radiance
|
|
48
|
+
* sky_type_human_readable
|
|
49
|
+
* ground_hemisphere
|
|
50
|
+
* sky_hemisphere
|
|
51
|
+
* ground_reflectance
|
|
52
|
+
* is_point_in_time
|
|
53
|
+
* is_climate_based
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
SKYTYPES = {
|
|
57
|
+
0: ('+s', 'Sunny sky with sun'),
|
|
58
|
+
1: ('-s', 'Sunny sky without sun'),
|
|
59
|
+
2: ('+i', 'intermediate sky with sun'),
|
|
60
|
+
3: ('-i', 'intermediate sky without sun'),
|
|
61
|
+
4: ('-c', 'Cloudy sky'),
|
|
62
|
+
5: ('-u', 'Uniform cloudy sky')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
__slots__ = ('_altitude', '_azimuth', '_sky_type')
|
|
66
|
+
|
|
67
|
+
def __init__(self, altitude, azimuth, sky_type=0, ground_reflectance=0.2):
|
|
68
|
+
"""Create a CIE standard sky."""
|
|
69
|
+
_PointInTime.__init__(self, ground_reflectance)
|
|
70
|
+
self.altitude = altitude
|
|
71
|
+
self.azimuth = azimuth
|
|
72
|
+
self.sky_type = sky_type
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def altitude(self):
|
|
76
|
+
"""Get or set a number between -90 and 90 for the solar altitude.
|
|
77
|
+
|
|
78
|
+
The altitude is measured in degrees above the horizon.
|
|
79
|
+
"""
|
|
80
|
+
return self._altitude
|
|
81
|
+
|
|
82
|
+
@altitude.setter
|
|
83
|
+
def altitude(self, value):
|
|
84
|
+
value = typing.float_in_range(value, -90, 90, 'Solar altitude')
|
|
85
|
+
self._altitude = value
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def azimuth(self):
|
|
89
|
+
"""Get or set a number between 0 and 360 for the solar azimuth.
|
|
90
|
+
|
|
91
|
+
The azimuth is measured in degrees east of North. East is 90, South is 180 and
|
|
92
|
+
West is 270. Note that this input is different from Radiance convention. In
|
|
93
|
+
Radiance the azimuth degrees are measured in west of South.
|
|
94
|
+
"""
|
|
95
|
+
return self._azimuth
|
|
96
|
+
|
|
97
|
+
@azimuth.setter
|
|
98
|
+
def azimuth(self, value):
|
|
99
|
+
value = typing.float_in_range(value, 0, 360, 'Solar azimuth')
|
|
100
|
+
self._azimuth = value
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def sky_type(self):
|
|
104
|
+
"""Get and set sky type.
|
|
105
|
+
|
|
106
|
+
An integer between 0 and 5 to indicate CIE Sky Type.
|
|
107
|
+
|
|
108
|
+
* 0 = Sunny with sun. Sunny sky with sun. In addition to the sky distribution
|
|
109
|
+
function, a source description of the sun is generated.
|
|
110
|
+
* 1 = Sunny without sun. Sunny sky without sun. The sky distribution will
|
|
111
|
+
correspond to a standard CIE clear day.
|
|
112
|
+
* 2 = Intermediate with sun. In addition to the sky distribution, a (somewhat
|
|
113
|
+
subdued) sun is generated.
|
|
114
|
+
* 3 = Intermediate without sun. The sky will correspond to a standard CIE
|
|
115
|
+
intermediate day.
|
|
116
|
+
* 4 = Cloudy sky. The sky distribution will correspond to a standard CIE
|
|
117
|
+
overcast day.
|
|
118
|
+
* 5 = Uniform cloudy sky. The sky distribution will be completely uniform.
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
return self._sky_type
|
|
122
|
+
|
|
123
|
+
@sky_type.setter
|
|
124
|
+
def sky_type(self, value):
|
|
125
|
+
value = typing.int_in_range(value, 0, 5, 'CIE sky type')
|
|
126
|
+
self._sky_type = value
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def sky_type_human_readable(self):
|
|
130
|
+
"""A human readable description of sky type."""
|
|
131
|
+
return self.SKYTYPES[self.sky_type][1]
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def sky_type_radiance(self):
|
|
135
|
+
"""Sky type in Radiance format.
|
|
136
|
+
|
|
137
|
+
* +s = Sunny with sun. Sunny sky with sun. In addition to the sky distribution
|
|
138
|
+
function, a source description of the sun is generated.
|
|
139
|
+
* -s = Sunny without sun. Sunny sky without sun. The sky distribution will
|
|
140
|
+
correspond to a standard CIE clear day.
|
|
141
|
+
* +i = Intermediate with sun. In addition to the sky distribution, a (somewhat
|
|
142
|
+
subdued) sun is generated.
|
|
143
|
+
* -i = Intermediate without sun. The sky will correspond to a standard CIE
|
|
144
|
+
intermediate day.
|
|
145
|
+
* -c = Cloudy sky. The sky distribution will correspond to a standard CIE
|
|
146
|
+
overcast day.
|
|
147
|
+
* -u = Uniform cloudy sky. The sky distribution will be completely uniform.
|
|
148
|
+
|
|
149
|
+
"""
|
|
150
|
+
return self.SKYTYPES[self.sky_type][0]
|
|
151
|
+
|
|
152
|
+
@classmethod
|
|
153
|
+
def from_lat_long(
|
|
154
|
+
cls, latitude, longitude, time_zone, month, day, hour, sky_type=0,
|
|
155
|
+
north_angle=0, ground_reflectance=0.2):
|
|
156
|
+
"""Create sky with certain illuminance.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
latitude: Location latitude between -90 (south) and 90 (north).
|
|
160
|
+
longitude: Location longitude between -180 (west) and 180 (east).
|
|
161
|
+
time_zone: Time zone between -12 hours (west) and +14 hours (east). If
|
|
162
|
+
None, the time will be interpreted as solar time at the given longitude.
|
|
163
|
+
month: An integer between 1-12 for month.
|
|
164
|
+
day: An integer between 1 to 28-31 depending on the input month.
|
|
165
|
+
hour: A float number larger or equal to 0 and smaller than 24.
|
|
166
|
+
sky_type: An integer between 0..5 to indicate CIE Sky Type.
|
|
167
|
+
|
|
168
|
+
* 0 = Sunny with sun. Sunny sky with sun. In addition to the sky
|
|
169
|
+
distribution function, a source description of the sun is generated.
|
|
170
|
+
* 1 = Sunny without sun. Sunny sky without sun. The sky distribution will
|
|
171
|
+
correspond to a standard CIE clear day.
|
|
172
|
+
* 2 = Intermediate with sun. In addition to the sky distribution, a
|
|
173
|
+
(somewhat subdued) sun is generated.
|
|
174
|
+
* 3 = Intermediate without sun. The sky will correspond to a standard CIE
|
|
175
|
+
intermediate day.
|
|
176
|
+
* 4 = Cloudy sky. The sky distribution will correspond to a standard CIE
|
|
177
|
+
overcast day.
|
|
178
|
+
* 5 = Uniform cloudy sky. The sky distribution will be completely
|
|
179
|
+
uniform.
|
|
180
|
+
|
|
181
|
+
north_angle: North angle in degrees. A number between -360 and 360 for the
|
|
182
|
+
counterclockwise difference between the North and the positive Y-axis in
|
|
183
|
+
degrees. 90 is West and 270 is East (Default: 0).
|
|
184
|
+
ground_reflectance: Average ground reflectance (Default: 0.2).
|
|
185
|
+
"""
|
|
186
|
+
# calculate altitude and azimuth using ladybug's sunpath
|
|
187
|
+
sp = Sunpath(latitude, longitude, time_zone, north_angle)
|
|
188
|
+
sun = sp.calculate_sun(month, day, hour)
|
|
189
|
+
return cls(sun.altitude, sun.azimuth_from_y_axis, sky_type, ground_reflectance)
|
|
190
|
+
|
|
191
|
+
@classmethod
|
|
192
|
+
def from_location(cls, location, month, day, hour, sky_type=0,
|
|
193
|
+
north_angle=0, ground_reflectance=0.2):
|
|
194
|
+
"""Create a standard CIE sky for a location.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
location: A Ladybug location.
|
|
198
|
+
month: An integer between 1-12 for month.
|
|
199
|
+
day: An integer between 1 to 28-31 depending on the input month.
|
|
200
|
+
hour: A float number larger or equal to 0 and smaller than 24.
|
|
201
|
+
sky_type: An integer between 0..5 to indicate CIE Sky Type.
|
|
202
|
+
|
|
203
|
+
* 0 = Sunny with sun. Sunny sky with sun. In addition to the sky
|
|
204
|
+
distribution function, a source description of the sun is generated.
|
|
205
|
+
* 1 = Sunny without sun. Sunny sky without sun. The sky distribution will
|
|
206
|
+
correspond to a standard CIE clear day.
|
|
207
|
+
* 2 = Intermediate with sun. In addition to the sky distribution, a
|
|
208
|
+
(somewhat subdued) sun is generated.
|
|
209
|
+
* 3 = Intermediate without sun. The sky will correspond to a standard CIE
|
|
210
|
+
intermediate day.
|
|
211
|
+
* 4 = Cloudy sky. The sky distribution will correspond to a standard CIE
|
|
212
|
+
overcast day.
|
|
213
|
+
* 5 = Uniform cloudy sky. The sky distribution will be completely
|
|
214
|
+
uniform.
|
|
215
|
+
|
|
216
|
+
north_angle: North angle in degrees. A number between -360 and 360 for the
|
|
217
|
+
counterclockwise difference between the North and the positive Y-axis in
|
|
218
|
+
degrees. 90 is West and 270 is East (Default: 0).
|
|
219
|
+
ground_reflectance: Average ground reflectance (Default: 0.2).
|
|
220
|
+
"""
|
|
221
|
+
assert isinstance(location, Location), \
|
|
222
|
+
'location must be from type Location not {}'.format(type(location))
|
|
223
|
+
return cls.from_lat_long(
|
|
224
|
+
location.latitude, location.longitude, location.time_zone, month, day, hour,
|
|
225
|
+
sky_type, north_angle, ground_reflectance)
|
|
226
|
+
|
|
227
|
+
@classmethod
|
|
228
|
+
def from_dict(cls, data):
|
|
229
|
+
"""Create the sky from a dictionary.
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
data: A python dictionary in the following format
|
|
233
|
+
|
|
234
|
+
.. code-block:: python
|
|
235
|
+
|
|
236
|
+
{
|
|
237
|
+
'type': 'CIE',
|
|
238
|
+
'altitude': 0.0,
|
|
239
|
+
'azimuth': 0.0,
|
|
240
|
+
'sky_type': 0, # optional integer for sky type
|
|
241
|
+
'ground_reflectance': 0.2 # optional fraction for ground reflectance
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
"""
|
|
245
|
+
assert 'type' in data, \
|
|
246
|
+
'Input dict is missing type. Not a valid CIE dictionary.'
|
|
247
|
+
assert data['type'] == 'CIE', \
|
|
248
|
+
'Input type must be CIE not %s' % data['type']
|
|
249
|
+
|
|
250
|
+
st = data['sky_type'] if 'sky_type' in data else 0
|
|
251
|
+
gr = data['ground_reflectance'] if 'ground_reflectance' in data else 0.2
|
|
252
|
+
return cls(data['altitude'], data['azimuth'], st, gr)
|
|
253
|
+
|
|
254
|
+
@classmethod
|
|
255
|
+
def from_string(cls, sky_string):
|
|
256
|
+
"""Create a CIE sky from a string.
|
|
257
|
+
|
|
258
|
+
Args:
|
|
259
|
+
sky_string: A text string representing a CIE sky. This can be a minimal
|
|
260
|
+
representation of the sky (eg. "cie -alt 71.6 -az 185.2 -type 0").
|
|
261
|
+
Or it can be a detailed specification of time and location (eg.
|
|
262
|
+
"cie 21 Jun 12:00 -lat 41.78 -lon -87.75 -type 0"). The "-type"
|
|
263
|
+
property of CIE skies is optional and, if unspecified, it
|
|
264
|
+
defaults to 0 (Sunny with Sun).
|
|
265
|
+
Any sky string can optionally have a "-g" property of a fractional
|
|
266
|
+
number, which sets the reflectance of the ground. If unspecified,
|
|
267
|
+
the ground will have a reflectance of 0.2. The detailed string can
|
|
268
|
+
optionally have a "-tz" property with an integer between -12 and +14
|
|
269
|
+
to denote the time zone. If unspecified, the time will be interpreted
|
|
270
|
+
as solar time at the given longitude. The detailed string can also
|
|
271
|
+
have a "-n" property between 0 and 360 to set the counterclockwise
|
|
272
|
+
difference between the North and the positive Y-axis in degrees.
|
|
273
|
+
All other properties specified in the string are required.
|
|
274
|
+
|
|
275
|
+
Usage:
|
|
276
|
+
|
|
277
|
+
.. code-block:: python
|
|
278
|
+
|
|
279
|
+
# minimal string representation of the sky
|
|
280
|
+
sky_string = "cie -alt 71.6 -az 185.2 -type 2"
|
|
281
|
+
sky = CIE.from_string(sky_string)
|
|
282
|
+
|
|
283
|
+
# detailed location-specific representation of the sky
|
|
284
|
+
sky_string = "cie 21 Jun 12:00 -lat 41.78 -lon -87.75 -tz -6"
|
|
285
|
+
sky = CIE.from_string(sky_string)
|
|
286
|
+
"""
|
|
287
|
+
# check the input and parse the datetime if it exists
|
|
288
|
+
lower_str = sky_string.lower()
|
|
289
|
+
assert lower_str.startswith('cie'), 'Expected string representation ' \
|
|
290
|
+
'of CIE sky "{}" to start with "cie".'.format(sky_string)
|
|
291
|
+
split_str = shlex.split(lower_str)
|
|
292
|
+
try:
|
|
293
|
+
dtime = DateTime.from_date_time_string(' '.join(split_str[1:4]))
|
|
294
|
+
except (ValueError, IndexError): # simpler sky representation
|
|
295
|
+
dtime = None
|
|
296
|
+
|
|
297
|
+
# make a parser for all of the other sky properties
|
|
298
|
+
pars = argparse.ArgumentParser()
|
|
299
|
+
pars.add_argument('-type', action='store', dest='type', type=int, default=0)
|
|
300
|
+
pars.add_argument('-g', action='store', dest='g', type=float, default=0.2)
|
|
301
|
+
|
|
302
|
+
# create the sky object
|
|
303
|
+
if dtime is None:
|
|
304
|
+
pars.add_argument('-alt', action='store', dest='alt', type=float, default=90)
|
|
305
|
+
pars.add_argument('-az', action='store', dest='az', type=float, default=0)
|
|
306
|
+
props = pars.parse_args(split_str[1:])
|
|
307
|
+
return cls(props.alt, props.az, props.type, props.g)
|
|
308
|
+
else:
|
|
309
|
+
pars.add_argument('-lat', action='store', dest='lat', type=float, default=0)
|
|
310
|
+
pars.add_argument('-lon', action='store', dest='lon', type=float, default=0)
|
|
311
|
+
pars.add_argument('-tz', action='store', dest='tz', type=int, default=0)
|
|
312
|
+
pars.add_argument('-n', action='store', dest='n', type=float, default=0)
|
|
313
|
+
props = pars.parse_args(split_str[4:])
|
|
314
|
+
return cls.from_lat_long(
|
|
315
|
+
props.lat, props.lon, props.tz, dtime.month, dtime.day,
|
|
316
|
+
dtime.float_hour, props.type, props.n, props.g)
|
|
317
|
+
|
|
318
|
+
# TODO: add support for additional parameters
|
|
319
|
+
# TODO: add gensky to radiance-command and use it for validating inputs
|
|
320
|
+
def to_radiance(self):
|
|
321
|
+
"""Return radiance definition as a string."""
|
|
322
|
+
command = '!gensky -ang %.6f %.6f %s -g %.3f' % (
|
|
323
|
+
self.altitude, self.azimuth - 180.0, self.sky_type_radiance,
|
|
324
|
+
self.ground_reflectance
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
return '%s\n\n%s\n\n%s\n' % (
|
|
328
|
+
command, self.sky_hemisphere, self.ground_hemisphere
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
def to_dict(self):
|
|
332
|
+
"""Translate sky to a dictionary."""
|
|
333
|
+
return {
|
|
334
|
+
'type': 'CIE',
|
|
335
|
+
'altitude': self.altitude,
|
|
336
|
+
'azimuth': self.azimuth,
|
|
337
|
+
'sky_type': self.sky_type,
|
|
338
|
+
'ground_reflectance': self.ground_reflectance
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
def to_file(self, folder, name=None, mkdir=False):
|
|
342
|
+
"""Write sky hemisphere to a sky_hemisphere.rad Radiance file.
|
|
343
|
+
|
|
344
|
+
Args:
|
|
345
|
+
folder: Target folder.
|
|
346
|
+
name: File name.
|
|
347
|
+
mkdir: A boolean to note if the directory should be created if doesn't
|
|
348
|
+
exist (default: False).
|
|
349
|
+
|
|
350
|
+
Returns:
|
|
351
|
+
Full path to the newly created file.
|
|
352
|
+
"""
|
|
353
|
+
content = self.to_radiance()
|
|
354
|
+
name = typing.valid_string(name) if name \
|
|
355
|
+
else '%.3f_%.3f_%s.sky' % (
|
|
356
|
+
self.altitude, self.azimuth,
|
|
357
|
+
self.sky_type_human_readable.replace(' ', '_').lower()
|
|
358
|
+
)
|
|
359
|
+
return futil.write_to_file_by_name(folder, name, content, mkdir)
|
|
360
|
+
|
|
361
|
+
def __eq__(self, value):
|
|
362
|
+
if type(value) != type(self) \
|
|
363
|
+
or value.altitude != self.altitude \
|
|
364
|
+
or value.azimuth != self.azimuth \
|
|
365
|
+
or value.sky_type != self.sky_type \
|
|
366
|
+
or self.ground_reflectance != value.ground_reflectance \
|
|
367
|
+
or self.ground_hemisphere != value.ground_hemisphere \
|
|
368
|
+
or self.sky_hemisphere != value.sky_hemisphere:
|
|
369
|
+
return False
|
|
370
|
+
return True
|
|
371
|
+
|
|
372
|
+
def __ne__(self, value):
|
|
373
|
+
return not self.__eq__(value)
|
|
374
|
+
|
|
375
|
+
def __repr__(self):
|
|
376
|
+
"""Sky representation."""
|
|
377
|
+
return 'cie -alt {} -az {} -type {} -g {}'.format(
|
|
378
|
+
self.altitude, self.azimuth, self.sky_type, self.ground_reflectance)
|