urbanopt-reopt 0.5.6 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,111 +1,111 @@
1
- def convert_powerflow_resolution(timeseries_kw, original_res, destination_res)
2
- if timeseries_kw.nil?
3
- return nil
4
- end
5
-
6
- if timeseries_kw.length == 0
7
- return nil
8
- end
9
-
10
- if original_res > destination_res
11
- # Timesteps will be reduced, i.e. 35040 -> 8760
12
-
13
- # This algorithm works by stepping along the origin timeseries at an interval equal to
14
- # one timestep in the destintion timeseries and then averaging all origin values that
15
- # coincide with the interval. Averages are weighted if a destination timestep
16
- # only partaially overlaps an origin timestep.
17
-
18
- # EX 1
19
- # stepping interval 2
20
- # origin stepping | 1 | 2 | 2 | 4 |
21
- # destination stepping | 1.5 | 3 |
1
+ def convert_powerflow_resolution(timeseries_kw, original_res, destination_res)
2
+ if timeseries_kw.nil?
3
+ return nil
4
+ end
22
5
 
23
- # EX 2
24
- # stepping interval 2.5
25
- # origin stepping | 1 | 1 | 4 | 2 | 2 |
26
- # destination stepping | 1.6 | 2.4 |
27
-
28
- result = []
29
- stepping_interval = Float(original_res) / Float(destination_res)
30
- current_origin_ts = 0 # fraction stepped along the origin time series
31
- current_origin_idx = 0 # current integer index of the origin timeseries
32
- (0..(8760*destination_res-1)).each do |ts|
33
- next_stopping_ts = current_origin_ts + stepping_interval #stop at the next destination interval
34
- total_power = [] #create to store wieghted origin timestep values to average
35
- while current_origin_ts != next_stopping_ts do
36
- next_origin_ts_int = Integer(current_origin_ts) + 1
37
- # Calc next stopping point that will being you to the next origin or destination time step
38
- next_origin_ts = [next_origin_ts_int, next_stopping_ts].min
39
- # Calc next step length
40
- delta_to_next_origin_ts = next_origin_ts - current_origin_ts
41
- # Add the proportional origin timestep value to the total power variable
42
- total_power.push(Float(timeseries_kw[current_origin_idx]) * delta_to_next_origin_ts)
43
- # Only move on to the next origin timestep if you are not ending mid way though an origin timestep
44
- # i.e in EX 2 above, the value 4 is needed in destination timestep 1 and 2
45
- if next_origin_ts_int <= next_stopping_ts
46
- current_origin_idx += 1
47
- end
48
- # Step to the next stopping point
49
- current_origin_ts += delta_to_next_origin_ts
50
- end
51
- # Add averaged total power variable for the destination time step
52
- result.push(Float(total_power.sum) / stepping_interval)
53
- end
54
- end
55
- if destination_res > original_res
56
- #Timesteps will be expanded, i.e. 8760 -> 35040
6
+ if timeseries_kw.empty?
7
+ return nil
8
+ end
9
+
10
+ if original_res > destination_res
11
+ # Timesteps will be reduced, i.e. 35040 -> 8760
12
+
13
+ # This algorithm works by stepping along the origin timeseries at an interval equal to
14
+ # one timestep in the destintion timeseries and then averaging all origin values that
15
+ # coincide with the interval. Averages are weighted if a destination timestep
16
+ # only partaially overlaps an origin timestep.
17
+
18
+ # EX 1
19
+ # stepping interval 2
20
+ # origin stepping | 1 | 2 | 2 | 4 |
21
+ # destination stepping | 1.5 | 3 |
57
22
 
58
- # This algorithm works by stepping along the destination timeseries. Steps are made to the next
59
- # destination or origin breakpoint, and at each step the propotional amount of the origin stepped
60
- # is added to the destination. For example, in in EX 1 below 4 steps are made each with adding the full amount of
61
- # the origin (1, 1, 2 and 2) since each in the destination overlaps perfectly with 2 origin
62
- # timesteps. In EX 2, the origin overlaps with the first 2 destination timesteps but the third
63
- # destination value much be compose of half the 1st origin timestep value and half the second
64
- # (i.e 4, 4, (4 * 1/2) + (3 * 1/2), 3, and 3 are added to the destination).
65
-
66
- # EX 1
67
- # stepping interval 2
68
- # origin stepping | 1 | 2 |
69
- # destination stepping | 1 | 1 | 2 | 2 |
23
+ # EX 2
24
+ # stepping interval 2.5
25
+ # origin stepping | 1 | 1 | 4 | 2 | 2 |
26
+ # destination stepping | 1.6 | 2.4 |
70
27
 
