urbanopt-scenario 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
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
29
  "set-value": "^3.0.2",
29
30
  "ssri": ">=8.0.1",
30
- "yargs-parser": "^20.2.1",
31
- "ini": "^2.0.0"
31
+ "vuepress": "^1.8.2",
32
+ "yargs-parser": "^20.2.1"
32
33
  }
33
34
  }
@@ -42,7 +42,7 @@ require 'logger'
42
42
 
43
43
  module URBANopt
44
44
  module Scenario
45
- @@logger = Logger.new(STDOUT)
45
+ @@logger = Logger.new($stdout)
46
46
 
47
47
  # Definining class variable "@@logger" to log errors, info and warning messages.
48
48
  def self.logger
@@ -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.exists?(bundle_path) or Dir.empty?(bundle_path)
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
@@ -107,8 +106,8 @@ module URBANopt
107
106
  # for now only add openstudio and urbanopt gems to the load path
108
107
  # and only those with 'urbanopt' or 'openstudio' in the before-last path position
109
108
  tmp_path_arr = Pathname(ld).each_filename.to_a
110
- if tmp_path_arr[-2].include? 'urbanopt' or tmp_path_arr[-2].include? 'openstudio'
111
- puts "adding DIR to load path: #{ld}"
109
+ if tmp_path_arr[-2].include?('urbanopt') || tmp_path_arr[-2].include?('openstudio')
110
+ # puts "adding DIR to load path: #{ld}"
112
111
  $LOAD_PATH.unshift(ld)
113
112
  end
114
113
  end
@@ -121,7 +120,6 @@ module URBANopt
121
120
  @@logger.error(e.message)
122
121
  raise
123
122
  end
124
-
125
123
  end
126
124
 
127
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
- return File.join(@scenario.run_dir, @feature_id + '/')
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] + '.csv')
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 # End elec_query
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 # End gas_query
185
+ end
186
186
  gas_query.close
187
187
  feature_db.close
188
- end # End feature_list loop
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 + '.csv'))
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 + '.csv'))
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..-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.keys.each do |k|
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' + '.csv'), transformer_csv)
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' + '.json')
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
- if feature_type == 'Building'
136
+ case feature_type
137
+ when 'Building'
137
138
  building_osws << simulation_dir.in_osw_path
138
- elsif feature_type == 'District System'
139
+ when 'District System'
139
140
  district_system_osws << simulation_dir.in_osw_path
140
- elsif feature_type == 'Transformer'
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"
@@ -50,13 +50,14 @@ module URBANopt
50
50
 
51
51
  run_dir.each do |folder|
52
52
  # create visualization for scenarios
53
- if feature == false
53
+ case feature
54
+ when false
54
55
  name = folder.split('/')[-1]
55
56
  csv_dir = File.join(folder, 'default_scenario_report.csv')
56
57
  # create visualization for features
57
- elsif feature == true
58
+ when true
58
59
  index = run_dir.index(folder)
59
- name = folder.split('/')[-1] + '-' + feature_names[index]
60
+ name = "#{folder.split('/')[-1]}-#{feature_names[index]}"
60
61
  csv_dir = File.join(folder, 'feature_reports/default_feature_report.csv')
61
62
  end
62
63
 
@@ -192,7 +193,6 @@ module URBANopt
192
193
  monthly_sum_dec += v.to_f
193
194
  i += 1
194
195
  end
195
-
196
196
  end
197
197
  end
198
198
 
@@ -241,6 +241,6 @@ module URBANopt
241
241
  file << "var scenarioData = #{JSON.pretty_generate(@all_results)};"
242
242
  end
243
243
  end
244
- end # ResultVisualization
245
- end # Scenario
246
- end # URBANopt
244
+ end
245
+ end
246
+ 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
- return File.join(scenario.run_dir, @feature_id + '/')
81
+
82
+ return File.join(scenario.run_dir, "#{@feature_id}/")
81
83
  end
82
84
 
83
85
  ##
@@ -40,6 +40,6 @@
40
40
 
41
41
  module URBANopt
42
42
  module Scenario
43
- VERSION = '0.6.1'.freeze
43
+ VERSION = '0.6.2'.freeze
44
44
  end
45
45
  end
@@ -27,12 +27,12 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rake', '~> 13.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.7'
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.6.0'
35
- spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.4.0'
34
+ spec.add_runtime_dependency 'urbanopt-core', '~> 0.6.1'
35
+ spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.4.1'
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanopt-scenario
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.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: 2021-05-14 00:00:00.000000000 Z
12
+ date: 2021-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -54,33 +54,33 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.7'
56
56
  - !ruby/object:Gem::Dependency
57
- name: json-schema
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.8'
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.8'
69
+ version: '2.3'
70
70
  - !ruby/object:Gem::Dependency
71
- name: json_pure
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.3'
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.3'
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.6.0
104
+ version: 0.6.1
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.6.0
111
+ version: 0.6.1
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.4.0
118
+ version: 0.4.1
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.4.0
125
+ version: 0.4.1
126
126
  description: Library to export data point OSW files from URBANopt Scenario CSV
127
127
  email:
128
128
  - rawad.elkontar@nrel.gov