urbanopt-scenario 0.4.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +1 -1
  3. data/CHANGELOG.md +39 -0
  4. data/Gemfile +8 -14
  5. data/LICENSE.md +29 -17
  6. data/RDOC_MAIN.md +2 -2
  7. data/README.md +1 -1
  8. data/Rakefile +16 -6
  9. data/docs/.vuepress/components/InnerJsonSchema.vue +7 -15
  10. data/docs/.vuepress/config.js +13 -9
  11. data/docs/.vuepress/highlight.js +1 -1
  12. data/docs/.vuepress/json-schema-deref-loader.js +22 -0
  13. data/docs/README.md +2 -2
  14. data/docs/package-lock.json +429 -498
  15. data/docs/package.json +7 -4
  16. data/lib/urbanopt-scenario.rb +16 -6
  17. data/lib/urbanopt/scenario.rb +16 -6
  18. data/lib/urbanopt/scenario/default_reports.rb +16 -6
  19. data/lib/urbanopt/scenario/extension.rb +21 -9
  20. data/lib/urbanopt/scenario/logger.rb +16 -6
  21. data/lib/urbanopt/scenario/scenario_base.rb +20 -10
  22. data/lib/urbanopt/scenario/scenario_csv.rb +54 -28
  23. data/lib/urbanopt/scenario/scenario_datapoint_base.rb +20 -10
  24. data/lib/urbanopt/scenario/scenario_post_processor_base.rb +18 -8
  25. data/lib/urbanopt/scenario/scenario_post_processor_default.rb +40 -25
  26. data/lib/urbanopt/scenario/scenario_post_processor_opendss.rb +25 -15
  27. data/lib/urbanopt/scenario/scenario_runner_base.rb +22 -11
  28. data/lib/urbanopt/scenario/scenario_runner_osw.rb +22 -10
  29. data/lib/urbanopt/scenario/scenario_visualization.rb +25 -15
  30. data/lib/urbanopt/scenario/simulation_dir_base.rb +19 -9
  31. data/lib/urbanopt/scenario/simulation_dir_osw.rb +20 -10
  32. data/lib/urbanopt/scenario/simulation_mapper_base.rb +19 -9
  33. data/lib/urbanopt/scenario/version.rb +17 -7
  34. data/urbanopt-scenario-gem.gemspec +13 -8
  35. metadata +8 -65
  36. data/docs/.vuepress/components/ScenarioSchema.vue +0 -12
  37. data/docs/schemas/scenario-schema.md +0 -3
@@ -1,21 +1,31 @@
1
1
  # *********************************************************************************
2
- # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2021, 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,
6
6
  # are permitted provided that the following conditions are met:
7
- #
7
+
8
8
  # Redistributions of source code must retain the above copyright notice, this list
9
9
  # of conditions and the following disclaimer.
10
- #
10
+
11
11
  # Redistributions in binary form must reproduce the above copyright notice, this
12
12
  # list of conditions and the following disclaimer in the documentation and/or other
13
13
  # materials provided with the distribution.
14
- #
14
+
15
15
  # Neither the name of the copyright holder nor the names of its contributors may be
16
16
  # used to endorse or promote products derived from this software without specific
17
17
  # prior written permission.
18
- #
18
+
19
+ # Redistribution of this software, without modification, must refer to the software
20
+ # by the same designation. Redistribution of a modified version of this software
21
+ # (i) may not refer to the modified version by the same designation, or by any
22
+ # confusingly similar designation, and (ii) must refer to the underlying software
23
+ # originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
24
+ # the term “URBANopt”, or any confusingly similar designation may not be used to
25
+ # refer to any modified version of this software or any modified version of the
26
+ # underlying software originally provided by Alliance without the prior written
27
+ # consent of Alliance.
28
+
19
29
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
30
  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
31
  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -35,7 +45,7 @@ module URBANopt
35
45
  # ScenarioPostProcessorBase post-processes a Scenario to create scenario level results.
36
46
  ##
37
47
  # [parameters:]
38
- # +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
48
+ # * +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
39
49
  def initialize(scenario_base)
40
50
  @scenario_base = scenario_base
41
51
  end
@@ -53,7 +63,7 @@ module URBANopt
53
63
  # Add results from a simulation_dir to this result.
54
64
  ##
55
65
  # [parameters:]
