Skip to content

Commit

Permalink
fix(daylight): Add handler for Glare Autonomy
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Apr 6, 2022
1 parent 713b378 commit 819a82e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pollination_handlers/outputs/daylight.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def read_udi_from_folder(result_folder):
return read_sensor_grid_result(result_folder, 'udi', 'full_id')


def read_ga_from_folder(result_folder):
"""Read glare autonomy values from a folder with radiance .da result files."""
return read_sensor_grid_result(result_folder, 'ga', 'full_id', factor=100)


def read_hours_from_folder(result_folder):
"""Read hours from a folder with radiance .res result files."""
return read_sensor_grid_result(result_folder, 'res', 'full_id', False)
Expand Down
12 changes: 9 additions & 3 deletions pollination_handlers/outputs/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import json


def read_sensor_grid_result(result_folder, extension, grid_key, is_percent=True):
def read_sensor_grid_result(
result_folder, extension, grid_key, is_percent=True, factor=1):
"""Read results from files that align with sensor grids.
Args:
Expand All @@ -13,6 +14,9 @@ def read_sensor_grid_result(result_folder, extension, grid_key, is_percent=True)
is_percent: Boolean to note if the values are intended to be percent, in
which case a check will be done to ensure no value is greater than
one hundred.
factor: An optional number to be multiplied by all of the results.
This can be used to perform unit conversions or change fractional values
to percentages. (Default: 1)
Returns:
A matrix with each sub-list containing the values for each of the sensor grids.
Expand Down Expand Up @@ -42,8 +46,10 @@ def read_sensor_grid_result(result_folder, extension, grid_key, is_percent=True)
for _ in range(st_ln):
next(inf)
if is_percent:
results.append([min(float(next(inf)), 100) for _ in range(sensor_count)])
results.append(
[min(float(next(inf)) * factor, 100) for _ in range(sensor_count)]
)
else:
results.append([float(next(inf)) for _ in range(sensor_count)])
results.append([float(next(inf)) * factor for _ in range(sensor_count)])

return results

0 comments on commit 819a82e

Please sign in to comment.