urbanopt-reopt 0.4.0 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +2 -2
- data/CHANGELOG.md +56 -0
- data/Gemfile +1 -7
- data/LICENSE.md +33 -21
- data/Rakefile +16 -6
- data/docs/package-lock.json +10084 -151
- data/docs/package.json +8 -4
- 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 +96 -76
- data/lib/urbanopt/reopt/reopt_lite_api.rb +29 -17
- data/lib/urbanopt/reopt/reopt_logger.rb +16 -6
- data/lib/urbanopt/reopt/reopt_post_processor.rb +20 -9
- data/lib/urbanopt/reopt/scenario/reopt_scenario_csv.rb +16 -6
- data/lib/urbanopt/reopt/scenario_report_adapter.rb +99 -84
- data/lib/urbanopt/reopt/utilities.rb +111 -0
- data/lib/urbanopt/reopt/version.rb +17 -7
- data/lib/urbanopt/reopt_scenario.rb +16 -6
- data/urbanopt-reopt.gemspec +4 -2
- metadata +19 -6
- data/.travis.yml +0 -22
- data/a.txt +0 -1
@@ -0,0 +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 |
|
22
|
+
|
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
|
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) 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
|
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.5.6'.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
@@ -24,13 +24,15 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
26
|
spec.required_ruby_version = '~> 2.5.0'
|
27
|
-
|
27
|
+
|
28
28
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
29
29
|
spec.add_development_dependency 'rake', '~> 13.0'
|
30
30
|
spec.add_development_dependency 'rspec', '~> 3.7'
|
31
31
|
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
32
|
+
spec.add_development_dependency 'rdoc', '~> 4.3.0'
|
32
33
|
|
33
34
|
spec.add_dependency 'certified', '~> 1'
|
34
35
|
spec.add_dependency 'json_pure', '~> 2'
|
35
|
-
spec.add_dependency 'urbanopt-scenario', '~> 0.
|
36
|
+
spec.add_dependency 'urbanopt-scenario', '~> 0.5.0'
|
37
|
+
|
36
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.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ 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
|
@@ -100,14 +114,14 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
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.
|
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
|
@@ -133,7 +146,6 @@ files:
|
|
133
146
|
- RDOC_MAIN.md
|
134
147
|
- README.md
|
135
148
|
- Rakefile
|
136
|
-
- a.txt
|
137
149
|
- deploy_docs.sh
|
138
150
|
- developer_nrel_key.rb
|
139
151
|
- doc_templates/LICENSE.md
|
@@ -170,6 +182,7 @@ files:
|
|
170
182
|
- lib/urbanopt/reopt/reopt_schema/reopt_output_schema.json
|
171
183
|
- lib/urbanopt/reopt/scenario/reopt_scenario_csv.rb
|
172
184
|
- lib/urbanopt/reopt/scenario_report_adapter.rb
|
185
|
+
- lib/urbanopt/reopt/utilities.rb
|
173
186
|
- lib/urbanopt/reopt/version.rb
|
174
187
|
- lib/urbanopt/reopt_scenario.rb
|
175
188
|
- urbanopt-reopt.gemspec
|
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
|
data/a.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
123
|