56
- # +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
66
+ # * +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
57
67
  def add_simulation_dir(simulation_dir)
58
68
  raise 'add_simulation_dir not implemented for ScenarioPostProcessorBase, override in your class'
59
69
  end
@@ -1,21 +1,31 @@
1
1
  # *********************************************************************************
2
- # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2021, 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,
6
6
  # are permitted provided that the following conditions are met:
7
- #
7
+
8
8
  # Redistributions of source code must retain the above copyright notice, this list
9
9
  # of conditions and the following disclaimer.
10
- #
10
+
11
11
  # Redistributions in binary form must reproduce the above copyright notice, this
12
12
  # list of conditions and the following disclaimer in the documentation and/or other
13
13
  # materials provided with the distribution.
14
- #
14
+
15
15
  # Neither the name of the copyright holder nor the names of its contributors may be
16
16
  # used to endorse or promote products derived from this software without specific
17
17
  # prior written permission.
18
- #
18
+
19
+ # Redistribution of this software, without modification, must refer to the software
20
+ # by the same designation. Redistribution of a modified version of this software
21
+ # (i) may not refer to the modified version by the same designation, or by any
22
+ # confusingly similar designation, and (ii) must refer to the underlying software
23
+ # originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
24
+ # the term “URBANopt”, or any confusingly similar designation may not be used to
25
+ # refer to any modified version of this software or any modified version of the
26
+ # underlying software originally provided by Alliance without the prior written
27
+ # consent of Alliance.
28
+
19
29
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
30
  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
31
  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -32,8 +42,6 @@ require 'urbanopt/scenario/scenario_post_processor_base'
32
42
  require 'urbanopt/reporting/default_reports'
33
43
 
34
44
  require 'csv'
35
- require 'json'
36
- require 'fileutils'
37
45
  require 'sqlite3'
38
46
 
39
47
  module URBANopt
@@ -43,7 +51,7 @@ module URBANopt
43
51
  # ScenarioPostProcessorBase post-processes a scenario to create scenario level results
44
52
  ##
45
53
  # [parameters:]
46
- # +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
54
+ # * +scenario_base+ - _ScenarioBase_ - An object of ScenarioBase class.
47
55
  def initialize(scenario_base)
48
56
  super(scenario_base)
49
57
 
@@ -69,7 +77,7 @@ module URBANopt
69
77
  # Add results from a simulation_dir to this result.
70
78
  ##
71
79
  # [parameters:]
72
- # +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
80
+ # * +simulation_dir+ - _SimulationDirOSW_ - An object on SimulationDirOSW class.
73
81
  def add_simulation_dir(simulation_dir)
74
82
  feature_reports = URBANopt::Reporting::DefaultReports::FeatureReport.from_simulation_dir(simulation_dir)
75
83
 
@@ -86,6 +94,9 @@ module URBANopt
86
94
 
87
95
  # Create database file with scenario-level results
88
96
  # Sum values for each timestep across all features. Save to new table in a new database
97
+ ##
98
+ # [parameters:]
99
+ # * +file_name+ - _String_ - Assign a name to the saved scenario results file
89
100
  def create_scenario_db_file(file_name = @default_save_name)
90
101
  new_db_file = File.join(@initialization_hash[:directory_name], "#{file_name}.db")
91
102
  scenario_db = SQLite3::Database.open new_db_file
@@ -97,8 +108,9 @@ module URBANopt
97
108
  Hour VARCHAR(255),
98
109
  Minute VARCHAR(255),
99
110
  Dst INTEGER,
100
- ReportDataDictionaryIndex INTEGER,
101
- Value INTEGER
111
+ FuelType VARCHAR(255),
112
+ Value INTEGER,
113
+ FuelUnits VARCHAR(255)
102
114
  )"
103
115
 
104
116
  values_arr = []
@@ -121,18 +133,19 @@ module URBANopt
121
133
  else
122
134
  raise "Couldn't find scenario CSV: #{scenario_csv}"
123
135
  end
124
- feature_1_name = File.basename(feature_list[0]) # Get name of first feature, so we can read eplusout.sql from there
125
- uo_output_sql_file = File.join(@initialization_hash[:directory_name], feature_1_name, 'eplusout.sql')
126
136
  feature_list.each do |feature| # Loop through each feature in the scenario
