honeybee-radiance-postprocess 0.4.389__py2.py3-none-any.whl → 0.4.391__py2.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.
@@ -7,7 +7,9 @@ import click
7
7
  import numpy as np
8
8
 
9
9
  from honeybee.model import Model
10
+ from honeybee.room import Room
10
11
  from ladybug_geometry.geometry3d.face import Face3D
12
+ from ladybug_geometry.geometry3d.pointvector import Vector3D
11
13
 
12
14
  from ..vis_metadata import _abnt_nbr_15575_daylight_levels_vis_metadata
13
15
 
@@ -27,13 +29,23 @@ def abnt():
27
29
  )
28
30
  @click.argument('model-file', type=click.Path(
29
31
  exists=True, file_okay=True, dir_okay=False, resolve_path=True))
32
+ @click.option(
33
+ '--ground-level', '-gl', help='A value to define the height of the ground '
34
+ 'level. This will make sure that rooms below this height will not be '
35
+ 'counted as ground level rooms.',
36
+ default=0, show_default=True, type=click.FLOAT
37
+ )
38
+ @click.option(
39
+ '--room-center/--grid-center', '-rc/-gc', help='Flag to note whether the '
40
+ 'evaluation of the center is at the room center or the grid center.',
41
+ default=True, show_default=True)
30
42
  @click.option(
31
43
  '--sub-folder', '-sf', help='Relative path for subfolder to write output '
32
44
  'files.', default='abnt_nbr_15575', type=click.Path(
33
45
  exists=False, file_okay=False, dir_okay=True, resolve_path=True, path_type=Path)
34
46
  )
35
47
  def abnt_nbr_15575(
36
- folder, model_file, sub_folder
48
+ folder, model_file, ground_level, room_center, sub_folder
37
49
  ):
