openstudio-analysis 1.0.0.rc19 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.gitlab-ci.yml +20 -0
  4. data/.rubocop.yml +2 -133
  5. data/.travis.yml +2 -2
  6. data/CHANGELOG.md +26 -32
  7. data/Gemfile +5 -6
  8. data/LICENSE.md +28 -0
  9. data/README.md +16 -8
  10. data/Rakefile +38 -3
  11. data/lib/openstudio-analysis.rb +35 -0
  12. data/lib/openstudio/analysis.rb +57 -26
  13. data/lib/openstudio/analysis/algorithm_attributes.rb +36 -1
  14. data/lib/openstudio/analysis/formulation.rb +41 -6
  15. data/lib/openstudio/analysis/server_api.rb +53 -36
  16. data/lib/openstudio/analysis/support_files.rb +40 -0
  17. data/lib/openstudio/analysis/translator/datapoints.rb +39 -4
  18. data/lib/openstudio/analysis/translator/excel.rb +43 -8
  19. data/lib/openstudio/analysis/translator/workflow.rb +54 -14
  20. data/lib/openstudio/analysis/version.rb +36 -1
  21. data/lib/openstudio/analysis/workflow.rb +37 -2
  22. data/lib/openstudio/analysis/workflow_step.rb +97 -70
  23. data/lib/openstudio/helpers/hash.rb +35 -0
  24. data/lib/openstudio/helpers/string.rb +36 -2
  25. data/lib/openstudio/weather/epw.rb +32 -17
  26. data/openstudio-analysis.gemspec +21 -18
  27. data/update_license.rb +120 -0
  28. metadata +62 -200
  29. data/LGPL-2.1.txt +0 -502
  30. data/LICENSE.txt +0 -65
  31. data/rubocop-todo.yml +0 -246
  32. data/spec/files/0_1_09_no_variables.xlsx +0 -0
  33. data/spec/files/0_1_09_outputvars.xlsx +0 -0
  34. data/spec/files/0_1_09_setup_version_2.xlsx +0 -0
  35. data/spec/files/0_1_09_small_list.xlsx +0 -0
  36. data/spec/files/0_1_09_small_list_incomplete.xlsx +0 -0
  37. data/spec/files/0_1_09_small_list_repeat_vars.xlsx +0 -0
  38. data/spec/files/0_1_09_small_list_validation_errors.xlsx +0 -0
  39. data/spec/files/0_1_10_proxy.xlsx +0 -0
  40. data/spec/files/0_1_10_proxy_user.xlsx +0 -0
  41. data/spec/files/0_1_10_template_input.xlsx +0 -0
  42. data/spec/files/0_1_11_discrete_variables.xlsx +0 -0
  43. data/spec/files/0_1_12_discrete_dynamic_columns.xlsx +0 -0
  44. data/spec/files/0_2_0_template.xlsx +0 -0
  45. data/spec/files/0_2_0_template_simpletest.xlsx +0 -0
  46. data/spec/files/0_3_0_dynamic_uuids.xlsx +0 -0
  47. data/spec/files/0_3_0_measure_existence.xlsx +0 -0
  48. data/spec/files/0_3_0_outputs.xlsx +0 -0
  49. data/spec/files/0_3_3_short_names.xlsx +0 -0
  50. data/spec/files/0_3_5_multiple_measure_paths.xlsx +0 -0
  51. data/spec/files/0_3_7_unique_measure_names.xlsx +0 -0
  52. data/spec/files/0_3_7_worker_init_final.xlsx +0 -0
  53. data/spec/files/0_4_0_lhs_discrete_continuous.xlsx +0 -0
  54. data/spec/files/0_4_0_multiple_seeds.xlsx +0 -0
  55. data/spec/files/0_4_0_pivot_test.xlsx +0 -0
  56. data/spec/files/analysis/examples/discrete_lhs_example.json +0 -809
  57. data/spec/files/analysis/examples/medium_office_example.json +0 -1673
  58. data/spec/files/analysis/examples/medium_office_workflow.json +0 -1298
  59. data/spec/files/measures/ActualMeasureNoJson/measure.rb +0 -80
  60. data/spec/files/measures/ActualMeasureNoJson/measure.xml +0 -2
  61. data/spec/files/measures/ExampleMeasure/measure.json +0 -3
  62. data/spec/files/measures/ExampleMeasure/measure.rb +0 -5
  63. data/spec/files/measures/ExampleMeasure/measure.xml +0 -1
  64. data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json +0 -36
  65. data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb +0 -22
  66. data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml +0 -5
  67. data/spec/files/measures/NoMeasureRbFile/.gitkeep +0 -0
  68. data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.json +0 -3
  69. data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.rb +0 -5
  70. data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.xml +0 -1
  71. data/spec/files/measures/SetThermostatSchedules/measure.json +0 -63
  72. data/spec/files/measures/SetThermostatSchedules/measure.rb +0 -254
  73. data/spec/files/measures/SetThermostatSchedules/measure.xml +0 -2
  74. data/spec/files/measures/example_measure_auto_directory_name/measure.json +0 -3
  75. data/spec/files/measures/example_measure_auto_directory_name/measure.rb +0 -5
  76. data/spec/files/measures/example_measure_auto_directory_name/measure.xml +0 -1
  77. data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.json +0 -3
  78. data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.rb +0 -5
  79. data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.xml +0 -1
  80. data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.rb +0 -5
  81. data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.xml +0 -1
  82. data/spec/files/measures/rotate_building/measure.rb +0 -5
  83. data/spec/files/measures/rotate_building/measure.xml +0 -1
  84. data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.rb +0 -5
  85. data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.xml +0 -1
  86. data/spec/files/measures_second_path/measure_in_another_dir/measure.json +0 -3
  87. data/spec/files/measures_second_path/measure_in_another_dir/measure.rb +0 -5
  88. data/spec/files/measures_second_path/measure_in_another_dir/measure.xml +0 -1
  89. data/spec/files/partial_weather.epw +0 -32
  90. data/spec/files/partial_weather_2.epw +0 -32
  91. data/spec/files/small_seed.osm +0 -4622
  92. data/spec/files/worker_init/first_file.rb +0 -15
  93. data/spec/files/worker_init/second_file.rb +0 -15
  94. data/spec/files/workflow/analysis.osa +0 -1334
  95. data/spec/files/workflow/datapoint_0.osd +0 -65
  96. data/spec/files/workflow/datapoint_1.osd +0 -65
  97. data/spec/files/workflow/datapoint_2.osd +0 -65
  98. data/spec/files/workflow/datapoint_wrong_osa_id.osd +0 -65
  99. data/spec/integration/server_api_spec.rb +0 -48
  100. data/spec/openstudio/excel_spec.rb +0 -571
  101. data/spec/openstudio/formulation_spec.rb +0 -157
  102. data/spec/openstudio/hash_spec.rb +0 -21
  103. data/spec/openstudio/osw_spec.rb +0 -94
  104. data/spec/openstudio/server_api_spec.rb +0 -25
  105. data/spec/openstudio/string_spec.rb +0 -0
  106. data/spec/openstudio/support_files_spec.rb +0 -54
  107. data/spec/openstudio/weather_spec.rb +0 -45
  108. data/spec/openstudio/workflow_spec.rb +0 -91
  109. data/spec/openstudio/workflow_step_spec.rb +0 -118
  110. data/spec/schema/osa.json +0 -613
  111. data/spec/schema/osa.png +0 -0
  112. data/spec/schema/osd.json +0 -110
  113. data/spec/schema/osd.png +0 -0
  114. data/spec/spec_helper.rb +0 -19
