urbanopt-reopt 0.5.4 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +30 -0
- data/Gemfile +1 -1
- data/LICENSE.md +33 -21
- data/Rakefile +18 -8
- data/docs/package-lock.json +13843 -1118
- data/docs/package.json +10 -6
- data/lib/urbanopt-reopt.rb +16 -6
- data/lib/urbanopt/reopt.rb +16 -6
- data/lib/urbanopt/reopt/extension.rb +16 -6
- data/lib/urbanopt/reopt/feature_report_adapter.rb +82 -103
- data/lib/urbanopt/reopt/reopt_lite_api.rb +81 -57
- data/lib/urbanopt/reopt/reopt_logger.rb +17 -7
- data/lib/urbanopt/reopt/reopt_post_processor.rb +89 -56
- data/lib/urbanopt/reopt/scenario/reopt_scenario_csv.rb +23 -13
- data/lib/urbanopt/reopt/scenario_report_adapter.rb +88 -110
- data/lib/urbanopt/reopt/utilities.rb +106 -102
- data/lib/urbanopt/reopt/version.rb +17 -7
- data/lib/urbanopt/reopt_scenario.rb +16 -6
- data/urbanopt-reopt.gemspec +4 -7
- metadata +15 -29
@@ -1,107 +1,111 @@
|
|
1
|
-
def convert_powerflow_resolution(timeseries_kw, original_res, destination_res)
|
2
|
-
|
3
|
-
|
4
|
-
|
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 |
|
1
|
+
def convert_powerflow_resolution(timeseries_kw, original_res, destination_res)
|
2
|
+
if timeseries_kw.nil?
|
3
|
+
return nil
|
4
|
+
end
|
18
5
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
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 |
|
53
22
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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 |
|
23
|
+
# EX 2
|
24
|
+
# stepping interval 2.5
|
25
|
+
# origin stepping | 1 | 1 | 4 | 2 | 2 |
|
26
|
+
# destination stepping | 1.6 | 2.4 |
|
66
27
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
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)
|
101
53
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
105
104
|
end
|
106
|
-
|
107
|
-
|
105
|
+
end
|
106
|
+
if destination_res == original_res
|
107
|
+
# No resolution conversion necessary
|
108
|
+
result = timeseries_kw
|
109
|
+
end
|
110
|
+
return result
|
111
|
+
end
|
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
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.
|
@@ -30,6 +40,6 @@
|
|
30
40
|
|
31
41
|
module URBANopt # :nodoc:
|
32
42
|
module REopt # :nodoc:
|
33
|
-
VERSION = '0.
|
43
|
+
VERSION = '0.6.1'.freeze
|
34
44
|
end
|
35
45
|
end
|
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
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.
|
data/urbanopt-reopt.gemspec
CHANGED
@@ -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.
|
25
|
+
spec.required_ruby_version = '~> 2.7.0'
|
27
26
|
|
28
|
-
spec.add_development_dependency 'bundler', '
|
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.
|
37
|
-
|
34
|
+
spec.add_dependency 'urbanopt-scenario', '~> 0.6.2'
|
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.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02
|
11
|
+
date: 2021-07-02 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:
|
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:
|
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:
|
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:
|
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:
|
54
|
+
version: 4.3.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
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:
|
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.
|
103
|
+
version: 0.6.2
|
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.
|
110
|
+
version: 0.6.2
|
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.
|
187
|
+
version: 2.7.0
|
202
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
189
|
requirements:
|
204
190
|
- - ">="
|