urbanopt-cli 0.2.0.pre5 → 0.2.0.pre6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/example_files/Gemfile +1 -1
- data/example_files/mappers/Baseline.rb +38 -33
- data/example_files/mappers/base_workflow.osw +1 -0
- data/lib/uo_cli/version.rb +1 -1
- data/lib/uo_cli.rb +104 -44
- data/uo_cli.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1526537dc5660dcdf15f90de2c38ca79097d710b
|
4
|
+
data.tar.gz: fcd6a41d2f450dd114b9bd363f0842a8622494d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19f93d4b54b442dd211af34096c2e125e5465a46e16cbba494f32d0d160351d95958987266c57ddf62f53953b188e462ce38ce774996524b492d2393e2232b18
|
7
|
+
data.tar.gz: 4d3b613a41825e1cdf9ca1bdac133e900f11caba41a1a7fd5dac5e0dc5d284b9a966f58f9b0676ef326bfb3f71666ab3867f16b5cacb91f0a3473004222e1e49
|
data/Gemfile
CHANGED
@@ -52,7 +52,7 @@ if allow_local && File.exists?('../urbanopt-geojson-gem')
|
|
52
52
|
elsif allow_local
|
53
53
|
gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
|
54
54
|
else
|
55
|
-
gem 'urbanopt-geojson', '0.2.0.
|
55
|
+
gem 'urbanopt-geojson', '0.2.0.pre3'
|
56
56
|
# temporary
|
57
57
|
# gem 'urbanopt-scenario', github: 'URBANopt/urbanopt-scenario-gem', branch: 'develop'
|
58
58
|
end
|
data/example_files/Gemfile
CHANGED
@@ -63,7 +63,7 @@ if allow_local && File.exists?('../urbanopt-geojson-gem')
|
|
63
63
|
elsif allow_local
|
64
64
|
gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
|
65
65
|
else
|
66
|
-
gem 'urbanopt-geojson', '0.2.0.
|
66
|
+
gem 'urbanopt-geojson', '0.2.0.pre3'
|
67
67
|
# gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
|
68
68
|
end
|
69
69
|
|
@@ -117,37 +117,7 @@ module URBANopt
|
|
117
117
|
end
|
118
118
|
rescue
|
119
119
|
end
|
120
|
-
|
121
|
-
# ChangeBuildingLocation
|
122
|
-
# cec climate zone takes precedence
|
123
|
-
cec_found = false
|
124
|
-
begin
|
125
|
-
cec_climate_zone = feature.cec_climate_zone
|
126
|
-
if !cec_climate_zone.empty?
|
127
|
-
cec_climate_zone = "T24-CEC" + cec_climate_zone
|
128
|
-
OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'climate_zone', cec_climate_zone)
|
129
|
-
cec_found = true
|
130
|
-
end
|
131
|
-
rescue
|
132
|
-
end
|
133
|
-
if !cec_found
|
134
|
-
begin
|
135
|
-
climate_zone = feature.climate_zone
|
136
|
-
if !climate_zone.empty?
|
137
|
-
climate_zone = "ASHRAE 169-2013-" + climate_zone
|
138
|
-
OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'climate_zone', climate_zone)
|
139
|
-
end
|
140
|
-
rescue
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
begin
|
145
|
-
weather_filename = feature.weather_filename
|
146
|
-
if !feature.weather_filename.empty?
|
147
|
-
OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'weather_file_name', weather_filename)
|
148
|
-
end
|
149
|
-
rescue
|
150
|
-
end
|
120
|
+
|
151
121
|
# convert to hash
|
152
122
|
building_hash = feature.to_hash
|
153
123
|
# check for detailed model filename
|
@@ -273,6 +243,41 @@ module URBANopt
|
|
273
243
|
return new_time
|
274
244
|
end
|
275
245
|
|
246
|
+
|
247
|
+
# ChangeBuildingLocation
|
248
|
+
# set skip measure to false change building location
|
249
|
+
OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', '__SKIP__', false)
|
250
|
+
|
251
|
+
# cec climate zone takes precedence
|
252
|
+
cec_found = false
|
253
|
+
begin
|
254
|
+
cec_climate_zone = feature.cec_climate_zone
|
255
|
+
if !cec_climate_zone.empty?
|
256
|
+
cec_climate_zone = "T24-CEC" + cec_climate_zone
|
257
|
+
OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'climate_zone', cec_climate_zone)
|
258
|
+
cec_found = true
|
259
|
+
end
|
260
|
+
rescue
|
261
|
+
end
|
262
|
+
if !cec_found
|
263
|
+
begin
|
264
|
+
climate_zone = feature.climate_zone
|
265
|
+
if !climate_zone.empty?
|
266
|
+
climate_zone = "ASHRAE 169-2013-" + climate_zone
|
267
|
+
OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'climate_zone', climate_zone)
|
268
|
+
end
|
269
|
+
rescue
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
begin
|
274
|
+
weather_filename = feature.weather_filename
|
275
|
+
if !feature.weather_filename.empty?
|
276
|
+
OpenStudio::Extension.set_measure_argument(osw, 'ChangeBuildingLocation', 'weather_file_name', weather_filename)
|
277
|
+
end
|
278
|
+
rescue
|
279
|
+
end
|
280
|
+
|
276
281
|
#set weekday start time
|
277
282
|
begin
|
278
283
|
weekday_start_time = feature.weekday_start_time
|
@@ -382,10 +387,10 @@ module URBANopt
|
|
382
387
|
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_id', feature_id)
|
383
388
|
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_name', feature_name)
|
384
389
|
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_type', feature_type)
|
385
|
-
end
|
390
|
+
end
|
386
391
|
|
387
392
|
return osw
|
388
|
-
end
|
393
|
+
end
|
389
394
|
|
390
395
|
end #BaselineMapper
|
391
396
|
end #Scenario
|
data/lib/uo_cli/version.rb
CHANGED
data/lib/uo_cli.rb
CHANGED
@@ -45,7 +45,7 @@ module URBANopt
|
|
45
45
|
# Set up user interface
|
46
46
|
@user_input = {}
|
47
47
|
the_parser = OptionParser.new do |opts|
|
48
|
-
opts.banner = "Usage: uo [-
|
48
|
+
opts.banner = "Usage: uo [-peomradsfiv]\n" +
|
49
49
|
"\n" +
|
50
50
|
"URBANopt CLI\n" +
|
51
51
|
"First create a project folder with -p, then run additional commands as desired\n" +
|
@@ -53,10 +53,27 @@ module URBANopt
|
|
53
53
|
opts.separator ""
|
54
54
|
|
55
55
|
opts.on("-p", "--project_folder <DIR>",String, "Create project directory named <DIR> in your current folder\n" +
|
56
|
-
" You must be
|
56
|
+
" You must be inside the project directory you just created for all following commands to work") do |folder|
|
57
57
|
@user_input[:project_folder] = folder
|
58
58
|
end
|
59
|
+
|
60
|
+
opts.on("-e", "--empty_project_folder", String, "Use with -p argument to create an empty project folder\n" +
|
61
|
+
" Example: uo -e -p <DIR>\n" +
|
62
|
+
" Then add your own Feature file in the project directory you created,\n" +
|
63
|
+
" add Weather files in the weather folder and add OpenStudio models of Features \n" +
|
64
|
+
" in the Feature File, if any in the osm_building folder \n" +
|
65
|
+
" You must be inside the project directory you just created for all following commands to work") do
|
66
|
+
@user_input[:empty_project_folder] = "Create empty project folder" # This text does not get displayed to the user
|
67
|
+
end
|
59
68
|
|
69
|
+
opts.on("-o", "--overwrite_project_folder", String, "Use with -p argument to overwrite existing project folder and replace with new project folder.\n" +
|
70
|
+
" Or, use with -e and -p argument to overwrite existing project folder and replace with new empty project folder.\n" +
|
71
|
+
" Usage: uo -o -p <DIR>\n" +
|
72
|
+
" or, uo -o -e -p <DIR>\n" +
|
73
|
+
" Where, <DIR> is the existing project folder") do
|
74
|
+
@user_input[:overwrite_project_folder] = "Overwriting existing project folder" # This text does not get displayed to the user
|
75
|
+
end
|
76
|
+
|
60
77
|
opts.on("-m", "--make_scenario", String, "Create ScenarioCSV files for each MapperFile using the Feature file path. Must specify -f argument\n" +
|
61
78
|
" Example: uo -m -f example_project.json\n" +
|
62
79
|
" Or, Create Scenario CSV for each MapperFile for a single Feature from Feature File. Must specify -f and -i argument\n" +
|
@@ -175,11 +192,18 @@ module URBANopt
|
|
175
192
|
#
|
176
193
|
# Folder gets created in the current working directory
|
177
194
|
# Includes weather for UO's example location, a base workflow file, and mapper files to show a baseline and a high-efficiency option.
|
178
|
-
def self.create_project_folder(dir_name)
|
179
|
-
if
|
180
|
-
|
181
|
-
|
182
|
-
|
195
|
+
def self.create_project_folder(dir_name, empty_folder = false, overwrite_project = false)
|
196
|
+
if overwrite_project == true
|
197
|
+
if Dir.exist?(dir_name)
|
198
|
+
FileUtils.rm_rf(dir_name)
|
199
|
+
puts "Overwriting project directory: #{dir_name}"
|
200
|
+
end
|
201
|
+
elsif overwrite_project == false
|
202
|
+
if Dir.exist?(dir_name)
|
203
|
+
abort("ERROR: there is already a directory here named #{dir_name}... aborting")
|
204
|
+
end
|
205
|
+
end
|
206
|
+
puts "CREATING NEW URBANopt project directory: #{dir_name}"
|
183
207
|
Dir.mkdir dir_name
|
184
208
|
Dir.mkdir File.join(dir_name, 'mappers')
|
185
209
|
Dir.mkdir File.join(dir_name, 'weather')
|
@@ -188,66 +212,100 @@ module URBANopt
|
|
188
212
|
weather_dir_abs_path = File.absolute_path(File.join(dir_name, 'weather/'))
|
189
213
|
osm_dir_abs_path = File.absolute_path(File.join(dir_name, 'osm_building/'))
|
190
214
|
|
191
|
-
# FIXME: When residential hpxml flow is implemented
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
215
|
+
# FIXME: When residential hpxml flow is implemented
|
216
|
+
# (https://github.com/urbanopt/urbanopt-example-geojson-project/pull/24 gets merged)
|
217
|
+
# these files will change
|
218
|
+
|
219
|
+
|
196
220
|
remote_mapper_files = [
|
197
221
|
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/mappers/base_workflow.osw",
|
198
222
|
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/mappers/Baseline.rb",
|
199
223
|
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/mappers/HighEfficiency.rb",
|
200
224
|
]
|
201
|
-
remote_weather_files = [
|
202
|
-
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/weather/USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.epw",
|
203
|
-
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/weather/USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.ddy",
|
204
|
-
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/weather/USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.stat",
|
205
|
-
]
|
206
|
-
|
207
|
-
osm_files = [
|
208
|
-
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/osm_building/7.osm",
|
209
|
-
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/osm_building/8.osm",
|
210
|
-
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/osm_building/9.osm"
|
211
|
-
]
|
212
225
|
|
213
|
-
|
226
|
+
example_gem_file = "https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/Gemfile"
|
227
|
+
|
228
|
+
# Download mapper files to user's local machine
|
214
229
|
remote_mapper_files.each do |mapper_file|
|
215
230
|
mapper_path, mapper_name = File.split(mapper_file)
|
216
231
|
mapper_download = open(mapper_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
217
232
|
IO.copy_stream(mapper_download, File.join(mappers_dir_abs_path, mapper_name))
|
218
233
|
end
|
219
|
-
|
220
|
-
|
221
|
-
weather_download = open(weather_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
222
|
-
IO.copy_stream(weather_download, File.join(weather_dir_abs_path, weather_name))
|
223
|
-
end
|
224
|
-
osm_files.each do |osm_file|
|
225
|
-
osm_path, osm_name = File.split(osm_file)
|
226
|
-
osm_download = open(osm_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
227
|
-
IO.copy_stream(osm_download, File.join(osm_dir_abs_path, osm_name))
|
228
|
-
end
|
234
|
+
|
235
|
+
# Download gemfile to user's local machine
|
229
236
|
gem_path, gem_name = File.split(example_gem_file)
|
230
237
|
example_gem_download = open(example_gem_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
231
238
|
IO.copy_stream(example_gem_download, File.join(dir_name, gem_name))
|
232
239
|
|
233
|
-
|
234
|
-
|
235
|
-
|
240
|
+
#if argument for creating an empty folder is not added
|
241
|
+
if empty_folder == false
|
242
|
+
|
243
|
+
example_feature_file = "https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/example_project.json"
|
244
|
+
|
245
|
+
remote_weather_files = [
|
246
|
+
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/weather/USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.epw",
|
247
|
+
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/weather/USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.ddy",
|
248
|
+
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/weather/USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.stat",
|
249
|
+
]
|
236
250
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
251
|
+
osm_files = [
|
252
|
+
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/osm_building/7.osm",
|
253
|
+
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/osm_building/8.osm",
|
254
|
+
"https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/osm_building/9.osm"
|
255
|
+
]
|
256
|
+
|
257
|
+
config_file = "https://raw.githubusercontent.com/urbanopt/urbanopt-cli/master/example_files/runner.conf"
|
258
|
+
config_path, config_name = File.split(config_file)
|
259
|
+
config_download = open(config_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
260
|
+
IO.copy_stream(config_download, File.join(dir_name, config_name))
|
261
|
+
|
262
|
+
|
263
|
+
# Download weather file to user's local machine
|
264
|
+
remote_weather_files.each do |weather_file|
|
265
|
+
weather_path, weather_name = File.split(weather_file)
|
266
|
+
weather_download = open(weather_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
267
|
+
IO.copy_stream(weather_download, File.join(weather_dir_abs_path, weather_name))
|
268
|
+
end
|
269
|
+
|
270
|
+
osm_files.each do |osm_file|
|
271
|
+
osm_path, osm_name = File.split(osm_file)
|
272
|
+
osm_download = open(osm_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
273
|
+
IO.copy_stream(osm_download, File.join(osm_dir_abs_path, osm_name))
|
274
|
+
end
|
275
|
+
|
276
|
+
feature_path, feature_name = File.split(example_feature_file)
|
277
|
+
example_feature_download = open(example_feature_file, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
|
278
|
+
IO.copy_stream(example_feature_download, File.join(dir_name, feature_name))
|
279
|
+
|
280
|
+
end
|
241
281
|
end
|
242
282
|
|
243
283
|
|
244
284
|
# Perform CLI actions
|
245
|
-
if @user_input[:project_folder]
|
246
|
-
|
285
|
+
if @user_input[:project_folder] && @user_input[:empty_project_folder].nil?
|
286
|
+
if @user_input[:overwrite_project_folder]
|
287
|
+
create_project_folder(@user_input[:project_folder], empty_folder = false, overwrite_project = true)
|
288
|
+
puts "\nOverwriting exiting project folder #{@user_input[:project_folder]}."
|
289
|
+
puts "Creating a new project folder."
|
290
|
+
elsif @user_input[:overwrite_project_folder].nil?
|
291
|
+
create_project_folder(@user_input[:project_folder], empty_folder = false, overwrite_project = false)
|
292
|
+
end
|
247
293
|
puts "\nAn example FeatureFile is included: 'example_project.json'. You may place your own FeatureFile alongside the example."
|
248
294
|
puts "Weather data is provided for the example FeatureFile. Additional weather data files may be downloaded from energyplus.net/weather for free"
|
249
295
|
puts "If you use additional weather files, ensure they are added to the 'weather' directory. You will need to configure your mapper file and your osw file to use the desired weather file"
|
250
|
-
puts "Next, move inside your new folder ('cd <FolderYouJustCreated>') and create ScenarioFiles using this CLI: 'uo -m -f <FFP>'"
|
296
|
+
puts "Next, move inside your new folder ('cd <FolderYouJustCreated>') and create ScenarioFiles using this CLI call: 'uo -m -f <FFP>'"
|
297
|
+
elsif @user_input[:project_folder] && @user_input[:empty_project_folder]
|
298
|
+
if @user_input[:overwrite_project_folder]
|
299
|
+
create_project_folder(@user_input[:project_folder], empty_folder = true, overwrite_project = true)
|
300
|
+
puts "\nOverwriting exiting project folder #{@user_input[:project_folder]}."
|
301
|
+
puts "Creating a new project folder."
|
302
|
+
elsif @user_input[:overwrite_project].nil?
|
303
|
+
create_project_folder(@user_input[:project_folder], empty_folder = true, overwrite_project = false)
|
304
|
+
end
|
305
|
+
puts "Add your FeatureFile in the Project directory you just created."
|
306
|
+
puts "Add your weather data files in the Weather folder. They may be downloaded from energyplus.net/weather for free"
|
307
|
+
puts "Add your OpenStudio models for Features in your Feature file, if any in the osm_building folder"
|
308
|
+
puts "Next, move inside your new folder ('cd <FolderYouJustCreated>') and create ScenarioFiles using this CLI call: 'uo -m -f <FFP>'"
|
251
309
|
end
|
252
310
|
|
253
311
|
if @user_input[:make_scenario_from]
|
@@ -268,6 +326,8 @@ module URBANopt
|
|
268
326
|
end
|
269
327
|
end
|
270
328
|
|
329
|
+
|
330
|
+
|
271
331
|
if @user_input[:run_scenario]
|
272
332
|
if @user_input[:scenario].nil?
|
273
333
|
abort("\nYou must provide '-s' flag and a valid path to a ScenarioFile!\n---\n\n")
|
data/uo_cli.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
# use specific versions of urbanopt and openstudio dependencies while under heavy development
|
38
38
|
spec.add_dependency "urbanopt-scenario", "0.2.0.pre2"
|
39
|
-
spec.add_dependency "urbanopt-geojson", "0.2.0.
|
39
|
+
spec.add_dependency "urbanopt-geojson", "0.2.0.pre3"
|
40
40
|
|
41
41
|
spec.add_development_dependency "bundler", "~> 1.17"
|
42
42
|
spec.add_development_dependency "rake", "~> 12.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urbanopt-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.pre6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.2.0.
|
47
|
+
version: 0.2.0.pre3
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.2.0.
|
54
|
+
version: 0.2.0.pre3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|