urbanopt-scenario 0.3.0 → 0.4.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +2 -2
  3. data/.gitignore +2 -0
  4. data/CHANGELOG.md +32 -0
  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 +1 -1
  10. data/README.md +1 -1
  11. data/Rakefile +1 -1
  12. data/docs/README.md +1 -1
  13. data/docs/package-lock.json +2499 -2322
  14. data/docs/package.json +13 -9
  15. data/lib/urbanopt-scenario.rb +1 -1
  16. data/lib/urbanopt/scenario.rb +2 -1
  17. data/lib/urbanopt/scenario/default_reports.rb +3 -8
  18. data/lib/urbanopt/scenario/extension.rb +1 -1
  19. data/lib/urbanopt/scenario/logger.rb +1 -1
  20. data/lib/urbanopt/scenario/scenario_base.rb +1 -1
  21. data/lib/urbanopt/scenario/scenario_csv.rb +22 -9
  22. data/lib/urbanopt/scenario/scenario_datapoint_base.rb +8 -1
  23. data/lib/urbanopt/scenario/scenario_post_processor_base.rb +1 -1
  24. data/lib/urbanopt/scenario/scenario_post_processor_default.rb +81 -8
  25. data/lib/urbanopt/scenario/scenario_post_processor_opendss.rb +6 -7
  26. data/lib/urbanopt/scenario/scenario_runner_base.rb +2 -2
  27. data/lib/urbanopt/scenario/scenario_runner_osw.rb +23 -9
  28. data/lib/urbanopt/scenario/scenario_visualization.rb +236 -0
  29. data/lib/urbanopt/scenario/simulation_dir_base.rb +1 -1
  30. data/lib/urbanopt/scenario/simulation_dir_osw.rb +2 -5
  31. data/lib/urbanopt/scenario/simulation_mapper_base.rb +1 -1
  32. data/lib/urbanopt/scenario/version.rb +2 -2
  33. data/package-lock.json +3 -0
  34. data/urbanopt-scenario-gem.gemspec +10 -6
  35. metadata +73 -46
  36. data/doc_templates/LICENSE.md +0 -27
  37. data/doc_templates/README.md.erb +0 -42
  38. data/doc_templates/copyright_erb.txt +0 -31
  39. data/doc_templates/copyright_js.txt +0 -4
  40. data/doc_templates/copyright_ruby.txt +0 -29
  41. data/lib/measures/.rubocop.yml +0 -5
  42. data/lib/measures/default_feature_reports/LICENSE.md +0 -27
  43. data/lib/measures/default_feature_reports/README.md +0 -26
  44. data/lib/measures/default_feature_reports/README.md.erb +0 -42
  45. data/lib/measures/default_feature_reports/measure.rb +0 -1013
  46. data/lib/measures/default_feature_reports/measure.xml +0 -160
  47. data/lib/urbanopt/scenario/default_reports/construction_cost.rb +0 -169
  48. data/lib/urbanopt/scenario/default_reports/date.rb +0 -97
  49. data/lib/urbanopt/scenario/default_reports/distributed_generation.rb +0 -379
  50. data/lib/urbanopt/scenario/default_reports/end_use.rb +0 -159
  51. data/lib/urbanopt/scenario/default_reports/end_uses.rb +0 -140
  52. data/lib/urbanopt/scenario/default_reports/feature_report.rb +0 -267
  53. data/lib/urbanopt/scenario/default_reports/generator.rb +0 -92
  54. data/lib/urbanopt/scenario/default_reports/location.rb +0 -99
  55. data/lib/urbanopt/scenario/default_reports/logger.rb +0 -44
  56. data/lib/urbanopt/scenario/default_reports/power_distribution.rb +0 -102
  57. data/lib/urbanopt/scenario/default_reports/program.rb +0 -265
  58. data/lib/urbanopt/scenario/default_reports/reporting_period.rb +0 -304
  59. data/lib/urbanopt/scenario/default_reports/scenario_report.rb +0 -317
  60. data/lib/urbanopt/scenario/default_reports/schema/README.md +0 -33
  61. data/lib/urbanopt/scenario/default_reports/schema/scenario_csv_columns.txt +0 -34
  62. data/lib/urbanopt/scenario/default_reports/schema/scenario_schema.json +0 -857
  63. data/lib/urbanopt/scenario/default_reports/solar_pv.rb +0 -93
  64. data/lib/urbanopt/scenario/default_reports/storage.rb +0 -105
  65. data/lib/urbanopt/scenario/default_reports/timeseries_csv.rb +0 -299
  66. data/lib/urbanopt/scenario/default_reports/validator.rb +0 -97
  67. 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