137
+ uo_output_sql_file = File.join(@initialization_hash[:directory_name], File.basename(feature), 'eplusout.sql')
127
138
  feature_db = SQLite3::Database.open uo_output_sql_file
128
139
  # Doing "db.results_as_hash = true" is prettier, but in this case significantly slower.
129
140
 
130
- # RDDI == 10 is the timestep value for facility electricity in OS 3.0.1
131
- # TODO: Dynamically read RDDI from table RDDI, insted of hardcoding it
132
- elec_query = feature_db.query "SELECT ReportData.TimeIndex, Time.Year, Time.Month, Time.Day, Time.Hour, Time.Minute, Time.Dst, ReportData.Value
141
+ elec_query = feature_db.query "SELECT ReportData.TimeIndex, Time.Year, Time.Month, Time.Day, Time.Hour,
142
+ Time.Minute, Time.Dst, ReportData.Value
133
143
  FROM ReportData
134
144
  INNER JOIN Time ON Time.TimeIndex=ReportData.TimeIndex
135
- WHERE ReportDataDictionaryIndex == 10
145
+ INNER JOIN ReportDataDictionary AS rddi ON rddi.ReportDataDictionaryIndex=ReportData.ReportDataDictionaryIndex
146
+ WHERE rddi.IndexGroup == 'Facility:Electricity'
147
+ AND rddi.ReportingFrequency == 'Zone Timestep'
148
+ AND Time.Year > 1900
136
149
  ORDER BY ReportData.TimeIndex"
137
150
 
138
151
  elec_query.each do |row| # Add up all the values for electricity usage across all Features at this timestep
@@ -149,12 +162,14 @@ module URBANopt
149
162
  end # End elec_query
150
163
  elec_query.close
151
164
 
152
- # RDDI == 1382 is the timestep value for facility gas in OS 3.0.1
153
- # TODO: Dynamically read RDDI from table RDDI, insted of hardcoding it
154
- gas_query = feature_db.query "SELECT ReportData.TimeIndex, Time.Year, Time.Month, Time.Day, Time.Hour, Time.Minute, Time.Dst, ReportData.Value
165
+ gas_query = feature_db.query "SELECT ReportData.TimeIndex, Time.Year, Time.Month, Time.Day, Time.Hour,
166
+ Time.Minute, Time.Dst, ReportData.Value
155
167
  FROM ReportData
156
168
  INNER JOIN Time ON Time.TimeIndex=ReportData.TimeIndex
157
- WHERE ReportDataDictionaryIndex == 1382
169
+ INNER JOIN ReportDataDictionary AS rddi ON rddi.ReportDataDictionaryIndex=ReportData.ReportDataDictionaryIndex
170
+ WHERE rddi.IndexGroup == 'Facility:Gas'
171
+ AND rddi.ReportingFrequency == 'Zone Timestep'
172
+ AND Time.Year > 1900
158
173
  ORDER BY ReportData.TimeIndex"
159
174
 
160
175
  gas_query.each do |row|
@@ -175,8 +190,8 @@ module URBANopt
175
190
  elec_sql = []
176
191
  gas_sql = []
177
192
  values_arr.each do |i|
178
- elec_sql << "(#{i[:time_index]}, #{i[:year]}, #{i[:month]}, #{i[:day]}, #{i[:hour]}, #{i[:minute]}, #{i[:dst]}, 10, #{i[:elec_val]})"
179
- gas_sql << "(#{i[:time_index]}, #{i[:year]}, #{i[:month]}, #{i[:day]}, #{i[:hour]}, #{i[:minute]}, #{i[:dst]}, 1382, #{i[:gas_val]})"
193
+ elec_sql << "(#{i[:time_index]}, #{i[:year]}, #{i[:month]}, #{i[:day]}, #{i[:hour]}, #{i[:minute]}, #{i[:dst]}, 'Electricity', #{i[:elec_val]}, 'J')"
194
+ gas_sql << "(#{i[:time_index]}, #{i[:year]}, #{i[:month]}, #{i[:day]}, #{i[:hour]}, #{i[:minute]}, #{i[:dst]}, 'Gas', #{i[:gas_val]}, 'J')"
180
195
  end
181
196
 
182
197
  # Put summed Values into the database
@@ -189,7 +204,7 @@ module URBANopt
189
204
  # Save scenario result
