openstudio-analysis 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openstudio/analysis/translator/excel.rb +55 -6
  3. data/lib/openstudio/analysis/version.rb +1 -1
  4. data/lib/openstudio-analysis.rb +1 -0
  5. data/spec/files/analysis/medium_office.json +220 -234
  6. data/spec/files/analysis/medium_office.zip +0 -0
  7. data/spec/files/export/analysis/Kats model v2.json +18 -19
  8. data/spec/files/export/analysis/Kats model v2.zip +0 -0
  9. data/spec/files/export/analysis/discrete_dynamic_seed.json +18 -19
  10. data/spec/files/export/analysis/discrete_dynamic_seed.zip +0 -0
  11. data/spec/files/export/analysis/discrete_seed.json +103 -109
  12. data/spec/files/export/analysis/discrete_seed.zip +0 -0
  13. data/spec/files/export/analysis/output_vars.json +95 -101
  14. data/spec/files/export/analysis/output_vars.zip +0 -0
  15. data/spec/files/export/analysis/small_seed.json +95 -101
  16. data/spec/files/export/analysis/small_seed.zip +0 -0
  17. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-create-a-new-localhost-instance.68.xml +9 -0
  18. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-test-not-localhost.68.xml +9 -0
  19. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi.68.xml +7 -0
  20. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-variables.26.xml +19 -0
  21. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-with-dynamic-columns.10.xml +18 -0
  22. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-no-variables-defined.68.xml +20 -0
  23. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup-with-user.34.xml +9 -0
  24. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup.40.xml +9 -0
  25. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-output-variables.20.xml +37 -0
  26. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-version-0-1-9.17.xml +21 -0
  27. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-incomplete-variables.68.xml +9 -0
  28. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables-should-not-validate.68.xml +9 -0
  29. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables.68.xml +24 -0
  30. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-with-with-repeated-variable-names.68.xml +9 -0
  31. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-1-10.17.xml +13 -0
  32. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-2-0-simple.2.xml +20 -0
  33. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-2-0.3.xml +33 -0
  34. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel.68.xml +7 -0
  35. metadata +38 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 466587d9aa1f5975444f2db97383dbbf947ba15d
4
- data.tar.gz: b86d47a7c0535c75d10f90fa9579572d2d8c25c2
3
+ metadata.gz: d683426f53729c1e849371d14163a51de8bd3fed
4
+ data.tar.gz: 1f9d4dadb3d92791c38cd638c11e2c43964aa34d
5
5
  SHA512:
6
- metadata.gz: 1fc01077b23f6312e4b8563ffe4901625fa5c939406e7028412bc4190b455b5562e8763183177351eb983b2b7fc3e9d00b3d601a1802ba6333a9046f805d3ba0
7
- data.tar.gz: feaa588b52ffeef346b32fe480e6593191350e5e529605767894088b2415f360cd353081b7f15be7bee282adabd413c2f055564d7b5857a52275a7f0b318d45f
6
+ metadata.gz: d87903bcd2c30d112ecfb625d786603c2e3f9aabf23b4a6a5a1b2cf65093768cdab3da379cad0a9a886469d6688f546abb49a86841a0601f5dc23722da934f6a
7
+ data.tar.gz: 943e938546c5f148095103912d3e7ce95a68780c21442b158bf6989d6f2e82352aa40256a4e1893d428ba7bf17fe942570896f9bd1c610fd81ab7a3ad11fd723
@@ -167,6 +167,8 @@ module OpenStudio
167
167
  @template_json
168
168
  end
169
169
 
170
+ # save_analysis will iterate over each model that is defined in the spreadsheet and save the
171
+ # zip and json file.
170
172
  def save_analysis
171
173
  @template_json = create_analysis_hash
172
174
 
@@ -309,6 +311,15 @@ module OpenStudio
309
311
  binding
310
312
  end
311
313
 
