openstudio-analysis 1.0.0.rc9 → 1.0.0.rc10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +47 -43
- data/CHANGELOG.md +5 -0
- data/lib/openstudio/analysis/formulation.rb +4 -4
- data/lib/openstudio/analysis/server_api.rb +69 -69
- data/lib/openstudio/analysis/support_files.rb +1 -1
- data/lib/openstudio/analysis/translator/datapoints.rb +61 -42
- data/lib/openstudio/analysis/translator/excel.rb +38 -38
- data/lib/openstudio/analysis/translator/workflow.rb +3 -4
- data/lib/openstudio/analysis/version.rb +1 -1
- data/lib/openstudio/analysis/workflow.rb +8 -8
- data/lib/openstudio/analysis/workflow_step.rb +27 -18
- data/lib/openstudio/analysis.rb +6 -6
- data/lib/openstudio/helpers/string.rb +2 -2
- data/lib/openstudio/weather/epw.rb +2 -2
- data/openstudio-analysis.gemspec +1 -1
- data/spec/openstudio/excel_spec.rb +4 -4
- data/spec/openstudio/formulation_spec.rb +2 -2
- data/spec/openstudio/osw_spec.rb +2 -2
- data/spec/openstudio/support_files_spec.rb +1 -3
- data/spec/openstudio/workflow_spec.rb +1 -1
- data/spec/schema/osa.json +3 -0
- metadata +2 -2
@@ -38,6 +38,15 @@ module OpenStudio
|
|
38
38
|
@measure_definition_version_uuid = nil
|
39
39
|
@arguments = []
|
40
40
|
|
41
|
+
@arguments << {
|
42
|
+
display_name: 'Skip Entire Measure',
|
43
|
+
display_name_short: 'Skip',
|
44
|
+
name: '__SKIP__',
|
45
|
+
value_type: 'boolean',
|
46
|
+
default_value: false,
|
47
|
+
value: false
|
48
|
+
}
|
49
|
+
|
41
50
|
# TODO: eventually the variables should be its own class. This would then be an array of Variable objects.
|
42
51
|
@variables = []
|
43
52
|
end
|
@@ -56,8 +65,8 @@ module OpenStudio
|
|
56
65
|
# @return [Boolean] True/false if it assigned it
|
57
66
|
def argument_value(argument_name, value)
|
58
67
|
a = @arguments.find_all { |a| a[:name] == argument_name }
|
59
|
-
|
60
|
-
|
68
|
+
raise "could not find argument_name of #{argument_name} in measure #{name}. Valid argument names are #{argument_names}." if a.empty?
|
69
|
+
raise "more than one argument with the same name of #{argument_name} in measure #{name}" if a.size > 1
|
61
70
|
|
62
71
|
a = a.first
|
63
72
|
|
@@ -101,11 +110,11 @@ module OpenStudio
|
|
101
110
|
options = { variable_type: 'variable' }.merge(options)
|
102
111
|
distribution[:mode] = distribution[:mean] if distribution.key? :mean
|
103
112
|
|
104
|
-
|
113
|
+
raise "Set the static value in the options 'options[:static_value]', not the distribution" if distribution[:static_value]
|
105
114
|
|
106
115
|
a = @arguments.find_all { |a| a[:name] == argument_name }
|
107
|
-
|
108
|
-
|
116
|
+
raise "could not find argument_name of #{argument_name} in measure #{name}. Valid argument names are #{argument_names}." if a.empty?
|
117
|
+
raise "more than one argument with the same name of #{argument_name} in measure #{name}" if a.size > 1
|
109
118
|
|
110
119
|
if distribution_valid?(distribution)
|
111
120
|
# grab the argument hash
|
@@ -213,7 +222,7 @@ module OpenStudio
|
|
213
222
|
end
|
214
223
|
|
215
224
|
else
|
216
|
-
|
225
|
+
raise "Do not know how to create the Hash for Version #{version}"
|
217
226
|
end
|
218
227
|
|
219
228
|
hash
|
@@ -240,7 +249,7 @@ module OpenStudio
|
|
240
249
|
if File.exist?(path_to_measure) && File.file?(path_to_measure)
|
241
250
|
path_to_measure = File.dirname(path_to_measure)
|
242
251
|
else
|
243
|
-
|
252
|
+
raise "Could not find measure '#{instance_name}' in '#{path_to_measure}'" unless options[:ignore_not_found]
|
244
253
|
end
|
245
254
|
|
246
255
|
# Extract the directory
|
@@ -328,7 +337,7 @@ module OpenStudio
|
|
328
337
|
if File.exist?(path_to_measure) && File.file?(path_to_measure)
|
329
338
|
path_to_measure = File.dirname(path_to_measure)
|
330
339
|
else
|
331
|
-
|
340
|
+
raise "Could not find measure '#{instance_name}' in '#{path_to_measure}'" unless options[:ignore_not_found]
|
332
341
|
end
|
333
342
|
|
334
343
|
# Extract the directo
|
@@ -409,31 +418,31 @@ module OpenStudio
|
|
409
418
|
# validate the arguments of the distribution
|
410
419
|
def distribution_valid?(d)
|
411
420
|
# regardless of uncertainty description the following must be defined
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
421
|
+
raise 'No distribution defined for variable' unless d.key? :type
|
422
|
+
raise 'No minimum defined for variable' unless d.key? :minimum
|
423
|
+
raise 'No maximum defined for variable' unless d.key? :maximum
|
424
|
+
raise 'No mean/mode defined for variable' unless d.key? :mode
|
416
425
|
|
417
426
|
if d[:type] =~ /uniform/
|
418
427
|
# Do we need to tell the user that we don't really need the mean/mode for uniform ?
|
419
428
|
elsif d[:type] =~ /discrete/
|
420
429
|
# require min, max, mode
|
421
|
-
|
430
|
+
raise 'No values passed for discrete distribution' unless d[:values] || d[:values].empty?
|
422
431
|
if d[:weights]
|
423
|
-
|
424
|
-
|
432
|
+
raise 'Weights are not the same length as values' unless d[:values].size == d[:weights].size
|
433
|
+
raise 'Weights do not sum up to one' unless d[:weights].reduce(:+).between?(0.99, 1.01) # allow a small error for now
|
425
434
|
else
|
426
435
|
fraction = 1 / d[:values].size.to_f
|
427
436
|
d[:weights] = [fraction] * d[:values].size
|
428
437
|
end
|
429
438
|
elsif d[:type] =~ /integer_sequence/
|
430
|
-
|
431
|
-
|
439
|
+
d[:weights] = 1
|
440
|
+
d[:values] = 1
|
432
441
|
elsif d[:type] =~ /triangle/
|
433
442
|
# requires min, max, mode
|
434
443
|
elsif d[:type] =~ /normal/ # both normal and lognormal
|
435
444
|
# require min, max, mode, stddev
|
436
|
-
|
445
|
+
raise 'No standard deviation for variable' unless d[:standard_deviation]
|
437
446
|
end
|
438
447
|
|
439
448
|
true
|
data/lib/openstudio/analysis.rb
CHANGED
@@ -32,7 +32,7 @@ module OpenStudio
|
|
32
32
|
# Process an OSA with a set of OSDs into OSWs
|
33
33
|
def self.make_osws(osa_filename, osd_array)
|
34
34
|
translator = OpenStudio::Analysis::Translator::Workflow.new(osa_filename)
|
35
|
-
osd_array.each {|osd| translator.process_datapoints osd}
|
35
|
+
osd_array.each { |osd| translator.process_datapoints osd }
|
36
36
|
end
|
37
37
|
|
38
38
|
# Retrieve aws instance options from a project. This will return a hash
|
@@ -55,14 +55,14 @@ module OpenStudio
|
|
55
55
|
csv.process
|
56
56
|
options = csv.settings
|
57
57
|
else
|
58
|
-
|
58
|
+
raise 'Invalid file extension'
|
59
59
|
end
|
60
60
|
|
61
61
|
return options
|
62
62
|
end
|
63
63
|
|
64
64
|
# Generate a DEnCity complient hash for uploading from the analysis hash
|
65
|
-
#TODO make this work off of the analysis object, not the hash.
|
65
|
+
# TODO make this work off of the analysis object, not the hash.
|
66
66
|
def self.to_dencity_analysis(analysis_hash, analysis_uuid)
|
67
67
|
dencity_hash = {}
|
68
68
|
a = analysis_hash[:analysis]
|
@@ -78,7 +78,7 @@ module OpenStudio
|
|
78
78
|
if a[:problem][:algorithm]
|
79
79
|
provenance[:analysis_information] = a[:problem][:algorithm]
|
80
80
|
else
|
81
|
-
|
81
|
+
raise 'No algorithm found in the analysis.json.'
|
82
82
|
end
|
83
83
|
|
84
84
|
if a[:problem][:workflow]
|
@@ -129,13 +129,13 @@ module OpenStudio
|
|
129
129
|
measure_metadata << new_wfi
|
130
130
|
end
|
131
131
|
else
|
132
|
-
|
132
|
+
raise 'No workflow found in the analysis.json'
|
133
133
|
end
|
134
134
|
|
135
135
|
dencity_hash[:analysis] = provenance
|
136
136
|
dencity_hash[:measure_definitions] = measure_metadata
|
137
137
|
else
|
138
|
-
|
138
|
+
raise 'No problem found in the analysis.json'
|
139
139
|
end
|
140
140
|
return dencity_hash
|
141
141
|
end
|
@@ -20,11 +20,11 @@ def typecast_value(variable_type, value, inspect_string = false)
|
|
20
20
|
elsif value.downcase == 'false'
|
21
21
|
out_value = false
|
22
22
|
else
|
23
|
-
|
23
|
+
raise "Can't cast to a bool from a value of '#{value}' of class '#{value.class}'"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
else
|
27
|
-
|
27
|
+
raise "Unknown variable type of '#{@variable['type']}'"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -56,7 +56,7 @@ module OpenStudio
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.load(filename)
|
59
|
-
|
59
|
+
raise "EPW file does not exist: #{filename}" unless File.exist?(filename)
|
60
60
|
f = OpenStudio::Weather::Epw.new(filename)
|
61
61
|
end
|
62
62
|
|
@@ -65,7 +65,7 @@ module OpenStudio
|
|
65
65
|
xml_builder_obj.name @city
|
66
66
|
xml_builder_obj.visibility '0'
|
67
67
|
xml_builder_obj.description do
|
68
|
-
xml_builder_obj.cdata!(
|
68
|
+
xml_builder_obj.cdata!('<img src="kml/ep_header8.png" width=180 align=right><br><table><tr><td colspan="2">'\
|
69
69
|
"<b>#{@city}</b></href></td></tr>\n" +
|
70
70
|
# "<tr><td></td><td><b>Data Type</td></tr>\n"+
|
71
71
|
"<tr><td></td><td>WMO <b>#{@wmo}</b></td></tr>\n" +
|
data/openstudio-analysis.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_dependency 'faraday', '~> 0.8'
|
26
26
|
s.add_dependency 'nokogiri', '~> 1.6'
|
27
27
|
s.add_dependency 'roo', '~> 2.4'
|
28
|
-
s.add_dependency 'rubyzip', '~> 1.2'
|
28
|
+
s.add_dependency 'rubyzip', '~> 1.2'
|
29
29
|
s.add_dependency 'semantic', '~> 1.4'
|
30
30
|
s.add_dependency 'bcl', '~> 0.5.7'
|
31
31
|
s.add_dependency 'dencity', '~> 0.1.0'
|
@@ -54,7 +54,7 @@ describe OpenStudio::Analysis::Translator::Excel do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should fail to process' do
|
57
|
-
expect { @excel.process }.to raise_error(
|
57
|
+
expect { @excel.process }.to raise_error('duplicate variable names found in list ["Insulation R-value (ft^2*h*R/Btu)."]')
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -443,8 +443,8 @@ describe OpenStudio::Analysis::Translator::Excel do
|
|
443
443
|
expect(j['analysis']['output_variables'].first['display_name_short']).to eq 'Site EUI'
|
444
444
|
expect(j['analysis']['problem']['workflow'][0]['variables'][0]['argument']['display_name']).to eq 'Orientation'
|
445
445
|
expect(j['analysis']['problem']['workflow'][0]['variables'][0]['argument']['display_name_short']).to eq 'Shorter Display Name'
|
446
|
-
expect(j['analysis']['problem']['workflow'][1]['arguments'][
|
447
|
-
expect(j['analysis']['problem']['workflow'][1]['arguments'][
|
446
|
+
expect(j['analysis']['problem']['workflow'][1]['arguments'][1]['display_name']).to eq 'unknown'
|
447
|
+
expect(j['analysis']['problem']['workflow'][1]['arguments'][1]['display_name_short']).to eq 'un'
|
448
448
|
end
|
449
449
|
end
|
450
450
|
|
@@ -485,7 +485,7 @@ describe OpenStudio::Analysis::Translator::Excel do
|
|
485
485
|
|
486
486
|
expect(@excel.worker_inits.size).to eq 2
|
487
487
|
expect(@excel.worker_inits[0][:name]).to eq 'initialize me'
|
488
|
-
expect(@excel.worker_inits[0][:args]).to eq
|
488
|
+
expect(@excel.worker_inits[0][:args]).to eq '["first_arg",2,{a_hash: "input"}]'
|
489
489
|
|
490
490
|
# test the eval'ing of the args
|
491
491
|
a = eval(@excel.analysis.worker_inits.first[:metadata][:args])
|
@@ -47,7 +47,7 @@ describe OpenStudio::Analysis::Formulation do
|
|
47
47
|
|
48
48
|
h = a.to_hash
|
49
49
|
expect(h[:analysis][:problem][:analysis_type]).to eq nil
|
50
|
-
expect(a.save
|
50
|
+
expect(a.save("#{run_dir}/analysis.json")).to eq true
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should increment objective functions' do
|
@@ -124,7 +124,7 @@ describe OpenStudio::Analysis::Formulation do
|
|
124
124
|
m.argument_value('heating_sch', 'some-string')
|
125
125
|
|
126
126
|
expect(a.workflow.measures.size).to eq 2
|
127
|
-
expect(a.workflow.measures[1].arguments[
|
127
|
+
expect(a.workflow.measures[1].arguments[3][:value]).to eq 'some-string'
|
128
128
|
expect(a.workflow.measures[1].variables[0][:uuid]).to match /[\w]{8}(-[\w]{4}){3}-[\w]{12}/
|
129
129
|
|
130
130
|
a.analysis_type = 'single_run'
|
data/spec/openstudio/osw_spec.rb
CHANGED
@@ -65,7 +65,7 @@ describe OpenStudio::Analysis::Translator::Workflow do
|
|
65
65
|
expect(result).to be_a(Hash)
|
66
66
|
|
67
67
|
# Save the file to the export directory
|
68
|
-
File.open('../../../spec/files/export/workflow/0.osw', 'w') { |f| f << JSON.pretty_generate(result)}
|
68
|
+
File.open('../../../spec/files/export/workflow/0.osw', 'w') { |f| f << JSON.pretty_generate(result) }
|
69
69
|
|
70
70
|
expect(result.key?(:seed_model)).to eq false
|
71
71
|
expect(result[:seed_file]).to eq 'large_office_air_cooled_chiller.osm'
|
@@ -75,7 +75,7 @@ describe OpenStudio::Analysis::Translator::Workflow do
|
|
75
75
|
|
76
76
|
it 'should not write a osd with a different osa id' do
|
77
77
|
osd_path = 'datapoint_wrong_osa_id.osd'
|
78
|
-
expect{ @translator.process_datapoint(osd_path).first }.to raise_error(RuntimeError)
|
78
|
+
expect { @translator.process_datapoint(osd_path).first }.to raise_error(RuntimeError)
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should write several osds' do
|
@@ -38,14 +38,12 @@ describe OpenStudio::Analysis::SupportFiles do
|
|
38
38
|
expect(@s.size).to eq 1
|
39
39
|
|
40
40
|
f = 'non-existent.rb'
|
41
|
-
expect{@s.add(f)}.to raise_error /Path or file does not exist and cannot be added.*/
|
41
|
+
expect { @s.add(f) }.to raise_error /Path or file does not exist and cannot be added.*/
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should add metadata data' do
|
45
|
-
|
46
45
|
end
|
47
46
|
|
48
|
-
|
49
47
|
it 'should add a directory' do
|
50
48
|
@s.clear
|
51
49
|
@s.add_files('spec/files/measures/**/*.rb', d: 'new')
|
@@ -64,7 +64,7 @@ describe OpenStudio::Analysis::Workflow do
|
|
64
64
|
@w.add_measure_from_path('thermostat_2', 'thermostat 2', p)
|
65
65
|
|
66
66
|
m = @w.find_measure('thermostat_2')
|
67
|
-
expect(m.argument_names).to eq %w(zones cooling_sch heating_sch material_cost)
|
67
|
+
expect(m.argument_names).to eq %w(__SKIP__ zones cooling_sch heating_sch material_cost)
|
68
68
|
|
69
69
|
d = {
|
70
70
|
type: 'uniform',
|
data/spec/schema/osa.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstudio-analysis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Long
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|