urbanopt-scenario 0.3.0.pre1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +3 -3
  3. data/.gitignore +2 -0
  4. data/CHANGELOG.md +60 -2
  5. data/CONTRIBUTING.md +1 -1
  6. data/Gemfile +33 -17
  7. data/Jenkinsfile +1 -1
  8. data/LICENSE.md +1 -1
  9. data/RDOC_MAIN.md +2 -2
  10. data/README.md +1 -1
  11. data/Rakefile +1 -1
  12. data/docs/.vuepress/components/InnerJsonSchema.vue +7 -15
  13. data/docs/.vuepress/config.js +13 -9
  14. data/docs/.vuepress/highlight.js +1 -1
  15. data/docs/.vuepress/json-schema-deref-loader.js +22 -0
  16. data/docs/README.md +2 -2
  17. data/docs/package-lock.json +2384 -2323
  18. data/docs/package.json +12 -8
  19. data/lib/urbanopt-scenario.rb +1 -1
  20. data/lib/urbanopt/scenario.rb +2 -1
  21. data/lib/urbanopt/scenario/default_reports.rb +3 -8
  22. data/lib/urbanopt/scenario/extension.rb +6 -4
  23. data/lib/urbanopt/scenario/logger.rb +1 -1
  24. data/lib/urbanopt/scenario/scenario_base.rb +5 -5
  25. data/lib/urbanopt/scenario/scenario_csv.rb +29 -17
  26. data/lib/urbanopt/scenario/scenario_datapoint_base.rb +12 -5
  27. data/lib/urbanopt/scenario/scenario_post_processor_base.rb +3 -3
  28. data/lib/urbanopt/scenario/scenario_post_processor_default.rb +121 -11
  29. data/lib/urbanopt/scenario/scenario_post_processor_opendss.rb +13 -14
  30. data/lib/urbanopt/scenario/scenario_runner_base.rb +8 -7
  31. data/lib/urbanopt/scenario/scenario_runner_osw.rb +29 -13
  32. data/lib/urbanopt/scenario/scenario_visualization.rb +235 -0
  33. data/lib/urbanopt/scenario/simulation_dir_base.rb +4 -4
  34. data/lib/urbanopt/scenario/simulation_dir_osw.rb +6 -13
  35. data/lib/urbanopt/scenario/simulation_mapper_base.rb +4 -4
  36. data/lib/urbanopt/scenario/version.rb +2 -2
  37. data/package-lock.json +3 -0
  38. data/urbanopt-scenario-gem.gemspec +11 -10
  39. metadata +80 -57
  40. data/doc_templates/LICENSE.md +0 -27
  41. data/doc_templates/README.md.erb +0 -42
  42. data/doc_templates/copyright_erb.txt +0 -31
  43. data/doc_templates/copyright_js.txt +0 -4
  44. data/doc_templates/copyright_ruby.txt +0 -29
  45. data/docs/.vuepress/components/ScenarioSchema.vue +0 -12
  46. data/docs/schemas/scenario-schema.md +0 -3
  47. data/lib/measures/.rubocop.yml +0 -5
  48. data/lib/measures/default_feature_reports/LICENSE.md +0 -27
  49. data/lib/measures/default_feature_reports/README.md +0 -56
  50. data/lib/measures/default_feature_reports/README.md.erb +0 -42
  51. data/lib/measures/default_feature_reports/measure.rb +0 -1006
  52. data/lib/measures/default_feature_reports/measure.xml +0 -143
  53. data/lib/measures/default_feature_reports/tests/USA_CO_Golden-NREL.724666_TMY3.epw +0 -8768
  54. data/lib/measures/default_feature_reports/tests/default_feature_reports_test.rb +0 -238
  55. data/lib/measures/default_feature_reports/tests/example_model.osm +0 -4378
  56. data/lib/urbanopt/scenario/default_reports/construction_cost.rb +0 -169
  57. data/lib/urbanopt/scenario/default_reports/date.rb +0 -97
  58. data/lib/urbanopt/scenario/default_reports/distributed_generation.rb +0 -379
  59. data/lib/urbanopt/scenario/default_reports/end_use.rb +0 -159
  60. data/lib/urbanopt/scenario/default_reports/end_uses.rb +0 -140
  61. data/lib/urbanopt/scenario/default_reports/feature_report.rb +0 -267
  62. data/lib/urbanopt/scenario/default_reports/generator.rb +0 -92
  63. data/lib/urbanopt/scenario/default_reports/location.rb +0 -99
  64. data/lib/urbanopt/scenario/default_reports/logger.rb +0 -44
  65. data/lib/urbanopt/scenario/default_reports/power_distribution.rb +0 -102
  66. data/lib/urbanopt/scenario/default_reports/program.rb +0 -266
  67. data/lib/urbanopt/scenario/default_reports/reporting_period.rb +0 -305
  68. data/lib/urbanopt/scenario/default_reports/scenario_report.rb +0 -317
  69. data/lib/urbanopt/scenario/default_reports/schema/README.md +0 -33
  70. data/lib/urbanopt/scenario/default_reports/schema/scenario_csv_columns.txt +0 -32
  71. data/lib/urbanopt/scenario/default_reports/schema/scenario_schema.json +0 -857
  72. data/lib/urbanopt/scenario/default_reports/solar_pv.rb +0 -93
  73. data/lib/urbanopt/scenario/default_reports/storage.rb +0 -105
  74. data/lib/urbanopt/scenario/default_reports/timeseries_csv.rb +0 -299
  75. data/lib/urbanopt/scenario/default_reports/validator.rb +0 -97
  76. data/lib/urbanopt/scenario/default_reports/wind.rb +0 -92