@@ -1,3 +1,38 @@
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ #
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+ #
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
27
+ # GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
35
+
1
36
  module OpenStudio
2
37
  module Analysis
3
38
  module Translator
@@ -46,7 +81,7 @@ module OpenStudio
46
81
  @name = nil
47
82
  @analysis_name = nil
48
83
  @settings = {}
49
- @weather_files = [] # remove this from excel!
84
+ @weather_files = []
50
85
  @weather_paths = []
51
86
  @models = []
52
87
  @other_files = []
@@ -210,7 +245,7 @@ module OpenStudio
210
245
  # @append_model_name [Boolean] Append the name of the seed model to the display name
211
246
  # @return [Object] An OpenStudio::Analysis
212
247
  def analysis(seed_model = nil, append_model_name = false)
213
- raise 'There are no seed models defined in the excel file. Please add one.' if @models.size == 0
248
+ raise 'There are no seed models defined in the excel file. Please add one.' if @models.empty?
214
249
  raise "There are more than one seed models defined in the excel file. Call 'analyses' to return the array" if @models.size > 1 && seed_model.nil?
215
250
 
216
251
  seed_model = @models.first if seed_model.nil?
@@ -426,7 +461,7 @@ module OpenStudio
426
461
 
427
462
  if b_settings
428
463
  @version = row[1].chomp if row[0] == 'Spreadsheet Version'