190
205
  ##
191
206
  # [parameters:]
192
- # +file_name+ - _String_ - Assign a name to the saved scenario results file
207
+ # * +file_name+ - _String_ - Assign a name to the saved scenario results file
193
208
  def save(file_name = @default_save_name)
194
209
  @scenario_result.save
195
210
 
@@ -1,21 +1,31 @@
1
1
  # *********************************************************************************
2
- # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2021, 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,
6
6
  # are permitted provided that the following conditions are met:
7
- #
7
+
8
8
  # Redistributions of source code must retain the above copyright notice, this list
9
9
  # of conditions and the following disclaimer.
10
- #
10
+
11
11
  # Redistributions in binary form must reproduce the above copyright notice, this
12
12
  # list of conditions and the following disclaimer in the documentation and/or other
13
13
  # materials provided with the distribution.
14
- #
14
+
15
15
  # Neither the name of the copyright holder nor the names of its contributors may be
16
16
  # used to endorse or promote products derived from this software without specific
17
17
  # prior written permission.
18
- #
18
+
19
+ # Redistribution of this software, without modification, must refer to the software
20
+ # by the same designation. Redistribution of a modified version of this software
21
+ # (i) may not refer to the modified version by the same designation, or by any
22
+ # confusingly similar designation, and (ii) must refer to the underlying software
23
+ # originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
24
+ # the term “URBANopt”, or any confusingly similar designation may not be used to
25
+ # refer to any modified version of this software or any modified version of the
26
+ # underlying software originally provided by Alliance without the prior written
27
+ # consent of Alliance.
28
+
19
29
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
30
  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
31
  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -34,7 +44,6 @@ require 'urbanopt/reporting/default_reports'
34
44
  require 'csv'
35
45
  require 'json'
36
46
  require 'fileutils'
37
- require 'pathname'
38
47
 
39
48
  module URBANopt
40
49
  module Scenario
@@ -43,8 +52,8 @@ module URBANopt
43
52
  # OpenDSSPostProcessor post-processes OpenDSS results to selected OpenDSS results and integrate them in scenario and feature reports.
44
53
  ##
45
54
  # [parameters:]
46
- # +scenario_report+ - _ScenarioBase_ - An object of Scenario_report class.
47
- # +opendss_results_dir_name+ - _directory name of opendss results
55
+ # * +scenario_report+ - _ScenarioBase_ - An object of Scenario_report class.
56
+ # * +opendss_results_dir_name+ - _directory name of opendss results
48
57
  def initialize(scenario_report, opendss_results_dir_name = 'opendss')
49
58
  if !scenario_report.nil?
50
59
  @scenario_report = scenario_report
@@ -202,9 +211,9 @@ module URBANopt
202
211
  # Save csv report method
203
212
  ##
204
213
  # [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
214
+ # * +feature_report+ - _feature report object_ - An onject of the feature report
215
+ # * +updated_feature_report_csv+ - _CSV_ - An updated feature report csv
216
+ # * +file_name+ - _String_ - Assigned name to save the file with no extension
208
217
  def save_csv(feature_report, updated_feature_report_csv, file_name = 'default_feature_report')
209
218
  File.write(File.join(feature_report.directory_name, 'feature_reports', "#{file_name}.csv"), updated_feature_report_csv)
210
219
  end
@@ -213,7 +222,7 @@ module URBANopt
213
222
  # create opendss json report results
214
223
  ##
215
224
  # [parameters:]
216
- # +feature_report+ - _feature report object_ - An onject of the feature report
225
+ # * +feature_report+ - _feature report object_ - An onject of the feature report
217
226
  def add_summary_results(feature_report)
218
227
  under_voltage_hrs = 0
219
228
  over_voltage_hrs = 0
@@ -258,7 +267,7 @@ module URBANopt
258
267
  updated_feature_csv = merge_data(@feature_reports_data[id], @opendss_data[id])
259
268
 
260
269
  # save fetaure reports
261
- feature_report.save_feature_report('default_feature_report_opendss')
270
+ feature_report.save_json_report('default_feature_report_opendss')
262
271
 
263
272
  # resave updated csv report
264
273
  save_csv(feature_report, updated_feature_csv, 'default_feature_report_opendss')
