Skip to content

Commit

Permalink
fix(grid util): add the info for the last sensor grid
Browse files Browse the repository at this point in the history
This is an edge case when the number of sensors in the last grid is smaller than then number of sensors in each grid. Now the code catches this case and adds the information as needed.
  • Loading branch information
mostaphaRoudsari committed Oct 4, 2021
1 parent 0630ad1 commit 02bc4e7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions honeybee_radiance_folder/gridutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def get_target_file(index):
if not os.path.isdir(output_folder):
os.mkdir(output_folder)

extra_sensors = False
out_grid_info = []
outf_index = 0
outf = get_target_file(outf_index)
Expand Down Expand Up @@ -129,6 +130,7 @@ def get_target_file(index):
if outf_index == grid_count:
# This was the last file and more sensors are left.
# Add the remainder of the sensors to this file and close the file.
extra_sensors = True
counter = 0
for line in inf:
counter += 1
Expand All @@ -150,6 +152,16 @@ def get_target_file(index):
if 'end_ln' not in dist_info[i]['dist_info'][-1]:
dist_info[i]['dist_info'][-1]['end_ln'] = line_out_count - 1
inf.close()
if not extra_sensors:
# add the information for the last sensor grid
out_data = {
'name': str(outf_index),
'identifier': str(outf_index),
'full_id': str(outf_index),
'group': '',
'count': line_out_count
}
out_grid_info.append(out_data)

dist_info_file = os.path.join(output_folder, '_dist_info.json')
with open(dist_info_file, 'w') as dist_out_file:
Expand Down

0 comments on commit 02bc4e7

Please sign in to comment.