429
- @settings[(row[0].to_underscore).to_s] = row[1] if row[0]
464
+ @settings[row[0].to_underscore.to_s] = row[1] if row[0]
430
465
  if @settings['cluster_name']
431
466
  @settings['cluster_name'] = @settings['cluster_name'].to_underscore
432
467
  end
@@ -463,7 +498,7 @@ module OpenStudio
463
498
  @measure_paths << File.expand_path(File.join(@root_path, tmp_filepath))
464
499
  end
465
500
  end
466
- @run_setup[(row[0].to_underscore).to_s] = row[1] if row[0]
501
+ @run_setup[row[0].to_underscore.to_s] = row[1] if row[0]
467
502
 
468
503
  # type cast
469
504
  if @run_setup['allow_multiple_jobs']
@@ -476,14 +511,14 @@ module OpenStudio
476
511
  if row[0]
477
512
  v = row[1]
478
513
  v.to_i if v % 1 == 0
479
- @problem[(row[0].to_underscore).to_s] = v
514
+ @problem[row[0].to_underscore.to_s] = v
480
515
  end
481
516
 
482
517
  elsif b_algorithm_setup
483
518
  if row[0] && !row[0].empty?
484
519
  v = row[1]
485
520
  v = v.to_i if v % 1 == 0
486
- @algorithm[(row[0].to_underscore).to_s] = v
521
+ @algorithm[row[0].to_underscore.to_s] = v
487
522
  end
488
523
  elsif b_weather_files
489
524
  if row[0] == 'Weather File'
@@ -501,7 +536,7 @@ module OpenStudio
501
536
  tmp_m_name = SecureRandom.uuid
502
537
  end
503
538
  # Only add models if the row is flagged
504
- if row[0] && row[0].downcase == 'model'
539
+ if row[0]&.casecmp('model')&.zero?
505
540
  model_path = row[3]
506
541
  unless (Pathname.new model_path).absolute?
507
542
  model_path = File.expand_path(File.join(@root_path, model_path))
@@ -688,7 +723,7 @@ module OpenStudio
688
723
  relation_to_eui: /typical\svar\sto\seui\srelationship/i,
689
724
  clean: true)
690
725
  end
691
- rescue => e
726
+ rescue StandardError => e
692
727
  raise "Unable to parse spreadsheet #{@xls_filename} with version #{@version} due to error: #{e.message}"
693
728
  end
694
729
 
@@ -1,3 +1,38 @@
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ #
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+ #
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
27
+ # GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
35
+
1
36
  module OpenStudio
2
37
  module Analysis
3
38
  module Translator
@@ -33,11 +68,11 @@ module OpenStudio
33
68
  @measure_paths = options[:measure_paths] ? options[:measure_paths] : []