38
50
  """Calculate metrics for ABNT NBR 15575.
39
51
 
@@ -96,7 +108,15 @@ def abnt_nbr_15575(
96
108
 
97
109
  try:
98
110
  folder = Path(folder)
99
- hb_model = Model.from_file(model_file)
111
+ hb_model: Model = Model.from_file(model_file)
112
+ grouped_rooms, floor_heights = Room.group_by_floor_height(hb_model.rooms)
113
+
114
+ # pick the first group >= to ground level
115
+ for gr, fh in zip(grouped_rooms, floor_heights):
116
+ if fh >= ground_level:
117
+ ground_level_rooms = gr
118
+ break
119
+
100
120
  sensor_grids = hb_model.properties.radiance.sensor_grids
101
121
  sg_full_identifier = {sg.full_identifier: sg for sg in sensor_grids}
102
122
 
@@ -106,9 +126,14 @@ def abnt_nbr_15575(
106
126
  if not illuminance_levels_folder.exists():
107
127
  illuminance_levels_folder.mkdir(parents=True, exist_ok=True)
108
128
 
109
- summary_file = sub_folder.joinpath('abnt_nbr_15575.json')
110
- summary_rooms_file = sub_folder.joinpath('abnt_nbr_15575_rooms.json')
129
+ summary_rooms_csv = sub_folder.joinpath('abnt_nbr_15575_rooms.csv')
111
130
  folder_names = ['4_930AM', '4_330PM', '10_930AM', '10_330PM']
131
+ pit_mapper = {
132
+ '4_930AM': 'Abril 09:30',
133
+ '4_330PM': 'Abril 15:30',
134
+ '10_930AM': 'Outubro 09:30',
135
+ '10_330PM': 'Outubro 15:30'
136
+ }
112
137
 
113
138
  metric_info_dict = _abnt_nbr_15575_daylight_levels_vis_metadata()
114
139
  summary_output = {}
@@ -129,28 +154,40 @@ def abnt_nbr_15575(
129
154
  x_coords = sensor_points[:, 0]
130
155
  y_coords = sensor_points[:, 1]
131
156
 
157
+ room = hb_model.rooms_by_identifier([sensor_grid.room_identifier])[0]
158
+
132
159
  pof_sensor_grid = \
133
160
  pof_sensor_grids.get(grid_info['full_id'], None)
134
161
  # if pof is not calculated for this grid
135
162
  if pof_sensor_grid is None:
136
- faces_3d = [Face3D(face_vertices) for face_vertices in sensor_grid.mesh.face_vertices]
137
- face_3d_union = Face3D.join_coplanar_faces(faces_3d, 0.05)
138
- assert len(face_3d_union) == 1
139
- if face_3d_union[0].is_convex:
140
- centroid = face_3d_union[0].centroid
141
- pof_sensor_grids[grid_info['full_id']] = (centroid.x, centroid.y)
163
+ if room_center:
164
+ pof_sensor_grids[grid_info['full_id']] = \
165
+ room.center + Vector3D(0, 0, 0.75)
142
166
  else:
143
- pof = face_3d_union[0].pole_of_inaccessibility(0.01)
144
- pof_sensor_grids[grid_info['full_id']] = (pof.x, pof.y)
145
-
146
- x, y = pof_sensor_grids[grid_info['full_id']]
167
+ faces_3d = [Face3D(face_vertices) for face_vertices in sensor_grid.mesh.face_vertices]
168
+ face_3d_union = Face3D.join_coplanar_faces(faces_3d, 0.05)
169
+ assert len(face_3d_union) == 1
170
+ if face_3d_union[0].is_convex:
171
+ centroid = face_3d_union[0].centroid
172
+ pof_sensor_grids[grid_info['full_id']] = centroid
173
+ else:
174
+ pof = face_3d_union[0].pole_of_inaccessibility(0.01)
175
+ pof_sensor_grids[grid_info['full_id']] = pof
176
+
177
+ x = pof_sensor_grids[grid_info['full_id']].x
178
+ y = pof_sensor_grids[grid_info['full_id']].y
147
179
  f_xy = perform_interpolation(x, y, x_coords, y_coords, pit_values)
148
180
 
181
+ if room in ground_level_rooms:
182
+ minimo = 48
183
+ else:
184
+ minimo = 60
185
+
149
186
  if f_xy >= 120:
150
187
  level = 'Superior'
151
188
  elif f_xy >= 90:
152
189
  level = 'Intermediário'
153
- elif f_xy >= 60: # add check for ground floor (48 lux)
190
+ elif f_xy >= minimo: # add check for ground floor (48 lux)
154
191
  level = 'Mínimo'
155
192
  else:
156
193
  level = 'Não atende'
@@ -161,12 +198,14 @@ def abnt_nbr_15575(
161
198
  summary_rooms_output[grid_info['full_id']] = {
162
199
  'nível': level,
163
200
  'iluminância': f_xy,
164
- 'grids_info': grid_info
201
+ 'grids_info': grid_info,
202
+ pit_mapper[_subfolder]: f_xy,
165
203
  }
166
204
  else:
167
205
  if f_xy < room_summary['iluminância']:
168
206
  room_summary['nível'] = level
169
207
  room_summary['iluminância'] = f_xy
208
+ room_summary[pit_mapper[_subfolder]] = f_xy
170
209
 
171
210
  sub_output.append(
172
211
  {
@@ -196,11 +235,48 @@ def abnt_nbr_15575(
196
235
  grids_info_file = folder.joinpath(_subfolder, 'grids_info.json')
197
236
  grids_info_file.write_text(json.dumps(grids_info, indent=2))
198
237
 
199
- with summary_file.open(mode='w', encoding='utf-8') as output_file:
200
- json.dump(summary_output, output_file, indent=4, ensure_ascii=False)
201
-
202
- with summary_rooms_file.open(mode='w', encoding='utf-8') as output_file:
203
- json.dump(summary_rooms_output, output_file, indent=4, ensure_ascii=False)
238
+ # set up the default data types
239
+ dtype = [
240
+ ('Sensor Grid', 'O'),
241
+ ('Sensor Grid ID', 'O'),
242
+ ('Abril 09:30', np.float32),
243
+ ('Abril 15:30', np.float32),
244
+ ('Outubro 09:30', np.float32),
245
+ ('Outubro 15:30', np.float32),
246
+ ('Atendimento', 'O')
247
+ ]
248
+
249
+ # set up format
250
+ fmt = ['%s', '%s', '%.2f', '%.2f', '%.2f', '%.2f', '%s']
251
+
252
+ arrays = []
253
+ for room_summary in summary_rooms_output.values():
254
+ data = []
255
+ data.append(room_summary['grids_info']['name'])
256
+ data.append(room_summary['grids_info']['full_id'])
257
+ data.append(room_summary['Abril 09:30'])
258
+ data.append(room_summary['Abril 15:30'])
259
+ data.append(room_summary['Outubro 09:30'])
260
+ data.append(room_summary['Outubro 15:30'])
261
+ data.append(room_summary['nível'])
262
+ arrays.append(tuple(data))
263
+
264
+ # create structured array
265
+ struct_array = np.array(arrays, dtype=dtype)
266
+
267
+ header = [dt[0] for dt in dtype]
268
+ # write header to summary_rooms_csv
269
+ with summary_rooms_csv.open(mode='w', encoding='utf-8') as output_file:
270
+ output_file.write(','.join(header))
271
+ output_file.write('\n') # add newline after header
272
+
273
+ # write structured array to summary_rooms_csv
274
+ with summary_rooms_csv.open(mode='a', encoding='utf-8') as output_file:
275
+ np.savetxt(output_file, struct_array, delimiter=',', fmt=fmt)
276
+
277
+ center_points_file = sub_folder.joinpath('center_points.json')
278
+ data = [pof.to_dict() for pof in pof_sensor_grids.values()]
279
+ center_points_file.write_text(json.dumps(data, indent=4))
204
280
 
205
281
  except Exception:
206
282
  _logger.exception('Failed to calculate ABNT NBR 15575 metrics.')
@@ -16,31 +16,31 @@ def _abnt_nbr_15575_daylight_levels_vis_metadata():
16
16
  colors = [Color(255, 198, 143), Color(255, 255, 209), Color(192, 231, 189), Color(83, 169, 206)]
17
17
  illuminance_levels_lpar = \
18
18
  LegendParameters(min=0, max=3, colors=colors, segment_count=4,
19
- title='Illuminance Level')
19
+ title='Níveis de iluminamento')
20
20
  illuminance_levels_lpar.ordinal_dictionary = level_value
21
21
 
22
22
  metric_info_dict = {
23
23
  '4_930AM': {
24
24
  'type': 'VisualizationMetaData',
25
- 'data_type': GenericType('Illuminance April 23rd 9:30am', '').to_dict(),
25
+ 'data_type': GenericType('23 de abril 9:30h', '').to_dict(),
26
26
  'unit': '',
27
27
  'legend_parameters': illuminance_levels_lpar.to_dict()
28
28
  },
29
29
  '4_330PM': {
30
30
  'type': 'VisualizationMetaData',
31
- 'data_type': GenericType('Illuminance April 23rd 3:30pm', '').to_dict(),
31
+ 'data_type': GenericType('23 de abril 15:30h', '').to_dict(),
32
32
  'unit': '',
33
33
  'legend_parameters': illuminance_levels_lpar.to_dict()
34
34
  },
35
35
  '10_930AM': {
36
36
  'type': 'VisualizationMetaData',
37
- 'data_type': GenericType('Illuminance October 23rd 9:30am', '').to_dict(),
37
+ 'data_type': GenericType('23 de outubro 9:30h', '').to_dict(),
38
38
  'unit': '',
39
39
  'legend_parameters': illuminance_levels_lpar.to_dict()
40
40
  },
41
41
  '10_330PM': {
42
42
  'type': 'VisualizationMetaData',
43
- 'data_type': GenericType('Illuminance October 23rd 3:30pm', '').to_dict(),
43
+ 'data_type': GenericType('23 de outubro 15:30h', '').to_dict(),
44
44
  'unit': '',
45
45
  'legend_parameters': illuminance_levels_lpar.to_dict()
46
46
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: honeybee-radiance-postprocess
3
- Version: 0.4.389
3
+ Version: 0.4.391
4
4
  Summary: Postprocessing of Radiance results and matrices
5
5
  Home-page: https://github.com/ladybug-tools/honeybee-radiance-postprocess
6
6
  Author: Ladybug Tools
@@ -12,9 +12,9 @@ honeybee_radiance_postprocess/metrics.py,sha256=6EHCuXf5jnhh6GglI9mTd0MFpfhfPFoK
12
12
  honeybee_radiance_postprocess/reader.py,sha256=6myKzfGC1pO8zPixg1kKrKjPihHabTKUh2t5BlJvij0,2367
13
13
  honeybee_radiance_postprocess/type_hints.py,sha256=4R0kZgacQrqzoh8Tq7f8MVzUDzynV-C_jlh80UV6GPE,1122
14
14
  honeybee_radiance_postprocess/util.py,sha256=-J5k1dhvyYJkb42jvTS_xxtokfGbmcucVPXdMWU1jUk,5098
15
- honeybee_radiance_postprocess/vis_metadata.py,sha256=darKbj987NXW72GNcTdKQmgqSTpeG39OBwEgbJGEgPw,1820
15
+ honeybee_radiance_postprocess/vis_metadata.py,sha256=7ywIgdiuNKcctxifhpy7-Q2oaSX2ngQBeA0Kh7q1Gg0,1780
16
16
  honeybee_radiance_postprocess/cli/__init__.py,sha256=4RkpR91GPXWatDE4I_27ce-N4FwolQoO6WO7H24DMXE,777
17
- honeybee_radiance_postprocess/cli/abnt.py,sha256=fTMqgzuaZ6d7BE8CI4GWQBr1_r-qWhpay0cPdfrIoR4,9017
17
+ honeybee_radiance_postprocess/cli/abnt.py,sha256=QYBAiYhfJYD1cUaU_Cf4Sn83co9TbPr0fjKiyhZl5Bw,12037
18
18
  honeybee_radiance_postprocess/cli/grid.py,sha256=6peLEAPVe-iw05_wdRpFruZLqO8myvC-_QT5W1q5sk8,10677
19
19
  honeybee_radiance_postprocess/cli/leed.py,sha256=QBR6AMJJWuZ0TevyMi2tXCWMLdS-ZSqtVTZDgqxwa7M,3112
20
20
  honeybee_radiance_postprocess/cli/mtxop.py,sha256=UZJnjNpPjDmShy1-Mxos4H2vTUqk_yP3ZyaC1_LLFeI,5015
@@ -27,9 +27,9 @@ honeybee_radiance_postprocess/results/__init__.py,sha256=1agBQbfT4Tf8KqSZzlfKYX8
27
27
  honeybee_radiance_postprocess/results/annual_daylight.py,sha256=o4Y5kbD3a4X4KRfsbOlWzgrnNKU365GcivM6qQGUGXU,31605
28
28
  honeybee_radiance_postprocess/results/annual_irradiance.py,sha256=5zwrr4MNeHUebbSRpSBbscPOZUs2AHmYCQfIIbdYImY,8298
29
29
  honeybee_radiance_postprocess/results/results.py,sha256=jkjsxTuvVfBus6tM2UjQE3ZKPooLInWEd2guqO61v9E,53600
30
- honeybee_radiance_postprocess-0.4.389.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
31
- honeybee_radiance_postprocess-0.4.389.dist-info/METADATA,sha256=Ha5G2HzkSveW-ITmxpJeG4WFsfkbfst7HJMo5cSV_ik,2245
32
- honeybee_radiance_postprocess-0.4.389.dist-info/WHEEL,sha256=unfA4MOaH0icIyIA5oH6E2sn2Hq5zKtLlHsWapZGwes,110
33
- honeybee_radiance_postprocess-0.4.389.dist-info/entry_points.txt,sha256=gFtVPx6UItXt27GfEZZO00eOZChJJEL6JwGSAB_O3rs,96
34
- honeybee_radiance_postprocess-0.4.389.dist-info/top_level.txt,sha256=4-sFbzy7ewP2EDqJV3jeFlAFx7SuxtoBBELWaKAnLdA,30
35
- honeybee_radiance_postprocess-0.4.389.dist-info/RECORD,,
30
+ honeybee_radiance_postprocess-0.4.391.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
31
+ honeybee_radiance_postprocess-0.4.391.dist-info/METADATA,sha256=5mLAHjElsgqsSSSRmO2mi3N1wDljjQQ1NcOU3i4O5gc,2245
32
+ honeybee_radiance_postprocess-0.4.391.dist-info/WHEEL,sha256=unfA4MOaH0icIyIA5oH6E2sn2Hq5zKtLlHsWapZGwes,110
33
+ honeybee_radiance_postprocess-0.4.391.dist-info/entry_points.txt,sha256=gFtVPx6UItXt27GfEZZO00eOZChJJEL6JwGSAB_O3rs,96
34
+ honeybee_radiance_postprocess-0.4.391.dist-info/top_level.txt,sha256=4-sFbzy7ewP2EDqJV3jeFlAFx7SuxtoBBELWaKAnLdA,30
35
+ honeybee_radiance_postprocess-0.4.391.dist-info/RECORD,,