urbanopt-scenario 0.6.0 → 0.7.0
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 +2 -3
- data/CHANGELOG.md +23 -0
- data/Gemfile +3 -1
- data/docs/package-lock.json +20264 -1990
- data/docs/package.json +5 -4
- data/lib/urbanopt/scenario/logger.rb +1 -1
- data/lib/urbanopt/scenario/scenario_csv.rb +6 -6
- data/lib/urbanopt/scenario/scenario_datapoint_base.rb +5 -5
- data/lib/urbanopt/scenario/scenario_post_processor_default.rb +4 -4
- data/lib/urbanopt/scenario/scenario_post_processor_opendss.rb +6 -6
- data/lib/urbanopt/scenario/scenario_runner_osw.rb +4 -3
- data/lib/urbanopt/scenario/scenario_visualization.rb +30 -22
- data/lib/urbanopt/scenario/simulation_dir_base.rb +1 -5
- data/lib/urbanopt/scenario/simulation_dir_osw.rb +3 -1
- data/lib/urbanopt/scenario/version.rb +1 -1
- data/urbanopt-scenario-gem.gemspec +4 -4
- metadata +17 -17
data/docs/package.json
CHANGED
@@ -13,21 +13,22 @@
|
|
13
13
|
"highlight.js": "^10.4.1",
|
14
14
|
"json-schema-ref-parser": "^9.0.6",
|
15
15
|
"json-schema-view-js": "git+https://git@github.com/bgschiller/json-schema-view-js.git",
|
16
|
-
"vuepress": "^1.6.0",
|
17
16
|
"webpack-dev-middleware": "^3.6.0"
|
18
17
|
},
|
19
18
|
"devDependencies": {
|
20
19
|
"braces": "^3.0.2",
|
21
20
|
"dot-prop": "^5.3.0",
|
22
21
|
"gh-pages": "^3.1.0",
|
22
|
+
"ini": "^2.0.0",
|
23
23
|
"is-svg": ">=4.3.1",
|
24
24
|
"js-yaml": "^3.14.0",
|
25
25
|
"minimist": ">=1.2.3",
|
26
26
|
"node-forge": ">=0.10.0",
|
27
|
+
"postcss": "^8.2.15",
|
27
28
|
"serialize-javascript": "^5.0.1",
|
28
|
-
"set-value": "^
|
29
|
+
"set-value": "^4.0.1",
|
29
30
|
"ssri": ">=8.0.1",
|
30
|
-
"
|
31
|
-
"
|
31
|
+
"vuepress": "^1.8.2",
|
32
|
+
"yargs-parser": "^20.2.1"
|
32
33
|
}
|
33
34
|
}
|
@@ -82,7 +82,6 @@ module URBANopt
|
|
82
82
|
|
83
83
|
# Require all simulation mappers in mapper_files_dir
|
84
84
|
def load_mapper_files
|
85
|
-
|
86
85
|
# loads default values from extension gem
|
87
86
|
options = OpenStudio::Extension::RunnerConfig.default_config
|
88
87
|
# check if runner.conf file exists
|
@@ -94,9 +93,9 @@ module URBANopt
|
|
94
93
|
|
95
94
|
# bundle path is assigned from the runner.conf if it exists or is assigned in the root_dir
|
96
95
|
bundle_path = !options.key?(:bundle_install_path) || options[:bundle_install_path] === '' ? File.join(@root_dir, '.bundle/install/') : options[:bundle_install_path]
|
97
|
-
|
96
|
+
|
98
97
|
# checks if bundle path doesn't exist or is empty
|
99
|
-
if !Dir.
|
98
|
+
if !Dir.exist?(bundle_path) || Dir.empty?(bundle_path)
|
100
99
|
# install bundle
|
101
100
|
OpenStudio::Extension::Runner.new(@root_dir)
|
102
101
|
end
|
@@ -105,8 +104,10 @@ module URBANopt
|
|
105
104
|
lib_dirs = Dir.glob(File.join(bundle_path, '/**/lib'))
|
106
105
|
lib_dirs.each do |ld|
|
107
106
|
# for now only add openstudio and urbanopt gems to the load path
|
108
|
-
|
109
|
-
|
107
|
+
# and only those with 'urbanopt' or 'openstudio' in the before-last path position
|
108
|
+
tmp_path_arr = Pathname(ld).each_filename.to_a
|
109
|
+
if tmp_path_arr[-2].include?('urbanopt') || tmp_path_arr[-2].include?('openstudio')
|
110
|
+
# puts "adding DIR to load path: #{ld}"
|
110
111
|
$LOAD_PATH.unshift(ld)
|
111
112
|
end
|
112
113
|
end
|
@@ -119,7 +120,6 @@ module URBANopt
|
|
119
120
|
@@logger.error(e.message)
|
120
121
|
raise
|
121
122
|
end
|
122
|
-
|
123
123
|
end
|
124
124
|
|
125
125
|
# Gets all the simulation directories
|
@@ -41,7 +41,7 @@
|
|
41
41
|
module URBANopt
|
42
42
|
module Scenario
|
43
43
|
class ScenarioDatapoint
|
44
|
-
attr_reader :scenario, :feature_id, :feature_name, :mapper_class #:nodoc:#
|
44
|
+
attr_reader :scenario, :feature_id, :feature_name, :mapper_class, :feature #:nodoc:#
|
45
45
|
|
46
46
|
##
|
47
47
|
# ScenarioDatapoint is an agnostic description of the simulation of a Feature in a Scenario
|
@@ -58,9 +58,7 @@ module URBANopt
|
|
58
58
|
@feature_name = feature_name
|
59
59
|
@feature = scenario.feature_file.get_feature_by_id(feature_id)
|
60
60
|
@mapper_class = mapper_class
|
61
|
-
end
|
62
|
-
|
63
|
-
attr_reader :feature #:nodoc:
|
61
|
+
end #:nodoc:
|
64
62
|
|
65
63
|
##
|
66
64
|
# Gets the type of a feature
|
@@ -83,7 +81,8 @@ module URBANopt
|
|
83
81
|
def run_dir
|
84
82
|
raise 'Feature ID not set' if @feature_id.nil?
|
85
83
|
raise 'Scenario run dir not set' if @scenario.run_dir.nil?
|
86
|
-
|
84
|
+
|
85
|
+
return File.join(@scenario.run_dir, "#{@feature_id}/")
|
87
86
|
end
|
88
87
|
|
89
88
|
##
|
@@ -138,6 +137,7 @@ module URBANopt
|
|
138
137
|
if !File.exist?(out_osw)
|
139
138
|
return true
|
140
139
|
end
|
140
|
+
|
141
141
|
out_osw_time = File.mtime(out_osw)
|
142
142
|
|
143
143
|
# array of files that this datapoint depends on
|
@@ -117,7 +117,7 @@ module URBANopt
|
|
117
117
|
feature_list = Pathname.new(@initialization_hash[:directory_name]).children.select(&:directory?) # Folders in the run/scenario directory
|
118
118
|
|
119
119
|
# get scenario CSV
|
120
|
-
scenario_csv = File.join(@initialization_hash[:root_dir], @initialization_hash[:name]
|
120
|
+
scenario_csv = File.join(@initialization_hash[:root_dir], "#{@initialization_hash[:name]}.csv")
|
121
121
|
if File.exist?(scenario_csv)
|
122
122
|
# csv found
|
123
123
|
feature_ids = CSV.read(scenario_csv, headers: true)
|
@@ -159,7 +159,7 @@ module URBANopt
|
|
159
159
|
# running sum
|
160
160
|
arr_match[:elec_val] += Float(row[7])
|
161
161
|
end
|
162
|
-
end
|
162
|
+
end
|
163
163
|
elec_query.close
|
164
164
|
|
165
165
|
gas_query = feature_db.query "SELECT ReportData.TimeIndex, Time.Year, Time.Month, Time.Day, Time.Hour,
|
@@ -182,10 +182,10 @@ module URBANopt
|
|
182
182
|
# running sum
|
183
183
|
arr_match[:gas_val] += Float(row[7])
|
184
184
|
end
|
185
|
-
end
|
185
|
+
end
|
186
186
|
gas_query.close
|
187
187
|
feature_db.close
|
188
|
-
end
|
188
|
+
end
|
189
189
|
|
190
190
|
elec_sql = []
|
191
191
|
gas_sql = []
|
@@ -80,7 +80,7 @@ module URBANopt
|
|
80
80
|
# load building features data
|
81
81
|
@scenario_report.feature_reports.each do |feature_report|
|
82
82
|
# read results from opendss
|
83
|
-
opendss_csv = CSV.read(File.join(@opendss_results_dir, 'results', 'Features', feature_report.id
|
83
|
+
opendss_csv = CSV.read(File.join(@opendss_results_dir, 'results', 'Features', "#{feature_report.id}.csv"))
|
84
84
|
# add results to data
|
85
85
|
@opendss_data[feature_report.id] = opendss_csv
|
86
86
|
end
|
@@ -102,7 +102,7 @@ module URBANopt
|
|
102
102
|
# add transformer results to @opendss_data
|
103
103
|
transformer_ids.each do |id|
|
104
104
|
# read results from transformers
|
105
|
-
transformer_csv = CSV.read(File.join(tf_results_path, id
|
105
|
+
transformer_csv = CSV.read(File.join(tf_results_path, "#{id}.csv"))
|
106
106
|
# add results to data
|
107
107
|
@opendss_data[id] = transformer_csv
|
108
108
|
end
|
@@ -133,7 +133,7 @@ module URBANopt
|
|
133
133
|
if row.include? 'Datetime'
|
134
134
|
row.map { |header| header.prepend('opendss_') }
|
135
135
|
end
|
136
|
-
csv << (feature_report_data[i] + row[1
|
136
|
+
csv << (feature_report_data[i] + row[1..])
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -142,7 +142,7 @@ module URBANopt
|
|
142
142
|
|
143
143
|
# add feature reports for transformers
|
144
144
|
def save_transformers_reports
|
145
|
-
@opendss_data.
|
145
|
+
@opendss_data.each_key do |k|
|
146
146
|
if k.include? 'Transformer'
|
147
147
|
|
148
148
|
# create transformer directory
|
@@ -171,7 +171,7 @@ module URBANopt
|
|
171
171
|
end
|
172
172
|
|
173
173
|
# save transformer CSV report
|
174
|
-
File.write(File.join(transformer_dir, 'feature_reports', 'default_feature_report_opendss
|
174
|
+
File.write(File.join(transformer_dir, 'feature_reports', 'default_feature_report_opendss.csv'), transformer_csv)
|
175
175
|
|
176
176
|
# create transformer report
|
177
177
|
transformer_report = URBANopt::Reporting::DefaultReports::FeatureReport.new(id: k, name: k, directory_name: transformer_dir, feature_type: 'Transformer',
|
@@ -187,7 +187,7 @@ module URBANopt
|
|
187
187
|
transformer_hash = transformer_report.to_hash
|
188
188
|
# transformer_hash.delete_if { |k, v| v.nil? }
|
189
189
|
|
190
|
-
json_name_path = File.join(transformer_dir, 'feature_reports', 'default_feature_report_opendss
|
190
|
+
json_name_path = File.join(transformer_dir, 'feature_reports', 'default_feature_report_opendss.json')
|
191
191
|
|
192
192
|
# save the json file
|
193
193
|
File.open(json_name_path, 'w') do |f|
|
@@ -133,11 +133,12 @@ module URBANopt
|
|
133
133
|
# add each osw file to its corresponding group id +simulation_dir+ is out_of_date
|
134
134
|
if simulation_dir.out_of_date?
|
135
135
|
|
136
|
-
|
136
|
+
case feature_type
|
137
|
+
when 'Building'
|
137
138
|
building_osws << simulation_dir.in_osw_path
|
138
|
-
|
139
|
+
when 'District System'
|
139
140
|
district_system_osws << simulation_dir.in_osw_path
|
140
|
-
|
141
|
+
when 'Transformer'
|
141
142
|
transformer_osws << simulation_dir.in_osw_path
|
142
143
|
else
|
143
144
|
raise "ScenarioRunnerOSW does not know how to run a #{feature_type} feature"
|
@@ -47,17 +47,19 @@ module URBANopt
|
|
47
47
|
class ResultVisualization
|
48
48
|
def self.create_visualization(run_dir, feature = true, feature_names = false)
|
49
49
|
@all_results = []
|
50
|
-
|
50
|
+
name = nil
|
51
51
|
run_dir.each do |folder|
|
52
52
|
# create visualization for scenarios
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
case feature
|
54
|
+
when false
|
55
|
+
name = folder.split('/')[-2]
|
56
|
+
csv_dir = folder
|
57
|
+
|
56
58
|
# create visualization for features
|
57
|
-
|
59
|
+
when true
|
58
60
|
index = run_dir.index(folder)
|
59
|
-
name = folder.split('/')[-
|
60
|
-
csv_dir =
|
61
|
+
name = "#{folder.split('/')[-3]}-#{feature_names[index]}"
|
62
|
+
csv_dir = folder
|
61
63
|
end
|
62
64
|
|
63
65
|
if File.exist?(csv_dir)
|
@@ -192,7 +194,6 @@ module URBANopt
|
|
192
194
|
monthly_sum_dec += v.to_f
|
193
195
|
i += 1
|
194
196
|
end
|
195
|
-
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
@@ -205,42 +206,49 @@ module URBANopt
|
|
205
206
|
annual_values[headers_unitless[j]] = annual_sum
|
206
207
|
end
|
207
208
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
209
|
+
results = {}
|
210
|
+
results['name'] = name
|
211
|
+
results['monthly_values'] = {}
|
212
|
+
results['annual_values'] = {}
|
212
213
|
|
213
214
|
if @jan_next_year_index.nil? || @feb_index.nil? || @mar_index.nil? || @apr_index.nil? || @may_index.nil? || @jun_index.nil? || @jul_index.nil? || @aug_index.nil? || @sep_index.nil? || @oct_index.nil? || @nov_index.nil? || @dec_index.nil?
|
214
|
-
|
215
|
+
results['complete_simulation'] = false
|
215
216
|
puts "#{name} did not contain an annual simulation…visualizations will not render for it."
|
216
217
|
else
|
217
|
-
|
218
|
+
results['complete_simulation'] = true
|
218
219
|
end
|
219
220
|
|
220
221
|
monthly_totals&.each do |key, value|
|
221
222
|
unless key == 'Datetime'
|
222
|
-
|
223
|
+
results['monthly_values'][key] = value
|
223
224
|
end
|
224
225
|
end
|
225
226
|
|
226
227
|
annual_values&.each do |key, value|
|
227
228
|
unless key == 'Datetime'
|
228
|
-
|
229
|
+
results['annual_values'][key] = value
|
229
230
|
end
|
230
231
|
end
|
231
232
|
|
232
233
|
end
|
233
234
|
|
234
|
-
unless
|
235
|
-
@all_results <<
|
235
|
+
unless results.nil?
|
236
|
+
@all_results << results
|
236
237
|
end
|
237
238
|
end
|
239
|
+
|
238
240
|
# create json with required data stored in a variable
|
239
|
-
|
241
|
+
if feature == false
|
242
|
+
# In case of scenario visualization store result at top of the run folder
|
243
|
+
results_path = File.expand_path('../../scenarioData.js', run_dir[0])
|
244
|
+
else
|
245
|
+
# In case of feature visualization store result at top of scenario folder folder
|
246
|
+
results_path = File.expand_path('../../../scenarioData.js', run_dir[0])
|
247
|
+
end
|
240
248
|
File.open(results_path, 'w') do |file|
|
241
249
|
file << "var scenarioData = #{JSON.pretty_generate(@all_results)};"
|
242
250
|
end
|
243
251
|
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
@@ -54,11 +54,7 @@ module URBANopt
|
|
54
54
|
@feature_names = feature_names
|
55
55
|
end
|
56
56
|
|
57
|
-
attr_reader :scenario #:nodoc:
|
58
|
-
|
59
|
-
attr_reader :features #:nodoc:
|
60
|
-
|
61
|
-
attr_reader :feature_names #:nodoc:
|
57
|
+
attr_reader :scenario, :features, :feature_names #:nodoc: #:nodoc: #:nodoc:
|
62
58
|
|
63
59
|
##
|
64
60
|
# Return the directory that this simulation will run in
|
@@ -71,13 +71,15 @@ module URBANopt
|
|
71
71
|
end
|
72
72
|
|
73
73
|
attr_reader :mapper_class, :feature_id
|
74
|
+
|
74
75
|
##
|
75
76
|
# Return the directory that this simulation will run in.
|
76
77
|
##
|
77
78
|
def run_dir
|
78
79
|
raise 'Feature ID not set' if @feature_id.nil?
|
79
80
|
raise 'Scenario run dir not set' if scenario.run_dir.nil?
|
80
|
-
|
81
|
+
|
82
|
+
return File.join(scenario.run_dir, "#{@feature_id}/")
|
81
83
|
end
|
82
84
|
|
83
85
|
##
|
@@ -25,14 +25,14 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
27
27
|
spec.add_development_dependency 'rake', '~> 13.0'
|
28
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
29
29
|
|
30
|
-
spec.add_runtime_dependency 'json-schema', '~> 2.8'
|
31
30
|
spec.add_runtime_dependency 'json_pure', '~> 2.3'
|
31
|
+
spec.add_runtime_dependency 'json-schema', '~> 2.8'
|
32
32
|
|
33
33
|
spec.add_runtime_dependency 'sqlite3', '1.4.2'
|
34
|
-
spec.add_runtime_dependency 'urbanopt-core', '~> 0.
|
35
|
-
spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.
|
34
|
+
spec.add_runtime_dependency 'urbanopt-core', '~> 0.7.0'
|
35
|
+
spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.5.0'
|
36
36
|
|
37
37
|
# no longer need the below
|
38
38
|
# need to include all measure gems listed in mappers in project gemfiles
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urbanopt-scenario
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rawad El Kontar
|
8
8
|
- Dan Macumber
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -45,42 +45,42 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '3.
|
48
|
+
version: '3.9'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '3.
|
55
|
+
version: '3.9'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: json_pure
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '2.
|
62
|
+
version: '2.3'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '2.
|
69
|
+
version: '2.3'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: json-schema
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '2.
|
76
|
+
version: '2.8'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '2.
|
83
|
+
version: '2.8'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: sqlite3
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,28 +101,28 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
104
|
+
version: 0.7.0
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.
|
111
|
+
version: 0.7.0
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: urbanopt-reporting
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.
|
118
|
+
version: 0.5.0
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
125
|
+
version: 0.5.0
|
126
126
|
description: Library to export data point OSW files from URBANopt Scenario CSV
|
127
127
|
email:
|
128
128
|
- rawad.elkontar@nrel.gov
|
@@ -182,7 +182,7 @@ homepage: https://github.com/urbanopt
|
|
182
182
|
licenses:
|
183
183
|
- Nonstandard
|
184
184
|
metadata: {}
|
185
|
-
post_install_message:
|
185
|
+
post_install_message:
|
186
186
|
rdoc_options: []
|
187
187
|
require_paths:
|
188
188
|
- lib
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
200
|
rubygems_version: 3.1.4
|
201
|
-
signing_key:
|
201
|
+
signing_key:
|
202
202
|
specification_version: 4
|
203
203
|
summary: Library to export data point OSW files from URBANopt Scenario CSV
|
204
204
|
test_files: []
|