Skip to content

Commit

Permalink
fix(abnt): Add option for room center or grid center
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkelkp committed Jun 21, 2024
1 parent aba0efe commit a251124
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
33 changes: 22 additions & 11 deletions honeybee_radiance_postprocess/cli/abnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from honeybee.model import Model
from ladybug_geometry.geometry3d.face import Face3D
from ladybug_geometry.geometry3d.pointvector import Point3D
from ladybug_geometry.geometry3d.pointvector import Vector3D

from ..vis_metadata import _abnt_nbr_15575_daylight_levels_vis_metadata

Expand All @@ -28,13 +28,17 @@ def abnt():
)
@click.argument('model-file', type=click.Path(
exists=True, file_okay=True, dir_okay=False, resolve_path=True))
@click.option(
'--room-center/--grid-center', '-rc/-gc', help='Flag to note whether the '
'evaluation of the center is at the room center or the grid center.',
default=True, show_default=True)
@click.option(
'--sub-folder', '-sf', help='Relative path for subfolder to write output '
'files.', default='abnt_nbr_15575', type=click.Path(
exists=False, file_okay=False, dir_okay=True, resolve_path=True, path_type=Path)
)
def abnt_nbr_15575(
folder, model_file, sub_folder
folder, model_file, room_center, sub_folder
):
"""Calculate metrics for ABNT NBR 15575.
Expand Down Expand Up @@ -97,7 +101,7 @@ def perform_interpolation(x, y, x_coords, y_coords, pit_values):

try:
folder = Path(folder)
hb_model = Model.from_file(model_file)
hb_model: Model = Model.from_file(model_file)
sensor_grids = hb_model.properties.radiance.sensor_grids
sg_full_identifier = {sg.full_identifier: sg for sg in sensor_grids}

Expand Down Expand Up @@ -139,15 +143,22 @@ def perform_interpolation(x, y, x_coords, y_coords, pit_values):
pof_sensor_grids.get(grid_info['full_id'], None)
# if pof is not calculated for this grid
if pof_sensor_grid is None:
faces_3d = [Face3D(face_vertices) for face_vertices in sensor_grid.mesh.face_vertices]
face_3d_union = Face3D.join_coplanar_faces(faces_3d, 0.05)
assert len(face_3d_union) == 1
if face_3d_union[0].is_convex:
centroid = face_3d_union[0].centroid
pof_sensor_grids[grid_info['full_id']] = centroid
if room_center:
room = hb_model.rooms_by_identifier(
[sensor_grid.room_identifier]
)[0]
pof_sensor_grids[grid_info['full_id']] = \
room.center + Vector3D(0, 0, 0.75)
else:
pof = face_3d_union[0].pole_of_inaccessibility(0.01)
pof_sensor_grids[grid_info['full_id']] = pof
faces_3d = [Face3D(face_vertices) for face_vertices in sensor_grid.mesh.face_vertices]
face_3d_union = Face3D.join_coplanar_faces(faces_3d, 0.05)
assert len(face_3d_union) == 1
if face_3d_union[0].is_convex:
centroid = face_3d_union[0].centroid
pof_sensor_grids[grid_info['full_id']] = centroid
else:
pof = face_3d_union[0].pole_of_inaccessibility(0.01)
pof_sensor_grids[grid_info['full_id']] = pof

x = pof_sensor_grids[grid_info['full_id']].x
y = pof_sensor_grids[grid_info['full_id']].y
Expand Down
10 changes: 5 additions & 5 deletions honeybee_radiance_postprocess/vis_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ def _abnt_nbr_15575_daylight_levels_vis_metadata():
colors = [Color(255, 198, 143), Color(255, 255, 209), Color(192, 231, 189), Color(83, 169, 206)]
illuminance_levels_lpar = \
LegendParameters(min=0, max=3, colors=colors, segment_count=4,
title='Illuminance Level')
title='Níveis de iluminamento')
illuminance_levels_lpar.ordinal_dictionary = level_value

metric_info_dict = {
'4_930AM': {
'type': 'VisualizationMetaData',
'data_type': GenericType('Illuminance April 23rd 9:30am', '').to_dict(),
'data_type': GenericType('23 de abril 9:30h', '').to_dict(),
'unit': '',
'legend_parameters': illuminance_levels_lpar.to_dict()
},
'4_330PM': {
'type': 'VisualizationMetaData',
'data_type': GenericType('Illuminance April 23rd 3:30pm', '').to_dict(),
'data_type': GenericType('23 de abril 15:30h', '').to_dict(),
'unit': '',
'legend_parameters': illuminance_levels_lpar.to_dict()
},
'10_930AM': {
'type': 'VisualizationMetaData',
'data_type': GenericType('Illuminance October 23rd 9:30am', '').to_dict(),
'data_type': GenericType('23 de outubro 9:30h', '').to_dict(),
'unit': '',
'legend_parameters': illuminance_levels_lpar.to_dict()
},
'10_330PM': {
'type': 'VisualizationMetaData',
'data_type': GenericType('Illuminance October 23rd 3:30pm', '').to_dict(),
'data_type': GenericType('23 de outubro 15:30h', '').to_dict(),
'unit': '',
'legend_parameters': illuminance_levels_lpar.to_dict()
}
Expand Down

0 comments on commit a251124

Please sign in to comment.