34
69
 
35
70
  # Initialize static inputs from the OSA
36
- @seed_file = File.basename @osa[:seed][:path]
71
+ @seed_file = File.basename(@osa[:seed][:path])
37
72
  if @options[:seed]
38
73
  @seed_file = @options[:seed]
39
74
  end
40
- @weather_file = File.basename @osa[:weather_file][:path]
75
+ @weather_file = File.basename(@osa[:weather_file][:path])
41
76
  @osa_id = @osa[:_id]
42
77
  @steps = []
43
78
  @osa[:problem][:workflow].each_with_index do |step, i|
@@ -45,10 +80,9 @@ module OpenStudio
45
80
  step_hash[:measure_dir_name] = File.basename(step[:measure_definition_directory])
46
81
  step_hash[:arguments] = {}
47
82
  # Measures can have no arguments -- make sure to catch it
48
- if @osa[:problem][:workflow][i][:arguments]
49
- @osa[:problem][:workflow][i][:arguments].each do |arg|
50
- step_hash[:arguments][arg[:name].to_sym] = arg[:value]
51
- end
83
+ @osa[:problem][:workflow][i][:arguments]&.each do |arg|
84
+ next if arg[:value].nil?
85
+ step_hash[:arguments][arg[:name].to_sym] = arg[:value]
52
86
  end
53
87
  step_hash[:name] = step[:name] if step[:name]
54
88
  step_hash[:description] = step[:description] if step[:description]
@@ -91,8 +125,16 @@ module OpenStudio
91
125
  end
92
126
 
93
127
  # Overwrite the seed and weather files if they are present in the datapoint.json
94
- weather_file = osd[:weather_file] != '' ? osd[:weather_file] : @weather_file
95
- seed_file = osd[:seed] != '' ? osd[:seed] : @seed_file
128
+ if (osd[:weather_file] != '') && !osd[:weather_file].nil?
129
+ weather_file = osd[:weather_file]
130
+ else
131
+ weather_file = @weather_file
132
+ end
133
+ if (osd[:seed] != '') && !osd[:seed].nil?
134
+ seed_file = osd[:seed]
135
+ else
136
+ seed_file = @seed_file
137
+ end
96
138
 
97
139
  # Save the OSW hash
98
140
  osw = {}
@@ -116,12 +158,10 @@ module OpenStudio
116
158
  def process_datapoints(osd_filename_array)
117
159
  r = []
118
160
  osd_filename_array.each do |osd_file|
119
- begin
120
- r << process_datapoint(osd_file)
121
- rescue => e
122
- r << nil
123
- puts "Warning: Failed to process datapoint #{osd_file} with error #{e.message} in #{e.backtrace.join('\n')}"
124
- end
161
+ r << process_datapoint(osd_file)
162
+ rescue StandardError => e
163
+ r << nil
164
+ puts "Warning: Failed to process datapoint #{osd_file} with error #{e.message} in #{e.backtrace.join('\n')}"
125
165
  end
126
166
 
127
167
  r
@@ -1,5 +1,40 @@
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ #
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+ #
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
27
+ # GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
35
+
1
36
  module OpenStudio
2
37
  module Analysis
3
- VERSION = '1.0.0.rc19'.freeze
38
+ VERSION = '1.0.4'.freeze
4
39
  end
5
40
  end
@@ -1,3 +1,38 @@
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ #
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+ #
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
27
+ # GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
35
+
1
36
  # OpenStudio::Analysis::Workflow configured the list of measures to run and in what order
2
37
  module OpenStudio
3
38
  module Analysis
@@ -118,7 +153,7 @@ module OpenStudio
118
153
  m = add_measure(measure['name'], measure['display_name'], measure['local_path_to_measure'], hash)
119
154
 
120
155
  measure['variables'].each do |variable|
121
- next unless %w(variable pivot).include? variable['variable_type']
156
+ next unless ['variable', 'pivot'].include? variable['variable_type']
122
157
 
