Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(well): Add pass/fail folder #207

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
23 changes: 22 additions & 1 deletion honeybee_radiance_postprocess/well/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import numpy as np

from ladybug.analysisperiod import AnalysisPeriod
from ladybug.datatype.generic import GenericType
from ladybug.datacollection import HourlyContinuousCollection
from ladybug.datatype.generic import GenericType
from ladybug.header import Header
from honeybee.model import Model
from honeybee.units import conversion_factor_to_meters
Expand Down Expand Up @@ -458,6 +458,27 @@ def to_datacollection(aperture_group: str, values: np.ndarray):
da_file.parent.mkdir(parents=True, exist_ok=True)
np.savetxt(da_file, da, fmt='%.2f')

sda_pf_folder = ies_lm_folder.joinpath('pass_fail')
sda_pf_folder.mkdir(parents=True, exist_ok=True)
for l01_pf, grid_info in zip(l01_pass_sda_grids, grids_info):
grid_id = grid_info['full_id']
l01_sda_pf_folder = sda_pf_folder.joinpath('L01')
l01_sda_pf_folder.mkdir(parents=True, exist_ok=True)
l01_pf_file = l01_sda_pf_folder.joinpath(f'{grid_id}.pf')
l01_pf = l01_pf.astype(int)
np.savetxt(l01_pf_file, l01_pf, fmt='%d')
grids_info_file = l01_sda_pf_folder.joinpath('grids_info.json')
grids_info_file.write_text(json.dumps(grids_info, indent=2))
for l06_pf, grid_info in zip(l06_pass_sda_grids, grids_info):
grid_id = grid_info['full_id']
l06_sda_pf_folder = sda_pf_folder.joinpath('L06')
l06_sda_pf_folder.mkdir(parents=True, exist_ok=True)
l06_pf_file = l06_sda_pf_folder.joinpath(f'{grid_id}.pf')
l06_pf = l06_pf.astype(int)
np.savetxt(l06_pf_file, l06_pf, fmt='%d')
grids_info_file = l06_sda_pf_folder.joinpath('grids_info.json')
grids_info_file.write_text(json.dumps(grids_info, indent=2))

da_grids_info_file = l06_ies_lm_folder.joinpath(
'results', 'da', 'grids_info.json')
da_grids_info_file.write_text(json.dumps(grids_info, indent=2))
Expand Down
Loading