Class: EnergyPlus::DDYFile
- Inherits:
-
Object
- Object
- EnergyPlus::DDYFile
- Defined in:
- lib/energyplus/DDYFile.rb
Instance Method Summary collapse
- #cooling(typestr) ⇒ Object
- #findObjectByComment(comment) ⇒ Object
-
#get_data_source ⇒ Object
returns an array of “data source, year, and type.
-
#get_indicating_type(ddyobj) ⇒ Object
updated for ddy for EP 7.1 2012.
-
#heating(typestr) ⇒ Object
untyped enumerations for heating, cooling, and humidification make this an array, the first column of the array is the ep object, the remaining items are the “attributes and tags”.
- #humidification(typestr) ⇒ Object
-
#initialize(path) ⇒ DDYFile
constructor
A new instance of DDYFile.
- #objects ⇒ Object
- #write_idf_snippet(filename, ddyobj) ⇒ Object
Constructor Details
#initialize(path) ⇒ DDYFile
Returns a new instance of DDYFile.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/energyplus/DDYFile.rb', line 23 def initialize(path) @path = path @lines = [] if File.exists?(@path) File.open(@path) do |f| while line = f.gets @lines << line.chomp end end end end |
Instance Method Details
#cooling(typestr) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/energyplus/DDYFile.rb', line 159 def cooling(typestr) search = "Annual Cooling " + typestr obj = findObjectByComment(search) puts "[DDYFile] #{File.basename(@path.to_s)} missing cooling #{typestr}" if obj.nil? = [] << search.gsub("\\","") << search.gsub("\\","").gsub(" ","_").gsub(".","_").gsub("%","").gsub("=>","_").gsub("__","_") << obj return end |
#findObjectByComment(comment) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/energyplus/DDYFile.rb', line 61 def findObjectByComment(comment) comment = Regexp.new(comment) objects().each do |object| if object.comment =~ comment return object end end return nil end |
#get_data_source ⇒ Object
returns an array of “data source, year, and type
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/energyplus/DDYFile.rb', line 73 def get_data_source #! Using Design Conditions from "Climate Design Data 2005 ASHRAE Handbook" #! Using Design Conditions from "Climate Design Data 2009 ASHRAE Handbook" src_s = "" @lines.each_index do |i| if @lines[i] =~ /Climate Design Data [0-9]{4} ASHRAE Handbook/ src_s = @lines[i] break end end src = [] src << src_s.match("Climate Design Data [0-9]{4} ASHRAE Handbook")[0] src << src_s.match("[0-9]{4}")[0] src << "ASHRAE Handbook" return src end |
#get_indicating_type(ddyobj) ⇒ Object
updated for ddy for EP 7.1 2012
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/energyplus/DDYFile.rb', line 105 def get_indicating_type(ddyobj) val = ddyobj.fieldString(8).downcase if val == "dewpoint" res = [] res << val res << ddyobj.fieldValue(9) res << "C" elsif val == "wetbulb" res = [] res << val res << ddyobj.fieldValue(9) res << "C" elsif val == "enthalpy" res = [] res << val res << ddyobj.fieldValue(12) res << "kJ/kg" end return res end |
#heating(typestr) ⇒ Object
untyped enumerations for heating, cooling, and humidification make this an array, the first column of the array is the ep object, the remaining items are the “attributes and tags”
129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/energyplus/DDYFile.rb', line 129 def heating(typestr) search = "Annual Heating " + typestr obj = findObjectByComment(search) puts "[DDYFile] #{File.basename(@path.to_s)} missing heating #{typestr}" if obj.nil? = [] << search.gsub("\\","") << search.gsub("\\","").gsub(" ","_").gsub(".","_").gsub("%","").gsub("=>","_").gsub("__","_") << obj return end |
#humidification(typestr) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/energyplus/DDYFile.rb', line 144 def humidification(typestr) search = "Annual Humidification " + typestr obj = findObjectByComment(search) puts "[DDYFile] #{File.basename(@path.to_s)} missing humidification #{typestr}" if obj.nil? = [] << search.gsub("\\","") << search.gsub("\\","").gsub(" ","_").gsub(".","_").gsub("%","").gsub("=>","_").gsub("__","_") << obj return end |
#objects ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/energyplus/DDYFile.rb', line 35 def objects objects = [] object_fields = [] object_type = '' inobject = false object_comment = nil @lines.each_index do |i| if not inobject and @lines[i] =~ /^\s*\w/ object_fields = [] inobject = true object_type = @lines[i] if @lines[i-1] =~ /^\s*!/ object_comment = @lines[i-1] end elsif inobject and @lines[i] =~ /^[^!]*;/ object_fields << @lines[i] inobject = false objects << IdfObject.new(object_type,object_fields,object_comment) elsif inobject object_fields << @lines[i] else end end return objects end |
#write_idf_snippet(filename, ddyobj) ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/energyplus/DDYFile.rb', line 93 def write_idf_snippet(filename, ddyobj) if not ddyobj.nil? File.delete(filename) if File.exists?(filename) File.open(filename, 'w') do |fl| #add version identifier to file fl << "\nVersion,\n 7.1; ! Version Identifier \n\n" fl << ddyobj end end end |