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,177 @@
|
|
|
1
|
+
from .hemisphere import Hemisphere
|
|
2
|
+
from ..ground import Ground
|
|
3
|
+
import honeybee.typing as typing
|
|
4
|
+
import ladybug.futil as futil
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class _SkyDome(object):
|
|
8
|
+
"""Virtual SkyDome base-class with Radiance ground and sky sphere.
|
|
9
|
+
|
|
10
|
+
Properties:
|
|
11
|
+
* ground_hemisphere
|
|
12
|
+
* sky_hemisphere
|
|
13
|
+
* is_point_in_time
|
|
14
|
+
* is_climate_based
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
__slots__ = ('_ground_hemisphere', '_sky_hemisphere')
|
|
18
|
+
|
|
19
|
+
def __init__(self, modifier='skyfunc'):
|
|
20
|
+
self._ground_hemisphere = Ground(modifier)
|
|
21
|
+
self._sky_hemisphere = Hemisphere(modifier)
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def ground_hemisphere(self):
|
|
25
|
+
"""Sky ground glow source."""
|
|
26
|
+
return self._ground_hemisphere
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def sky_hemisphere(self):
|
|
30
|
+
"""Sky hemisphere glow source."""
|
|
31
|
+
return self._sky_hemisphere
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def is_point_in_time(self):
|
|
35
|
+
"""Return True if the sky is generated for a single point in time."""
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def is_climate_based(self):
|
|
40
|
+
"""Return True if the sky is created based on values from weather data."""
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def from_dict(cls, data):
|
|
45
|
+
"""Create the sky baseclass from a dictionary.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
data: A python dictionary in the following format
|
|
49
|
+
|
|
50
|
+
.. code-block:: python
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
'type': 'SkyDome',
|
|
54
|
+
'ground_hemisphere': {}, # see ground.Ground class [optional],
|
|
55
|
+
'sky_hemisphere': {} # see hemisphere.Hemisphere class [optional]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
"""
|
|
59
|
+
assert 'type' in data, \
|
|
60
|
+
'Input dict is missing type. Not a valid SkyDome dictionary.'
|
|
61
|
+
assert data['type'] == 'SkyDome', \
|
|
62
|
+
'Input type must be SkyDome not %s' % data['type']
|
|
63
|
+
|
|
64
|
+
sky = cls()
|
|
65
|
+
|
|
66
|
+
if 'ground_hemisphere' in data and data['ground_hemisphere'] is not None:
|
|
67
|
+
sky._ground_hemisphere = Ground.from_dict(data['ground_hemisphere'])
|
|
68
|
+
|
|
69
|
+
if 'sky_hemisphere' in data and data['sky_hemisphere'] is not None:
|
|
70
|
+
sky._sky_hemisphere = Hemisphere.from_dict(data['sky_hemisphere'])
|
|
71
|
+
|
|
72
|
+
return sky
|
|
73
|
+
|
|
74
|
+
def to_radiance(self):
|
|
75
|
+
"""Return radiance definition as a string."""
|
|
76
|
+
return '%s\n\n%s\n' % (self.sky_hemisphere, self.ground_hemisphere)
|
|
77
|
+
|
|
78
|
+
def to_dict(self):
|
|
79
|
+
"""Translate sky to a dictionary."""
|
|
80
|
+
return {
|
|
81
|
+
'type': 'SkyDome',
|
|
82
|
+
'ground_hemisphere': self.ground_hemisphere.to_dict(),
|
|
83
|
+
'sky_hemisphere': self.sky_hemisphere.to_dict()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
def to_file(self, folder, name=None, mkdir=False):
|
|
87
|
+
"""Write sky hemisphere to a sky_hemisphere.rad Radiance file.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
folder: Target folder.
|
|
91
|
+
name: File name.
|
|
92
|
+
mkdir: A boolean to note if the directory should be created if doesn't
|
|
93
|
+
exist (default: False).
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Full path to the newly created file.
|
|
97
|
+
"""
|
|
98
|
+
content = self.to_radiance()
|
|
99
|
+
name = typing.valid_string(name) if name else 'skydome.rad'
|
|
100
|
+
return futil.write_to_file_by_name(folder, name, content, mkdir)
|
|
101
|
+
|
|
102
|
+
def ToString(self):
|
|
103
|
+
"""Overwrite .NET ToString."""
|
|
104
|
+
return self.__repr__()
|
|
105
|
+
|
|
106
|
+
def __repr__(self):
|
|
107
|
+
"""Sky representation."""
|
|
108
|
+
return self.to_radiance()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class _PointInTime(_SkyDome):
|
|
112
|
+
"""Point-in-time sky base-class with Radiance ground and sky sphere.
|
|
113
|
+
|
|
114
|
+
Properties:
|
|
115
|
+
* ground_hemisphere
|
|
116
|
+
* sky_hemisphere
|
|
117
|
+
* ground_reflectance
|
|
118
|
+
* is_point_in_time
|
|
119
|
+
* is_climate_based
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
__slots__ = ('_ground_reflectance',)
|
|
123
|
+
|
|
124
|
+
def __init__(self, ground_reflectance):
|
|
125
|
+
_SkyDome.__init__(self)
|
|
126
|
+
self.ground_reflectance = ground_reflectance
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def ground_reflectance(self):
|
|
130
|
+
"""Get or set a value between 0 and 1 for the ground reflectance.
|
|
131
|
+
|
|
132
|
+
If not specified, a default of 0.2 will be used."""
|
|
133
|
+
return self._ground_reflectance
|
|
134
|
+
|
|
135
|
+
@ground_reflectance.setter
|
|
136
|
+
def ground_reflectance(self, ground_reflectance):
|
|
137
|
+
self._ground_reflectance = \
|
|
138
|
+
typing.float_in_range(ground_reflectance, 0, 1, 'ground reflectance') \
|
|
139
|
+
if ground_reflectance is not None else 0.2
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def is_point_in_time(self):
|
|
143
|
+
"""Return True if the sky is generated for a single point in time."""
|
|
144
|
+
return True
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def from_dict(cls, data):
|
|
148
|
+
"""Create the sky baseclass from a dictionary.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
data: A python dictionary in the following format
|
|
152
|
+
|
|
153
|
+
.. code-block:: python
|
|
154
|
+
|
|
155
|
+
{
|
|
156
|
+
'ground_reflectance': 0.2,
|
|
157
|
+
'ground_hemisphere': {}, # see ground.Ground class [optional],
|
|
158
|
+
'sky_hemisphere': {} # see hemisphere.Hemisphere class [optional]
|
|
159
|
+
}
|
|
160
|
+
"""
|
|
161
|
+
sky = cls(data['ground_reflectance'])
|
|
162
|
+
|
|
163
|
+
if 'ground_hemisphere' in data and data['ground_hemisphere'] is not None:
|
|
164
|
+
sky._ground_hemisphere = Ground.from_dict(data['ground_hemisphere'])
|
|
165
|
+
|
|
166
|
+
if 'sky_hemisphere' in data and data['sky_hemisphere'] is not None:
|
|
167
|
+
sky._sky_hemisphere = Hemisphere.from_dict(data['sky_hemisphere'])
|
|
168
|
+
|
|
169
|
+
return sky
|
|
170
|
+
|
|
171
|
+
def to_dict(self):
|
|
172
|
+
"""Translate sky to a dictionary."""
|
|
173
|
+
return {
|
|
174
|
+
'ground_reflectance': self.ground_reflectance,
|
|
175
|
+
'ground_hemisphere': self.ground_hemisphere.to_dict(),
|
|
176
|
+
'sky_hemisphere': self.sky_hemisphere.to_dict()
|
|
177
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"""Generate sky with certain irradiance."""
|
|
2
|
+
from __future__ import division
|
|
3
|
+
import argparse
|
|
4
|
+
import shlex
|
|
5
|
+
|
|
6
|
+
import honeybee.typing as typing
|
|
7
|
+
import ladybug.futil as futil
|
|
8
|
+
|
|
9
|
+
from ._skybase import _PointInTime
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CertainIrradiance(_PointInTime):
|
|
13
|
+
"""sky with certain irradiance.
|
|
14
|
+
|
|
15
|
+
The output of CertainIrradiance sky is similar to using command below::
|
|
16
|
+
|
|
17
|
+
gensky -c -B desired_irradiance
|
|
18
|
+
|
|
19
|
+
You can also generate the sky with certain illuminance using ``from_illuminance``
|
|
20
|
+
classmethod. The method converts the illuminance value to irradiance by dividing it
|
|
21
|
+
by 179.0::
|
|
22
|
+
|
|
23
|
+
gensky -c -B [desired_illuminance / 179.0]
|
|
24
|
+
|
|
25
|
+
It also includes ground glow source. Ground reflectance is set to %20 by default
|
|
26
|
+
which is gensky's default value. Use `ground_reflectance` property to adjust this
|
|
27
|
+
value.
|
|
28
|
+
|
|
29
|
+
Note:
|
|
30
|
+
|
|
31
|
+
The conversion factor in the Radiance system for luminous efficacy is fixed at
|
|
32
|
+
KR= 179 lumens/watt (lm/w). This should not be confused with the more usual
|
|
33
|
+
daylighting value, which can be anywhere between 50 and 150 lm/w depending on the
|
|
34
|
+
type of sky or light considered.
|
|
35
|
+
|
|
36
|
+
For more information see links below on the Radiance forum:
|
|
37
|
+
|
|
38
|
+
* https://discourse.radiance-online.org/t/coefficient-179/547
|
|
39
|
+
* https://discourse.radiance-online.org/t/luminous-efficacy/1400
|
|
40
|
+
|
|
41
|
+
Default value is set to 558.659 which corresponds to a sky with 100,000 lux
|
|
42
|
+
horizontal illuminance.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
irradiance: Desired horizontal diffuse irradiance value in watts/meter2
|
|
46
|
+
(Default: 558.659).
|
|
47
|
+
ground_reflectance: Average ground reflectance (Default: 0.2).
|
|
48
|
+
uniform: Boolean to note whether the sky is uniform instead of
|
|
49
|
+
cloudy. (Default: False)
|
|
50
|
+
|
|
51
|
+
Properties:
|
|
52
|
+
* irradiance
|
|
53
|
+
* illuminance
|
|
54
|
+
* ground_hemisphere
|
|
55
|
+
* sky_hemisphere
|
|
56
|
+
* ground_reflectance
|
|
57
|
+
* uniform
|
|
58
|
+
* is_point_in_time
|
|
59
|
+
* is_climate_based
|
|
60
|
+
"""
|
|
61
|
+
__slots__ = ('_irradiance', '_uniform')
|
|
62
|
+
|
|
63
|
+
def __init__(self, irradiance=558.659, ground_reflectance=0.2, uniform=False):
|
|
64
|
+
"""Create sky with certain irradiance."""
|
|
65
|
+
_PointInTime.__init__(self, ground_reflectance)
|
|
66
|
+
self.irradiance = irradiance
|
|
67
|
+
self.uniform = uniform
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def from_illuminance(cls, illuminance=100000, ground_reflectance=0.2, uniform=False):
|
|
71
|
+
"""Create sky with certain illuminance.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
illuminance: Desired horizontal illuminance value in lux (Default: 100000).
|
|
75
|
+
ground_reflectance: Average ground reflectance (Default: 0.2).
|
|
76
|
+
uniform: Boolean to note whether the sky is uniform instead of
|
|
77
|
+
cloudy. (Default: False)
|
|
78
|
+
"""
|
|
79
|
+
return cls(illuminance / 179.0, ground_reflectance, uniform)
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def irradiance(self):
|
|
83
|
+
"""Sky irradiance value."""
|
|
84
|
+
return self._irradiance
|
|
85
|
+
|
|
86
|
+
@irradiance.setter
|
|
87
|
+
def irradiance(self, irradiance):
|
|
88
|
+
self._irradiance = typing.float_positive(irradiance) \
|
|
89
|
+
if irradiance is not None else 558.659
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def illuminance(self):
|
|
93
|
+
"""Sky illuminance value."""
|
|
94
|
+
return round(self._irradiance * 179.0, 2)
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def uniform(self):
|
|
98
|
+
"""Boolean to note whether the sky is uniform instead of cloudy."""
|
|
99
|
+
return self._uniform
|
|
100
|
+
|
|
101
|
+
@uniform.setter
|
|
102
|
+
def uniform(self, value):
|
|
103
|
+
self._uniform = bool(value)
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def is_point_in_time(self):
|
|
107
|
+
"""Return True if the sky is generated for a single point in time."""
|
|
108
|
+
return False
|
|
109
|
+
|
|
110
|
+
@classmethod
|
|
111
|
+
def from_dict(cls, data):
|
|
112
|
+
"""Create the sky from a dictionary.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
data: A python dictionary in the following format
|
|
116
|
+
|
|
117
|
+
.. code-block:: python
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
'type': 'CertainIrradiance',
|
|
121
|
+
'irradiance': 558.659,
|
|
122
|
+
'ground_reflectance': 0.2,
|
|
123
|
+
'uniform': False
|
|
124
|
+
}
|
|
125
|
+
"""
|
|
126
|
+
assert 'type' in data, \
|
|
127
|
+
'Input dict is missing type. Not a valid CertainIrradiance dictionary.'
|
|
128
|
+
assert data['type'] == 'CertainIrradiance', \
|
|
129
|
+
'Input type must be CertainIrradiance not %s' % data['type']
|
|
130
|
+
|
|
131
|
+
uniform = data['uniform'] if 'uniform' in data else False
|
|
132
|
+
gr = data['ground_reflectance'] if 'ground_reflectance' in data else 0.2
|
|
133
|
+
return cls(data['irradiance'], gr, uniform)
|
|
134
|
+
|
|
135
|
+
@classmethod
|
|
136
|
+
def from_string(cls, sky_string):
|
|
137
|
+
"""Create a CertainIrradiance sky from a string.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
sky_string: A text string representing a CertainIrradiance sky. This
|
|
141
|
+
can be either a string with a certain irradiance (eg.
|
|
142
|
+
"irradiance 558.659") or with a certain illuminance (eg.
|
|
143
|
+
"illuminance 100000"). Any sky string can optionally
|
|
144
|
+
have a "-g" property of a fractional number, which sets the
|
|
145
|
+
reflectance of the ground. If unspecified, the ground will have
|
|
146
|
+
a reflectance of 0.2. This sky can also have a "-u" property to
|
|
147
|
+
set the sky as uniform instead of the default cloudy.
|
|
148
|
+
|
|
149
|
+
Usage:
|
|
150
|
+
|
|
151
|
+
.. code-block:: python
|
|
152
|
+
|
|
153
|
+
# irradiance string representation of the sky
|
|
154
|
+
sky_string = "irradiance 558.659"
|
|
155
|
+
sky = CertainIrradiance.from_string(sky_string)
|
|
156
|
+
|
|
157
|
+
# illuminance string representation of the sky
|
|
158
|
+
sky_string = "illuminance 100000 -g 0.3 -u"
|
|
159
|
+
sky = CertainIrradiance.from_string(sky_string)
|
|
160
|
+
"""
|
|
161
|
+
# check the input
|
|
162
|
+
lower_str = sky_string.lower()
|
|
163
|
+
assert lower_str.startswith(('irradiance', 'illuminance')), \
|
|
164
|
+
'Expected string representation of CertainIrradiance sky "{}" to ' \
|
|
165
|
+
'start with "irradiance" or "illuminance".'.format(sky_string)
|
|
166
|
+
split_str = shlex.split(lower_str)
|
|
167
|
+
# make a parser for all of the other sky properties
|
|
168
|
+
pars = argparse.ArgumentParser()
|
|
169
|
+
pars.add_argument('value', action='store', type=float)
|
|
170
|
+
pars.add_argument('-g', action='store', dest='g', type=float, default=0.2)
|
|
171
|
+
pars.add_argument('-u', action='store_true', dest='u', default=False)
|
|
172
|
+
props = pars.parse_args(split_str[1:])
|
|
173
|
+
|
|
174
|
+
# create the sky object
|
|
175
|
+
if split_str[0] == 'irradiance':
|
|
176
|
+
return cls(props.value, props.g, props.u)
|
|
177
|
+
else:
|
|
178
|
+
return cls.from_illuminance(props.value, props.g, props.u)
|
|
179
|
+
|
|
180
|
+
def to_radiance(self):
|
|
181
|
+
"""Return radiance definition as a string."""
|
|
182
|
+
sky_type = '-u' if self.uniform else '-c'
|
|
183
|
+
command = '!gensky -ang 45 0 %s -B %.6f -g %.3f' % (
|
|
184
|
+
sky_type, self.irradiance, self.ground_reflectance
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
return '%s\n\n%s\n\n%s\n' % (
|
|
188
|
+
command, self.sky_hemisphere, self.ground_hemisphere
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
def to_dict(self):
|
|
192
|
+
"""Translate sky to a dictionary."""
|
|
193
|
+
return {
|
|
194
|
+
'type': 'CertainIrradiance',
|
|
195
|
+
'irradiance': self.irradiance,
|
|
196
|
+
'ground_reflectance': self.ground_reflectance,
|
|
197
|
+
'uniform': self.uniform
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
def to_file(self, folder, name=None, mkdir=False):
|
|
201
|
+
"""Write sky hemisphere to a sky_hemisphere.rad Radiance file.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
folder: Target folder.
|
|
205
|
+
name: File name.
|
|
206
|
+
mkdir: A boolean to note if the directory should be created if doesn't
|
|
207
|
+
exist (default: False).
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
Full path to the newly created file.
|
|
211
|
+
"""
|
|
212
|
+
content = self.to_radiance()
|
|
213
|
+
name = typing.valid_string(name) if name \
|
|
214
|
+
else '%d_lux.sky' % int(self.illuminance)
|
|
215
|
+
return futil.write_to_file_by_name(folder, name, content, mkdir)
|
|
216
|
+
|
|
217
|
+
def __eq__(self, value):
|
|
218
|
+
if type(value) != type(self) \
|
|
219
|
+
or value.irradiance != self.irradiance \
|
|
220
|
+
or self.ground_reflectance != value.ground_reflectance \
|
|
221
|
+
or self.ground_hemisphere != value.ground_hemisphere \
|
|
222
|
+
or self.sky_hemisphere != value.sky_hemisphere:
|
|
223
|
+
return False
|
|
224
|
+
return True
|
|
225
|
+
|
|
226
|
+
def __ne__(self, value):
|
|
227
|
+
return not self.__eq__(value)
|
|
228
|
+
|
|
229
|
+
def __repr__(self):
|
|
230
|
+
"""Sky representation."""
|
|
231
|
+
base_str = 'irradiance {} -g {}'.format(self.irradiance, self.ground_reflectance)
|
|
232
|
+
return base_str + ' -u' if self.uniform else base_str
|