Skip to content

Commit

Permalink
fix(recipe): Add visible/solar option to annual-irradiance recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Feb 15, 2022
1 parent a93ad6c commit 30edab4
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import os
import pathlib
from queenbee_local import QueenbeeTask
from queenbee_local import load_input_param as qb_load_input_param


_default_inputs = { 'bsdfs': None,
Expand Down Expand Up @@ -47,7 +46,7 @@ def radiance_parameters(self):

@property
def fixed_radiance_parameters(self):
return '-aa 0.0 -I -ab 1 -c 1'
return '-aa 0.0 -I -ab 1 -c 1 -faf'

@property
def sensor_count(self):
Expand All @@ -57,6 +56,8 @@ def sensor_count(self):
def conversion(self):
return '0.265 0.670 0.065'

header = luigi.Parameter(default='keep')

order_by = luigi.Parameter(default='sensor')

output_format = luigi.Parameter(default='f')
Expand Down Expand Up @@ -109,7 +110,7 @@ def params_folder(self):
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance dc scoeff scene.oct grid.pts sky.dome sky.mtx --sensor-count {sensor_count} --output results.ill --rad-params "{radiance_parameters}" --rad-params-locked "{fixed_radiance_parameters}" --conversion "{conversion}" --output-format {output_format} --order-by-{order_by}'.format(sensor_count=self.sensor_count, radiance_parameters=self.radiance_parameters, fixed_radiance_parameters=self.fixed_radiance_parameters, conversion=self.conversion, output_format=self.output_format, order_by=self.order_by)
return 'honeybee-radiance dc scoeff scene.oct grid.pts sky.dome sky.mtx --sensor-count {sensor_count} --output results.ill --rad-params "{radiance_parameters}" --rad-params-locked "{fixed_radiance_parameters}" --conversion "{conversion}" --output-format {output_format} --order-by-{order_by} --{header}-header'.format(sensor_count=self.sensor_count, radiance_parameters=self.radiance_parameters, fixed_radiance_parameters=self.fixed_radiance_parameters, conversion=self.conversion, output_format=self.output_format, order_by=self.order_by, header=self.header)

def output(self):
return {
Expand Down Expand Up @@ -172,6 +173,8 @@ def output_format(self):

calculate_values = luigi.Parameter(default='value')

header = luigi.Parameter(default='keep')

order_by = luigi.Parameter(default='sensor')

@property
Expand Down Expand Up @@ -216,7 +219,7 @@ def params_folder(self):
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance dc scontrib scene.oct grid.pts suns.mod --{calculate_values} --sensor-count {sensor_count} --rad-params "{radiance_parameters}" --rad-params-locked "{fixed_radiance_parameters}" --conversion "{conversion}" --output-format {output_format} --output results.ill --order-by-{order_by}'.format(calculate_values=self.calculate_values, sensor_count=self.sensor_count, radiance_parameters=self.radiance_parameters, fixed_radiance_parameters=self.fixed_radiance_parameters, conversion=self.conversion, output_format=self.output_format, order_by=self.order_by)
return 'honeybee-radiance dc scontrib scene.oct grid.pts suns.mod --{calculate_values} --sensor-count {sensor_count} --rad-params "{radiance_parameters}" --rad-params-locked "{fixed_radiance_parameters}" --conversion "{conversion}" --output-format {output_format} --output results.ill --order-by-{order_by} --{header}-header'.format(calculate_values=self.calculate_values, sensor_count=self.sensor_count, radiance_parameters=self.radiance_parameters, fixed_radiance_parameters=self.fixed_radiance_parameters, conversion=self.conversion, output_format=self.output_format, order_by=self.order_by, header=self.header)

def output(self):
return {
Expand Down Expand Up @@ -335,7 +338,7 @@ def radiance_parameters(self):

@property
def fixed_radiance_parameters(self):
return '-aa 0.0 -I -c 1'
return '-aa 0.0 -I -c 1 -faf'

@property
def sensor_count(self):
Expand All @@ -345,6 +348,8 @@ def sensor_count(self):
def conversion(self):
return '0.265 0.670 0.065'

header = luigi.Parameter(default='keep')

order_by = luigi.Parameter(default='sensor')

output_format = luigi.Parameter(default='f')
Expand Down Expand Up @@ -397,7 +402,7 @@ def params_folder(self):
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance dc scoeff scene.oct grid.pts sky.dome sky.mtx --sensor-count {sensor_count} --output results.ill --rad-params "{radiance_parameters}" --rad-params-locked "{fixed_radiance_parameters}" --conversion "{conversion}" --output-format {output_format} --order-by-{order_by}'.format(sensor_count=self.sensor_count, radiance_parameters=self.radiance_parameters, fixed_radiance_parameters=self.fixed_radiance_parameters, conversion=self.conversion, output_format=self.output_format, order_by=self.order_by)
return 'honeybee-radiance dc scoeff scene.oct grid.pts sky.dome sky.mtx --sensor-count {sensor_count} --output results.ill --rad-params "{radiance_parameters}" --rad-params-locked "{fixed_radiance_parameters}" --conversion "{conversion}" --output-format {output_format} --order-by-{order_by} --{header}-header'.format(sensor_count=self.sensor_count, radiance_parameters=self.radiance_parameters, fixed_radiance_parameters=self.fixed_radiance_parameters, conversion=self.conversion, output_format=self.output_format, order_by=self.order_by, header=self.header)

def output(self):
return {
Expand Down Expand Up @@ -426,7 +431,7 @@ def output_artifacts(self):
}]


class _AnnualIrradianceRayTracing_d75637b2Orchestrator(luigi.WrapperTask):
class _AnnualIrradianceRayTracing_2c2db9eeOrchestrator(luigi.WrapperTask):
"""Runs all the tasks in this module."""
# user input for this module
_input_params = luigi.DictParameter()
Expand Down
42 changes: 19 additions & 23 deletions lbt_recipes/annual_irradiance/flow/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
import os
import pathlib
from queenbee_local import QueenbeeTask
from queenbee_local import load_input_param as qb_load_input_param
from .dependencies.annual_irradiance_ray_tracing import _AnnualIrradianceRayTracing_d75637b2Orchestrator as AnnualIrradianceRayTracing_d75637b2Workerbee
from .dependencies.annual_irradiance_ray_tracing import _AnnualIrradianceRayTracing_2c2db9eeOrchestrator as AnnualIrradianceRayTracing_2c2db9eeWorkerbee


_default_inputs = { 'cpu_count': 50,
'grid_filter': '*',
'min_sensor_count': 1,
'model': None,
'north': 0.0,
'output_type': 'solar',
'params_folder': '__params',
'radiance_parameters': '-ab 2 -ad 5000 -lw 2e-05',
'simulation_folder': '.',
Expand Down Expand Up @@ -155,7 +155,7 @@ def map_dag_inputs(self):
return inputs

def run(self):
yield [AnnualIrradianceRayTracing_d75637b2Workerbee(_input_params=self.map_dag_inputs)]
yield [AnnualIrradianceRayTracing_2c2db9eeWorkerbee(_input_params=self.map_dag_inputs)]
done_file = pathlib.Path(self.execution_folder, 'annual_irradiance_raytracing.done')
done_file.parent.mkdir(parents=True, exist_ok=True)
done_file.write_text('done!')
Expand Down Expand Up @@ -183,7 +183,7 @@ def sensor_grids(self):
def items(self):
try:
# assume the input is a file
return qb_load_input_param(self.sensor_grids)
return QueenbeeTask.load_input_param(self.sensor_grids)
except:
# it is a parameter
return pathlib.Path(self.input()['SplitGridFolder']['sensor_grids'].path).as_posix()
Expand Down Expand Up @@ -470,18 +470,16 @@ def sky_type(self):

@property
def output_type(self):
return 'solar'

@property
def output_format(self):
return 'ASCII'
return self._input_params['output_type']

@property
def sun_up_hours(self):
return 'sun-up-hours'

cumulative = luigi.Parameter(default='hourly')

output_format = luigi.Parameter(default='ASCII')

sky_density = luigi.Parameter(default='1')

@property
Expand Down Expand Up @@ -797,18 +795,16 @@ def sky_type(self):

@property
def output_type(self):
return 'solar'

@property
def output_format(self):
return 'ASCII'
return self._input_params['output_type']

@property
def sun_up_hours(self):
return 'sun-up-hours'

cumulative = luigi.Parameter(default='hourly')

output_format = luigi.Parameter(default='ASCII')

sky_density = luigi.Parameter(default='1')

@property
Expand Down Expand Up @@ -856,7 +852,7 @@ def output_artifacts(self):


class GenerateSunpath(QueenbeeTask):
"""Generate a Radiance sun matrix (AKA sun-path)."""
"""Generate a Radiance sun matrix using honeybee-radiance methods."""

# DAG Input parameters
_input_params = luigi.DictParameter()
Expand All @@ -868,7 +864,7 @@ def north(self):

@property
def output_type(self):
return '1'
return self._input_params['output_type']

@property
def wea(self):
Expand All @@ -889,7 +885,7 @@ def params_folder(self):
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'gendaymtx -n -D sunpath.mtx -M suns.mod -O{output_type} -r {north} -v sky.wea'.format(output_type=self.output_type, north=self.north)
return 'honeybee-radiance sunpath radiance sky.wea --name sunpath --{output_type} --north {north}'.format(output_type=self.output_type, north=self.north)

def output(self):
return {
Expand All @@ -898,7 +894,7 @@ def output(self):
),

'sun_modifiers': luigi.LocalTarget(
pathlib.Path(self.execution_folder, 'resources/suns.mod').resolve().as_posix()
pathlib.Path(self.execution_folder, 'resources/sunpath.mod').resolve().as_posix()
)
}

Expand All @@ -918,8 +914,8 @@ def output_artifacts(self):
},

{
'name': 'sun-modifiers', 'from': 'suns.mod',
'to': pathlib.Path(self.execution_folder, 'resources/suns.mod').resolve().as_posix(),
'name': 'sun-modifiers', 'from': 'sunpath.mod',
'to': pathlib.Path(self.execution_folder, 'resources/sunpath.mod').resolve().as_posix(),
'optional': False,
'type': 'file'
}]
Expand Down Expand Up @@ -1009,7 +1005,7 @@ def params_folder(self):
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance grid merge-folder ./input_folder ./output_folder {extension}'.format(extension=self.extension)
return 'honeybee-radiance grid merge-folder ./input_folder ./output_folder {extension} --dist-info dist_info.json'.format(extension=self.extension)