71
- # EX 2
72
- # stepping interval 2.5
73
- # origin stepping | 4 | 3 |
74
- # destination stepping | 4 | 4 | 3.5 | 3 | 3 |
75
-
76
- result = []
77
- stepping_interval = (Float(destination_res) / Float(original_res))
78
- current_destination_ts = 0 # fraction stepped along the origin time series
79
- (0..(8760*original_res-1)).each do |original_ts|
80
- # keep track of step length along the destination time series
81
- original_indices_stepped = 0
82
- # See if you are start in the middle of a destination time step and add the proportional
83
- # value to the most recent (and incomplete) destination value
84
- remainder = (current_destination_ts - Integer(current_destination_ts))
85
- if remainder > 0
86
- current_destination_ts += (1 - remainder)
87
- original_indices_stepped += (1 - remainder)
88
- result[-1] = result[-1] + (Float(timeseries_kw[original_ts])*(1-remainder))
89
- end
90
- # Make whole steps along the destination timeseries that overlap perfectly with the
91
- # origin timeseries
92
- while (original_indices_stepped < stepping_interval) and ((original_indices_stepped + 1) <= stepping_interval)
93
- result.push(Float(timeseries_kw[original_ts]))
94
- original_indices_stepped += 1
95
- current_destination_ts += 1
96
- end
97
- # See if you need to end your step in the middle of a destination time step and
98
- # just add the proportional value from the current origin timestep
99
- remainder = (stepping_interval - original_indices_stepped)
100
- if remainder > 0
101
- result.push((Float(timeseries_kw[original_ts]) * remainder))
102
- current_destination_ts += remainder
103
- end
104
- end
28
+ result = []
29
+ stepping_interval = Float(original_res) / Float(destination_res)
30
+ current_origin_ts = 0 # fraction stepped along the origin time series
31
+ current_origin_idx = 0 # current integer index of the origin timeseries
32
+ (0..(8760 * destination_res - 1)).each do |ts|
33
+ next_stopping_ts = current_origin_ts + stepping_interval # stop at the next destination interval
34
+ total_power = [] # create to store wieghted origin timestep values to average
35
+ while current_origin_ts != next_stopping_ts
36
+ next_origin_ts_int = Integer(current_origin_ts) + 1
37
+ # Calc next stopping point that will being you to the next origin or destination time step
38
+ next_origin_ts = [next_origin_ts_int, next_stopping_ts].min
39
+ # Calc next step length
40
+ delta_to_next_origin_ts = next_origin_ts - current_origin_ts
41
+ # Add the proportional origin timestep value to the total power variable
42
+ total_power.push(Float(timeseries_kw[current_origin_idx]) * delta_to_next_origin_ts)
43
+ # Only move on to the next origin timestep if you are not ending mid way though an origin timestep
44
+ # i.e in EX 2 above, the value 4 is needed in destination timestep 1 and 2
45
+ if next_origin_ts_int <= next_stopping_ts
46
+ current_origin_idx += 1
47
+ end
48
+ # Step to the next stopping point
49
+ current_origin_ts += delta_to_next_origin_ts
50
+ end
51
+ # Add averaged total power variable for the destination time step
52
+ result.push(Float(total_power.sum) / stepping_interval)
105
53
  end