@@ -1,97 +0,0 @@
1
- # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
29
- # *********************************************************************************
30
-
31
- require 'json'
32
-
33
- module URBANopt
34
- module Scenario
35
- module DefaultReports
36
- class Validator
37
- @@schema = nil
38
-
39
- # Initialize the root directory
40
- def initialize
41
- super
42
-
43
- @root_dir = File.absolute_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..'))
44
-
45
- @instance_lock = Mutex.new
46
- @@schema ||= schema
47
- end
48
-
49
- # Return the absolute path of the default reports files
50
- def files_dir
51
- File.absolute_path(File.join(@root_dir, 'lib/urbanopt/scenario/default_reports/'))
52
- end
53
-
54
- # return path to schema file
55
- def schema_file
56
- File.join(files_dir, 'schema/scenario_schema.json')
57
- end
58
-
59
- # return schema
60
- def schema
61
- @instance_lock.synchronize do
62
- if @@schema.nil?
63
- File.open(schema_file, 'r') do |f|
64
- @@schema = JSON.parse(f.read, symbolize_names: true)
65
- end
66
- end
67
- end
68
-
69
- @@schema
70
- end
71
-
72
- ##
73
- # validate data against schema
74
- ##
75
- # [parameters:]
76
- # +schema+ - _Hash_ - A hash of the JSON scenario_schema.
77
- # +data+ - _Hash_ - A hash of the data to be validated against scenario_schema.
78
- ##
79
- def validate(schema, data)
80
- JSON::Validator.fully_validate(schema, data)
81
- end
82
-
83
- # check if the schema is valid
84
- def schema_valid?
85
- metaschema = JSON::Validator.validator_for_name('draft6').metaschema
86
- JSON::Validator.validate(metaschema, @@schema)
87
- end
88
-
89
- # return detailed schema validation errors
90
- def schema_validation_errors
91
- metaschema = JSON::Validator.validator_for_name('draft6').metaschema
92
- JSON::Validator.fully_validate(metaschema, @@schema)
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,92 +0,0 @@
1
- # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
- # contributors. All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without modification,
6
- # are permitted provided that the following conditions are met:
7
- #
8
- # Redistributions of source code must retain the above copyright notice, this list
9
- # of conditions and the following disclaimer.
10
- #
11
- # Redistributions in binary form must reproduce the above copyright notice, this
12
- # list of conditions and the following disclaimer in the documentation and/or other
13
- # materials provided with the distribution.
14
- #
15
- # Neither the name of the copyright holder nor the names of its contributors may be
16
- # used to endorse or promote products derived from this software without specific
17
- # prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
- # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
- # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
- # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
- # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
- # OF THE POSSIBILITY OF SUCH DAMAGE.
29
- # *********************************************************************************
30
-
31
- require 'json'
32
- require 'json-schema'
33
-
34
- module URBANopt
35
- module Scenario
36
- module DefaultReports
37
- ##
38
- # Onsite wind system attributes
39
- ##
40
- class Wind
41
- ##
42
- # _Float_ - power capacity in kilowatts
43
- #
44
- attr_accessor :size_kw
45
-
46
- ##
47
- # Initialize Wind attributes from a hash. Wind attributes currently are limited to power capacity.
48
- ##
49
- # [parameters:]
50
- #
51
- # * +hash+ - _Hash_ - A hash containting a +:size_kw+ key/value pair which represents the nameplate capacity in kilowatts (kW)
52
- #
53
- def initialize(hash = {})
54
- hash.delete_if { |k, v| v.nil? }
55
-
56
- @size_kw = hash[:size_kw]
57
-
58
- # initialize class variables @@validator and @@schema
59
- @@validator ||= Validator.new
60
- @@schema ||= @@validator.schema
61
-
62
- # initialize @@logger
63
- @@logger ||= URBANopt::Scenario::DefaultReports.logger
64
- end
65
-
66
- ##
67
- # Convert to a Hash equivalent for JSON serialization
68
- ##
69
- def to_hash
70
- result = {}
71
-
72
- result[:size_kw] = @size_kw if @size_kw
73
-
74
- return result
75
- end
76
-
77
- ##
78
- # Merge Wind systems
79
- ##
80
- def self.add_wind(existing_wind, new_wind)
81
- if existing_wind.size_kw.nil? && new_wind.size_kw.nil?
82
- existing_wind.size_kw = nil
83
- else
84
- existing_wind.size_kw = (existing_wind.size_kw || 0) + (new_wind.size_kw || 0)
85
- end
86
-
87
- return existing_wind
88
- end
89
- end
90
- end
91
- end
92
- end