urbanopt-scenario 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8cb63dabcc5a248580c0f5941030e985d95aa03f5cf6e9ecaeead96b5879d3a
4
- data.tar.gz: ba1fba337a0c9daf1ef6f699bb44864fc663a604bc2d6806919b44947326d7c6
3
+ metadata.gz: 07bc344e1b00e7a82bae3418bccb9883d3545961b49c3f9b887993bb0f76e3fe
4
+ data.tar.gz: '09911a325c45c5b38ea4eed13758e5306cf674b62485b7dd9fc271f12734e62d'
5
5
  SHA512:
6
- metadata.gz: 81d7ecde2901d1f8cef37c69ab4052cad2a70e9e87654724d09374cb6646eb9ef61393451e0215ac784534dde74647ca2719d1cb943306a7bf0d45fb1d0d16bf
7
- data.tar.gz: d9c810fb5d2bda25f6b9910b4e49e6ab7c9a1c065e3570319e85a4d58cd4f047f7d30e1a651bf7c4a6ed867b3f418255d5c7dd1aa4cf342c11a3c369680ed8fb
6
+ metadata.gz: 5e7e5cfd5eb849e97d3691d9001e26422cf90bda0cd0f471367189f11afdecd4bcdfc3baa4171e9e86574e0bb9ba7d125aed9da61982f24c564b2b0ae6b18cec
7
+ data.tar.gz: 7b11327eb4ea23787255a49c00a7db44f4172bb62f0583273ce7c8ddee2925b5e09057cc0dd68101f24d1adf82f386d6cffc3b089adb808573cef48ea6ae1fd4
@@ -1,5 +1,10 @@
1
1
  # URBANopt Scenario Gem
2
2
 
3
+ ## Version 0.4.2
4
+ Date Range: 09/29/20 - 09/30/20
5
+
6
+ - Fixed [#158]( https://github.com/urbanopt/urbanopt-scenario-gem/pull/158 ), SQLite Query fix for gas consumption reporting
7
+
3
8
  ## Version 0.4.1
4
9
  Date Range: 09/22/20 - 09/28/20
5
10
 
data/Gemfile CHANGED
@@ -32,21 +32,21 @@ allow_local = ENV['FAVOR_LOCAL_GEMS']
32
32
  # gem 'openstudio-model-articulation', github: 'NREL/openstudio-model-articulation-gem', branch: 'develop'
33
33
  # end
34
34
 
35
- #if allow_local && File.exist?('../urbanopt-core-gem')
36
- # gem 'urbanopt-core', path: '../urbanopt-core-gem'
37
- #elsif allow_local
38
- # gem 'urbanopt-core', github: 'URBANopt/urbanopt-core-gem', branch: 'develop'
39
- #else
40
- # gem 'urbanopt-core', '~>0.4.0'
41
- #end
42
-
43
- #if allow_local && File.exist?('../urbanopt-reporting-gem')
35
+ # if allow_local && File.exist?('../urbanopt-core-gem')
36
+ # gem 'urbanopt-core', path: '../urbanopt-core-gem'
37
+ # elsif allow_local
38
+ # gem 'urbanopt-core', github: 'URBANopt/urbanopt-core-gem', branch: 'develop'
39
+ # else
40
+ # gem 'urbanopt-core', '~>0.4.0'
41
+ # end
42
+
43
+ # if allow_local && File.exist?('../urbanopt-reporting-gem')
44
44
  # gem 'urbanopt-reporting', path: '../urbanopt-reporting-gem'
45
- #elsif allow_local
45
+ # elsif allow_local
46
46
  # gem 'urbanopt-reporting', github: 'URBANopt/urbanopt-reporting-gem', branch: 'develop'
47
- #else
48
- # gem 'urbanopt-reporting', '~> 0.2.0'
49
- #end
47
+ # else
48
+ # gem 'urbanopt-reporting', '~> 0.2.0'
49
+ # end
50
50
 
51
51
  # if allow_local && File.exist?('../openstudio-load-flexibility-measures-gem')
52
52
  # gem 'openstudio-load-flexibility-measures', path: '../openstudio-load-flexibility-measures-gem'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # URBANopt Scenario Gem
2
2
 
3
- The URBANopt<sup>&trade;</sup> Scenario Gem includes functionality for defining scenarios, running simulations, and post-processing results. User defined SimulationMapper classes translate each Feature to a SimulationDir which is a directory containing simulation input files. A ScenarioRunner is used to perform simulations for each SimulationDir. Finally, a ScenarioPostProcessor can run on a Scenario to generate scenario level results.
3
+ The URBANopt<sup>&trade;</sup> Scenario Gem includes functionality for defining scenarios, running simulations, and post-processing results. User defined SimulationMapper classes translate each Feature to a SimulationDir which is a directory containing simulation input files. The ScenarioRunner is used to perform simulations for each SimulationDir. Finally, a ScenarioPostProcessor can run on a Scenario to generate scenario level results.
4
4
 
5
5
  [RDoc Documentation](https://urbanopt.github.io/urbanopt-scenario-gem/)
6
6
 
@@ -91,21 +91,27 @@ module URBANopt
91
91
  scenario_db = SQLite3::Database.open new_db_file
92
92
  scenario_db.execute "CREATE TABLE IF NOT EXISTS ReportData(
93
93
  TimeIndex INTEGER,
94
+ Year VARCHAR(255),
95
+ Month VARCHAR(255),
96
+ Day VARCHAR(255),
97
+ Hour VARCHAR(255),
98
+ Minute VARCHAR(255),
99
+ Dst INTEGER,
94
100
  ReportDataDictionaryIndex INTEGER,
95
101
  Value INTEGER
96
102
  )"
97
103
 
98
104
  values_arr = []
99
105
  feature_list = Pathname.new(@initialization_hash[:directory_name]).children.select(&:directory?) # Folders in the run/scenario directory
100
-
106
+
101
107
  # get scenario CSV
102
108
  scenario_csv = File.join(@initialization_hash[:root_dir], @initialization_hash[:name] + '.csv')
103
109
  if File.exist?(scenario_csv)
104
110
  # csv found
105
- feature_ids = CSV.read(scenario_csv, :headers => true)
111
+ feature_ids = CSV.read(scenario_csv, headers: true)
106
112
  feature_list = []
107
113
  # loop through building feature ids from scenario csv
108
- feature_ids["Feature Id"].each do |feature|
114
+ feature_ids['Feature Id'].each do |feature|
109
115
  if Dir.exist?(File.join(@initialization_hash[:directory_name], feature))
110
116
  feature_list << File.join(@initialization_hash[:directory_name], feature)
111
117
  else
@@ -121,40 +127,45 @@ module URBANopt
121
127
  feature_db = SQLite3::Database.open uo_output_sql_file
122
128
  # Doing "db.results_as_hash = true" is prettier, but in this case significantly slower.
123
129
 
124
- # RDDI == 10 is the timestep value for facility electricity
125
- elec_query = feature_db.query "SELECT TimeIndex, Value
126
- FROM ReportData
127
- WHERE (TimeIndex % 2) != 0
128
- AND ReportDataDictionaryIndex=10 order by TimeIndex"
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
133
+ FROM ReportData
134
+ INNER JOIN Time ON Time.TimeIndex=ReportData.TimeIndex
135
+ WHERE ReportDataDictionaryIndex == 10
136
+ ORDER BY ReportData.TimeIndex"
129
137
 
130
138
  elec_query.each do |row| # Add up all the values for electricity usage across all Features at this timestep
131
139
  # row[0] == TimeIndex, row[1] == Value
140
+
132
141
  arr_match = values_arr.find { |v| v[:time_index] == row[0] }
133
142
  if arr_match.nil?
134
143
  # add new row to value_arr
135
- values_arr << { time_index: row[0], elec_val: Float(row[1]), gas_val: 0 }
144
+ 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 }
136
145
  else
