openstudio-analysis 1.3.5 → 1.3.6
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/.github/workflows/openstudio-analysis.yml +40 -40
- data/.gitignore +21 -21
- data/.rubocop.yml +9 -9
- data/CHANGELOG.md +269 -265
- data/Gemfile +14 -14
- data/README.md +102 -102
- data/Rakefile +40 -40
- data/lib/openstudio/analysis/algorithm_attributes.rb +47 -47
- data/lib/openstudio/analysis/formulation.rb +857 -857
- data/lib/openstudio/analysis/server_api.rb +862 -862
- data/lib/openstudio/analysis/server_scripts.rb +108 -108
- data/lib/openstudio/analysis/support_files.rb +104 -104
- data/lib/openstudio/analysis/translator/datapoints.rb +454 -454
- data/lib/openstudio/analysis/translator/excel.rb +893 -893
- data/lib/openstudio/analysis/translator/workflow.rb +143 -143
- data/lib/openstudio/analysis/version.rb +12 -12
- data/lib/openstudio/analysis/workflow.rb +279 -279
- data/lib/openstudio/analysis/workflow_step.rb +523 -523
- data/lib/openstudio/analysis.rb +144 -144
- data/lib/openstudio/helpers/hash.rb +10 -10
- data/lib/openstudio/helpers/string.rb +36 -36
- data/lib/openstudio/helpers/utils.rb +36 -36
- data/lib/openstudio/weather/epw.rb +178 -178
- data/lib/openstudio-analysis.rb +47 -47
- data/openstudio-analysis.gemspec +38 -38
- data/update_license.rb +60 -60
- metadata +9 -9
@@ -1,143 +1,143 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
-
# See also https://openstudio.net/license
|
4
|
-
# *******************************************************************************
|
5
|
-
|
6
|
-
module OpenStudio
|
7
|
-
module Analysis
|
8
|
-
module Translator
|
9
|
-
class Workflow
|
10
|
-
attr_reader :osa_filename
|
11
|
-
attr_reader :root_path
|
12
|
-
attr_reader :analysis
|
13
|
-
attr_reader :osa
|
14
|
-
attr_reader :osw_version
|
15
|
-
attr_reader :options
|
16
|
-
attr_reader :file_paths
|
17
|
-
attr_reader :measure_paths
|
18
|
-
attr_reader :seed_file
|
19
|
-
attr_reader :weather_file
|
20
|
-
attr_reader :osa_id
|
21
|
-
attr_reader :steps
|
22
|
-
|
23
|
-
def initialize(osa_filename, options = {})
|
24
|
-
@osa_filename = osa_filename
|
25
|
-
@root_path = File.expand_path(File.dirname(@osa_filename))
|
26
|
-
|
27
|
-
# try to read the osa json file
|
28
|
-
if File.exist?(@osa_filename)
|
29
|
-
@osa = ::JSON.parse(File.read(@osa_filename), symbolize_names: true)[:analysis]
|
30
|
-
else
|
31
|
-
raise "File #{@osa_filename} does not exist"
|
32
|
-
end
|
33
|
-
|
34
|
-
# Initialize some other instance variables
|
35
|
-
@osw_version = '0.0.1'
|
36
|
-
@options = options
|
37
|
-
@file_paths = options[:file_paths] ? options[:file_paths] : []
|
38
|
-
@file_paths << '../lib'
|
39
|
-
@measure_paths = options[:measure_paths] ? options[:measure_paths] : []
|
40
|
-
|
41
|
-
# Initialize static inputs from the OSA
|
42
|
-
!@osa[:seed].nil? ? @seed_file = File.basename(@osa[:seed][:path]) : @seed_file = ''
|
43
|
-
if @options[:seed]
|
44
|
-
@seed_file = @options[:seed]
|
45
|
-
end
|
46
|
-
!@osa[:weather_file].nil? ? @weather_file = File.basename(@osa[:weather_file][:path]) : @weather_file = ''
|
47
|
-
@osa_id = @osa[:_id]
|
48
|
-
@steps = []
|
49
|
-
@osa[:problem][:workflow].each_with_index do |step, i|
|
50
|
-
step_hash = {}
|
51
|
-
step_hash[:measure_dir_name] = File.basename(step[:measure_definition_directory])
|
52
|
-
step_hash[:arguments] = {}
|
53
|
-
# Measures can have no arguments -- make sure to catch it
|
54
|
-
@osa[:problem][:workflow][i][:arguments]&.each do |arg|
|
55
|
-
next if arg[:value].nil?
|
56
|
-
step_hash[:arguments][arg[:name].to_sym] = arg[:value]
|
57
|
-
end
|
58
|
-
step_hash[:name] = step[:name] if step[:name]
|
59
|
-
step_hash[:description] = step[:description] if step[:description]
|
60
|
-
if @options[:da_descriptions]
|
61
|
-
step_hash[:name] = @options[:da_descriptions][i][:name]
|
62
|
-
step_hash[:description] = @options[:da_descriptions][i][:description]
|
63
|
-
end
|
64
|
-
# DLM: the following fields are deprecated and should be removed once EDAPT reports no longer rely on them, they are moved to step.results
|
65
|
-
step_hash[:measure_id] = step[:measure_definition_uuid] if step[:measure_definition_uuid]
|
66
|
-
step_hash[:version_id] = step[:measure_definition_version_uuid] if step[:measure_definition_version_uuid]
|
67
|
-
step_hash[:modeler_description] = step[:modeler_description] if step[:modeler_description]
|
68
|
-
step_hash[:taxonomy] = step[:taxonomy] if step[:taxonomy]
|
69
|
-
step_hash[:measure_type] = step[:measure_type]
|
70
|
-
step_hash[:measure_type] = 'ModelMeasure'
|
71
|
-
@steps << step_hash
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# Convert a file in the form of an OSD into an OSW
|
76
|
-
def process_datapoint(osd_filename)
|
77
|
-
# Try to read the osd json file
|
78
|
-
osd = nil
|
79
|
-
if File.exist?(osd_filename)
|
80
|
-
osd = ::JSON.parse(File.read(osd_filename), symbolize_names: true)[:data_point]
|
81
|
-
else
|
82
|
-
raise "File #{osd_filename} does not exist"
|
83
|
-
end
|
84
|
-
|
85
|
-
# Parse the osd hash based off of the osa hash. First check that the analysis id matches
|
86
|
-
raise "File #{osd_filename} does not reference #{@osa_id}." unless @osa_id == osd[:analysis_id]
|
87
|
-
osw_steps_instance = @steps
|
88
|
-
osw_steps_instance.each_with_index do |step, i|
|
89
|
-
next unless @osa[:problem][:workflow][i][:variables]
|
90
|
-
@osa[:problem][:workflow][i][:variables].each do |var|
|
91
|
-
var_name = var[:argument][:name]
|
92
|
-
var_value_uuid = var[:uuid]
|
93
|
-
var_value = osd[:set_variable_values][var_value_uuid.to_sym]
|
94
|
-
step[:arguments][var_name.to_sym] = var_value
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Overwrite the seed and weather files if they are present in the datapoint.json
|
99
|
-
if (osd[:weather_file] != '') && !osd[:weather_file].nil?
|
100
|
-
weather_file = osd[:weather_file]
|
101
|
-
else
|
102
|
-
weather_file = @weather_file
|
103
|
-
end
|
104
|
-
if (osd[:seed] != '') && !osd[:seed].nil?
|
105
|
-
seed_file = osd[:seed]
|
106
|
-
else
|
107
|
-
seed_file = @seed_file
|
108
|
-
end
|
109
|
-
|
110
|
-
# Save the OSW hash
|
111
|
-
osw = {}
|
112
|
-
created_at = ::Time.now
|
113
|
-
osw[:seed_file] = seed_file
|
114
|
-
osw[:weather_file] = weather_file
|
115
|
-
osw[:file_format_version] = @osw_version
|
116
|
-
osw[:osa_id] = @osa_id
|
117
|
-
osw[:osd_id] = osd[:_id]
|
118
|
-
osw[:created_at] = created_at
|
119
|
-
osw[:measure_paths] = @measure_paths
|
120
|
-
osw[:file_paths] = @file_paths
|
121
|
-
osw[:run_directory] = './run'
|
122
|
-
osw[:steps] = osw_steps_instance
|
123
|
-
osw[:name] = osd[:name] if osd[:name]
|
124
|
-
osw[:description] = osd[:description] if osd[:description]
|
125
|
-
osw
|
126
|
-
end
|
127
|
-
|
128
|
-
# Runs an array of OSD files
|
129
|
-
def process_datapoints(osd_filename_array)
|
130
|
-
r = []
|
131
|
-
osd_filename_array.each do |osd_file|
|
132
|
-
r << process_datapoint(osd_file)
|
133
|
-
rescue StandardError => e
|
134
|
-
r << nil
|
135
|
-
puts "Warning: Failed to process datapoint #{osd_file} with error #{e.message} in #{e.backtrace.join('\n')}"
|
136
|
-
end
|
137
|
-
|
138
|
-
r
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
+
# See also https://openstudio.net/license
|
4
|
+
# *******************************************************************************
|
5
|
+
|
6
|
+
module OpenStudio
|
7
|
+
module Analysis
|
8
|
+
module Translator
|
9
|
+
class Workflow
|
10
|
+
attr_reader :osa_filename
|
11
|
+
attr_reader :root_path
|
12
|
+
attr_reader :analysis
|
13
|
+
attr_reader :osa
|
14
|
+
attr_reader :osw_version
|
15
|
+
attr_reader :options
|
16
|
+
attr_reader :file_paths
|
17
|
+
attr_reader :measure_paths
|
18
|
+
attr_reader :seed_file
|
19
|
+
attr_reader :weather_file
|
20
|
+
attr_reader :osa_id
|
21
|
+
attr_reader :steps
|
22
|
+
|
23
|
+
def initialize(osa_filename, options = {})
|
24
|
+
@osa_filename = osa_filename
|
25
|
+
@root_path = File.expand_path(File.dirname(@osa_filename))
|
26
|
+
|
27
|
+
# try to read the osa json file
|
28
|
+
if File.exist?(@osa_filename)
|
29
|
+
@osa = ::JSON.parse(File.read(@osa_filename), symbolize_names: true)[:analysis]
|
30
|
+
else
|
31
|
+
raise "File #{@osa_filename} does not exist"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Initialize some other instance variables
|
35
|
+
@osw_version = '0.0.1'
|
36
|
+
@options = options
|
37
|
+
@file_paths = options[:file_paths] ? options[:file_paths] : []
|
38
|
+
@file_paths << '../lib'
|
39
|
+
@measure_paths = options[:measure_paths] ? options[:measure_paths] : []
|
40
|
+
|
41
|
+
# Initialize static inputs from the OSA
|
42
|
+
!@osa[:seed].nil? ? @seed_file = File.basename(@osa[:seed][:path]) : @seed_file = ''
|
43
|
+
if @options[:seed]
|
44
|
+
@seed_file = @options[:seed]
|
45
|
+
end
|
46
|
+
!@osa[:weather_file].nil? ? @weather_file = File.basename(@osa[:weather_file][:path]) : @weather_file = ''
|
47
|
+
@osa_id = @osa[:_id]
|
48
|
+
@steps = []
|
49
|
+
@osa[:problem][:workflow].each_with_index do |step, i|
|
50
|
+
step_hash = {}
|
51
|
+
step_hash[:measure_dir_name] = File.basename(step[:measure_definition_directory])
|
52
|
+
step_hash[:arguments] = {}
|
53
|
+
# Measures can have no arguments -- make sure to catch it
|
54
|
+
@osa[:problem][:workflow][i][:arguments]&.each do |arg|
|
55
|
+
next if arg[:value].nil?
|
56
|
+
step_hash[:arguments][arg[:name].to_sym] = arg[:value]
|
57
|
+
end
|
58
|
+
step_hash[:name] = step[:name] if step[:name]
|
59
|
+
step_hash[:description] = step[:description] if step[:description]
|
60
|
+
if @options[:da_descriptions]
|
61
|
+
step_hash[:name] = @options[:da_descriptions][i][:name]
|
62
|
+
step_hash[:description] = @options[:da_descriptions][i][:description]
|
63
|
+
end
|
64
|
+
# DLM: the following fields are deprecated and should be removed once EDAPT reports no longer rely on them, they are moved to step.results
|
65
|
+
step_hash[:measure_id] = step[:measure_definition_uuid] if step[:measure_definition_uuid]
|
66
|
+
step_hash[:version_id] = step[:measure_definition_version_uuid] if step[:measure_definition_version_uuid]
|
67
|
+
step_hash[:modeler_description] = step[:modeler_description] if step[:modeler_description]
|
68
|
+
step_hash[:taxonomy] = step[:taxonomy] if step[:taxonomy]
|
69
|
+
step_hash[:measure_type] = step[:measure_type]
|
70
|
+
step_hash[:measure_type] = 'ModelMeasure'
|
71
|
+
@steps << step_hash
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Convert a file in the form of an OSD into an OSW
|
76
|
+
def process_datapoint(osd_filename)
|
77
|
+
# Try to read the osd json file
|
78
|
+
osd = nil
|
79
|
+
if File.exist?(osd_filename)
|
80
|
+
osd = ::JSON.parse(File.read(osd_filename), symbolize_names: true)[:data_point]
|
81
|
+
else
|
82
|
+
raise "File #{osd_filename} does not exist"
|
83
|
+
end
|
84
|
+
|
85
|
+
# Parse the osd hash based off of the osa hash. First check that the analysis id matches
|
86
|
+
raise "File #{osd_filename} does not reference #{@osa_id}." unless @osa_id == osd[:analysis_id]
|
87
|
+
osw_steps_instance = @steps
|
88
|
+
osw_steps_instance.each_with_index do |step, i|
|
89
|
+
next unless @osa[:problem][:workflow][i][:variables]
|
90
|
+
@osa[:problem][:workflow][i][:variables].each do |var|
|
91
|
+
var_name = var[:argument][:name]
|
92
|
+
var_value_uuid = var[:uuid]
|
93
|
+
var_value = osd[:set_variable_values][var_value_uuid.to_sym]
|
94
|
+
step[:arguments][var_name.to_sym] = var_value
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Overwrite the seed and weather files if they are present in the datapoint.json
|
99
|
+
if (osd[:weather_file] != '') && !osd[:weather_file].nil?
|
100
|
+
weather_file = osd[:weather_file]
|
101
|
+
else
|
102
|
+
weather_file = @weather_file
|
103
|
+
end
|
104
|
+
if (osd[:seed] != '') && !osd[:seed].nil?
|
105
|
+
seed_file = osd[:seed]
|
106
|
+
else
|
107
|
+
seed_file = @seed_file
|
108
|
+
end
|
109
|
+
|
110
|
+
# Save the OSW hash
|
111
|
+
osw = {}
|
112
|
+
created_at = ::Time.now
|
113
|
+
osw[:seed_file] = seed_file
|
114
|
+
osw[:weather_file] = weather_file
|
115
|
+
osw[:file_format_version] = @osw_version
|
116
|
+
osw[:osa_id] = @osa_id
|
117
|
+
osw[:osd_id] = osd[:_id]
|
118
|
+
osw[:created_at] = created_at
|
119
|
+
osw[:measure_paths] = @measure_paths
|
120
|
+
osw[:file_paths] = @file_paths
|
121
|
+
osw[:run_directory] = './run'
|
122
|
+
osw[:steps] = osw_steps_instance
|
123
|
+
osw[:name] = osd[:name] if osd[:name]
|
124
|
+
osw[:description] = osd[:description] if osd[:description]
|
125
|
+
osw
|
126
|
+
end
|
127
|
+
|
128
|
+
# Runs an array of OSD files
|
129
|
+
def process_datapoints(osd_filename_array)
|
130
|
+
r = []
|
131
|
+
osd_filename_array.each do |osd_file|
|
132
|
+
r << process_datapoint(osd_file)
|
133
|
+
rescue StandardError => e
|
134
|
+
r << nil
|
135
|
+
puts "Warning: Failed to process datapoint #{osd_file} with error #{e.message} in #{e.backtrace.join('\n')}"
|
136
|
+
end
|
137
|
+
|
138
|
+
r
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
-
# See also https://openstudio.net/license
|
4
|
-
# *******************************************************************************
|
5
|
-
|
6
|
-
module OpenStudio
|
7
|
-
module Analysis
|
8
|
-
# format should be ^.*\-{1}[a-z]+[0-9]+
|
9
|
-
# for example: -rc1, -beta6, -customusecase0
|
10
|
-
VERSION = '1.3.
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
|
3
|
+
# See also https://openstudio.net/license
|
4
|
+
# *******************************************************************************
|
5
|
+
|
6
|
+
module OpenStudio
|
7
|
+
module Analysis
|
8
|
+
# format should be ^.*\-{1}[a-z]+[0-9]+
|
9
|
+
# for example: -rc1, -beta6, -customusecase0
|
10
|
+
VERSION = '1.3.6'.freeze
|
11
|
+
end
|
12
|
+
end
|