honeybee-grasshopper-radiance 1.35.2__py3-none-any.whl → 1.35.3__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.
@@ -0,0 +1,187 @@
1
+ # Honeybee: A Plugin for Environmental Analysis (GPL)
2
+ # This file is part of Honeybee.
3
+ #
4
+ # Copyright (c) 2025, Ladybug Tools.
5
+ # You should have received a copy of the GNU Affero General Public License
6
+ # along with Honeybee; If not, see <http://www.gnu.org/licenses/>.
7
+ #
8
+ # @license AGPL-3.0-or-later <https://spdx.org/licenses/AGPL-3.0-or-later>
9
+
10
+ """
11
+ Calculate typical statistics (Average, median, minimum, maximum, sum) for an
12
+ annual daylight or irradiance simulation.
13
+
14
+ Statistics can either be computed per sensor or per timestep.
15
+
16
+ -
17
+ Args:
18
+ _results: An list of annual Radiance result files from the "HB Annual Daylight"
19
+ component (containing the .ill files and the sun-up-hours.txt).
20
+ This can also be just the path to the folder containing these
21
+ result files.
22
+ dyn_sch_: Optional dynamic Aperture Group Schedules from the "HB Aperture Group
23
+ Schedule" component, which will be used to customize the behavior
24
+ of any dyanmic aperture geometry in the output metrics. If unsupplied,
25
+ all dynamic aperture groups will be in their default state in for
26
+ the output metrics.
27
+ _hoys_: An optional numbers or list of numbers to select the hours of the year (HOYs)
28
+ for which results will be computed. These HOYs can be obtained from the
29
+ "LB Calculate HOY" or the "LB Analysis Period" components. If None, all
30
+ hours of the results will be used.
31
+ grid_filter_: The name of a grid or a pattern to filter the grids. For instance,
32
+ first_floor_* will simulate only the sensor grids that have an
33
+ identifier that starts with first_floor_. By default all the grids
34
+ will be processed.
35
+ per_timestep_: Set to True to calculate statistics per-timestep instead of per-sensor.
36
+ (Default: False)
37
+
38
+ Returns:
39
+ report: Reports, errors, warnings, etc.
40
+ average: Average illuminance or irradiance values for each sensor or timestep
41
+ in lux or W/m2. This is either a list of values or a list of data collections
42
+ if per_timestep_ is True.
43
+ median: Median illuminance or irradiance values for each sensor or timestep
44
+ in lux or W/m2. This is either a list of values or a list of data collections
45
+ if per_timestep_ is True.
46
+ minimum: Minimum illuminance or irradiance values for each sensor or timestep
47
+ in lux or W/m2. This is either a list of values or a list of data collections
48
+ if per_timestep_ is True.
49
+ maximum: Maximum illuminance or irradiance values for each sensor or timestep
50
+ in lux or W/m2. This is either a list of values or a list of data collections
51
+ if per_timestep_ is True.
52
+ cumulative: Cumulative illuminance or irradiance values for each sensor or timestep
53
+ in lux or W/m2. This is either a list of values or a list of data collections
54
+ if per_timestep_ is True.
55
+ """
56
+
57
+ ghenv.Component.Name = "HB Annual Statistics"
58
+ ghenv.Component.NickName = 'AnnualStatistics'
59
+ ghenv.Component.Message = '1.9.0'
60
+ ghenv.Component.Category = 'HB-Radiance'
61
+ ghenv.Component.SubCategory = '4 :: Results'
62
+ ghenv.Component.AdditionalHelpFromDocStrings = '2'
63
+
64
+ import os
65
+ import json
66
+ import subprocess
67
+
68
+ try:
69
+ from ladybug.datacollection import HourlyContinuousCollection
70
+ from ladybug.futil import write_to_file
71
+ except ImportError as e:
72
+ raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))
73
+
74
+ try:
75
+ from honeybee.config import folders
76
+ except ImportError as e:
77
+ raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))
78
+
79
+ try:
80
+ from honeybee_radiance_postprocess.dynamic import DynamicSchedule
81
+ except ImportError as e:
82
+ raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e))
83
+
84
+ try:
85
+ from pollination_handlers.outputs.helper import read_sensor_grid_result
86
+ except ImportError as e:
87
+ raise ImportError('\nFailed to import pollination_handlers:\n\t{}'.format(e))
88
+
89
+ try:
90
+ from ladybug_rhino.grasshopper import all_required_inputs, list_to_data_tree, \
91
+ give_warning
92
+ except ImportError as e:
93
+ raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))
94
+
95
+
96
+ if all_required_inputs(ghenv.Component):
97
+ # compute the annual summary
98
+ grid_filter_ = '*' if grid_filter_ is None else grid_filter_
99
+ res_folder = _results
100
+ per_timestep = False if per_timestep_ is None else per_timestep_
101
+
102
+ # check to see if results use the newer numpy arrays
103
+ if os.path.isdir(os.path.join(res_folder, '__static_apertures__')) or \
104
+ os.path.isfile(os.path.join(res_folder, 'grid_states.json')):
105
+ cmds = [folders.python_exe_path, '-m', 'honeybee_radiance_postprocess',
106
+ 'post-process', 'annual-statistics', res_folder, '-sf',
107
+ 'statistics']
108
+ if len(_hoys_) != 0:
109
+ hoys_str = '\n'.join(str(h) for h in _hoys_)
110
+ hoys_file = os.path.join(res_folder, 'hoys.txt')
111
+ write_to_file(hoys_file, hoys_str)
112
+ cmds.extend(['--hoys-file', hoys_file])
113
+ if grid_filter_ != '*':
114
+ cmds.extend(['--grids-filter', grid_filter_])
115
+ if len(dyn_sch_) != 0:
116
+ if os.path.isfile(os.path.join(res_folder, 'grid_states.json')):
117
+ dyn_sch = dyn_sch_[0] if isinstance(dyn_sch_[0], DynamicSchedule) else \
118
+ DynamicSchedule.from_group_schedules(dyn_sch_)
119
+ dyn_sch_file = dyn_sch.to_json(folder=res_folder)
120
+ cmds.extend(['--states', dyn_sch_file])
121
+ else:
122
+ msg = 'No dynamic aperture groups were found in the Model.\n' \
123
+ 'The input dynamic schedules will be ignored.'
124
+ print(msg)
125
+ give_warning(ghenv.Component, msg)
126
+
127
+ if per_timestep:
128
+ cmds.extend(['--timestep'])
129
+
130
+ use_shell = True if os.name == 'nt' else False
131
+ custom_env = os.environ.copy()
132
+ custom_env['PYTHONHOME'] = ''
133
+ process = subprocess.Popen(
134
+ cmds, cwd=res_folder, shell=use_shell, env=custom_env,
135
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
136
+ stdout = process.communicate() # wait for the process to finish
137
+ if stdout[-1] != '':
138
+ print(stdout[-1])
139
+ raise ValueError('Failed to compute {} values.'.format(res_type))
140
+
141
+ res_dir = os.path.join(res_folder, 'statistics')
142
+ average_values_dir = os.path.join(res_dir, 'average_values')
143
+ median_values_dir = os.path.join(res_dir, 'median_values')
144
+ minimum_values_dir = os.path.join(res_dir, 'minimum_values')
145
+ maximum_values_dir = os.path.join(res_dir, 'maximum_values')
146
+ cumulative_values_dir = os.path.join(res_dir, 'cumulative_values')
147
+
148
+ if per_timestep is False:
149
+ average = list_to_data_tree(read_sensor_grid_result(average_values_dir, 'average', 'full_id', False))
150
+ median = list_to_data_tree(read_sensor_grid_result(median_values_dir, 'median', 'full_id', False))
151
+ minimum = list_to_data_tree(read_sensor_grid_result(minimum_values_dir, 'minimum', 'full_id', False))
152
+ maximum = list_to_data_tree(read_sensor_grid_result(maximum_values_dir, 'maximum', 'full_id', False))
153
+ cumulative = list_to_data_tree(read_sensor_grid_result(cumulative_values_dir, 'cumulative', 'full_id', False))
154
+ else:
155
+ with open(os.path.join(average_values_dir, 'grids_info.json')) as json_file:
156
+ grids_info = json.load(json_file)
157
+ average = []
158
+ median = []
159
+ minimum = []
160
+ maximum = []
161
+ cumulative = []
162
+ for grid_info in grids_info:
163
+ with open(os.path.join(average_values_dir, '{}_average.json'.format(grid_info['full_id']))) as json_file:
164
+ data_dict = json.load(json_file)
165
+ average.append(HourlyContinuousCollection.from_dict(data_dict))
166
+ with open(os.path.join(median_values_dir, '{}_median.json'.format(grid_info['full_id']))) as json_file:
167
+ data_dict = json.load(json_file)
168
+ median.append(HourlyContinuousCollection.from_dict(data_dict))
169
+ with open(os.path.join(minimum_values_dir, '{}_minimum.json'.format(grid_info['full_id']))) as json_file:
170
+ data_dict = json.load(json_file)
171
+ minimum.append(HourlyContinuousCollection.from_dict(data_dict))
172
+ with open(os.path.join(maximum_values_dir, '{}_maximum.json'.format(grid_info['full_id']))) as json_file:
173
+ data_dict = json.load(json_file)
174
+ maximum.append(HourlyContinuousCollection.from_dict(data_dict))
175
+ with open(os.path.join(cumulative_values_dir, '{}_cumulative.json'.format(grid_info['full_id']))) as json_file:
176
+ data_dict = json.load(json_file)
177
+ cumulative.append(HourlyContinuousCollection.from_dict(data_dict))
178
+ average = list_to_data_tree(average)
179
+ median = list_to_data_tree(median)
180
+ minimum = list_to_data_tree(minimum)
181
+ maximum = list_to_data_tree(maximum)
182
+ cumulative = list_to_data_tree(cumulative)
183
+ else:
184
+ msg = 'Summary is only only supported for Annual Daylight and Annual Irradiance ' \
185
+ 'simulations with NumPy arrays.'
186
+ print(msg)
187
+ give_warning(ghenv.Component, msg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: honeybee-grasshopper-radiance
3
- Version: 1.35.2
3
+ Version: 1.35.3
4
4
  Summary: Honeybee Radiance plugin for Grasshopper.
5
5
  Home-page: https://github.com/ladybug-tools/honeybee-grasshopper-radiance
6
6
  Author: Ladybug Tools
@@ -9,6 +9,7 @@ honeybee_grasshopper_radiance/src/HB Annual Glare Metrics.py,sha256=Uu-aqGjt3jlI
9
9
  honeybee_grasshopper_radiance/src/HB Annual Irradiance.py,sha256=siIRkhWb2i_wgZamlJGKktkgZ7CPi7qsML13Slti3Y4,6032
10
10
  honeybee_grasshopper_radiance/src/HB Annual Peak Values.py,sha256=x-q1Y6tUTsOovB5C6Y2E47L9XpSPE-Jv0WAY5Rdtim0,10002
11
11
  honeybee_grasshopper_radiance/src/HB Annual Results to Data.py,sha256=4HeXXyOFVQEBz60g4vC4f404BKjqmowUX6YZWNKzhvA,11021
12
+ honeybee_grasshopper_radiance/src/HB Annual Statistics.py,sha256=HGDZuvqHjjv77yA0HDjYdYESoXEQ5XRqkDE6498b1YQ,9526
12
13
  honeybee_grasshopper_radiance/src/HB Annual Sunlight Exposure.py,sha256=NlJefTSQofAIZrlG_PClFhYdXhfE_rChH81mRW9Gr0w,6393
13
14
  honeybee_grasshopper_radiance/src/HB Aperture Group Schedule.py,sha256=nL0lSzHEDI9iBGRSJODFAC1xDPu-GxTNIxGKa4qu7a8,3052
14
15
  honeybee_grasshopper_radiance/src/HB Apply Face Modifier.py,sha256=Hl73JhJpvQR052x0TRjJvp0CQ84VwaBBeQijVw9QhWY,4475
@@ -90,6 +91,7 @@ honeybee_grasshopper_radiance/user_objects/HB Annual Glare Metrics.ghuser,sha256
90
91
  honeybee_grasshopper_radiance/user_objects/HB Annual Irradiance.ghuser,sha256=w1r_ZZqRwsjTv6hw06xjc86uD_-mCIO-y9rbQS09eL4,7347
91
92
  honeybee_grasshopper_radiance/user_objects/HB Annual Peak Values.ghuser,sha256=9OM0F7Po7CuKPbxLNIvh-G_IxDKddhdelIYaq6K7j8Y,7127
92
93
  honeybee_grasshopper_radiance/user_objects/HB Annual Results to Data.ghuser,sha256=bQ9T5VAVir1Cb7CynWMNmJSAz-bk6S57z0IwKILq6hs,7147
94
+ honeybee_grasshopper_radiance/user_objects/HB Annual Statistics.ghuser,sha256=4IY2aovV99kob3iPTTlVgLJ9ZjFaY_sN2Y5ZX1OLomQ,6733
93
95
  honeybee_grasshopper_radiance/user_objects/HB Annual Sunlight Exposure.ghuser,sha256=SoeX9wjEJH1BJbDwGpdyuqeJO8EK2LLjskYRprIL_xI,5578
94
96
  honeybee_grasshopper_radiance/user_objects/HB Aperture Group Schedule.ghuser,sha256=7-tSPfPcf4DkuQGBv3MruJOnlffX8g0pf5_GRW1brHw,5178
95
97
  honeybee_grasshopper_radiance/user_objects/HB Apply Face Modifier.ghuser,sha256=tDRYfk6OGwxzvkilbeLX7QwY95W-l9sveozSc2Xb2Ys,4978
@@ -163,8 +165,8 @@ honeybee_grasshopper_radiance/user_objects/HB Wea From EPW.ghuser,sha256=PcjwWzO
163
165
  honeybee_grasshopper_radiance/user_objects/HB Wea From Tau Clear Sky.ghuser,sha256=du9nzM95d3uL2-1sf1fFll_QfRloVaL4Q_JGd7Nb5NI,5367
164
166
  honeybee_grasshopper_radiance/user_objects/HB Wea from Zhang-Huang.ghuser,sha256=9KMXIDn5sfhk0h4QfZoKfFuHvI6x0bXVDJ3Ozd2CWNg,4678
165
167
  honeybee_grasshopper_radiance/user_objects/__init__.py,sha256=7BOscRVupILqwFUBWP6nAsMNgNN8lXQPsQ_zYUvGEr8,50
166
- honeybee_grasshopper_radiance-1.35.2.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
167
- honeybee_grasshopper_radiance-1.35.2.dist-info/METADATA,sha256=8TYb6KCe8f2gnDYLNMyXCk-9Ve745Ka3iVCJJ6BuzIk,2879
168
- honeybee_grasshopper_radiance-1.35.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
169
- honeybee_grasshopper_radiance-1.35.2.dist-info/top_level.txt,sha256=BBzJ4nJKMDfzWMqymIH91kdsQlHSptnGHSk8i6_KZ_4,30
170
- honeybee_grasshopper_radiance-1.35.2.dist-info/RECORD,,
168
+ honeybee_grasshopper_radiance-1.35.3.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
169
+ honeybee_grasshopper_radiance-1.35.3.dist-info/METADATA,sha256=a6l_szw6CKFQ9-6QPyz4r6KPhFLNZ5FSO3rMDr1JV6A,2879
170
+ honeybee_grasshopper_radiance-1.35.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
171
+ honeybee_grasshopper_radiance-1.35.3.dist-info/top_level.txt,sha256=BBzJ4nJKMDfzWMqymIH91kdsQlHSptnGHSk8i6_KZ_4,30
172
+ honeybee_grasshopper_radiance-1.35.3.dist-info/RECORD,,