123
158
  dist = {
124
159
  type: variable['distribution']['type'],
@@ -161,7 +196,7 @@ module OpenStudio
161
196
  m = add_measure(measure[:measure_data][:name], measure[:measure_data][:display_name], measure[:measure_data][:local_path_to_measure], hash)
162
197
 
163
198
  measure[:vars].each do |variable|
164
- next unless %w(variable pivot).include? variable[:variable_type]
199
+ next unless ['variable', 'pivot'].include? variable[:variable_type]
165
200
 
166
201
  dist = variable[:distribution]
167
202
  opt = {
@@ -1,3 +1,38 @@
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
3
+ # All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # (1) Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ #
10
+ # (2) Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+ #
14
+ # (3) Neither the name of the copyright holder nor the names of any contributors
15
+ # may be used to endorse or promote products derived from this software without
16
+ # specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form
19
+ # of modifications or other derivative works may not use the "OpenStudio"
20
+ # trademark, "OS", "os", or any other confusingly similar designation without
21
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
27
+ # GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ # *******************************************************************************
35
+
1
36
  # OpenStudio::Analysis::WorkflowStep is a class container for storing a measure. The generic name of step may be used later
2
37
  # to include a workflow step on running EnergyPlus, radiance, etc.
3
38
  module OpenStudio
@@ -277,40 +312,36 @@ module OpenStudio
277
312
  # do not allow the choice variable_type
278
313
 
279
314
  s.type = hash[:measure_type] # this is actually the measure type
280
- if hash[:arguments]
281
- hash[:arguments].each do |arg|
282
- # warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
283
- var_type = arg[:variable_type] ? arg[:variable_type].downcase : arg[:value_type]
284
-
285
- if var_type == 'choice'
286
- # WARN the user that the measure had a "choice data type"
287
- var_type = 'string'
288
- end
315
+ hash[:arguments]&.each do |arg|
316
+ # warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
317
+ var_type = arg[:variable_type] ? arg[:variable_type].downcase : arg[:value_type]
289
318
 
290
- s.arguments << {
291
- display_name: arg[:display_name],
292
- display_name_short: arg[:display_name_short],
293
- name: arg[:name],
294
- value_type: var_type,
295
- default_value: arg[:default_value],
296
- value: arg[:default_value]
297
- }
319
+ if var_type == 'choice'
320
+ # WARN the user that the measure had a "choice data type"
321
+ var_type = 'string'
298
322
  end
323
+
324
+ s.arguments << {
325
+ display_name: arg[:display_name],
326
+ display_name_short: arg[:display_name_short],
327
+ name: arg[:name],
328
+ value_type: var_type,
329
+ default_value: arg[:default_value],
330
+ value: arg[:default_value]
331
+ }
299
332
  end
300
333
 
301
334
  # Load the arguments of variables, but do not make them variables. This format is more about arugments, than variables
302
- if hash[:variables]
303
- hash[:variables].each do |variable|
304
- # add the arguments first
305
- s.arguments << {
306
- display_name: variable[:argument][:display_name],
307
- display_name_short: variable[:argument][:display_name_short],
308
- name: variable[:argument][:name],
309
- value_type: variable[:argument][:value_type],
310
- default_value: variable[:argument][:default_value],
311
- value: variable[:argument][:default_value]
312
- }
313
- end
335
+ hash[:variables]&.each do |variable|
336
+ # add the arguments first
337
+ s.arguments << {
338
+ display_name: variable[:argument][:display_name],
339
+ display_name_short: variable[:argument][:display_name_short],
340
+ name: variable[:argument][:name],
341
+ value_type: variable[:argument][:value_type],
342
+ default_value: variable[:argument][:default_value],
343
+ value: variable[:argument][:default_value]
344
+ }
314
345
  end
315
346
 
316
347
  s
@@ -363,51 +394,47 @@ module OpenStudio
363
394
  s.measure_definition_version_uuid = hash[:measure_definition_version_uuid]
364
395
 
365
396
  s.type = hash[:measure_type] # this is actually the measure type
366
- if hash[:arguments]
367
- hash[:arguments].each do |arg|
368
- # warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
369
- var_type = arg[:value_type]
370
-
371
- if var_type == 'choice'
372
- # WARN the user that the measure had a "choice data type"
373
- var_type = 'string'
374
- end
397
+ hash[:arguments]&.each do |arg|
398
+ # warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
399
+ var_type = arg[:value_type]
375
400
 
376
- s.arguments << {
377
- display_name: arg[:display_name],
378
- display_name_short: arg[:display_name_short],
379
- name: arg[:name],
380
- value_type: var_type,
381
- default_value: arg[:default_value],
382
- value: arg[:value]
383
- }
401
+ if var_type == 'choice'
402
+ # WARN the user that the measure had a "choice data type"
403
+ var_type = 'string'
384
404
  end
405
+
406
+ s.arguments << {
407
+ display_name: arg[:display_name],
408
+ display_name_short: arg[:display_name_short],
409
+ name: arg[:name],
410
+ value_type: var_type,
411
+ default_value: arg[:default_value],
412
+ value: arg[:value]
413
+ }
385
414
  end
386
415
 
387
- if hash[:variables]
388
- hash[:variables].each do |variable|
389
- # add the arguments first
390
- s.arguments << {
391
- display_name: variable[:argument][:display_name],
392
- display_name_short: variable[:argument][:display_name_short],
393
- name: variable[:argument][:name],
394
- value_type: variable[:argument][:value_type],
395
- default_value: variable[:argument][:default_value],
396
- value: variable[:argument][:default_value]
397
- }
398
-
399
- var_options = {}
400
- var_options[:variable_type] = variable[:variable_type]
401
- var_options[:variable_display_name_short] = variable[:display_name_short]
402
- var_options[:static_value] = variable[:static_value]
403
- distribution = variable[:uncertainty_description]
404
- distribution[:minimum] = variable[:minimum]
405
- distribution[:mean] = distribution[:attributes].find { |a| a[:name] == 'modes' }[:value]
406
- distribution[:maximum] = variable[:maximum]
407
- distribution[:standard_deviation] = distribution[:attributes].find { |a| a[:name] == 'stddev' }[:value]
408
- distribution[:step_size] = distribution[:attributes].find { |a| a[:name] == 'delta_x' }[:value]
409
- s.make_variable(variable[:argument][:name], variable[:display_name], distribution, var_options)
410
- end
416
+ hash[:variables]&.each do |variable|
417
+ # add the arguments first
418
+ s.arguments << {
419
+ display_name: variable[:argument][:display_name],
420
+ display_name_short: variable[:argument][:display_name_short],
421
+ name: variable[:argument][:name],
422
+ value_type: variable[:argument][:value_type],
423
+ default_value: variable[:argument][:default_value],
424
+ value: variable[:argument][:default_value]
425
+ }
426
+
427
+ var_options = {}
428
+ var_options[:variable_type] = variable[:variable_type]
429
+ var_options[:variable_display_name_short] = variable[:display_name_short]
430
+ var_options[:static_value] = variable[:static_value]
431
+ distribution = variable[:uncertainty_description]
432
+ distribution[:minimum] = variable[:minimum]
433
+ distribution[:mean] = distribution[:attributes].find { |a| a[:name] == 'modes' }[:value]
434
+ distribution[:maximum] = variable[:maximum]
435
+ distribution[:standard_deviation] = distribution[:attributes].find { |a| a[:name] == 'stddev' }[:value]
436
+ distribution[:step_size] = distribution[:attributes].find { |a| a[:name] == 'delta_x' }[:value]
437
+ s.make_variable(variable[:argument][:name], variable[:display_name], distribution, var_options)
411
438
  end
412
439
 
413
440
  s