From aecd5c82eea194bf2cc2d21fa1e54b875376f02d Mon Sep 17 00:00:00 2001 From: Mikkel Pedersen Date: Tue, 6 Dec 2022 13:43:51 +0100 Subject: [PATCH] fix(entry): Update recipe to match results folder for post-processing --- pollination/three_phase/entry.py | 29 ++-- .../three_phase/three_phase/preparation.py | 9 -- pollination/three_phase/two_phase/__init__.py | 0 .../three_phase/two_phase/_raytracing.py | 142 ------------------ .../two_phase/dynamic/_raytracing.py | 2 +- .../three_phase/two_phase/dynamic/entry.py | 14 +- pollination/three_phase/two_phase/entry.py | 126 ---------------- requirements.txt | 5 +- 8 files changed, 23 insertions(+), 304 deletions(-) delete mode 100644 pollination/three_phase/two_phase/__init__.py delete mode 100644 pollination/three_phase/two_phase/_raytracing.py delete mode 100644 pollination/three_phase/two_phase/entry.py diff --git a/pollination/three_phase/entry.py b/pollination/three_phase/entry.py index bb6cb18..31858ab 100644 --- a/pollination/three_phase/entry.py +++ b/pollination/three_phase/entry.py @@ -7,8 +7,7 @@ from pollination.path.read import ReadJSONList -from .two_phase.entry import TwoPhaseEntryPoint -from .two_phase.dynamic.entry import DynamicGroup +from .two_phase.dynamic.entry import TwoPhaseSimulation from .three_phase.preparation import ThreePhaseInputsPreparation from .three_phase.calculation import ThreePhaseMatrixCalculation @@ -107,7 +106,7 @@ def create_rad_folder(self, input_model=model, grid_filter=grid_filter): }, { 'from': CreateRadianceFolderGrid()._outputs.sensor_grids_file, - 'to': 'results/_info.json' + 'to': 'results/grids_info.json' }, { 'from': CreateRadianceFolderGrid()._outputs.receivers, @@ -120,8 +119,9 @@ def create_rad_folder(self, input_model=model, grid_filter=grid_filter): def generate_sunpath(self, north=north, wea=wea): """Create sunpath for sun-up-hours.""" return [ - {'from': CreateSunMatrix()._outputs.sunpath, - 'to': 'resources/sky_vectors/sunpath.mtx'}, + { + 'from': CreateSunMatrix()._outputs.sunpath, + 'to': 'resources/sky_vectors/sunpath.mtx'}, { 'from': CreateSunMatrix()._outputs.sun_modifiers, 'to': 'resources/sky_vectors/suns.mod' @@ -194,7 +194,7 @@ def prepare_multiphase( ] @task( - template=DynamicGroup, + template=TwoPhaseSimulation, loop=prepare_multiphase._outputs.two_phase_info, needs=[ create_rad_folder, prepare_multiphase, @@ -260,10 +260,6 @@ def prepare_three_phase( 'from': ThreePhaseInputsPreparation()._outputs.grouped_apertures_folder, 'to': '../../model/sender' } - # { - # 'from': ThreePhaseInputsPreparation()._outputs.results_info, - # 'to': '../../results/3_phase/_info.json' - # } ] @task(template=ReadJSONList, needs=[prepare_three_phase]) @@ -297,12 +293,11 @@ def calculate_three_phase_matrix_total( sky_matrix=create_total_sky._outputs.sky_matrix, bsdf_folder=create_rad_folder._outputs.bsdf_folder, ): - # return [ - # { - # 'from': ThreePhaseMatrixCalculation()._outputs.results, - # 'to': '../../results' - # } - # ] - pass + return [ + { + 'from': ThreePhaseMatrixCalculation()._outputs.results, + 'to': '../../results' + } + ] results = Outputs.folder(source='results') diff --git a/pollination/three_phase/three_phase/preparation.py b/pollination/three_phase/three_phase/preparation.py index dcd7fbc..62adbbf 100644 --- a/pollination/three_phase/three_phase/preparation.py +++ b/pollination/three_phase/three_phase/preparation.py @@ -78,10 +78,6 @@ def get_three_phase_combinations( states_info=model_folder ): return [ - # { - # 'from': MultiPhaseCombinations()._outputs.results_mapper, - # 'to': 'results/_info.json' - # }, { 'from': MultiPhaseCombinations()._outputs.multiplication_file, 'to': 'multiplication_info.json' @@ -105,8 +101,3 @@ def get_three_phase_combinations( description='A JSON file with matrix multiplication information.', source='multiplication_info.json' ) - - results_info = Outputs.file( - description='A JSON file with information for loading the results.', - source='results/_info.json' - ) diff --git a/pollination/three_phase/two_phase/__init__.py b/pollination/three_phase/two_phase/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pollination/three_phase/two_phase/_raytracing.py b/pollination/three_phase/two_phase/_raytracing.py deleted file mode 100644 index 7948304..0000000 --- a/pollination/three_phase/two_phase/_raytracing.py +++ /dev/null @@ -1,142 +0,0 @@ -"""Raytracing DAG for two phase studies.""" - -from pollination_dsl.dag import Inputs, DAG, task -from dataclasses import dataclass - -from pollination.honeybee_radiance.contrib import DaylightContribution -from pollination.honeybee_radiance.coefficient import DaylightCoefficient -from pollination.honeybee_radiance.sky import AddRemoveSkyMatrix - - -@dataclass -class TwoPhaseRayTracing(DAG): - - radiance_parameters = Inputs.str( - description='The radiance parameters for ray tracing', - default='-ab 3 -ad 5000 -lw 1e-4' - ) - - octree = Inputs.file( - description='A Radiance octree file.', - extensions=['oct'] - ) - - octree_direct = Inputs.file( - description='A Radiance octree file for direct studies.', - extensions=['oct'] - ) - - octree_with_suns = Inputs.file( - description='A Radiance octree file with suns.', - extensions=['oct'] - ) - - grid_name = Inputs.str( - description='Sensor grid file name. This is useful to rename the final result ' - 'file to {grid_name}.ill' - ) - - sensor_grid = Inputs.file( - description='Sensor grid file.', - extensions=['pts'] - ) - - sensor_count = Inputs.int( - description='Number of sensors in the input sensor grid.' - ) - - sun_modifiers = Inputs.file( - description='A file with sun modifiers.' - ) - - sky_matrix = Inputs.file( - description='Path to total sky matrix file.' - ) - - sky_matrix_direct = Inputs.file( - description='Path to direct skymtx file (i.e. gendaymtx -d).' - ) - - sky_dome = Inputs.file( - description='Path to sky dome file.' - ) - - bsdfs = Inputs.folder( - description='Folder containing any BSDF files needed for ray tracing.', - optional=True - ) - - @task(template=DaylightContribution) - def direct_sunlight( - self, - name=grid_name, - radiance_parameters=radiance_parameters, - fixed_radiance_parameters='-aa 0.0 -I -ab 0 -dc 1.0 -dt 0.0 -dj 0.0 -dr 0', - sensor_count=sensor_count, - modifiers=sun_modifiers, - sensor_grid=sensor_grid, - output_format='a', # make it ascii so we expose the file as a separate output - scene_file=octree_with_suns, - bsdf_folder=bsdfs - ): - return [ - { - 'from': DaylightContribution()._outputs.result_file, - 'to': '../final/direct/{{self.name}}.ill' - } - ] - - @task(template=DaylightCoefficient) - def direct_sky( - self, - radiance_parameters=radiance_parameters, - fixed_radiance_parameters='-aa 0.0 -I -ab 1 -c 1 -faf', - sensor_count=sensor_count, - sky_matrix=sky_matrix_direct, sky_dome=sky_dome, - sensor_grid=sensor_grid, - scene_file=octree_direct, - bsdf_folder=bsdfs - ): - return [ - { - 'from': DaylightCoefficient()._outputs.result_file, - 'to': 'direct_sky.ill' - } - ] - - @task(template=DaylightCoefficient) - def total_sky( - self, - radiance_parameters=radiance_parameters, - fixed_radiance_parameters='-aa 0.0 -I -c 1 -faf', - sensor_count=sensor_count, - sky_matrix=sky_matrix, sky_dome=sky_dome, - sensor_grid=sensor_grid, - scene_file=octree, - bsdf_folder=bsdfs - ): - return [ - { - 'from': DaylightCoefficient()._outputs.result_file, - 'to': 'total_sky.ill' - } - ] - - @task( - template=AddRemoveSkyMatrix, - needs=[direct_sunlight, total_sky, direct_sky] - ) - def output_matrix_math( - self, - name=grid_name, - direct_sky_matrix=direct_sky._outputs.result_file, - total_sky_matrix=total_sky._outputs.result_file, - sunlight_matrix=direct_sunlight._outputs.result_file, - conversion='47.4 119.9 11.6' - ): - return [ - { - 'from': AddRemoveSkyMatrix()._outputs.results_file, - 'to': '../final/total/{{self.name}}.ill' - } - ] diff --git a/pollination/three_phase/two_phase/dynamic/_raytracing.py b/pollination/three_phase/two_phase/dynamic/_raytracing.py index 3d82958..38e6cb0 100644 --- a/pollination/three_phase/two_phase/dynamic/_raytracing.py +++ b/pollination/three_phase/two_phase/dynamic/_raytracing.py @@ -10,7 +10,7 @@ @dataclass -class DynamicRayTracing(DAG): +class TwoPhaseRayTracing(DAG): # inputs radiance_parameters = Inputs.str( diff --git a/pollination/three_phase/two_phase/dynamic/entry.py b/pollination/three_phase/two_phase/dynamic/entry.py index 991cd7e..79c5c11 100644 --- a/pollination/three_phase/two_phase/dynamic/entry.py +++ b/pollination/three_phase/two_phase/dynamic/entry.py @@ -3,11 +3,11 @@ from dataclasses import dataclass from pollination.honeybee_radiance_postprocess.grid import MergeFolderData -from ._raytracing import DynamicRayTracing +from ._raytracing import TwoPhaseRayTracing @dataclass -class DynamicGroup(DAG): +class TwoPhaseSimulation(DAG): """Dynamic entry point. This two phase workflow also includes the extra phase for accurately calculating the @@ -17,14 +17,14 @@ class DynamicGroup(DAG): # inputs identifier = Inputs.str( description='Identifier for this two-phase study. This value is usually the ' - 'identifier of the aperture group or is set to __static__ for the static ' - 'apertures in the model.', default='__static__' + 'identifier of the aperture group or is set to __static_apertures__ for the ' + 'static apertures in the model.', default='__static_apertures__' ) light_path = Inputs.str( description='Identifier for the light path of this two-phase study. This value ' - 'is the identifier of the aperture group or is set to __static___ for the ' - 'static apertures in the model.', default='__static__' + 'is the identifier of the aperture group or is set to __static_apertures__ for ' + 'the static apertures in the model.', default='__static_apertures__' ) radiance_parameters = Inputs.str( @@ -90,7 +90,7 @@ class DynamicGroup(DAG): ) @task( - template=DynamicRayTracing, + template=TwoPhaseRayTracing, loop=sensor_grids_info, # create a subfolder for each grid sub_folder='initial_results/{{item.full_id}}', diff --git a/pollination/three_phase/two_phase/entry.py b/pollination/three_phase/two_phase/entry.py deleted file mode 100644 index db5dfc2..0000000 --- a/pollination/three_phase/two_phase/entry.py +++ /dev/null @@ -1,126 +0,0 @@ -from pollination_dsl.dag import Inputs, DAG, task -from pollination_dsl.dag.inputs import ItemType -from dataclasses import dataclass -from pollination.honeybee_radiance.grid import MergeFolderData - -from ._raytracing import TwoPhaseRayTracing - - -@dataclass -class TwoPhaseEntryPoint(DAG): - """Two phase entry point. - - This two phase workflow also includes the extra phase for accurately calculating the - direct sunlight. - """ - - # inputs - identifier = Inputs.str( - description='Identifier for this two-phase study. This value is usually the ' - 'identifier of the aperture group or is set to __static__ for the static ' - 'apertures in the model.', default='__static__' - ) - - radiance_parameters = Inputs.str( - description='The radiance parameters for ray tracing.', - default='-ab 2 -ad 5000 -lw 2e-05' - ) - - sensor_grids_info = Inputs.list( - description='A list with sensor grids information.', - items_type=ItemType.JSONObject - ) - - sensor_grids_folder = Inputs.folder( - description='Corresponding sensor grid folder to sensor grids info.' - ) - - octree = Inputs.file( - description='Octree that describes the scene for indirect studies. This octree ' - 'includes all the scene with default modifiers except for the aperture groups ' - 'other the one that is the source for this calculation will be blacked out.' - ) - - octree_direct = Inputs.file( - description='Octree that describes the scene for direct studies. This octree ' - 'is similar to the octree for indirect studies with the difference that the ' - 'matrials for the scene are set to black.' - ) - - octree_direct_sun = Inputs.file( - description='A blacked out octree that includes the sunpath. This octree is ' - 'used for calculating the contribution from direct sunlight.' - ) - - sky_dome = Inputs.file( - description='A sky dome for daylight coefficient studies.' - ) - - total_sky = Inputs.file( - description='Sky matrix with both sun and sky components.' - ) - - direct_sky = Inputs.file( - description='Sky matrix with sun only.' - ) - - sun_modifiers = Inputs.file( - description='The list of sun modifiers that are included in octree_direct_sun.' - ) - - bsdf_folder = Inputs.folder( - description='The folder from Radiance model folder that includes the BSDF files.' - 'You only need to include the in-scene BSDFs for the two phase calculation.', - optional=True - ) - - results_folder = Inputs.str( - description='An optional string to define the folder that the outputs should be ' - 'copied to. You can use this input to copy the final results to a folder other ' - 'then the subfolder for this DAG', default='results' - ) - - @task( - template=TwoPhaseRayTracing, - loop=sensor_grids_info, - # create a subfolder for each grid - sub_folder='initial_results/{{item.full_id}}', - # sensor_grid sub_path - sub_paths={'sensor_grid': '{{item.full_id}}.pts'} - ) - def two_phase_raytracing( - self, - radiance_parameters=radiance_parameters, - octree=octree, - octree_direct=octree_direct, - octree_with_suns=octree_direct_sun, - grid_name='{{item.full_id}}', - sensor_grid=sensor_grids_folder, - sensor_count='{{item.count}}', - sky_matrix=total_sky, - sky_matrix_direct=direct_sky, - sky_dome=sky_dome, - sun_modifiers=sun_modifiers, - bsdfs=bsdf_folder - ): - pass - - @task( - template=MergeFolderData, - needs=[two_phase_raytracing], - sub_paths={ - 'dist_info': '_redist_info.json' - } - ) - def restructure_results( - self, identifier=identifier, - input_folder='initial_results/final/total', - extension='ill', dist_info=sensor_grids_folder, - results_folder=results_folder - ): - return [ - { - 'from': MergeFolderData()._outputs.output_folder, - 'to': '{{self.results_folder}}/{{self.identifier}}' - } - ] diff --git a/requirements.txt b/requirements.txt index 06a8d69..f970004 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ -pollination-honeybee-radiance==0.22.12 -pollination-path==0.3.1 +pollination-honeybee-radiance==0.22.21 +pollination-honeybee-radiance-postprocess==0.0.13 +pollination-path==0.3.2