@@ -268,7 +277,8 @@ module URBANopt
268
277
  save_transformers_reports
269
278
 
270
279
  # save the updated scenario reports
271
- @scenario_report.save(file_name = 'scenario_report_opendss')
280
+ # set save_feature_reports to false since only the scenario reports should be saved now
281
+ @scenario_report.save(file_name = 'scenario_report_opendss', save_feature_reports = false)
272
282
  end
273
283
  end
274
284
  end
@@ -1,21 +1,31 @@
1
1
  # *********************************************************************************
2
- # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2021, 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,
6
6
  # are permitted provided that the following conditions are met:
7
- #
7
+
8
8
  # Redistributions of source code must retain the above copyright notice, this list
9
9
  # of conditions and the following disclaimer.
10
- #
10
+
11
11
  # Redistributions in binary form must reproduce the above copyright notice, this
12
12
  # list of conditions and the following disclaimer in the documentation and/or other
13
13
  # materials provided with the distribution.
14
- #
14
+
15
15
  # Neither the name of the copyright holder nor the names of its contributors may be
16
16
  # used to endorse or promote products derived from this software without specific
17
17
  # prior written permission.
18
- #
18
+
19
+ # Redistribution of this software, without modification, must refer to the software
20
+ # by the same designation. Redistribution of a modified version of this software
21
+ # (i) may not refer to the modified version by the same designation, or by any
22
+ # confusingly similar designation, and (ii) must refer to the underlying software
23
+ # originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
24
+ # the term “URBANopt”, or any confusingly similar designation may not be used to
25
+ # refer to any modified version of this software or any modified version of the
26
+ # underlying software originally provided by Alliance without the prior written
27
+ # consent of Alliance.
28
+
19
29
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
30
  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
31
  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -40,8 +50,9 @@ module URBANopt
40
50
  # Create all SimulationDirs for Scenario.
41
51
  ##
42
52
  # [parameters:]
43
- # +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for scenario.
44
- # +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files
53
+ # * +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for scenario.
54
+ # * +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files
55
+ ##
45
56
  # [return:] _Array_ Returns an array of all SimulationDirs, even those created previously, for Scenario.
46
57
  def create_simulation_files(scenario, force_clear = false)
47
58
  raise 'create_input_files is not implemented for ScenarioRunnerBase, override in your class'
@@ -51,9 +62,9 @@ module URBANopt
51
62
  # Create and run all SimulationFiles for Scenario.
52
63
  ##
53
64
  # [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
- #
65
+ # * +scenario+ - _ScenarioBase_ - Scenario to create and run simulation input files for.
66
+ # * +force_clear+ - _Bool_ - Clear Scenario before creating Simulation input files.
67
+ ##
57
68
  # [return:] _Array_ Returns an array of all SimulationDirs, even those created previously, for Scenario.
58
69
  def run(scenario, force_clear = false, options = {})
59
70
  raise 'run is not implemented for ScenarioRunnerBase, override in your class'
@@ -1,21 +1,31 @@
1
1
  # *********************************************************************************
2
- # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2021, 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,
6
6
  # are permitted provided that the following conditions are met:
7
- #
7
+
8
8
  # Redistributions of source code must retain the above copyright notice, this list
9
9
  # of conditions and the following disclaimer.
10
- #
10
+
11
11
  # Redistributions in binary form must reproduce the above copyright notice, this
12
12
  # list of conditions and the following disclaimer in the documentation and/or other
13
13
  # materials provided with the distribution.
14
- #
14
+
15
15
  # Neither the name of the copyright holder nor the names of its contributors may be
16
16
  # used to endorse or promote products derived from this software without specific
17
17
  # prior written permission.
18
- #
18
+
19
+ # Redistribution of this software, without modification, must refer to the software
20
+ # by the same designation. Redistribution of a modified version of this software
21
+ # (i) may not refer to the modified version by the same designation, or by any
22
+ # confusingly similar designation, and (ii) must refer to the underlying software
23
+ # originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
24
+ # the term “URBANopt”, or any confusingly similar designation may not be used to
25
+ # refer to any modified version of this software or any modified version of the
26
+ # underlying software originally provided by Alliance without the prior written
27
+ # consent of Alliance.
28
+
19
29
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
30
  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
31
  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -46,8 +56,9 @@ module URBANopt
