urbanopt-scenario 0.3.0.pre1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +3 -3
- data/.gitignore +2 -0
- data/CHANGELOG.md +60 -2
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +33 -17
- data/Jenkinsfile +1 -1
- data/LICENSE.md +1 -1
- data/RDOC_MAIN.md +2 -2
- data/README.md +1 -1
- data/Rakefile +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 +2384 -2323
- data/docs/package.json +12 -8
- data/lib/urbanopt-scenario.rb +1 -1
- data/lib/urbanopt/scenario.rb +2 -1
- data/lib/urbanopt/scenario/default_reports.rb +3 -8
- data/lib/urbanopt/scenario/extension.rb +6 -4
- data/lib/urbanopt/scenario/logger.rb +1 -1
- data/lib/urbanopt/scenario/scenario_base.rb +5 -5
- data/lib/urbanopt/scenario/scenario_csv.rb +29 -17
- data/lib/urbanopt/scenario/scenario_datapoint_base.rb +12 -5
- data/lib/urbanopt/scenario/scenario_post_processor_base.rb +3 -3
- data/lib/urbanopt/scenario/scenario_post_processor_default.rb +121 -11
- data/lib/urbanopt/scenario/scenario_post_processor_opendss.rb +13 -14
- data/lib/urbanopt/scenario/scenario_runner_base.rb +8 -7
- data/lib/urbanopt/scenario/scenario_runner_osw.rb +29 -13
- data/lib/urbanopt/scenario/scenario_visualization.rb +235 -0
- data/lib/urbanopt/scenario/simulation_dir_base.rb +4 -4
- data/lib/urbanopt/scenario/simulation_dir_osw.rb +6 -13
- data/lib/urbanopt/scenario/simulation_mapper_base.rb +4 -4
- data/lib/urbanopt/scenario/version.rb +2 -2
- data/package-lock.json +3 -0
- data/urbanopt-scenario-gem.gemspec +11 -10
- metadata +80 -57
- data/doc_templates/LICENSE.md +0 -27
- data/doc_templates/README.md.erb +0 -42
- data/doc_templates/copyright_erb.txt +0 -31
- data/doc_templates/copyright_js.txt +0 -4
- data/doc_templates/copyright_ruby.txt +0 -29
- data/docs/.vuepress/components/ScenarioSchema.vue +0 -12
- data/docs/schemas/scenario-schema.md +0 -3
- data/lib/measures/.rubocop.yml +0 -5
- data/lib/measures/default_feature_reports/LICENSE.md +0 -27
- data/lib/measures/default_feature_reports/README.md +0 -56
- data/lib/measures/default_feature_reports/README.md.erb +0 -42
- data/lib/measures/default_feature_reports/measure.rb +0 -1006
- data/lib/measures/default_feature_reports/measure.xml +0 -143
- data/lib/measures/default_feature_reports/tests/USA_CO_Golden-NREL.724666_TMY3.epw +0 -8768
- data/lib/measures/default_feature_reports/tests/default_feature_reports_test.rb +0 -238
- data/lib/measures/default_feature_reports/tests/example_model.osm +0 -4378
- data/lib/urbanopt/scenario/default_reports/construction_cost.rb +0 -169
- data/lib/urbanopt/scenario/default_reports/date.rb +0 -97
- data/lib/urbanopt/scenario/default_reports/distributed_generation.rb +0 -379
- data/lib/urbanopt/scenario/default_reports/end_use.rb +0 -159
- data/lib/urbanopt/scenario/default_reports/end_uses.rb +0 -140
- data/lib/urbanopt/scenario/default_reports/feature_report.rb +0 -267
- data/lib/urbanopt/scenario/default_reports/generator.rb +0 -92
- data/lib/urbanopt/scenario/default_reports/location.rb +0 -99
- data/lib/urbanopt/scenario/default_reports/logger.rb +0 -44
- data/lib/urbanopt/scenario/default_reports/power_distribution.rb +0 -102
- data/lib/urbanopt/scenario/default_reports/program.rb +0 -266
- data/lib/urbanopt/scenario/default_reports/reporting_period.rb +0 -305
- data/lib/urbanopt/scenario/default_reports/scenario_report.rb +0 -317
- data/lib/urbanopt/scenario/default_reports/schema/README.md +0 -33
- data/lib/urbanopt/scenario/default_reports/schema/scenario_csv_columns.txt +0 -32
- data/lib/urbanopt/scenario/default_reports/schema/scenario_schema.json +0 -857
- data/lib/urbanopt/scenario/default_reports/solar_pv.rb +0 -93
- data/lib/urbanopt/scenario/default_reports/storage.rb +0 -105
- data/lib/urbanopt/scenario/default_reports/timeseries_csv.rb +0 -299
- data/lib/urbanopt/scenario/default_reports/validator.rb +0 -97
- data/lib/urbanopt/scenario/default_reports/wind.rb +0 -92
@@ -1,5 +1,5 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
2
|
+
# URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
3
|
# contributors. All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -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,11 +52,11 @@ 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
|
-
def run(scenario, force_clear = false)
|
59
|
+
def run(scenario, force_clear = false, options = {})
|
59
60
|
raise 'run is not implemented for ScenarioRunnerBase, override in your class'
|
60
61
|
end
|
61
62
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
2
|
+
# URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
3
|
# contributors. All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -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
|
@@ -55,6 +56,7 @@ module URBANopt
|
|
55
56
|
end
|
56
57
|
|
57
58
|
FileUtils.mkdir_p(scenario.run_dir) if !File.exist?(scenario.run_dir)
|
59
|
+
FileUtils.rm_rf(File.join(scenario.run_dir, 'run_status.json')) if File.exist?(File.join(scenario.run_dir, 'run_status.json'))
|
58
60
|
|
59
61
|
simulation_dirs = scenario.simulation_dirs
|
60
62
|
|
@@ -78,13 +80,15 @@ module URBANopt
|
|
78
80
|
# - Run osw file groups in order and store simulation failure in a array.
|
79
81
|
##
|
80
82
|
# [parameters:]
|
81
|
-
# +scenario+ - _ScenarioBase_ - Scenario to create and run SimulationFiles for.
|
82
|
-
# +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
|
+
##
|
83
86
|
# [return:] _Array_ Returns array of all SimulationFiles, even those created previously, for Scenario.
|
84
|
-
def run(scenario, force_clear = false)
|
87
|
+
def run(scenario, force_clear = false, options = {})
|
85
88
|
# instantiate openstudio runner - use the defaults for now. If need to change then create
|
86
89
|
# the runner.conf file (i.e. run `rake openstudio:runner:init`)
|
87
|
-
|
90
|
+
# allow passing gemfile_path and bundle_install_path in options
|
91
|
+
runner = OpenStudio::Extension::Runner.new(scenario.root_dir, [], options)
|
88
92
|
|
89
93
|
# create simulation files
|
90
94
|
simulation_dirs = create_simulation_files(scenario, force_clear)
|
@@ -156,18 +160,30 @@ module URBANopt
|
|
156
160
|
# puts "DATAPOINT FAILURES: #{failures}"
|
157
161
|
# end
|
158
162
|
|
159
|
-
#
|
163
|
+
# write results to file and to command line
|
164
|
+
get_results(scenario, simulation_dirs)
|
165
|
+
|
166
|
+
return simulation_dirs
|
167
|
+
end
|
168
|
+
|
169
|
+
def get_results(scenario, simulation_dirs)
|
170
|
+
# look for other failed datapoints (command line display)
|
171
|
+
# also compile datapoint status for latest_run.json file
|
172
|
+
status_arr = []
|
160
173
|
failed_sims = []
|
161
|
-
simulation_dirs.each do |
|
162
|
-
if File.exist?(
|
163
|
-
failed_sims <<
|
174
|
+
simulation_dirs.each do |sim_dir|
|
175
|
+
if File.exist?(sim_dir.failed_job_path)
|
176
|
+
failed_sims << sim_dir.run_dir.split('/')[-1]
|
164
177
|
end
|
178
|
+
status_arr << { "id": sim_dir.feature_id, "status": sim_dir.simulation_status, "mapper_class": sim_dir.mapper_class }
|
165
179
|
end
|
180
|
+
|
181
|
+
# write to file
|
182
|
+
File.open(File.join(scenario.run_dir, 'run_status.json'), 'w') { |f| f.write JSON.pretty_generate("timestamp": Time.now.strftime('%Y-%m-%dT%k:%M:%S.%L'), "results": status_arr) }
|
183
|
+
|
166
184
|
if !failed_sims.empty?
|
167
185
|
puts "FAILED SIMULATION IDs: #{failed_sims.join(',')}"
|
168
186
|
end
|
169
|
-
|
170
|
-
return simulation_dirs
|
171
187
|
end
|
172
188
|
end
|
173
189
|
end
|
@@ -0,0 +1,235 @@
|
|
1
|
+
# *********************************************************************************
|
2
|
+
# URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
|
+
# contributors. All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice, this list
|
9
|
+
# of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
|
+
# list of conditions and the following disclaimer in the documentation and/or other
|
13
|
+
# materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
|
+
# used to endorse or promote products derived from this software without specific
|
17
|
+
# prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
22
|
+
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
23
|
+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
24
|
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
27
|
+
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
28
|
+
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
# *********************************************************************************
|
30
|
+
|
31
|
+
require 'csv'
|
32
|
+
require 'date'
|
33
|
+
require 'json'
|
34
|
+
require 'fileutils'
|
35
|
+
|
36
|
+
module URBANopt
|
37
|
+
module Scenario
|
38
|
+
class ResultVisualization
|
39
|
+
def self.create_visualization(run_dir, feature = true)
|
40
|
+
@all_results = []
|
41
|
+
run_dir.each do |folder|
|
42
|
+
name = folder.split('/')[-1]
|
43
|
+
|
44
|
+
# create visualization for scenarios
|
45
|
+
if feature == false
|
46
|
+
csv_dir = File.join(folder, 'default_scenario_report.csv')
|
47
|
+
# create visualization for features
|
48
|
+
elsif feature == true
|
49
|
+
csv_dir = File.join(folder, 'feature_reports/default_feature_report.csv')
|
50
|
+
end
|
51
|
+
|
52
|
+
if File.exist?(csv_dir)
|
53
|
+
size = CSV.open(csv_dir).readlines.size
|
54
|
+
|
55
|
+
monthly_values = {}
|
56
|
+
monthly_totals = {}
|
57
|
+
annual_values = {}
|
58
|
+
|
59
|
+
headers_unitless = []
|
60
|
+
i = 0
|
61
|
+
CSV.foreach(csv_dir).map do |row|
|
62
|
+
if i == 0
|
63
|
+
# store header values from csv
|
64
|
+
headers = row
|
65
|
+
headers.each do |header|
|
66
|
+
header_unitless = header.to_s.split('(')[0]
|
67
|
+
headers_unitless << header_unitless
|
68
|
+
monthly_values[header_unitless] = []
|
69
|
+
end
|
70
|
+
# store values from csv for each row
|
71
|
+
elsif i <= size
|
72
|
+
headers_unitless.each_index do |j|
|
73
|
+
monthly_values[headers_unitless[j]] << row[j]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
i += 1
|
77
|
+
end
|
78
|
+
|
79
|
+
if monthly_values['Datetime'][0].split(/\W+/)[0].to_f > 31
|
80
|
+
format = '%Y/%m/%d %H:%M'
|
81
|
+
year = monthly_values['Datetime'][0].split(/\W+/)[0]
|
82
|
+
else
|
83
|
+
format = '%m/%d/%Y %H:%M'
|
84
|
+
year = monthly_values['Datetime'][0].split(/\W+/)[2]
|
85
|
+
end
|
86
|
+
|
87
|
+
# create dates for each month
|
88
|
+
jan_date = DateTime.new(year.to_i, 1, 1, 1, 0)
|
89
|
+
feb_date = DateTime.new(year.to_i, 2, 1, 0, 0)
|
90
|
+
mar_date = DateTime.new(year.to_i, 3, 1, 0, 0)
|
91
|
+
apr_date = DateTime.new(year.to_i, 4, 1, 0, 0)
|
92
|
+
may_date = DateTime.new(year.to_i, 5, 1, 0, 0)
|
93
|
+
jun_date = DateTime.new(year.to_i, 6, 1, 0, 0)
|
94
|
+
jul_date = DateTime.new(year.to_i, 7, 1, 0, 0)
|
95
|
+
aug_date = DateTime.new(year.to_i, 8, 1, 0, 0)
|
96
|
+
sep_date = DateTime.new(year.to_i, 9, 1, 0, 0)
|
97
|
+
oct_date = DateTime.new(year.to_i, 10, 1, 0, 0)
|
98
|
+
nov_date = DateTime.new(year.to_i, 11, 1, 0, 0)
|
99
|
+
dec_date = DateTime.new(year.to_i, 12, 1, 0, 0)
|
100
|
+
jan_next_year = DateTime.new(year.to_i + 1, 1, 1, 0, 0)
|
101
|
+
|
102
|
+
monthly_values['Datetime'].each do |i|
|
103
|
+
date_obj = DateTime.strptime(i.to_s, format)
|
104
|
+
index = monthly_values['Datetime'].index(i)
|
105
|
+
|
106
|
+
# store index of each date from the csv
|
107
|
+
if feb_date == date_obj
|
108
|
+
@feb_index = index
|
109
|
+
elsif mar_date == date_obj
|
110
|
+
@mar_index = index
|
111
|
+
elsif apr_date == date_obj
|
112
|
+
@apr_index = index
|
113
|
+
elsif may_date == date_obj
|
114
|
+
@may_index = index
|
115
|
+
elsif jun_date == date_obj
|
116
|
+
@jun_index = index
|
117
|
+
elsif jul_date == date_obj
|
118
|
+
@jul_index = index
|
119
|
+
elsif aug_date == date_obj
|
120
|
+
@aug_index = index
|
121
|
+
elsif sep_date == date_obj
|
122
|
+
@sep_index = index
|
123
|
+
elsif oct_date == date_obj
|
124
|
+
@oct_index = index
|
125
|
+
elsif nov_date == date_obj
|
126
|
+
@nov_index = index
|
127
|
+
elsif dec_date == date_obj
|
128
|
+
@dec_index = index
|
129
|
+
elsif jan_next_year == date_obj
|
130
|
+
@jan_next_year_index = index
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
headers_unitless.each_index do |j|
|
135
|
+
i = 0
|
136
|
+
k = 0
|
137
|
+
|
138
|
+
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 = annual_sum = 0
|
139
|
+
|
140
|
+
# loop through values for each header
|
141
|
+
all_values = monthly_values[headers_unitless[j]]
|
142
|
+
|
143
|
+
unless @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?
|
144
|
+
|
145
|
+
# for each header store monthly sums of values
|
146
|
+
all_values.each do |v|
|
147
|
+
if i < @feb_index
|
148
|
+
monthly_sum_jan += v.to_f
|
149
|
+
i += 1
|
150
|
+
elsif @feb_index <= i && i < @mar_index
|
151
|
+
monthly_sum_feb += v.to_f
|
152
|
+
i += 1
|
153
|
+
elsif @mar_index <= i && i < @apr_index
|
154
|
+
monthly_sum_mar += v.to_f
|
155
|
+
i += 1
|
156
|
+
elsif @apr_index <= i && i < @may_index
|
157
|
+
monthly_sum_apr += v.to_f
|
158
|
+
i += 1
|
159
|
+
elsif @may_index <= i && i < @jun_index
|
160
|
+
monthly_sum_may += v.to_f
|
161
|
+
i += 1
|
162
|
+
elsif @jun_index <= i && i < @jul_index
|
163
|
+
monthly_sum_jun += v.to_f
|
164
|
+
i += 1
|
165
|
+
elsif @jul_index <= i && i < @aug_index
|
166
|
+
monthly_sum_jul += v.to_f
|
167
|
+
i += 1
|
168
|
+
elsif @aug_index <= i && i < @sep_index
|
169
|
+
monthly_sum_aug += v.to_f
|
170
|
+
i += 1
|
171
|
+
elsif @sep_index <= i && i < @oct_index
|
172
|
+
monthly_sum_sep += v.to_f
|
173
|
+
i += 1
|
174
|
+
elsif @oct_index <= i && i < @nov_index
|
175
|
+
monthly_sum_oct += v.to_f
|
176
|
+
i += 1
|
177
|
+
elsif @nov_index <= i && i < @dec_index
|
178
|
+
monthly_sum_nov += v.to_f
|
179
|
+
i += 1
|
180
|
+
elsif @dec_index <= i && i < @jan_next_year_index
|
181
|
+
monthly_sum_dec += v.to_f
|
182
|
+
i += 1
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# sum up monthly values for annual aggregate
|
189
|
+
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
|
190
|
+
|
191
|
+
# store headers as key and monthly sums as values for each header
|
192
|
+
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]
|
193
|
+
|
194
|
+
annual_values[headers_unitless[j]] = annual_sum
|
195
|
+
end
|
196
|
+
|
197
|
+
@results = {}
|
198
|
+
@results['name'] = name
|
199
|
+
@results['monthly_values'] = {}
|
200
|
+
@results['annual_values'] = {}
|
201
|
+
|
202
|
+
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?
|
203
|
+
@results['complete_simulation'] = false
|
204
|
+
puts "#{name} did not contain an annual simulation…visualizations will not render for it."
|
205
|
+
else
|
206
|
+
@results['complete_simulation'] = true
|
207
|
+
end
|
208
|
+
|
209
|
+
monthly_totals&.each do |key, value|
|
210
|
+
unless key == 'Datetime'
|
211
|
+
@results['monthly_values'][key] = value
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
annual_values&.each do |key, value|
|
216
|
+
unless key == 'Datetime'
|
217
|
+
@results['annual_values'][key] = value
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
unless @results.nil?
|
224
|
+
@all_results << @results
|
225
|
+
end
|
226
|
+
end
|
227
|
+
# create json with required data stored in a variable
|
228
|
+
results_path = File.join(run_dir[0], '../scenarioData.js')
|
229
|
+
File.open(results_path, 'w') do |file|
|
230
|
+
file << "var scenarioData = #{JSON.pretty_generate(@all_results)};"
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end # ResultVisualization
|
234
|
+
end # Scenario
|
235
|
+
end # URBANopt
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
2
|
+
# URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
3
|
# contributors. All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
2
|
+
# URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
3
|
# contributors. All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -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
|
|
@@ -60,8 +60,7 @@ module URBANopt
|
|
60
60
|
@mapper_class = mapper_class
|
61
61
|
end
|
62
62
|
|
63
|
-
attr_reader :mapper_class
|
64
|
-
|
63
|
+
attr_reader :mapper_class, :feature_id
|
65
64
|
##
|
66
65
|
# Return the directory that this simulation will run in.
|
67
66
|
##
|
@@ -132,8 +131,6 @@ module URBANopt
|
|
132
131
|
return result
|
133
132
|
end
|
134
133
|
|
135
|
-
# rubocop: disable Metrics/AbcSize #:nodoc:
|
136
|
-
|
137
134
|
##
|
138
135
|
# Return true if the simulation is out of date (input files newer than results), false otherwise.
|
139
136
|
# Non-existant simulation input files are out of date.
|
@@ -197,9 +194,6 @@ module URBANopt
|
|
197
194
|
|
198
195
|
return false
|
199
196
|
end
|
200
|
-
# rubocop: enable Metrics/AbcSize #:nodoc:
|
201
|
-
|
202
|
-
# rubocop: disable Style/GuardClause #:nodoc:
|
203
197
|
|
204
198
|
##
|
205
199
|
# Return simulation status one of {'Not Started', 'Started', 'Complete', 'Failed'}
|
@@ -217,7 +211,6 @@ module URBANopt
|
|
217
211
|
|
218
212
|
return 'Not Started'
|
219
213
|
end
|
220
|
-
# rubocop: enable Style/GuardClause #:nodoc:
|
221
214
|
|
222
215
|
##
|
223
216
|
# Clear the directory that this simulation runs in
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
2
|
+
# URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
|
3
3
|
# contributors. All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -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
|