urbanopt-cli 0.8.0 → 0.8.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.
data/lib/uo_cli.rb CHANGED
@@ -151,7 +151,7 @@ module URBANopt
151
151
  "Use the FeatureID from your FeatureFile\n" \
152
152
  "Requires 'scenario-file' also be specified, to say which FeatureFile will create the ScenarioFile\n" \
153
153
  "Example: uo create --single-feature 2 --scenario-file example_project.json\n", type: String, short: :i
154
-
154
+
155
155
  opt :reopt_scenario_file, "\nCreate a ScenarioFile that includes a column defining the REopt assumptions file\n" \
156
156
  "Specify the existing ScenarioFile that you want to extend with REopt functionality\n" \
157
157
  "Example: uo create --reopt-scenario-file baseline_scenario.csv\n", type: String, short: :r
@@ -173,7 +173,7 @@ module URBANopt
173
173
 
174
174
  opt :num_parallel, "\nOPTIONAL: Run URBANopt simulations in parallel using <num_parallel> cores\n" \
175
175
  "Adjusts value of 'num_parallel' in the 'runner.conf' file\n" \
176
- "Example: uo run --num-parallel 2\n", default: 2, short: :n
176
+ "Example: uo run --num-parallel 2\n", short: :n
177
177
  end
178
178
  end
179
179
 
@@ -414,31 +414,31 @@ module URBANopt
414
414
  end
415
415
 
416
416
  feature_file = URBANopt::GeoJSON::GeoFile.from_file(featurefile)
417
- if @opthash.subopts[:reopt] == true || @opthash.subopts[:reopt_scenario] == true || @opthash.subopts[:reopt_feature] == true
418
- # TODO: Better way of grabbing assumptions file than the first file in the folder
419
- reopt_files_dir_contents_list = Dir.children(reopt_files_dir.to_s)
420
- reopt_assumptions_filename = File.basename(reopt_files_dir_contents_list[0])
417
+ if @opthash.subopts[:reopt] == true || @opthash.subopts[:reopt_scenario] == true || @opthash.subopts[:reopt_feature] == true
418
+ # TODO: Better way of grabbing assumptions file than the first file in the folder
419
+ reopt_files_dir_contents_list = Dir.children(reopt_files_dir.to_s)
420
+ reopt_assumptions_filename = File.basename(reopt_files_dir_contents_list[0])
421
421
  scenario_output = URBANopt::Scenario::REoptScenarioCSV.new(
422
- @scenario_name.downcase,
423
- @root_dir,
424
- run_dir,
425
- feature_file,
426
- mapper_files_dir,
427
- csv_file,
428
- num_header_rows,
429
- reopt_files_dir,
422
+ @scenario_name.downcase,
423
+ @root_dir,
424
+ run_dir,
425
+ feature_file,
426
+ mapper_files_dir,
427
+ csv_file,
428
+ num_header_rows,
429
+ reopt_files_dir,
430
430
  reopt_assumptions_filename
431
- )
432
- else
431
+ )
432
+ else
433
433
  scenario_output = URBANopt::Scenario::ScenarioCSV.new(
434
- @scenario_name.downcase,
435
- @root_dir,
436
- run_dir,
437
- feature_file,
438
- mapper_files_dir,
439
- csv_file,
434
+ @scenario_name.downcase,
435
+ @root_dir,
436
+ run_dir,
437
+ feature_file,
438
+ mapper_files_dir,
439
+ csv_file,
440
440
  num_header_rows
441
- )
441
+ )
442
442
  end
443
443
  scenario_output
444
444
  end
@@ -487,12 +487,12 @@ module URBANopt
487
487
  end
488
488
  end
489
489
 
490
- # Write new ScenarioFile with REopt column
491
- # params \
492
- # +existing_scenario_file+:: _string_ - Name of existing ScenarioFile
493
- def self.create_reopt_scenario_file(existing_scenario_file)
494
- existing_path, existing_name = File.split(File.expand_path(existing_scenario_file))
495
- # make reopt folder (if it does not exist)
490
+ # Write new ScenarioFile with REopt column
491
+ # params \
492
+ # +existing_scenario_file+:: _string_ - Name of existing ScenarioFile
493
+ def self.create_reopt_scenario_file(existing_scenario_file)
494
+ existing_path, existing_name = File.split(File.expand_path(existing_scenario_file))
495
+ # make reopt folder (if it does not exist)
496
496
  unless Dir.exist?(File.join(existing_path, 'reopt'))
497
497
  Dir.mkdir File.join(existing_path, 'reopt')
498
498
  # copy reopt files from cli examples
@@ -502,18 +502,18 @@ module URBANopt
502
502
  Pathname.new(reopt_files).children.each { |reopt_file| FileUtils.cp(reopt_file, File.join(existing_path, 'reopt')) }
503
503
  end
504
504
  end
505
- end
506
-
507
- table = CSV.read(existing_scenario_file, headers: true, col_sep: ',')
508
- # Add another column, row by row:
509
- table.each do |row|
510
- row['REopt Assumptions'] = 'multiPV_assumptions.json'
511
- end
505
+ end
506
+
507
+ table = CSV.read(existing_scenario_file, headers: true, col_sep: ',')
508
+ # Add another column, row by row:
509
+ table.each do |row|
510
+ row['REopt Assumptions'] = 'multiPV_assumptions.json'
511
+ end
512
512
  # write new file (name it REopt + existing scenario name)
513
- CSV.open(File.join(existing_path, 'REopt_' + existing_name), 'w') do |f|
514
- f << table.headers
515
- table.each { |row| f << row }
516
- end
513
+ CSV.open(File.join(existing_path, "REopt_#{existing_name}"), 'w') do |f|
514
+ f << table.headers
515
+ table.each { |row| f << row }
516
+ end
517
517
  end
