urbanopt-reopt 0.3.0.pre1 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,107 @@
1
+ def convert_powerflow_resolution(timeseries_kw, original_res, destination_res)
2
+ if timeseries_kw.length == 0
3
+ return nil
4
+ end
5
+
6
+ if original_res > destination_res
7
+ # Timesteps will be reduced, i.e. 35040 -> 8760
8
+
9
+ # This algorithm works by stepping along the origin timeseries at an interval equal to
10
+ # one timestep in the destintion timeseries and then averaging all origin values that
11
+ # coincide with the interval. Averages are weighted if a destination timestep
12
+ # only partaially overlaps an origin timestep.
13
+
14
+ # EX 1
15
+ # stepping interval 2
16
+ # origin stepping | 1 | 2 | 2 | 4 |
17
+ # destination stepping | 1.5 | 3 |
18
+
19
+ # EX 2
20
+ # stepping interval 2.5
21
+ # origin stepping | 1 | 1 | 4 | 2 | 2 |
22
+ # destination stepping | 1.6 | 2.4 |
23
+
24
+ result = []
25
+ stepping_interval = Float(original_res) / Float(destination_res)
26
+ current_origin_ts = 0 # fraction stepped along the origin time series
27
+ current_origin_idx = 0 # current integer index of the origin timeseries
28
+ (0..(8760*destination_res-1)).each do |ts|
29
+ next_stopping_ts = current_origin_ts + stepping_interval #stop at the next destination interval
30
+ total_power = [] #create to store wieghted origin timestep values to average
31
+ while current_origin_ts != next_stopping_ts do
32
+ next_origin_ts_int = Integer(current_origin_ts) + 1
33
+ # Calc next stopping point that will being you to the next origin or destination time step
34
+ next_origin_ts = [next_origin_ts_int, next_stopping_ts].min
35
+ # Calc next step length
36
+ delta_to_next_origin_ts = next_origin_ts - current_origin_ts
37
+ # Add the proportional origin timestep value to the total power variable
38
+ total_power.push(Float(timeseries_kw[current_origin_idx]) * delta_to_next_origin_ts)
39
+ # Only move on to the next origin timestep if you are not ending mid way though an origin timestep
40
+ # i.e in EX 2 above, the value 4 is needed in destination timestep 1 and 2
41
+ if next_origin_ts_int <= next_stopping_ts
42
+ current_origin_idx += 1
43
+ end
44
+ # Step to the next stopping point
45
+ current_origin_ts += delta_to_next_origin_ts
46
+ end
47
+ # Add averaged total power variable for the destination time step
48
+ result.push(Float(total_power.sum) / stepping_interval)
49
+ end
50
+ end
51
+ if destination_res > original_res
52
+ #Timesteps will be expanded, i.e. 8760 -> 35040
53
+
54
+ # This algorithm works by stepping along the destination timeseries. Steps are made to the next
55
+ # destination or origin breakpoint, and at each step the propotional amount of the origin stepped
56
+ # is added to the destination. For example, in in EX 1 below 4 steps are made each with adding the full amount of
57
+ # the origin (1, 1, 2 and 2) since each in the destination overlaps perfectly with 2 origin
58
+ # timesteps. In EX 2, the origin overlaps with the first 2 destination timesteps but the third
59
+ # destination value much be compose of half the 1st origin timestep value and half the second
60
+ # (i.e 4, 4, (4 * 1/2) + (3 * 1/2), 3, and 3 are added to the destination).
61
+
62
+ # EX 1
63
+ # stepping interval 2
64
+ # origin stepping | 1 | 2 |
65
+ # destination stepping | 1 | 1 | 2 | 2 |
66
+
67
+ # EX 2
68
+ # stepping interval 2.5
69
+ # origin stepping | 4 | 3 |
70
+ # destination stepping | 4 | 4 | 3.5 | 3 | 3 |
71
+
72
+ result = []
73
+ stepping_interval = (Float(destination_res) / Float(original_res))
74
+ current_destination_ts = 0 # fraction stepped along the origin time series
75
+ (0..(8760*original_res-1)).each do |original_ts|
76
+ # keep track of step length along the destination time series
77
+ original_indices_stepped = 0
78
+ # See if you are start in the middle of a destination time step and add the proportional
79
+ # value to the most recent (and incomplete) destination value
80
+ remainder = (current_destination_ts - Integer(current_destination_ts))
81
+ if remainder > 0
82
+ current_destination_ts += (1 - remainder)
83
+ original_indices_stepped += (1 - remainder)
84
+ result[-1] = result[-1] + (Float(timeseries_kw[original_ts])*(1-remainder))
85
+ end
86
+ # Make whole steps along the destination timeseries that overlap perfectly with the
87
+ # origin timeseries
88
+ while (original_indices_stepped < stepping_interval) and ((original_indices_stepped + 1) <= stepping_interval)
89
+ result.push(Float(timeseries_kw[original_ts]))
90
+ original_indices_stepped += 1
91
+ current_destination_ts += 1
92
+ end
93
+ # See if you need to end your step in the middle of a destination time step and
94
+ # just add the proportional value from the current origin timestep
95
+ remainder = (stepping_interval - original_indices_stepped)
96
+ if remainder > 0
97
+ result.push((Float(timeseries_kw[original_ts]) * remainder))
98
+ current_destination_ts += remainder
99
+ end
100
+ end
101
+ end
102
+ if destination_res == original_res
103
+ #No resolution conversion necessary
104
+ result = timeseries_kw
105
+ end
106
+ return result
107
+ 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,
@@ -30,6 +30,6 @@
30
30
 
