urbanopt-scenario 0.4.0 → 0.5.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/.github/pull_request_template.md +1 -1
- data/CHANGELOG.md +35 -0
- data/Gemfile +11 -15
- data/RDOC_MAIN.md +2 -2
- data/README.md +1 -1
- data/docs/.vuepress/components/InnerJsonSchema.vue +7 -15
- data/docs/.vuepress/config.js +13 -9
- data/docs/.vuepress/highlight.js +1 -1
- data/docs/.vuepress/json-schema-deref-loader.js +22 -0
- data/docs/README.md +2 -2
- data/docs/package-lock.json +355 -471
- data/docs/package.json +4 -4
- data/lib/urbanopt/scenario/extension.rb +5 -3
- data/lib/urbanopt/scenario/scenario_base.rb +4 -4
- data/lib/urbanopt/scenario/scenario_csv.rb +7 -8
- data/lib/urbanopt/scenario/scenario_datapoint_base.rb +4 -4
- data/lib/urbanopt/scenario/scenario_post_processor_base.rb +2 -2
- data/lib/urbanopt/scenario/scenario_post_processor_default.rb +62 -28
- data/lib/urbanopt/scenario/scenario_post_processor_opendss.rb +7 -8
- data/lib/urbanopt/scenario/scenario_runner_base.rb +6 -5
- data/lib/urbanopt/scenario/scenario_runner_osw.rb +6 -4
- data/lib/urbanopt/scenario/scenario_visualization.rb +4 -6
- data/lib/urbanopt/scenario/simulation_dir_base.rb +3 -3
- data/lib/urbanopt/scenario/simulation_dir_osw.rb +4 -4
- data/lib/urbanopt/scenario/simulation_mapper_base.rb +3 -3
- data/lib/urbanopt/scenario/version.rb +1 -1
- data/urbanopt-scenario-gem.gemspec +14 -7
- metadata +40 -27
- data/docs/.vuepress/components/ScenarioSchema.vue +0 -12
- data/docs/schemas/scenario-schema.md +0 -3
data/docs/package.json
CHANGED
@@ -10,11 +10,11 @@
|
|
10
10
|
},
|
11
11
|
"author": "NREL",
|
12
12
|
"dependencies": {
|
13
|
-
"highlight.js": "^10.
|
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.
|
17
|
-
"webpack-dev-middleware": "^3.
|
16
|
+
"vuepress": "^1.6.0",
|
17
|
+
"webpack-dev-middleware": "^3.6.0"
|
18
18
|
},
|
19
19
|
"devDependencies": {
|
20
20
|
"braces": "^3.0.2",
|
@@ -25,6 +25,6 @@
|
|
25
25
|
"node-forge": ">=0.10.0",
|
26
26
|
"serialize-javascript": "^5.0.1",
|
27
27
|
"set-value": "^3.0.2",
|
28
|
-
"yargs-parser": "
|
28
|
+
"yargs-parser": "^20.2.1"
|
29
29
|
}
|
30
30
|
}
|
@@ -39,14 +39,15 @@ module URBANopt
|
|
39
39
|
end
|
40
40
|
|
41
41
|
##
|
42
|
-
#
|
42
|
+
# [return:] Absolute path of the measures or nil if there is none, can be used when configuring OSWs.
|
43
43
|
def measures_dir
|
44
44
|
return File.absolute_path(File.join(@root_dir, 'lib', 'measures'))
|
45
45
|
end
|
46
46
|
|
47
47
|
##
|
48
48
|
# Relevant files such as weather data, design days, etc.
|
49
|
-
|
49
|
+
##
|
50
|
+
# [return:] Absolute path of the files or nil if there is none, used when configuring OSWs
|
50
51
|
def files_dir
|
51
52
|
return nil
|
52
53
|
end
|
@@ -54,7 +55,8 @@ module URBANopt
|
|
54
55
|
##
|
55
56
|
# Doc templates are common files like copyright files which are used to update measures and other code.
|
56
57
|
# Doc templates will only be applied to measures in the current repository.
|
57
|
-
|
58
|
+
##
|
59
|
+
# [return:] Absolute path of the doc templates dir or nil if there is none.
|
58
60
|
def doc_templates_dir
|
59
61
|
return File.absolute_path(File.join(@root_dir, 'doc_templates'))
|
60
62
|
end
|
@@ -36,10 +36,10 @@ module URBANopt
|
|
36
36
|
# Initialize ScenarioBase attributes: +name+ , +root directory+ , +run directory+ and +feature_file+
|
37
37
|
##
|
38
38
|
# [parameters:]
|
39
|
-
# +name+ - _String_ - Human readable scenario name.
|
40
|
-
# +root_dir+ - _String_ - Root directory for the scenario, contains Gemfile describing dependencies.
|
41
|
-
# +run_dir+ - _String_ - Directory for simulation of this scenario, deleting run directory clears the scenario.
|
42
|
-
# +feature_file+ - _FeatureFile_ - An instance of +URBANopt::Core::FeatureFile+ containing features for simulation.
|
39
|
+
# * +name+ - _String_ - Human readable scenario name.
|
40
|
+
# * +root_dir+ - _String_ - Root directory for the scenario, contains Gemfile describing dependencies.
|
41
|
+
# * +run_dir+ - _String_ - Directory for simulation of this scenario, deleting run directory clears the scenario.
|
42
|
+
# * +feature_file+ - _FeatureFile_ - An instance of +URBANopt::Core::FeatureFile+ containing features for simulation.
|
43
43
|
def initialize(name, root_dir, run_dir, feature_file)
|
44
44
|
@name = name
|
45
45
|
@root_dir = root_dir
|
@@ -42,14 +42,13 @@ module URBANopt
|
|
42
42
|
# The CSV file has three columns 1) feature_id, 2) feature_name, and 3) mapper_class_name. There is one row for each Feature.
|
43
43
|
##
|
44
44
|
# [parameters:]
|
45
|
-
# +name+ - _String_ - Human readable scenario name.
|
46
|
-
# +root_dir+ - _String_ - Root directory for the scenario, contains Gemfile describing dependencies.
|
47
|
-
# +run_dir+ - _String_ - Directory for simulation of this scenario, deleting run directory clears the scenario.
|
48
|
-
# +feature_file+ - _URBANopt::Core::FeatureFile_ - FeatureFile containing features to simulate.
|
49
|
-
# +mapper_files_dir+ - _String_ - Directory containing all mapper class files containing MapperBase definitions.
|
50
|
-
# +csv_file+ - _String_ - Path to CSV file assigning a MapperBase class to each feature in feature_file.
|
51
|
-
# +num_header_rows+ -
|
52
|
-
|
45
|
+
# * +name+ - _String_ - Human readable scenario name.
|
46
|
+
# * +root_dir+ - _String_ - Root directory for the scenario, contains Gemfile describing dependencies.
|
47
|
+
# * +run_dir+ - _String_ - Directory for simulation of this scenario, deleting run directory clears the scenario.
|
48
|
+
# * +feature_file+ - _URBANopt::Core::FeatureFile_ - FeatureFile containing features to simulate.
|
49
|
+
# * +mapper_files_dir+ - _String_ - Directory containing all mapper class files containing MapperBase definitions.
|
50
|
+
# * +csv_file+ - _String_ - Path to CSV file assigning a MapperBase class to each feature in feature_file.
|
51
|
+
# * +num_header_rows+ - _String_ - Number of header rows to skip in CSV file.
|
53
52
|
def initialize(name, root_dir, run_dir, feature_file, mapper_files_dir, csv_file, num_header_rows)
|
54
53
|
super(name, root_dir, run_dir, feature_file)
|
55
54
|
@mapper_files_dir = mapper_files_dir
|
@@ -38,10 +38,10 @@ module URBANopt
|
|
38
38
|
# A Simulation Mapper will map the
|
39
39
|
##
|
40
40
|
# [parameters:]
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
41
|
+
# * +scenario+ - _ScenarioBase_ - Scenario containing this ScenarioDatapoint.
|
42
|
+
# * +feature_id+ - _String_ - Unique id of the feature for this ScenarioDatapoint.
|
43
|
+
# * +feature_name+ - _String_ - Human readable name of the feature for this ScenarioDatapoint.
|
44
|
+
# * +mapper_class+ - _String_ - Name of Ruby class used to translate feature to simulation OSW.
|
45
45
|
def initialize(scenario, feature_id, feature_name, mapper_class)
|
46
46
|
@scenario = scenario
|
47
47
|
@feature_id = feature_id
|
@@ -35,7 +35,7 @@ module URBANopt
|
|
35
35
|
# ScenarioPostProcessorBase post-processes a Scenario to create scenario level results.
|
36
36
|
##
|
37
37
|
# [parameters:]
|
38
|
-
# +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
|
38
|
+
# * +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
|
39
39
|
def initialize(scenario_base)
|
40
40
|
@scenario_base = scenario_base
|
41
41
|
end
|
@@ -53,7 +53,7 @@ module URBANopt
|
|
53
53
|
# Add results from a simulation_dir to this result.
|
54
54
|
##
|
55
55
|
# [parameters:]
|
56
|
-
# +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
|
56
|
+
# * +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
|
57
57
|
def add_simulation_dir(simulation_dir)
|
58
58
|
raise 'add_simulation_dir not implemented for ScenarioPostProcessorBase, override in your class'
|
59
59
|
end
|
@@ -32,8 +32,6 @@ require 'urbanopt/scenario/scenario_post_processor_base'
|
|
32
32
|
require 'urbanopt/reporting/default_reports'
|
33
33
|
|
34
34
|
require 'csv'
|
35
|
-
require 'json'
|
36
|
-
require 'fileutils'
|
37
35
|
require 'sqlite3'
|
38
36
|
|
39
37
|
module URBANopt
|
@@ -43,11 +41,11 @@ module URBANopt
|
|
43
41
|
# ScenarioPostProcessorBase post-processes a scenario to create scenario level results
|
44
42
|
##
|
45
43
|
# [parameters:]
|
46
|
-
# +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
|
44
|
+
# * +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
|
47
45
|
def initialize(scenario_base)
|
48
46
|
super(scenario_base)
|
49
47
|
|
50
|
-
@initialization_hash = { directory_name: scenario_base.run_dir, name: scenario_base.name, id: scenario_base.name }
|
48
|
+
@initialization_hash = { directory_name: scenario_base.run_dir, name: scenario_base.name, id: scenario_base.name, root_dir: scenario_base.root_dir }
|
51
49
|
@scenario_result = URBANopt::Reporting::DefaultReports::ScenarioReport.new(@initialization_hash)
|
52
50
|
@default_save_name = 'default_scenario_report'
|
53
51
|
|
@@ -69,7 +67,7 @@ module URBANopt
|
|
69
67
|
# Add results from a simulation_dir to this result.
|
70
68
|
##
|
71
69
|
# [parameters:]
|
72
|
-
# +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
|
70
|
+
# * +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
|
73
71
|
def add_simulation_dir(simulation_dir)
|
74
72
|
feature_reports = URBANopt::Reporting::DefaultReports::FeatureReport.from_simulation_dir(simulation_dir)
|
75
73
|
|
@@ -86,57 +84,93 @@ module URBANopt
|
|
86
84
|
|
87
85
|
# Create database file with scenario-level results
|
88
86
|
# Sum values for each timestep across all features. Save to new table in a new database
|
87
|
+
##
|
88
|
+
# [parameters:]
|
89
|
+
# * +file_name+ - _String_ - Assign a name to the saved scenario results file
|
89
90
|
def create_scenario_db_file(file_name = @default_save_name)
|
90
91
|
new_db_file = File.join(@initialization_hash[:directory_name], "#{file_name}.db")
|
91
92
|
scenario_db = SQLite3::Database.open new_db_file
|
92
93
|
scenario_db.execute "CREATE TABLE IF NOT EXISTS ReportData(
|
93
94
|
TimeIndex INTEGER,
|
94
|
-
|
95
|
-
|
95
|
+
Year VARCHAR(255),
|
96
|
+
Month VARCHAR(255),
|
97
|
+
Day VARCHAR(255),
|
98
|
+
Hour VARCHAR(255),
|
99
|
+
Minute VARCHAR(255),
|
100
|
+
Dst INTEGER,
|
101
|
+
FuelType VARCHAR(255),
|
102
|
+
Value INTEGER,
|
103
|
+
FuelUnits VARCHAR(255)
|
96
104
|
)"
|
97
105
|
|
98
106
|
values_arr = []
|
99
107
|
feature_list = Pathname.new(@initialization_hash[:directory_name]).children.select(&:directory?) # Folders in the run/scenario directory
|
100
|
-
|
101
|
-
|
108
|
+
|
109
|
+
# get scenario CSV
|
110
|
+
scenario_csv = File.join(@initialization_hash[:root_dir], @initialization_hash[:name] + '.csv')
|
111
|
+
if File.exist?(scenario_csv)
|
112
|
+
# csv found
|
113
|
+
feature_ids = CSV.read(scenario_csv, headers: true)
|
114
|
+
feature_list = []
|
115
|
+
# loop through building feature ids from scenario csv
|
116
|
+
feature_ids['Feature Id'].each do |feature|
|
117
|
+
if Dir.exist?(File.join(@initialization_hash[:directory_name], feature))
|
118
|
+
feature_list << File.join(@initialization_hash[:directory_name], feature)
|
119
|
+
else
|
120
|
+
puts "warning: did not find a directory for datapoint #{feature}...skipping"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
else
|
124
|
+
raise "Couldn't find scenario CSV: #{scenario_csv}"
|
125
|
+
end
|
102
126
|
feature_list.each do |feature| # Loop through each feature in the scenario
|
127
|
+
uo_output_sql_file = File.join(@initialization_hash[:directory_name], File.basename(feature), 'eplusout.sql')
|
103
128
|
feature_db = SQLite3::Database.open uo_output_sql_file
|
104
129
|
# Doing "db.results_as_hash = true" is prettier, but in this case significantly slower.
|
105
130
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
131
|
+
elec_query = feature_db.query "SELECT ReportData.TimeIndex, Time.Year, Time.Month, Time.Day, Time.Hour,
|
132
|
+
Time.Minute, Time.Dst, ReportData.Value
|
133
|
+
FROM ReportData
|
134
|
+
INNER JOIN Time ON Time.TimeIndex=ReportData.TimeIndex
|
135
|
+
INNER JOIN ReportDataDictionary AS rddi ON rddi.ReportDataDictionaryIndex=ReportData.ReportDataDictionaryIndex
|
136
|
+
WHERE rddi.IndexGroup == 'Facility:Electricity'
|
137
|
+
AND rddi.ReportingFrequency == 'Zone Timestep'
|
138
|
+
AND Time.Year > 1900
|
139
|
+
ORDER BY ReportData.TimeIndex"
|
111
140
|
|
112
141
|
elec_query.each do |row| # Add up all the values for electricity usage across all Features at this timestep
|
113
142
|
# row[0] == TimeIndex, row[1] == Value
|
143
|
+
|
114
144
|
arr_match = values_arr.find { |v| v[:time_index] == row[0] }
|
115
145
|
if arr_match.nil?
|
116
146
|
# add new row to value_arr
|
117
|
-
values_arr << { time_index: row[0], elec_val: Float(row[
|
147
|
+
values_arr << { time_index: row[0], year: row[1], month: row[2], day: row[3], hour: row[4], minute: row[5], dst: row[6], elec_val: Float(row[7]), gas_val: 0 }
|
118
148
|
else
|
119
149
|
# running sum
|
120
|
-
arr_match[:elec_val] += Float(row[
|
150
|
+
arr_match[:elec_val] += Float(row[7])
|
121
151
|
end
|
122
152
|
end # End elec_query
|
123
153
|
elec_query.close
|
124
154
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
155
|
+
gas_query = feature_db.query "SELECT ReportData.TimeIndex, Time.Year, Time.Month, Time.Day, Time.Hour,
|
156
|
+
Time.Minute, Time.Dst, ReportData.Value
|
157
|
+
FROM ReportData
|
158
|
+
INNER JOIN Time ON Time.TimeIndex=ReportData.TimeIndex
|
159
|
+
INNER JOIN ReportDataDictionary AS rddi ON rddi.ReportDataDictionaryIndex=ReportData.ReportDataDictionaryIndex
|
160
|
+
WHERE rddi.IndexGroup == 'Facility:Gas'
|
161
|
+
AND rddi.ReportingFrequency == 'Zone Timestep'
|
162
|
+
AND Time.Year > 1900
|
163
|
+
ORDER BY ReportData.TimeIndex"
|
130
164
|
|
131
165
|
gas_query.each do |row|
|
132
166
|
# row[0] == TimeIndex, row[1] == Value
|
133
167
|
arr_match = values_arr.find { |v| v[:time_index] == row[0] }
|
134
168
|
if arr_match.nil?
|
135
169
|
# add new row to value_arr
|
136
|
-
values_arr << { time_index: row[0], gas_val: Float(row[
|
170
|
+
values_arr << { time_index: row[0], year: row[1], month: row[2], day: row[3], hour: row[4], minute: row[5], dst: row[6], gas_val: Float(row[7]), elec_val: 0 }
|
137
171
|
else
|
138
172
|
# running sum
|
139
|
-
arr_match[:gas_val] += Float(row[
|
173
|
+
arr_match[:gas_val] += Float(row[7])
|
140
174
|
end
|
141
175
|
end # End gas_query
|
142
176
|
gas_query.close
|
@@ -146,13 +180,13 @@ module URBANopt
|
|
146
180
|
elec_sql = []
|
147
181
|
gas_sql = []
|
148
182
|
values_arr.each do |i|
|
149
|
-
elec_sql << "(#{i[:time_index]},
|
150
|
-
gas_sql << "(#{i[:time_index]},
|
183
|
+
elec_sql << "(#{i[:time_index]}, #{i[:year]}, #{i[:month]}, #{i[:day]}, #{i[:hour]}, #{i[:minute]}, #{i[:dst]}, 'Electricity', #{i[:elec_val]}, 'J')"
|
184
|
+
gas_sql << "(#{i[:time_index]}, #{i[:year]}, #{i[:month]}, #{i[:day]}, #{i[:hour]}, #{i[:minute]}, #{i[:dst]}, 'Gas', #{i[:gas_val]}, 'J')"
|
151
185
|
end
|
152
186
|
|
153
187
|
# Put summed Values into the database
|
154
|
-
scenario_db.execute("INSERT INTO ReportData
|
155
|
-
scenario_db.execute("INSERT INTO ReportData
|
188
|
+
scenario_db.execute("INSERT INTO ReportData VALUES #{elec_sql.join(', ')}")
|
189
|
+
scenario_db.execute("INSERT INTO ReportData VALUES #{gas_sql.join(', ')}")
|
156
190
|
scenario_db.close
|
157
191
|
end
|
158
192
|
|
@@ -160,7 +194,7 @@ module URBANopt
|
|
160
194
|
# Save scenario result
|
161
195
|
##
|
162
196
|
# [parameters:]
|
163
|
-
# +file_name+ - _String_ - Assign a name to the saved scenario results file
|
197
|
+
# * +file_name+ - _String_ - Assign a name to the saved scenario results file
|
164
198
|
def save(file_name = @default_save_name)
|
165
199
|
@scenario_result.save
|
166
200
|
|
@@ -34,7 +34,6 @@ require 'urbanopt/reporting/default_reports'
|
|
34
34
|
require 'csv'
|
35
35
|
require 'json'
|
36
36
|
require 'fileutils'
|
37
|
-
require 'pathname'
|
38
37
|
|
39
38
|
module URBANopt
|
40
39
|
module Scenario
|
@@ -43,8 +42,8 @@ module URBANopt
|
|
43
42
|
# OpenDSSPostProcessor post-processes OpenDSS results to selected OpenDSS results and integrate them in scenario and feature reports.
|
44
43
|
##
|
45
44
|
# [parameters:]
|
46
|
-
# +scenario_report+ - _ScenarioBase_ - An object of Scenario_report class.
|
47
|
-
# +opendss_results_dir_name+ - _directory name of opendss results
|
45
|
+
# * +scenario_report+ - _ScenarioBase_ - An object of Scenario_report class.
|
46
|
+
# * +opendss_results_dir_name+ - _directory name of opendss results
|
48
47
|
def initialize(scenario_report, opendss_results_dir_name = 'opendss')
|
49
48
|
if !scenario_report.nil?
|
50
49
|
@scenario_report = scenario_report
|
@@ -202,9 +201,9 @@ module URBANopt
|
|
202
201
|
# Save csv report method
|
203
202
|
##
|
204
203
|
# [parameters:]
|
205
|
-
# +feature_report+ - _feature report object_ - An onject of the feature report
|
206
|
-
# +updated_feature_report_csv+ - _CSV_ - An updated feature report csv
|
207
|
-
# +file_name+ - _String_ - Assigned name to save the file with no extension
|
204
|
+
# * +feature_report+ - _feature report object_ - An onject of the feature report
|
205
|
+
# * +updated_feature_report_csv+ - _CSV_ - An updated feature report csv
|
206
|
+
# * +file_name+ - _String_ - Assigned name to save the file with no extension
|
208
207
|
def save_csv(feature_report, updated_feature_report_csv, file_name = 'default_feature_report')
|
209
208
|
File.write(File.join(feature_report.directory_name, 'feature_reports', "#{file_name}.csv"), updated_feature_report_csv)
|
210
209
|
end
|
@@ -213,7 +212,7 @@ module URBANopt
|
|
213
212
|
# create opendss json report results
|
214
213
|
##
|
215
214
|
# [parameters:]
|
216
|
-
# +feature_report+ - _feature report object_ - An onject of the feature report
|
215
|
+
# * +feature_report+ - _feature report object_ - An onject of the feature report
|
217
216
|
def add_summary_results(feature_report)
|
218
217
|
under_voltage_hrs = 0
|
219
218
|
over_voltage_hrs = 0
|
@@ -258,7 +257,7 @@ module URBANopt
|
|
258
257
|
updated_feature_csv = merge_data(@feature_reports_data[id], @opendss_data[id])
|
259
258
|
|
260
259
|
# save fetaure reports
|
261
|
-
feature_report.
|
260
|
+
feature_report.save_json_report('default_feature_report_opendss')
|
262
261
|
|
263
262
|
# resave updated csv report
|
264
263
|
save_csv(feature_report, updated_feature_csv, 'default_feature_report_opendss')
|
@@ -40,8 +40,9 @@ module URBANopt
|
|
40
40
|
# Create all SimulationDirs for Scenario.
|
41
41
|
##
|
42
42
|
# [parameters:]
|
43
|
-
# +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for scenario.
|
44
|
-
# +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files
|
43
|
+
# * +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for scenario.
|
44
|
+
# * +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files
|
45
|
+
##
|
45
46
|
# [return:] _Array_ Returns an array of all SimulationDirs, even those created previously, for Scenario.
|
46
47
|
def create_simulation_files(scenario, force_clear = false)
|
47
48
|
raise 'create_input_files is not implemented for ScenarioRunnerBase, override in your class'
|
@@ -51,9 +52,9 @@ module URBANopt
|
|
51
52
|
# Create and run all SimulationFiles for Scenario.
|
52
53
|
##
|
53
54
|
# [parameters:]
|
54
|
-
# +scenario+ - _ScenarioBase_ - Scenario to create and run simulation input files for.
|
55
|
-
# +force_clear+ - _Bool_ - Clear Scenario before creating Simulation input files.
|
56
|
-
|
55
|
+
# * +scenario+ - _ScenarioBase_ - Scenario to create and run simulation input files for.
|
56
|
+
# * +force_clear+ - _Bool_ - Clear Scenario before creating Simulation input files.
|
57
|
+
##
|
57
58
|
# [return:] _Array_ Returns an array of all SimulationDirs, even those created previously, for Scenario.
|
58
59
|
def run(scenario, force_clear = false, options = {})
|
59
60
|
raise 'run is not implemented for ScenarioRunnerBase, override in your class'
|
@@ -46,8 +46,9 @@ module URBANopt
|
|
46
46
|
# Create all OSWs for Scenario.
|
47
47
|
##
|
48
48
|
# [parameters:]
|
49
|
-
# +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for.
|
50
|
-
# +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files.
|
49
|
+
# * +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for.
|
50
|
+
# * +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files.
|
51
|
+
##
|
51
52
|
# [return:] _Array_ Returns array of all SimulationDirs, even those created previously, for Scenario.
|
52
53
|
def create_simulation_files(scenario, force_clear = false)
|
53
54
|
if force_clear
|
@@ -79,8 +80,9 @@ module URBANopt
|
|
79
80
|
# - Run osw file groups in order and store simulation failure in a array.
|
80
81
|
##
|
81
82
|
# [parameters:]
|
82
|
-
# +scenario+ - _ScenarioBase_ - Scenario to create and run SimulationFiles for.
|
83
|
-
# +force_clear+ - _Bool_ - Clear Scenario before creating SimulationFiles.
|
83
|
+
# * +scenario+ - _ScenarioBase_ - Scenario to create and run SimulationFiles for.
|
84
|
+
# * +force_clear+ - _Bool_ - Clear Scenario before creating SimulationFiles.
|
85
|
+
##
|
84
86
|
# [return:] _Array_ Returns array of all SimulationFiles, even those created previously, for Scenario.
|
85
87
|
def run(scenario, force_clear = false, options = {})
|
86
88
|
# instantiate openstudio runner - use the defaults for now. If need to change then create
|
@@ -31,7 +31,6 @@
|
|
31
31
|
require 'csv'
|
32
32
|
require 'date'
|
33
33
|
require 'json'
|
34
|
-
require 'fileutils'
|
35
34
|
|
36
35
|
module URBANopt
|
37
36
|
module Scenario
|
@@ -181,14 +180,13 @@ module URBANopt
|
|
181
180
|
monthly_sum_dec += v.to_f
|
182
181
|
i += 1
|
183
182
|
end
|
184
|
-
|
185
|
-
if k <= size
|
186
|
-
annual_sum += v.to_f
|
187
|
-
k += 1
|
188
|
-
end
|
183
|
+
|
189
184
|
end
|
190
185
|
end
|
191
186
|
|
187
|
+
# sum up monthly values for annual aggregate
|
188
|
+
annual_sum = monthly_sum_jan + monthly_sum_feb + monthly_sum_mar + monthly_sum_apr + monthly_sum_may + monthly_sum_jun + monthly_sum_jul + monthly_sum_aug + monthly_sum_sep + monthly_sum_oct + monthly_sum_nov + monthly_sum_dec
|
189
|
+
|
192
190
|
# store headers as key and monthly sums as values for each header
|
193
191
|
monthly_totals[headers_unitless[j]] = [monthly_sum_jan, monthly_sum_feb, monthly_sum_mar, monthly_sum_apr, monthly_sum_may, monthly_sum_jun, monthly_sum_jul, monthly_sum_aug, monthly_sum_sep, monthly_sum_oct, monthly_sum_nov, monthly_sum_dec]
|
194
192
|
|
@@ -35,9 +35,9 @@ module URBANopt
|
|
35
35
|
# SimulationDirBase is the agnostic representation of a directory of simulation input files.
|
36
36
|
##
|
37
37
|
# [parameters:]
|
38
|
-
# +scenario+ - _ScenarioBase_ - Scenario containing this SimulationDirBase.
|
39
|
-
# +features+ - _Array_ - Array of Features that this SimulationDirBase represents.
|
40
|
-
# +feature_names+ - _Array_ - Array of scenario specific names for these Features.
|
38
|
+
# * +scenario+ - _ScenarioBase_ - Scenario containing this SimulationDirBase.
|
39
|
+
# * +features+ - _Array_ - Array of Features that this SimulationDirBase represents.
|
40
|
+
# * +feature_names+ - _Array_ - Array of scenario specific names for these Features.
|
41
41
|
def initialize(scenario, features, feature_names)
|
42
42
|
@scenario = scenario
|
43
43
|
@features = features
|
@@ -37,10 +37,10 @@ module URBANopt
|
|
37
37
|
# SimulationDirOSW creates a OSW file to simulate features, a SimulationMapperBase is invoked to translate features to OSW.
|
38
38
|
##
|
39
39
|
# [parameters:]
|
40
|
-
# +scenario+ - _ScenarioBase_ - Scenario containing this SimulationFileBase.
|
41
|
-
# +features+ - _Array_ - Array of Features this SimulationFile represents.
|
42
|
-
# +feature_names+ - _Array_ - Array of scenario specific names for these Features.
|
43
|
-
# +mapper_class+ - _String_ - Name of class derived frmo SimulationMapperBase used to translate feature to simulation OSW.
|
40
|
+
# * +scenario+ - _ScenarioBase_ - Scenario containing this SimulationFileBase.
|
41
|
+
# * +features+ - _Array_ - Array of Features this SimulationFile represents.
|
42
|
+
# * +feature_names+ - _Array_ - Array of scenario specific names for these Features.
|
43
|
+
# * +mapper_class+ - _String_ - Name of class derived frmo SimulationMapperBase used to translate feature to simulation OSW.
|
44
44
|
def initialize(scenario, features, feature_names, mapper_class)
|
45
45
|
super(scenario, features, feature_names)
|
46
46
|
|
@@ -36,9 +36,9 @@ module URBANopt
|
|
36
36
|
|
37
37
|
# create osw file given a ScenarioBase object, features, and feature_names
|
38
38
|
# [parameters:]
|
39
|
-
# +scenario+ - _ScenarioBase_ - An object of ScenarioBase class.
|
40
|
-
# +features+ - _Array_ - Array of Features.
|
41
|
-
# +feature_names+ - _Array_ - Array of scenario specific names for these Features.
|
39
|
+
# * +scenario+ - _ScenarioBase_ - An object of ScenarioBase class.
|
40
|
+
# * +features+ - _Array_ - Array of Features.
|
41
|
+
# * +feature_names+ - _Array_ - Array of scenario specific names for these Features.
|
42
42
|
def create_osw(scenario, features, feature_names)
|
43
43
|
raise 'create_osw not implemented for SimulationMapperBase, override in your class'
|
44
44
|
end
|