137
146
  # running sum
138
- arr_match[:elec_val] += Float(row[1])
147
+ arr_match[:elec_val] += Float(row[7])
139
148
  end
140
149
  end # End elec_query
141
150
  elec_query.close
142
151
 
143
- # RDDI == 255 is the timestep value for facility gas
144
- gas_query = feature_db.query "SELECT TimeIndex, Value
145
- FROM ReportData
146
- WHERE (TimeIndex % 2) != 0
147
- AND ReportDataDictionaryIndex=255 order by TimeIndex"
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
155
+ FROM ReportData
156
+ INNER JOIN Time ON Time.TimeIndex=ReportData.TimeIndex
157
+ WHERE ReportDataDictionaryIndex == 1382
158
+ ORDER BY ReportData.TimeIndex"
148
159
 
149
160
  gas_query.each do |row|
150
161
  # row[0] == TimeIndex, row[1] == Value
151
162
  arr_match = values_arr.find { |v| v[:time_index] == row[0] }
152
163
  if arr_match.nil?
153
164
  # add new row to value_arr
154
- values_arr << { time_index: row[0], gas_val: Float(row[1]), elec_val: 0 }
165
+ 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 }
155
166
  else
156
167
  # running sum
157
- arr_match[:gas_val] += Float(row[1])
168
+ arr_match[:gas_val] += Float(row[7])
158
169
  end
159
170
  end # End gas_query
160
171
  gas_query.close
@@ -164,13 +175,13 @@ module URBANopt
164
175
  elec_sql = []
165
176
  gas_sql = []
166
177
  values_arr.each do |i|
167
- elec_sql << "(#{i[:time_index]}, 10, #{i[:elec_val]})"
168
- gas_sql << "(#{i[:time_index]}, 255, #{i[:gas_val]})"
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]})"
169
180
  end
170
181
 
171
182
  # Put summed Values into the database
172
- scenario_db.execute("INSERT INTO ReportData (TimeIndex, ReportDataDictionaryIndex, Value) VALUES #{elec_sql.join(', ')}")
173
- scenario_db.execute("INSERT INTO ReportData (TimeIndex, ReportDataDictionaryIndex, Value) VALUES #{gas_sql.join(', ')}")
183
+ scenario_db.execute("INSERT INTO ReportData VALUES #{elec_sql.join(', ')}")
184
+ scenario_db.execute("INSERT INTO ReportData VALUES #{gas_sql.join(', ')}")
174
185
  scenario_db.close
175
186
  end
176
187
 
@@ -30,6 +30,6 @@
30
30
 
31
31
  module URBANopt
32
32
  module Scenario
33
- VERSION = '0.4.1'.freeze
33
+ VERSION = '0.4.2'.freeze
34
34
  end
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanopt-scenario
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rawad El Kontar
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-09-28 00:00:00.000000000 Z
12
+ date: 2020-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler