From ac099d47ab9a36ca0ac555e9f03b95875b31d168 Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Wed, 24 Feb 2021 18:20:01 -0500 Subject: [PATCH] fix(map): Add a function to output result metadata I am also upgrading the default parameters to work with the new Parameter string format. --- pollination/ladybug_comfort/map.py | 74 ++++++++++++++++++++++-------- requirements.txt | 2 +- tests/map_test.py | 8 +++- 3 files changed, 63 insertions(+), 21 deletions(-) diff --git a/pollination/ladybug_comfort/map.py b/pollination/ladybug_comfort/map.py index 5d2042a..c1639a9 100644 --- a/pollination/ladybug_comfort/map.py +++ b/pollination/ladybug_comfort/map.py @@ -63,19 +63,19 @@ class PmvMap(Function): solarcal_par = Inputs.str( description='A SolarCalParameter string to customize the assumptions of ' - 'the SolarCal model.', default='SolarCalParameter: [posture:seated] ' - '[sharp:135] [absorptivity:0.7] [emissivity:0.95]' + 'the SolarCal model.', default='--posture seated --sharp 135 ' + '--absorptivity 0.7 --emissivity 0.95' ) comfort_par = Inputs.str( description='A PMVParameter string to customize the assumptions of ' - 'the PMV comfort model.', default='PMVParameter: [ppd_threshold:10]' + 'the PMV comfort model.', default='--ppd-threshold 10' ) run_period = Inputs.str( description='An AnalysisPeriod string to set the start and end dates of the ' 'analysis (eg. "6/21 to 9/21 between 8 and 16 @1"). If None, the analysis ' - 'will be for the entire result_sql run period.', default='None' + 'will be for the entire result_sql run period.', default='' ) write_set_map = Inputs.str( @@ -94,9 +94,9 @@ def run_pmv_map(self): return 'ladybug-comfort map pmv result.sql enclosure_info.json ' \ 'weather.epw --total-irradiance total.ill --direct-irradiance direct.ill ' \ '--ref-irradiance ref.ill --sun-up-hours sun-up-hours.txt ' \ - '--air-speed {{self.air_speed}} --met-rate {{self.met_rate}} ' \ - '--clo-value {{self.clo_value}} --solarcal-par {{self.solarcal_par}} ' \ - '--comfort-par {{self.comfort_par}} --run-period {{self.run_period}} ' \ + '--air-speed "{{self.air_speed}}" --met-rate "{{self.met_rate}}" ' \ + '--clo-value "{{self.clo_value}}" --solarcal-par "{{self.solarcal_par}}" ' \ + '--comfort-par "{{self.comfort_par}}" --run-period "{{self.run_period}}" ' \ '--{{self.write_set_map}} --folder output' result_folder = Outputs.folder( @@ -173,19 +173,19 @@ class AdaptiveMap(Function): solarcal_par = Inputs.str( description='A SolarCalParameter string to customize the assumptions of ' - 'the SolarCal model.', default='SolarCalParameter: [posture:seated] ' - '[sharp:135] [absorptivity:0.7] [emissivity:0.95]' + 'the SolarCal model.', default='--posture seated --sharp 135 ' + '--absorptivity 0.7 --emissivity 0.95' ) comfort_par = Inputs.str( description='An AdaptiveParameter string to customize the assumptions of ' - 'the Adaptive comfort model.', default='AdaptiveParameter: [standard:ASHRAE-55]' + 'the Adaptive comfort model.', default='--standard ASHRAE-55' ) run_period = Inputs.str( description='An AnalysisPeriod string to set the start and end dates of the ' 'analysis (eg. "6/21 to 9/21 between 8 and 16 @1"). If None, the analysis ' - 'will be for the entire result_sql run period.', default='None' + 'will be for the entire result_sql run period.', default='' ) @command @@ -193,8 +193,8 @@ def run_adaptive_map(self): return 'ladybug-comfort map adaptive result.sql enclosure_info.json ' \ 'weather.epw --total-irradiance total.ill --direct-irradiance direct.ill ' \ '--ref-irradiance ref.ill --sun-up-hours sun-up-hours.txt ' \ - '--air-speed {{self.air_speed}} --solarcal-par {{self.solarcal_par}} ' \ - '--comfort-par {{self.comfort_par}} --run-period {{self.run_period}} ' \ + '--air-speed "{{self.air_speed}}" --solarcal-par "{{self.solarcal_par}}" ' \ + '--comfort-par "{{self.comfort_par}}" --run-period "{{self.run_period}}" ' \ '--folder output' result_folder = Outputs.folder( @@ -272,19 +272,19 @@ class UtciMap(Function): solarcal_par = Inputs.str( description='A SolarCalParameter string to customize the assumptions of ' - 'the SolarCal model.', default='SolarCalParameter: [posture:standing] ' - '[sharp:135] [absorptivity:0.7] [emissivity:0.95]' + 'the SolarCal model.', default='--posture seated --sharp 135 ' + '--absorptivity 0.7 --emissivity 0.95' ) comfort_par = Inputs.str( description='A UTCIParameter string to customize the assumptions of ' - 'the UTCI comfort model.', default='UTCIParameter: [cold:9] [heat:26]' + 'the UTCI comfort model.', default='--cold 9 --heat 26' ) run_period = Inputs.str( description='An AnalysisPeriod string to set the start and end dates of the ' 'analysis (eg. "6/21 to 9/21 between 8 and 16 @1"). If None, the analysis ' - 'will be for the entire result_sql run period.', default='None' + 'will be for the entire result_sql run period.', default='' ) @command @@ -292,8 +292,8 @@ def run_utci_map(self): return 'ladybug-comfort map utci result.sql enclosure_info.json ' \ 'weather.epw --total-irradiance total.ill --direct-irradiance direct.ill ' \ '--ref-irradiance ref.ill --sun-up-hours sun-up-hours.txt ' \ - '--wind-speed {{self.wind_speed}} --solarcal-par {{self.solarcal_par}} ' \ - '--comfort-par {{self.comfort_par}} --run-period {{self.run_period}} ' \ + '--wind-speed "{{self.wind_speed}}" --solarcal-par "{{self.solarcal_par}}" ' \ + '--comfort-par "{{self.comfort_par}}" --run-period "{{self.run_period}}" ' \ '--folder output' result_folder = Outputs.folder( @@ -321,3 +321,39 @@ def run_utci_map(self): 'acceptable but how uncomfortably hot or cold they are.', path='output/condition_intensity.csv' ) + + +@dataclass +class MapResultInfo(Function): + """Get a JSON that specifies the data type and units for comfort map outputs.""" + + comfort_model = Inputs.str( + description='Text for the comfort model of the thermal mapping ' + 'simulation. Choose from: pmv, adaptive, utci.', + spec={'type': 'string', 'enum': ['pmv', 'adaptive', 'utci']} + ) + + run_period = Inputs.str( + description='The AnalysisPeriod string that dictates the start and end of ' + 'the analysis (eg. "6/21 to 9/21 between 8 and 16 @1"). If unspecified, it ' + 'will be assumed results are for a full year.', default='' + ) + + qualifier = Inputs.str( + description='Text for any options used on the comfort map simulation that ' + 'change the output data type of results. For example, the write-set-map text ' + 'of the pmv map can be passed here to ensure the output of this command is ' + 'for SET instead of operative temperature.', default='' + ) + + @command + def map_results_information(self): + return 'ladybug-comfort map map-result-info {{self.comfort_model}} ' \ + '--run-period "{{self.run_period}}" --qualifier "{{self.qualifier}}" ' \ + '--output-file results_info.json' + + results_info_file = Outputs.file( + description='A JSON that specifies the data type and units for comfort map ' + 'outputs. This JSON is needed by interfaces to correctly parse comfort map ' + 'results.', path='results_info.json' + ) diff --git a/requirements.txt b/requirements.txt index 8f5eaa1..0035f87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ pollination-dsl>=0.10.0 -ladybug-comfort>=0.11.4 +ladybug-comfort>=0.11.6 diff --git a/tests/map_test.py b/tests/map_test.py index 6f4e0d7..9db1321 100644 --- a/tests/map_test.py +++ b/tests/map_test.py @@ -1,4 +1,4 @@ -from pollination.ladybug_comfort.map import PmvMap, AdaptiveMap, UtciMap +from pollination.ladybug_comfort.map import PmvMap, AdaptiveMap, UtciMap, MapResultInfo from queenbee.plugin.function import Function @@ -18,3 +18,9 @@ def test_utci_map(): function = UtciMap().queenbee assert function.name == 'utci-map' assert isinstance(function, Function) + + +def test_map_result_info(): + function = MapResultInfo().queenbee + assert function.name == 'map-result-info' + assert isinstance(function, Function)