openstudio-analysis 1.0.0.rc19 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +20 -0
- data/.rubocop.yml +2 -133
- data/.travis.yml +2 -2
- data/CHANGELOG.md +6 -32
- data/Gemfile +9 -6
- data/README.md +15 -7
- data/Rakefile +38 -3
- data/lib/openstudio-analysis.rb +35 -0
- data/lib/openstudio/analysis.rb +35 -0
- data/lib/openstudio/analysis/algorithm_attributes.rb +36 -1
- data/lib/openstudio/analysis/formulation.rb +41 -6
- data/lib/openstudio/analysis/server_api.rb +46 -23
- data/lib/openstudio/analysis/support_files.rb +40 -0
- data/lib/openstudio/analysis/translator/datapoints.rb +39 -4
- data/lib/openstudio/analysis/translator/excel.rb +43 -8
- data/lib/openstudio/analysis/translator/workflow.rb +49 -5
- data/lib/openstudio/analysis/version.rb +36 -1
- data/lib/openstudio/analysis/workflow.rb +37 -2
- data/lib/openstudio/analysis/workflow_step.rb +35 -0
- data/lib/openstudio/helpers/hash.rb +35 -0
- data/lib/openstudio/helpers/string.rb +36 -2
- data/lib/openstudio/weather/epw.rb +31 -16
- data/openstudio-analysis.gemspec +4 -4
- data/spec/files/0_3_7_worker_init_final.xlsx +0 -0
- data/spec/files/analysis/examples/medium_office_example.json +2 -1
- data/spec/files/worker_init/second_file.sh +4 -0
- data/spec/integration/server_api_spec.rb +35 -0
- data/spec/openstudio/excel_spec.rb +36 -1
- data/spec/openstudio/formulation_spec.rb +46 -3
- data/spec/openstudio/hash_spec.rb +37 -2
- data/spec/openstudio/osw_spec.rb +37 -2
- data/spec/openstudio/server_api_spec.rb +43 -0
- data/spec/openstudio/string_spec.rb +34 -0
- data/spec/openstudio/support_files_spec.rb +39 -4
- data/spec/openstudio/weather_spec.rb +35 -0
- data/spec/openstudio/workflow_spec.rb +36 -1
- data/spec/openstudio/workflow_step_spec.rb +46 -6
- data/spec/spec_helper.rb +4 -2
- data/update_license.rb +119 -0
- metadata +29 -28
- data/rubocop-todo.yml +0 -246
- data/spec/files/worker_init/second_file.rb +0 -15
@@ -1,3 +1,38 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2018, 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::Algorithm define the algorithm parameters. The module and class names start to conflict
|
2
37
|
# with OpenStudio's namespace. Be careful adding new classes without first making sure that the namespace conflict
|
3
38
|
# is clear.
|
@@ -13,7 +48,7 @@ module OpenStudio
|
|
13
48
|
def set_attribute(attribute_name, attribute_value)
|
14
49
|
@attributes[attribute_name] = attribute_value
|
15
50
|
begin
|
16
|
-
|
51
|
+
unless Float(attribute_value).nil?
|
17
52
|
if Float(attribute_value).abs >= Float('1.0e+19')
|
18
53
|
raise "ERROR: Attribute `#{attribute_name}` is greater than 1E19. This may cause failures."
|
19
54
|
end
|
@@ -1,3 +1,38 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2018, 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 formulation class handles the generation of the OpenStudio Analysis format.
|
2
37
|
module OpenStudio
|
3
38
|
module Analysis
|
@@ -164,9 +199,9 @@ module OpenStudio
|
|
164
199
|
wf = nil
|
165
200
|
if @weather_file[:file]
|
166
201
|
wf = @weather_file
|
167
|
-
elsif
|
202
|
+
elsif !@weather_files.empty?
|
168
203
|
# get the first EPW file (not the first file)
|
169
|
-
wf = @weather_files.find { |w| File.extname(w[:file]).
|
204
|
+
wf = @weather_files.find { |w| File.extname(w[:file]).casecmp('.epw').zero? }
|
170
205
|
end
|
171
206
|
|
172
207
|
if wf
|
@@ -349,13 +384,13 @@ module OpenStudio
|
|
349
384
|
@worker_inits.each_with_index do |f, index|
|
350
385
|
ordered_file_name = "#{index.to_s.rjust(2, '0')}_#{File.basename(f[:file])}"
|
351
386
|
puts " Adding #{f[:file]} as #{ordered_file_name}"
|
352
|
-
zf.add(f[:file].sub(f[:file], "./
|
387
|
+
zf.add(f[:file].sub(f[:file], "./scripts/worker_initialization//#{ordered_file_name}"), f[:file])
|
353
388
|
|
354
389
|
if f[:metadata][:args]
|
355
390
|
arg_file = "#{File.basename(ordered_file_name, '.*')}.args"
|
356
391
|
file = Tempfile.new('arg')
|
357
392
|
file.write(f[:metadata][:args])
|
358
|
-
zf.add("./
|
393
|
+
zf.add("./scripts/worker_initialization/#{arg_file}", file)
|
359
394
|
file.close
|
360
395
|
end
|
361
396
|
end
|
@@ -364,13 +399,13 @@ module OpenStudio
|
|
364
399
|
@worker_finalizes.each_with_index do |f, index|
|
365
400
|
ordered_file_name = "#{index.to_s.rjust(2, '0')}_#{File.basename(f[:file])}"
|
366
401
|
puts " Adding #{f[:file]} as #{ordered_file_name}"
|
367
|
-
zf.add(f[:file].sub(f[:file], "./
|
402
|
+
zf.add(f[:file].sub(f[:file], "./scripts/worker_finalization/#{ordered_file_name}"), f[:file])
|
368
403
|
|
369
404
|
if f[:metadata][:args]
|
370
405
|
arg_file = "#{File.basename(ordered_file_name, '.*')}.args"
|
371
406
|
file = Tempfile.new('arg')
|
372
407
|
file.write(f[:metadata][:args])
|
373
|
-
zf.add("./
|
408
|
+
zf.add("./scripts/worker_finalization/#{arg_file}", file)
|
374
409
|
file.close
|
375
410
|
end
|
376
411
|
end
|
@@ -1,3 +1,38 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2018, 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
|
# Class manages the communication with the server.
|
2
37
|
# Presently, this class is simple and stores all information in hashs
|
3
38
|
module OpenStudio
|
@@ -6,16 +41,16 @@ module OpenStudio
|
|
6
41
|
attr_reader :hostname
|
7
42
|
|
8
43
|
# Define set of anlaysis methods require batch_run to be queued after them
|
9
|
-
BATCH_RUN_METHODS =
|
44
|
+
BATCH_RUN_METHODS = ['lhs', 'preflight', 'single_run', 'repeat_run', 'doe', 'diag', 'baseline_perturbation', 'batch_datapoints'].freeze
|
10
45
|
|
11
46
|
def initialize(options = {})
|
12
47
|
defaults = { hostname: 'http://localhost:8080', log_path: File.expand_path('~/os_server_api.log') }
|
13
48
|
options = defaults.merge(options)
|
14
|
-
|
49
|
+
if ENV['OS_SERVER_LOG_PATH']
|
15
50
|
@logger = ::Logger.new(ENV['OS_SERVER_LOG_PATH'] + '/os_server_api.log')
|
16
51
|
else
|
17
52
|
@logger = ::Logger.new(options[:log_path])
|
18
|
-
|
53
|
+
end
|
19
54
|
|
20
55
|
@hostname = options[:hostname]
|
21
56
|
|
@@ -209,11 +244,8 @@ module OpenStudio
|
|
209
244
|
j = JSON.parse resp.body, symbolize_names: true
|
210
245
|
status = j if j
|
211
246
|
end
|
212
|
-
|
213
247
|
rescue Faraday::ConnectionFailed
|
214
|
-
|
215
248
|
rescue Net::ReadTimeout
|
216
|
-
|
217
249
|
end
|
218
250
|
|
219
251
|
status
|
@@ -340,11 +372,12 @@ module OpenStudio
|
|
340
372
|
[downloaded, file_path_and_name]
|
341
373
|
end
|
342
374
|
|
343
|
-
|
375
|
+
# http://localhost:3000/data_points/ff857845-a4c6-4eb9-a52b-cbc6a41976d5/download_result_file?filename=
|
376
|
+
def download_datapoint_report(datapoint_id, report_name, save_directory = '.')
|
344
377
|
downloaded = false
|
345
378
|
file_path_and_name = nil
|
346
379
|
|
347
|
-
response = @conn.get "/data_points/#{datapoint_id}/
|
380
|
+
response = @conn.get "/data_points/#{datapoint_id}/download_result_file?filename=#{report_name}"
|
348
381
|
if response.status == 200
|
349
382
|
filename = response['content-disposition'].match(/filename=(\"?)(.+)\1/)[2]
|
350
383
|
downloaded = true
|
@@ -356,16 +389,6 @@ module OpenStudio
|
|
356
389
|
[downloaded, file_path_and_name]
|
357
390
|
end
|
358
391
|
|
359
|
-
def download_datapoints_reports(analysis_id, save_directory = '.')
|
360
|
-
# get the list of all the datapoints
|
361
|
-
dps = get_datapoint_status(analysis_id)
|
362
|
-
dps.each do |dp|
|
363
|
-
if dp[:status] == 'completed'
|
364
|
-
download_datapoint_reports(dp[:_id], save_directory)
|
365
|
-
end
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
392
|
def download_datapoint_jsons(analysis_id, save_directory = '.')
|
370
393
|
# get the list of all the datapoints
|
371
394
|
dps = get_datapoint_status(analysis_id)
|
@@ -555,7 +578,7 @@ module OpenStudio
|
|
555
578
|
upload = conn.load_analysis 'dencity_analysis.json'
|
556
579
|
begin
|
557
580
|
upload_response = upload.push
|
558
|
-
rescue => e
|
581
|
+
rescue StandardError => e
|
559
582
|
runner.registerError("Upload failure: #{e.message} in #{e.backtrace.join('/n')}")
|
560
583
|
else
|
561
584
|
if NoMethodError == upload_response.class
|
@@ -762,12 +785,12 @@ module OpenStudio
|
|
762
785
|
# @option options [String] :run_data_point_filename Name of ruby file that the server runs -- will be deprecated
|
763
786
|
# @option options [String] :push_to_dencity Whether or not to push to DEnCity
|
764
787
|
# @option options [String] :batch_run_method Which batch run method to use (batch_run or batch_run_local [no R])
|
765
|
-
def run(formulation_filename, analysis_zip_filename, analysis_type,
|
766
|
-
options = {})
|
788
|
+
def run(formulation_filename, analysis_zip_filename, analysis_type, options = {})
|
767
789
|
defaults = {
|
768
790
|
run_data_point_filename: 'run_openstudio_workflow_monthly.rb',
|
769
791
|
push_to_dencity: false,
|
770
|
-
batch_run_method: 'batch_run'
|
792
|
+
batch_run_method: 'batch_run',
|
793
|
+
without_delay: false
|
771
794
|
}
|
772
795
|
options = defaults.merge(options)
|
773
796
|
|
@@ -785,7 +808,7 @@ module OpenStudio
|
|
785
808
|
|
786
809
|
run_options = {
|
787
810
|
analysis_action: 'start',
|
788
|
-
without_delay:
|
811
|
+
without_delay: options[:without_delay],
|
789
812
|
analysis_type: analysis_type,
|
790
813
|
simulate_data_point_filename: 'simulate_data_point.rb', # TODO: remove these from server?
|
791
814
|
run_data_point_filename: options[:run_data_point_filename]
|
@@ -1,3 +1,38 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2018, 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::SupportFiles is a container to hold other analysis files that may need to be packaged.
|
2
37
|
# The most common use of support files are weather files, design day files, multiple seed files, worker initialization
|
3
38
|
# scripts, worker finalization scripts, and general libraries
|
@@ -12,6 +47,11 @@ module OpenStudio
|
|
12
47
|
@files = []
|
13
48
|
end
|
14
49
|
|
50
|
+
# Check if the array is empty
|
51
|
+
def empty?
|
52
|
+
@files.empty?
|
53
|
+
end
|
54
|
+
|
15
55
|
# Add a file to the support file list
|
16
56
|
#
|
17
57
|
# @param path_or_filename [String] Full path of the file to be added.
|
@@ -1,3 +1,38 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2018, 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
|
@@ -155,7 +190,7 @@ module OpenStudio
|
|
155
190
|
# @append_model_name [Boolean] Append the name of the seed model to the display name
|
156
191
|
# @return [Object] An OpenStudio::Analysis
|
157
192
|
def analysis(seed_model = nil, append_model_name = false)
|
158
|
-
raise 'There are no seed models defined in the excel file. Please add one.' if @models.
|
193
|
+
raise 'There are no seed models defined in the excel file. Please add one.' if @models.empty?
|
159
194
|
raise 'There are more than one seed models defined in the excel file. This is not supported by the CSV Translator.' if @models.size > 1 && seed_model.nil?
|
160
195
|
|
161
196
|
seed_model = @models.first if seed_model.nil?
|
@@ -315,7 +350,7 @@ module OpenStudio
|
|
315
350
|
|
316
351
|
def parse_csv_measures(measure_rows)
|
317
352
|
# Build metadata required for parsing
|
318
|
-
measures = measure_rows[0].uniq.
|
353
|
+
measures = measure_rows[0].uniq.reject(&:nil?).map(&:to_sym)
|
319
354
|
measure_map = {}
|
320
355
|
measure_var_list = []
|
321
356
|
measures.each do |measure|
|
@@ -383,12 +418,12 @@ module OpenStudio
|
|
383
418
|
var_hash[:distribution] = {}
|
384
419
|
case var_hash[:type].downcase
|
385
420
|
when 'bool', 'boolean'
|
386
|
-
var_hash[:distribution][:values] = (3..(measure_rows.length - 1)).map { |value| measure_rows[value.to_i][measure_map[measure][var]].to_s.
|
421
|
+
var_hash[:distribution][:values] = (3..(measure_rows.length - 1)).map { |value| measure_rows[value.to_i][measure_map[measure][var]].to_s.casecmp('true').zero? }
|
387
422
|
var_hash[:distribution][:maximum] = true
|
388
423
|
var_hash[:distribution][:minimum] = false
|
389
424
|
var_hash[:distribution][:mode] = var_hash[:distribution][:values].group_by { |i| i }.max { |x, y| x[1].length <=> y[1].length }[0]
|
390
425
|
when 'choice', 'string'
|
391
|
-
var_hash[:distribution][:values] = (3..
|
426
|
+
var_hash[:distribution][:values] = (3..measure_rows.length - 1).map { |value| measure_rows[value.to_i][measure_map[measure][var]].to_s }
|
392
427
|
var_hash[:distribution][:minimum] = var_hash[:distribution][:values].min
|
393
428
|
var_hash[:distribution][:maximum] = var_hash[:distribution][:values].max
|
394
429
|
var_hash[:distribution][:mode] = var_hash[:distribution][:values].group_by { |i| i }.max { |x, y| x[1].length <=> y[1].length }[0]
|
@@ -1,3 +1,38 @@
|
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2018, 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 = []
|
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.
|
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[
|
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[
|
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[
|
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[
|
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].
|
539
|
+
if row[0] && 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
|
|