Skip to content

Commit

Permalink
fix(postprocess): Add a function for point-in-time vis-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkelkp committed Feb 15, 2023
1 parent d367941 commit 75d4a41
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
22 changes: 22 additions & 0 deletions pollination/honeybee_radiance/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,28 @@ def create_daylight_factor_config(self):
cfg_file = Outputs.file(description='Output config file.', path='config.json')


@dataclass
class PointInTimeVisMetadata(Function):
"""Create a visualization metadata file for point-in-time."""

metric = Inputs.str(
description='Text for the type of metric to be output from the calculation. '
'Choose from: illuminance, irradiance, luminance, radiance.',
default='illuminance',
spec={'type': 'string',
'enum': ['illuminance', 'irradiance', 'luminance', 'radiance']}
)

@command
def create_point_in_time_vis_data(self):
return 'honeybee-radiance post-process point-in-time-vis-metadata ' \
'--metric {{self.metric}} --output-file vis_metadata.json'

# outputs
cfg_file = Outputs.file(
description='Output visualization metadata file.', path='vis_metadata.json')


@dataclass
class PointInTimeConfig(Function):
"""Create a config file for point-in-time results."""
Expand Down
18 changes: 17 additions & 1 deletion tests/post_process_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pollination.honeybee_radiance.post_process import ConvertToBinary, SumRow, \
AnnualIrradianceMetrics, AnnualDaylightMetrics, LeedIlluminanceCredits, \
SolarTrackingSynthesis, DaylightFactorConfig, DaylightFactorVisMetadata, \
ImagelessAnnualGlareVisMetadata
ImagelessAnnualGlareVisMetadata, PointInTimeVisMetadata

from queenbee.plugin.function import Function

Expand Down Expand Up @@ -83,3 +83,19 @@ def test_imageless_annual_glare_vis_metadata():
assert output_file.is_file()

nukedir(folder)

def test_point_in_time_vis_metadata():
function = PointInTimeVisMetadata()
qb_function = function.queenbee
assert qb_function.name == 'point-in-time-vis-metadata'
assert isinstance(qb_function, Function)

inputs = {'metric': 'illuminance'}
folder = Path('./tests/assets/temp')
if not folder.exists():
folder.mkdir(parents=True)
output_file = folder.joinpath('vis_metadata.json')
function._try(inputs, folder=folder)
assert output_file.is_file()

nukedir(folder)

0 comments on commit 75d4a41

Please sign in to comment.