46
56
  # Create all OSWs for Scenario.
47
57
  ##
48
58
  # [parameters:]
49
- # +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for.
50
- # +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files.
59
+ # * +scenario+ - _ScenarioBase_ - Scenario to create simulation input files for.
60
+ # * +force_clear+ - _Bool_ - Clear Scenario before creating simulation input files.
61
+ ##
51
62
  # [return:] _Array_ Returns array of all SimulationDirs, even those created previously, for Scenario.
52
63
  def create_simulation_files(scenario, force_clear = false)
53
64
  if force_clear
@@ -79,8 +90,9 @@ module URBANopt
79
90
  # - Run osw file groups in order and store simulation failure in a array.
80
91
  ##
81
92
  # [parameters:]
82
- # +scenario+ - _ScenarioBase_ - Scenario to create and run SimulationFiles for.
83
- # +force_clear+ - _Bool_ - Clear Scenario before creating SimulationFiles.
93
+ # * +scenario+ - _ScenarioBase_ - Scenario to create and run SimulationFiles for.
94
+ # * +force_clear+ - _Bool_ - Clear Scenario before creating SimulationFiles.
95
+ ##
84
96
  # [return:] _Array_ Returns array of all SimulationFiles, even those created previously, for Scenario.
85
97
  def run(scenario, force_clear = false, options = {})
86
98
  # instantiate openstudio runner - use the defaults for now. If need to change then create
@@ -1,21 +1,31 @@
1
1
  # *********************************************************************************
2
- # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt™, Copyright (c) 2019-2021, 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,
6
6
  # are permitted provided that the following conditions are met:
7
- #
7
+
8
8
  # Redistributions of source code must retain the above copyright notice, this list
9
9
  # of conditions and the following disclaimer.
10
- #
10
+
11
11
  # Redistributions in binary form must reproduce the above copyright notice, this
12
12
  # list of conditions and the following disclaimer in the documentation and/or other
13
13
  # materials provided with the distribution.
14
- #
14
+
15
15
  # Neither the name of the copyright holder nor the names of its contributors may be
16
16
  # used to endorse or promote products derived from this software without specific
17
17
  # prior written permission.
18
- #
18
+
19
+ # Redistribution of this software, without modification, must refer to the software
20
+ # by the same designation. Redistribution of a modified version of this software
21
+ # (i) may not refer to the modified version by the same designation, or by any
22
+ # confusingly similar designation, and (ii) must refer to the underlying software
23
+ # originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
24
+ # the term “URBANopt”, or any confusingly similar designation may not be used to
25
+ # refer to any modified version of this software or any modified version of the
26
+ # underlying software originally provided by Alliance without the prior written
27
+ # consent of Alliance.
28
+
19
29
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
30
  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
31
  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -31,21 +41,22 @@
31
41
  require 'csv'
32
42
  require 'date'
33
43
  require 'json'
34
- require 'fileutils'
35
44
 
36
45
  module URBANopt
37
46
  module Scenario
38
47
  class ResultVisualization
39
- def self.create_visualization(run_dir, feature = true)
48
+ def self.create_visualization(run_dir, feature = true, feature_names = false)
40
49
  @all_results = []
41
- run_dir.each do |folder|
42
- name = folder.split('/')[-1]
43
50
 
51
+ run_dir.each do |folder|
44
52
  # create visualization for scenarios
45
53
  if feature == false
54
+ name = folder.split('/')[-1]
46
55
  csv_dir = File.join(folder, 'default_scenario_report.csv')
47
56
  # create visualization for features
48
57
  elsif feature == true
58
+ index = run_dir.index(folder)
59
+ name = folder.split('/')[-1] + '-' + feature_names[index]
49
60
  csv_dir = File.join(folder, 'feature_reports/default_feature_report.csv')
50
61
  end
51
62
 
@@ -181,14 +192,13 @@ module URBANopt
181
192
  monthly_sum_dec += v.to_f
182
193
  i += 1
183
194
  end
184
- # sum up all values for annual aggregate
185
- if k <= size
186
- annual_sum += v.to_f
187
- k += 1
188
- end
195
+
189
196
  end
190
197
  end
191
198
 
199
+ # sum up monthly values for annual aggregate
200
+ 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
201
+
192
202
  # store headers as key and monthly sums as values for each header
193
203
  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
204