106
- if destination_res == original_res
107
- #No resolution conversion necessary
108
- result = timeseries_kw
54
+ end
55
+ if destination_res > original_res
56
+ # Timesteps will be expanded, i.e. 8760 -> 35040
57
+
58
+ # This algorithm works by stepping along the destination timeseries. Steps are made to the next
59
+ # destination or origin breakpoint, and at each step the propotional amount of the origin stepped
60
+ # is added to the destination. For example, in in EX 1 below 4 steps are made each with adding the full amount of
61
+ # the origin (1, 1, 2 and 2) since each in the destination overlaps perfectly with 2 origin
62
+ # timesteps. In EX 2, the origin overlaps with the first 2 destination timesteps but the third
63
+ # destination value much be compose of half the 1st origin timestep value and half the second
64
+ # (i.e 4, 4, (4 * 1/2) + (3 * 1/2), 3, and 3 are added to the destination).
65
+
66
+ # EX 1
67
+ # stepping interval 2
68
+ # origin stepping | 1 | 2 |
69
+ # destination stepping | 1 | 1 | 2 | 2 |
70
+
71
+ # EX 2
72
+ # stepping interval 2.5
73
+ # origin stepping | 4 | 3 |
74
+ # destination stepping | 4 | 4 | 3.5 | 3 | 3 |
75
+
76
+ result = []
77
+ stepping_interval = (Float(destination_res) / Float(original_res))
78
+ current_destination_ts = 0 # fraction stepped along the origin time series
79
+ (0..(8760 * original_res - 1)).each do |original_ts|
80
+ # keep track of step length along the destination time series
81
+ original_indices_stepped = 0
82
+ # See if you are start in the middle of a destination time step and add the proportional
83
+ # value to the most recent (and incomplete) destination value
84
+ remainder = (current_destination_ts - Integer(current_destination_ts))
85
+ if remainder > 0
86
+ current_destination_ts += (1 - remainder)
87
+ original_indices_stepped += (1 - remainder)
88
+ result[-1] = result[-1] + (Float(timeseries_kw[original_ts]) * (1 - remainder))
89
+ end
90
+ # Make whole steps along the destination timeseries that overlap perfectly with the
91
+ # origin timeseries
92
+ while (original_indices_stepped < stepping_interval) && ((original_indices_stepped + 1) <= stepping_interval)
93
+ result.push(Float(timeseries_kw[original_ts]))
94
+ original_indices_stepped += 1
95
+ current_destination_ts += 1
96
+ end
97
+ # See if you need to end your step in the middle of a destination time step and
98
+ # just add the proportional value from the current origin timestep
99
+ remainder = (stepping_interval - original_indices_stepped)
100
+ if remainder > 0
101
+ result.push((Float(timeseries_kw[original_ts]) * remainder))
102
+ current_destination_ts += remainder
103
+ end
109
104
  end
110
- return result
111
- end
105
+ end
106
+ if destination_res == original_res
107
+ # No resolution conversion necessary
108
+ result = timeseries_kw
109
+ end
110
+ return result
111
+ end
@@ -40,6 +40,6 @@
40
40
 
41
41
  module URBANopt # :nodoc:
42
42
  module REopt # :nodoc:
43
- VERSION = '0.5.6'.freeze
43
+ VERSION = '0.6.2'.freeze
44
44
  end
45
45
  end
@@ -1,4 +1,3 @@
1
-
2
1
  lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'urbanopt/reopt/version'
@@ -23,16 +22,14 @@ Gem::Specification.new do |spec|
23
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
23
  spec.require_paths = ['lib']
25
24
 
26
- spec.required_ruby_version = '~> 2.5.0'
25
+ spec.required_ruby_version = '~> 2.7.0'
27
26
 
28
- spec.add_development_dependency 'bundler', '~> 2.1'
27
+ spec.add_development_dependency 'bundler', '>= 2.1.0'
29
28
  spec.add_development_dependency 'rake', '~> 13.0'
30
- spec.add_development_dependency 'rspec', '~> 3.7'
31
- spec.add_development_dependency 'rubocop', '~> 0.54.0'
32
29
  spec.add_development_dependency 'rdoc', '~> 4.3.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.7'
33
31
 
34
32
  spec.add_dependency 'certified', '~> 1'
35
33
  spec.add_dependency 'json_pure', '~> 2'
36
- spec.add_dependency 'urbanopt-scenario', '~> 0.5.0'
37
-
34
+ spec.add_dependency 'urbanopt-scenario', '~> 0.6.3'
38
35
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanopt-reopt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: 2.1.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.1'
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,47 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.7'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.7'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
42
+ name: rdoc
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 0.54.0
47
+ version: 4.3.0
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 0.54.0
54
+ version: 4.3.0
69
55
  - !ruby/object:Gem::Dependency
70
- name: rdoc
56
+ name: rspec
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 4.3.0
61
+ version: '3.7'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 4.3.0
68
+ version: '3.7'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: certified
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +100,14 @@ dependencies:
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: 0.5.0
103
+ version: 0.6.3
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: 0.5.0
110
+ version: 0.6.3
125
111
  description: Classes and measures for utilizing the REopt Lite API within OpenStudio
126
112
  workflows.
127
113
  email:
@@ -198,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
184
  requirements:
199
185
  - - "~>"
200
186
  - !ruby/object:Gem::Version
201
- version: 2.5.0
187
+ version: 2.7.0
202
188
  required_rubygems_version: !ruby/object:Gem::Requirement
203
189
  requirements:
204
190
  - - ">="