def requires(self):
return {'AnnualIrradianceRaytracing': AnnualIrradianceRaytracing(_input_params=self._input_params)}
Expand Down Expand Up @@ -1067,7 +1063,7 @@ def params_folder(self):
return pathlib.Path(self.execution_folder, self._input_params['params_folder']).resolve().as_posix()

def command(self):
return 'honeybee-radiance grid merge-folder ./input_folder ./output_folder {extension}'.format(extension=self.extension)
return 'honeybee-radiance grid merge-folder ./input_folder ./output_folder {extension} --dist-info dist_info.json'.format(extension=self.extension)

def requires(self):
return {'AnnualIrradianceRaytracing': AnnualIrradianceRaytracing(_input_params=self._input_params)}
Expand Down Expand Up @@ -1187,7 +1183,7 @@ def output_parameters(self):
return [{'name': 'sensor-grids', 'from': 'output_folder/_info.json', 'to': pathlib.Path(self.params_folder, 'output_folder/_info.json').resolve().as_posix()}]


class _Main_d75637b2Orchestrator(luigi.WrapperTask):
class _Main_2c2db9eeOrchestrator(luigi.WrapperTask):
"""Runs all the tasks in this module."""
# user input for this module
_input_params = luigi.DictParameter()
Expand Down
41 changes: 40 additions & 1 deletion lbt_recipes/annual_irradiance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "MetaData",
"annotations": {},
"name": "annual-irradiance",
"tag": "0.2.2",
"tag": "0.2.4",
"app_version": null,
"keywords": [
"honeybee",
Expand Down Expand Up @@ -227,6 +227,45 @@
"maximum": 360
}
},
{
"type": "DAGStringInput",
"annotations": {},
"name": "output-type",
"description": "Text for the type of irradiance output, which can be solar or visible. Note that the output values will still be irradiance (W/m2) when visible is selected but these irradiance values will be just for the visible portion of the electromagnetic spectrum. The visible irradiance values can be converted into illuminance by multiplying them by the Radiance luminous efficacy factor of 179.",
"default": "solar",
"alias": [
{
"type": "DAGGenericInputAlias",
"annotations": {},
"name": "visible",
"description": "Text for the type of irradiance output, which can be solar (False) or visible (True). Note that the output values will still be irradiance (W/m2) when visible is selected but these irradiance values will be just for the visible portion of the electromagnetic spectrum. The visible irradiance values can be converted into illuminance by multiplying them by the Radiance luminous efficacy factor of 179. (Default: False).",
"platform": [
"grasshopper"
],
"handler": [
{
"type": "IOAliasHandler",
"annotations": {},
"language": "python",
"module": "pollination_handlers.inputs.bool_options",
"function": "visible_vs_solar_to_str",
"index": 0
}
],
"default": "False",
"required": false,
"spec": null
}
],
"required": false,
"spec": {
"type": "string",
"enum": [
"visible",
"solar"
]
}
},
{
"type": "DAGStringInput",
"annotations": {},
Expand Down
3 changes: 2 additions & 1 deletion lbt_recipes/annual_irradiance/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
'min_sensor_count': 1,
'model': None,
'north': 0.0,
'output_type': 'solar',
'radiance_parameters': '-ab 2 -ad 5000 -lw 2e-05',
'timestep': 1,
'wea': None}
Expand All @@ -38,7 +39,7 @@ class LetAnnualIrradianceFly(luigi.WrapperTask):
_input_params = luigi.DictParameter()

def requires(self):
yield [annual_irradiance_workerbee._Main_d75637b2Orchestrator(_input_params=self._input_params)]
yield [annual_irradiance_workerbee._Main_2c2db9eeOrchestrator(_input_params=self._input_params)]


def start(project_folder, user_values, workers):
Expand Down

0 comments on commit 30edab4

Please sign in to comment.