31
31
  module URBANopt # :nodoc:
32
32
  module REopt # :nodoc:
33
- VERSION = '0.3.0.pre1'.freeze
33
+ VERSION = '0.5.4'.freeze
34
34
  end
35
35
  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,
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = URBANopt::REopt::VERSION
9
9
  spec.authors = ['']
10
10
  spec.email = ['']
11
+ spec.licenses = 'Nonstandard'
11
12
 
12
- spec.summary = 'Classes and measures for utilizing the REopt Lite API within OpenStudio workflows.'
13
+ spec.summary = 'Accessing the REopt Lite API within OpenStudio workflows.'
13
14
  spec.description = 'Classes and measures for utilizing the REopt Lite API within OpenStudio workflows.'
14
15
  spec.homepage = 'https://github.com/urbanopt/urbanopt-reopt-gem'
15
16
 
@@ -22,14 +23,16 @@ Gem::Specification.new do |spec|
22
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
24
  spec.require_paths = ['lib']
24
25
 
26
+ spec.required_ruby_version = '~> 2.5.0'
27
+
25
28
  spec.add_development_dependency 'bundler', '~> 2.1'
26
29
  spec.add_development_dependency 'rake', '~> 13.0'
27
30
  spec.add_development_dependency 'rspec', '~> 3.7'
28
-
29
31
  spec.add_development_dependency 'rubocop', '~> 0.54.0'
32
+ spec.add_development_dependency 'rdoc', '~> 4.3.0'
30
33
 
31
- spec.add_dependency 'certified'
32
- spec.add_dependency 'json_pure'
33
- spec.add_dependency 'urbanopt-scenario', '~> 0.3.0.pre1'
34
+ spec.add_dependency 'certified', '~> 1'
35
+ spec.add_dependency 'json_pure', '~> 2'
36
+ spec.add_dependency 'urbanopt-scenario', '~> 0.5.0'
34
37
 
35
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanopt-reopt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre1
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2021-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,48 +66,62 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.54.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rdoc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 4.3.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 4.3.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: certified
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ">="
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '0'
89
+ version: '1'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ">="
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0'
96
+ version: '1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: json_pure
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ">="
101
+ - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '0'
103
+ version: '2'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">="
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '0'
110
+ version: '2'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: urbanopt-scenario
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 0.3.0.pre1
117
+ version: 0.5.0
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 0.3.0.pre1
124
+ version: 0.5.0
111
125
  description: Classes and measures for utilizing the REopt Lite API within OpenStudio
112
126
  workflows.
113
127
  email:
@@ -124,7 +138,6 @@ files:
124
138
  - ".rdoc_options"
125
139
  - ".rspec"
126
140
  - ".rubocop.yml"
127
- - ".travis.yml"
128
141
  - CHANGELOG.md
129
142
  - CONTRIBUTING.md
130
143
  - Gemfile
@@ -169,11 +182,13 @@ files:
169
182
  - lib/urbanopt/reopt/reopt_schema/reopt_output_schema.json
170
183
  - lib/urbanopt/reopt/scenario/reopt_scenario_csv.rb
171
184
  - lib/urbanopt/reopt/scenario_report_adapter.rb
185
+ - lib/urbanopt/reopt/utilities.rb
172
186
  - lib/urbanopt/reopt/version.rb
173
187
  - lib/urbanopt/reopt_scenario.rb
174
188
  - urbanopt-reopt.gemspec
175
189
  homepage: https://github.com/urbanopt/urbanopt-reopt-gem
176
- licenses: []
190
+ licenses:
191
+ - Nonstandard
177
192
  metadata: {}
178
193
  post_install_message:
179
194
  rdoc_options: []
@@ -181,17 +196,17 @@ require_paths:
181
196
  - lib
182
197
  required_ruby_version: !ruby/object:Gem::Requirement
183
198
  requirements:
184
- - - ">="
199
+ - - "~>"
185
200
  - !ruby/object:Gem::Version
186
- version: '0'
201
+ version: 2.5.0
187
202
  required_rubygems_version: !ruby/object:Gem::Requirement
188
203
  requirements:
189
- - - ">"
204
+ - - ">="
190
205
  - !ruby/object:Gem::Version
191
- version: 1.3.1
206
+ version: '0'
192
207
  requirements: []
193
- rubygems_version: 3.1.2
208
+ rubygems_version: 3.1.4
194
209
  signing_key:
195
210
  specification_version: 4
196
- summary: Classes and measures for utilizing the REopt Lite API within OpenStudio workflows.
211
+ summary: Accessing the REopt Lite API within OpenStudio workflows.
197
212
  test_files: []
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- #cache: bundler
5
- rvm:
6
- - 2.2.4
7
- matrix:
8
- include:
9
- - env: OPENSTUDIO_VERSION=2.7.0 && OPENSTUDIO_SHA=544f363db5 && RUBYLIB=/usr/local/openstudio-2.7.0/Ruby:/usr/Ruby
10
- before_install:
11
- - gem install bundler -v '1.17'
12
- - gem install bundler -v '~> 1.17'
13
- install:
14
- - bundle install
15
- before_script:
16
- - curl -sLO https://raw.githubusercontent.com/NREL/OpenStudio-server/develop/docker/deployment/scripts/install_openstudio.sh
17
- - chmod +x install_openstudio.sh
18
- - sudo ./install_openstudio.sh $OPENSTUDIO_VERSION $OPENSTUDIO_SHA
19
- - sudo ./install_openstudio.sh $OPENSTUDIO_VERSION $OPENSTUDIO_SHA
20
- script:
21
- - bundle exec rake
22
- - bundle exec rake