314
+ def add_directory_to_zip(zipfile, local_directory, relative_zip_directory)
315
+ # pp "Add Directory #{local_directory}"
316
+ Dir[File.join("#{local_directory}", '**', '**')].each do |file|
317
+ # pp "Adding File #{file}"
318
+ zipfile.add(file.sub(local_directory, relative_zip_directory), file)
319
+ end
320
+ zipfile
321
+ end
322
+
312
323
  # Package up the seed, weather files, and measures
313
324
  def save_analysis_zip(model)
314
325
  zipfile_name = "#{@export_path}/#{model[:name]}.zip"
@@ -320,11 +331,49 @@ module OpenStudio
320
331
  zipfile.add("./weather/#{File.basename(filename)}", filename)
321
332
  end
322
333
 
323
- Dir.glob("#{@measure_path}/**/*.rb").each do |measure|
324
- next if measure.include?('spec') # don't include the spec folders nor files
325
- measure_name = measure.split(File::SEPARATOR).last(2).first
326
- # puts " Adding ./measures/#{measure_name}/#{File.basename(measure)}"
327
- zipfile.add("./measures/#{measure_name}/#{File.basename(measure)}", measure)
334
+ # Add only the measures that are defined in the spreadsheet
335
+ added_measures = []
336
+ measure_files = Dir.glob("#{@measure_path}/**/measure.rb")
337
+
338
+ # go through each of the Variables
339
+ @variables['data'].each do |v|
340
+ measure_to_save = nil
341
+ measure_files.each do |measure|
342
+ # pp v['measure_file_name_directory']
343
+ if measure.include? "/#{v['measure_file_name_directory']}/"
344
+ measure_to_save = File.dirname(measure)
345
+ # pp "Measure to save is #{measure}"
346
+ break
347
+ end
348
+ end
349
+
350
+ if v['measure_file_name_directory'] =~ /baseline/i
351
+ puts ' Skipping baseline measure'
352
+ next
353
+ end
354
+
355
+ if measure_to_save && !added_measures.include?(measure_to_save)
356
+ # pp "Attempting to add measure #{measure_to_save}"
357
+ if File.exist?(measure_to_save)
358
+ # pp "Adding measure directory to zip #{measure_to_save}"
359
+ Dir[File.join(measure_to_save, '**')].each do |file|
360
+ if File.directory?(file)
361
+ if File.basename(file) == 'resources'
362
+ add_directory_to_zip(zipfile, file, "./measures/#{v['measure_file_name_directory']}/#{File.basename(file)}")
363
+ else
364
+ # pp "Skipping Directory #{File.basename(file)}"
365
+ end
366
+ else
367
+ # pp "Adding File #{file}"
368
+ # added_measures << measure_dir unless added_measures.include? measure_dir
369
+ zipfile.add(file.sub(measure_to_save, "./measures/#{v['measure_file_name_directory']}/"), file)
370
+ end
371
+ end
372
+ added_measures << measure_to_save unless added_measures.include? measure_to_save
373
+ else
374
+ fail "Could not find measure to add to zip for #{@measure_path}/#{v['measure_file_name_directory']}"
375
+ end
376
+ end
328
377
  end
329
378
 
330
379
  # puts "Adding #{model[:path]}"
@@ -516,7 +565,7 @@ module OpenStudio
516
565
  notes: 'notes',
517
566
  relation_to_eui: 'typical var to eui relationship',
518
567
  clean: true)
519
- elsif @version >= '0.1.12' # add delta x
568
+ elsif @version >= '0.1.12' # add delta x
520
569
  rows = @xls.sheet('Variables').parse(enabled: '# variable',
521
570
  measure_name_or_var_type: 'type',
522
571
  measure_file_name_or_var_display_name: 'parameter display name.*',
@@ -1,5 +1,5 @@
1
1
  module OpenStudio
2
2
  module Analysis
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -6,6 +6,7 @@ require 'erb'
6
6
  require 'zip'
7
7
  require 'semantic'
8
8
  require 'logger'
9
+ require 'pp'
9
10
 
10
11
  # core
11
12
  require 'openstudio/analysis/server_api'