Skip to content

Commit

Permalink
fix(well): Add CLI for WELL vis metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkelkp committed Jan 2, 2025
1 parent 1687b79 commit a0906ae
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions honeybee_radiance_postprocess/cli/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
import sys
import logging
import click
import json
import os

from ladybug.color import Color
from ladybug.datatype.generic import GenericType
from ladybug.legend import LegendParameters

from ..well.well import well_annual_daylight

Expand Down Expand Up @@ -45,6 +51,7 @@ def well_daylight(
Args:
folder: Results folder. This folder is an output folder of annual daylight
recipe. The daylight simulation must include aperture groups.
daylight_hours: Daylight hours schedule for EN 17037.
"""
with open(daylight_hours) as hourly_schedule:
daylight_hours = [int(float(v)) for v in hourly_schedule]
Expand All @@ -58,3 +65,46 @@ def well_daylight(
sys.exit(1)
else:
sys.exit(0)


@well.command('well-daylight-vis-metadata')
@click.option(
'--output-folder', '-o', help='Output folder for vis metadata files.',
type=click.Path(exists=False, file_okay=False, dir_okay=True, resolve_path=True),
default='visualization', show_default=True
)
def well_daylight_vis(output_folder):
"""Write visualization metadata files for WELL Daylight."""
colors = [Color(220, 0, 0), Color(0, 220, 0)]
pass_fail_lpar = \
LegendParameters(min=0, max=1, colors=colors, segment_count=2, title='Pass/Fail')
pass_fail_lpar.ordinal_dictionary = {0: "Fail", 1: "Pass"}

metric_info_dict = {
'L01': {
'type': 'VisualizationMetaData',
'data_type': GenericType('sDA200,40%', '').to_dict(),
'unit': '',
'legend_parameters': pass_fail_lpar.to_dict()
},
'L06': {
'type': 'VisualizationMetaData',
'data_type': GenericType('sDA300,50%', '').to_dict(),
'unit': '',
'legend_parameters': pass_fail_lpar.to_dict()
}
}
try:
if not os.path.exists(output_folder):
os.mkdir(output_folder)
for metric, data in metric_info_dict.items():
if not os.path.exists(os.path.join(output_folder, metric)):
os.mkdir(os.path.join(output_folder, metric))
file_path = os.path.join(output_folder, metric, 'vis_metadata.json')
with open(file_path, 'w') as fp:
json.dump(data, fp, indent=4)
except Exception:
_logger.exception('Failed to write the visualization metadata files.')
sys.exit(1)
else:
sys.exit(0)

0 comments on commit a0906ae

Please sign in to comment.