518
518
 
519
519
  # Create project folder
@@ -550,6 +550,15 @@ module URBANopt
550
550
 
551
551
  # copy config file
552
552
  FileUtils.cp(File.join(path_item, 'runner.conf'), dir_name)
553
+ # If the env var is set, change the num_parallel value to be what the env var is set to
554
+ if ENV['UO_NUM_PARALLEL']
555
+ runner_file_path = File.join(dir_name, 'runner.conf')
556
+ runner_conf_hash = JSON.parse(File.read(runner_file_path))
557
+ runner_conf_hash['num_parallel'] = ENV['UO_NUM_PARALLEL'].to_i
558
+ File.open(runner_file_path, 'w+') do |f|
559
+ f << runner_conf_hash.to_json
560
+ end
561
+ end
553
562
 
554
563
  # copy gemfile
555
564
  FileUtils.cp(File.join(path_item, 'Gemfile'), dir_name)
@@ -798,11 +807,11 @@ module URBANopt
798
807
  end
799
808
  end
800
809
 
801
- # Create REopt ScenarioFile from existing
802
- if @opthash.command == 'create' && @opthash.subopts[:reopt_scenario_file]
803
- puts "\nCreating ScenarioFile with REopt functionality, extending from #{@opthash.subopts[:reopt_scenario_file]}..."
804
- create_reopt_scenario_file(@opthash.subopts[:reopt_scenario_file])
805
- puts "\nDone"
810
+ # Create REopt ScenarioFile from existing
811
+ if @opthash.command == 'create' && @opthash.subopts[:reopt_scenario_file]
812
+ puts "\nCreating ScenarioFile with REopt functionality, extending from #{@opthash.subopts[:reopt_scenario_file]}..."
813
+ create_reopt_scenario_file(@opthash.subopts[:reopt_scenario_file])
814
+ puts "\nDone"
806
815
  end
807
816
 
808
817
  # Run simulations
@@ -868,7 +877,7 @@ module URBANopt
868
877
 
869
878
  puts "Scenario path: #{scenario_path}"
870
879
 
871
- #config_root_dir = File.dirname(File.expand_path(config_scenario_file))
880
+ # config_root_dir = File.dirname(File.expand_path(config_scenario_file))
872
881
  config_root_dir = config_path
873
882
  run_dir = File.join(config_root_dir, 'run', config_scenario_name.downcase)
874
883
  featurefile = Pathname.new(opendss_config[:urbanopt_geojson_file])
@@ -1025,7 +1034,7 @@ module URBANopt
1025
1034
  end
1026
1035
  elsif (@opthash.subopts[:reopt_scenario] == true) || (@opthash.subopts[:reopt_feature] == true)
1027
1036
  # Ensure reopt default files are prepared
1028
- #create_reopt_files(@opthash.subopts[:scenario])
1037
+ # create_reopt_files(@opthash.subopts[:scenario])
1029
1038
 
1030
1039
  scenario_base = default_post_processor.scenario_base
1031
1040
 
@@ -1232,9 +1241,9 @@ module URBANopt
1232
1241
  if feature_eui_value > validation_params['EUI'][@opthash.subopts[:units]][building_type]['max']
1233
1242
  puts "\nFeature #{File.basename(feature_path)} EUI of #{feature_eui_value.round(2)} #{unit_value} is greater than the validation maximum."
1234
1243
  elsif feature_eui_value < validation_params['EUI'][@opthash.subopts[:units]][building_type]['min']
1235
- puts "\nFeature #{File.basename(feature_path)} EUI of #{feature_eui_value.round(2)} #{unit_value} is less than the validation minimum."
1244
+ puts "\nFeature #{File.basename(feature_path)} (#{building_type}) EUI of #{feature_eui_value.round(2)} #{unit_value} is less than the validation minimum."
1236
1245
  else
1237
- puts "\nFeature #{File.basename(feature_path)} EUI of #{feature_eui_value.round(2)} #{unit_value} is within bounds set by #{validation_file_name}."
1246
+ puts "\nFeature #{File.basename(feature_path)} (#{building_type}) EUI of #{feature_eui_value.round(2)} #{unit_value} is within bounds set by #{validation_file_name}."
1238
1247
  end
1239
1248
  end
1240
1249
  end
data/uo_cli.gemspec CHANGED
@@ -34,9 +34,9 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  # use specific versions of urbanopt and openstudio dependencies while under heavy development
36
36
  spec.add_runtime_dependency 'optimist', '~> 3'
37
- spec.add_runtime_dependency 'urbanopt-geojson', '~> 0.8.0'
37
+ spec.add_runtime_dependency 'urbanopt-geojson', '~> 0.8.1'
38
38
  spec.add_runtime_dependency 'urbanopt-reopt', '~> 0.8.0'
39
- spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.6.0'
39
+ spec.add_runtime_dependency 'urbanopt-reporting', '~> 0.6.1'
40
40
  spec.add_runtime_dependency 'urbanopt-rnm-us', '~> 0.3.0'
41
41
  spec.add_runtime_dependency 'urbanopt-scenario', '~> 0.8.0'
42
42
 
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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-14 00:00:00.000000000 Z
11
+ date: 2022-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: optimist
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.0
33
+ version: 0.8.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.0
40
+ version: 0.8.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: urbanopt-reopt
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.6.0
61
+ version: 0.6.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.6.0
68
+ version: 0.6.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: urbanopt-rnm-us
71
71
  requirement: !ruby/object:Gem::Requirement