energyplus 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/energyplus.rb +13 -0
- data/lib/energyplus/DDYFile.rb +176 -0
- data/lib/energyplus/EpErrFile.rb +123 -0
- data/lib/energyplus/EpImfFile.rb +93 -0
- data/lib/energyplus/EpwFile.rb +120 -0
- data/lib/energyplus/EsoFile.rb +129 -0
- data/lib/energyplus/IdfObject.rb +55 -0
- data/lib/energyplus/KmlFile.rb +168 -0
- data/lib/energyplus/ResultsLog.rb +99 -0
- data/lib/energyplus/SchedulesCSV.rb +169 -0
- data/lib/energyplus/SlabGtpFile.rb +100 -0
- data/lib/energyplus/SlabIdfFile.rb +78 -0
- data/lib/energyplus/StatFile.rb +192 -0
- data/lib/energyplus/version.rb +22 -0
- metadata +77 -0
@@ -0,0 +1,169 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
require 'pathname'
|
21
|
+
require 'csv'
|
22
|
+
require 'Formats/Formats.rb'
|
23
|
+
|
24
|
+
def make_schedule_name(s)
|
25
|
+
schedule_name = s
|
26
|
+
schedule_name = schedule_name.gsub(/[A-Z][a-z]/, ' \0').lstrip
|
27
|
+
schedule_name = schedule_name.gsub(/[a-z][A-Z]/) {|s| "" << s[0] << " " << s[1]}
|
28
|
+
schedule_name = schedule_name.gsub('_', ' ').gsub('-',' ').gsub(',',' ').gsub('()', '')
|
29
|
+
schedule_name = schedule_name.split(' ').each{|p| p.capitalize!}.join(' ')
|
30
|
+
return schedule_name
|
31
|
+
end
|
32
|
+
|
33
|
+
class Schedule
|
34
|
+
attr_accessor :name, :type, :table, :hours_per_year
|
35
|
+
|
36
|
+
def initialize(s)
|
37
|
+
@lines = s.split("\n")
|
38
|
+
@name = make_schedule_name(@lines[0])
|
39
|
+
@type = @lines[1]
|
40
|
+
|
41
|
+
@table = Array.new
|
42
|
+
this_table = Array.new
|
43
|
+
duration = ""
|
44
|
+
this_cols = 0
|
45
|
+
open = false
|
46
|
+
multi_duration = false
|
47
|
+
(2..@lines.length-1).each do |idx|
|
48
|
+
parts = CSV.parse_line(@lines[idx])
|
49
|
+
|
50
|
+
if parts[0].include?('Through')
|
51
|
+
if open
|
52
|
+
if (not this_table[-1][0] == 'Total Hours/Year')
|
53
|
+
this_table.push(Array.new)
|
54
|
+
this_table[-1].push('Total Hours/Year') if not multi_duration
|
55
|
+
(1..this_cols-1).each {|i| this_table[-1].push("") }
|
56
|
+
end
|
57
|
+
multi_duration = true
|
58
|
+
close_table(this_table)
|
59
|
+
end
|
60
|
+
this_table = Array.new
|
61
|
+
duration = parts[0]
|
62
|
+
open = true
|
63
|
+
|
64
|
+
elsif parts[0]==('Hour')
|
65
|
+
this_table.push(Array.new)
|
66
|
+
this_cols = parts.length
|
67
|
+
this_table[-1].push(parts[0]) if not multi_duration
|
68
|
+
(1..this_cols-1).each {|i| this_table[-1].push(parts[i] + " (" + duration + ")") }
|
69
|
+
|
70
|
+
elsif parts[0].include?('Total Hours/Day')
|
71
|
+
this_table.push(Array.new)
|
72
|
+
this_table[-1].push(parts[0]) if not multi_duration
|
73
|
+
(1..this_cols-1).each {|i| this_table[-1].push(custom_print(parts[i].to_f, 4)) }
|
74
|
+
|
75
|
+
elsif parts[0].include?('Total Hours/Week')
|
76
|
+
this_table.push(Array.new)
|
77
|
+
this_table[-1].push(parts[0]) if not multi_duration
|
78
|
+
this_table[-1].push(custom_print(parts[1].to_f, 4))
|
79
|
+
(2..this_cols-1).each {|i| this_table[-1].push("") }
|
80
|
+
|
81
|
+
elsif parts[0].include?('Total Hours/Year')
|
82
|
+
@hours_per_year = parts[1].to_f
|
83
|
+
|
84
|
+
this_table.push(Array.new)
|
85
|
+
this_table[-1].push(parts[0]) if not multi_duration
|
86
|
+
this_table[-1].push(custom_print(parts[1].to_f, 4))
|
87
|
+
(2..this_cols-1).each {|i| this_table[-1].push("") }
|
88
|
+
else
|
89
|
+
parts.delete_at(0) if multi_duration
|
90
|
+
this_table.push(parts)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
close_table(this_table)
|
94
|
+
#print_table if multi_duration
|
95
|
+
end
|
96
|
+
|
97
|
+
def close_table(this_table)
|
98
|
+
if @table.empty?
|
99
|
+
@table = this_table
|
100
|
+
else
|
101
|
+
@table.each_index do |idx|
|
102
|
+
@table[idx].concat(this_table[idx])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def print_table
|
108
|
+
puts @name
|
109
|
+
puts @type
|
110
|
+
@table.each_index do |idx|
|
111
|
+
puts @table[idx].join(', ')
|
112
|
+
end
|
113
|
+
puts
|
114
|
+
end
|
115
|
+
|
116
|
+
def to_s
|
117
|
+
@lines.join("\n")
|
118
|
+
end
|
119
|
+
def hash
|
120
|
+
to_s.hash
|
121
|
+
end
|
122
|
+
def ==(other)
|
123
|
+
eql?(other)
|
124
|
+
end
|
125
|
+
def eql?(other)
|
126
|
+
other.is_a?(Schedule) && to_s == other.to_s
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
class SchedulesCSV
|
132
|
+
attr_accessor :schedules
|
133
|
+
|
134
|
+
def initialize(path)
|
135
|
+
@schedules = Hash.new
|
136
|
+
if File.exists?(path)
|
137
|
+
@path = Pathname.new(path)
|
138
|
+
process_schedules
|
139
|
+
else
|
140
|
+
@path = nil
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def process_schedules
|
145
|
+
File.open(@path) do |f|
|
146
|
+
name = ""
|
147
|
+
schedule_string = ""
|
148
|
+
while line = f.gets
|
149
|
+
|
150
|
+
if line.chomp.empty?
|
151
|
+
if not name.empty?
|
152
|
+
new_schedule = Schedule.new(schedule_string)
|
153
|
+
@schedules[new_schedule.name] = new_schedule
|
154
|
+
end
|
155
|
+
name = ""
|
156
|
+
schedule_string = ""
|
157
|
+
next
|
158
|
+
end
|
159
|
+
|
160
|
+
if name.empty?
|
161
|
+
name = line.chomp
|
162
|
+
schedule_string = line
|
163
|
+
else
|
164
|
+
schedule_string += line
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
module EnergyPlus
|
21
|
+
require 'pathname'
|
22
|
+
|
23
|
+
class SlabGtpFile
|
24
|
+
attr_accessor :convergence
|
25
|
+
attr_accessor :months
|
26
|
+
attr_accessor :averageTemps
|
27
|
+
|
28
|
+
def initialize(path)
|
29
|
+
@path = Pathname.new(path)
|
30
|
+
@convergence = false
|
31
|
+
@months = []
|
32
|
+
@averageTemps = []
|
33
|
+
init
|
34
|
+
end
|
35
|
+
|
36
|
+
def getGroundTemps
|
37
|
+
result = "Site:GroundTemperature:BuildingSurface,\n"
|
38
|
+
result+= " #{@averageTemps[0]}, !- January Ground Temperature {C}\n"
|
39
|
+
result+= " #{@averageTemps[1]}, !- February Ground Temperature {C}\n"
|
40
|
+
result+= " #{@averageTemps[2]}, !- March Ground Temperature {C}\n"
|
41
|
+
result+= " #{@averageTemps[3]}, !- April Ground Temperature {C}\n"
|
42
|
+
result+= " #{@averageTemps[4]}, !- May Ground Temperature {C}\n"
|
43
|
+
result+= " #{@averageTemps[5]}, !- June Ground Temperature {C}\n"
|
44
|
+
result+= " #{@averageTemps[6]}, !- July Ground Temperature {C}\n"
|
45
|
+
result+= " #{@averageTemps[7]}, !- August Ground Temperature {C}\n"
|
46
|
+
result+= " #{@averageTemps[8]}, !- September Ground Temperature {C}\n"
|
47
|
+
result+= " #{@averageTemps[9]}, !- October Ground Temperature {C}\n"
|
48
|
+
result+= " #{@averageTemps[10]}, !- November Ground Temperature {C}\n"
|
49
|
+
result+= " #{@averageTemps[11]}; !- December Ground Temperature {C}\n"
|
50
|
+
return result
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def init
|
56
|
+
if @path.exist?
|
57
|
+
File.open(@path) do |f|
|
58
|
+
text = f.read
|
59
|
+
parse(text)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def parse(text)
|
65
|
+
# check for convergence
|
66
|
+
regex = /(Convergence has been gained.).*\n/
|
67
|
+
if text.match(regex) then
|
68
|
+
@convergence = true
|
69
|
+
end
|
70
|
+
|
71
|
+
#parse out the monthly values
|
72
|
+
startRegex = /\s*Month\s*TAverage\s*TPerimeter\s*TCore\s*TInside\s*AverageFlux\s*PerimeterFlux\s*CoreFlux/
|
73
|
+
readingTable = false
|
74
|
+
numRowsRead = 0
|
75
|
+
text.each_line do |line|
|
76
|
+
if readingTable
|
77
|
+
|
78
|
+
# split each row and count as read
|
79
|
+
data = line.strip.split(/\s+/)
|
80
|
+
numRowsRead += 1
|
81
|
+
|
82
|
+
# insert into members
|
83
|
+
@months << data[2]
|
84
|
+
@averageTemps << data[1]
|
85
|
+
|
86
|
+
# only read 12 months
|
87
|
+
if numRowsRead == 12
|
88
|
+
break
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# have we started reading the table yet
|
93
|
+
if line.match(startRegex)
|
94
|
+
readingTable = true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
module EnergyPlus
|
21
|
+
require 'pathname'
|
22
|
+
|
23
|
+
class SlabIdfFile
|
24
|
+
|
25
|
+
def initialize(path)
|
26
|
+
@path = Pathname.new(path)
|
27
|
+
@initialized = false
|
28
|
+
@text = ""
|
29
|
+
init
|
30
|
+
end
|
31
|
+
|
32
|
+
def savefileas(path)
|
33
|
+
File.open(path, "w") do |f|
|
34
|
+
f << @text
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# function to alter input based on options
|
39
|
+
def setSetpoints(cdd, hdd)
|
40
|
+
#options is an array of cdd and hdd... so have to wait the values
|
41
|
+
#create a new array with the weighted values
|
42
|
+
heatSP = 21 #in deg c
|
43
|
+
coolSP = 24 #in deg c
|
44
|
+
|
45
|
+
weight = []
|
46
|
+
for i in 1..12
|
47
|
+
num = cdd * coolSP + hdd * heatSP
|
48
|
+
den = cdd + hdd
|
49
|
+
weight[i] = (num) / (den)
|
50
|
+
end
|
51
|
+
|
52
|
+
@text.gsub!("%JAN%", sprintf("%.2f", weight[1].to_s))
|
53
|
+
@text.gsub!("%FEB%", sprintf("%.2f", weight[2].to_s))
|
54
|
+
@text.gsub!("%MAR%", sprintf("%.2f", weight[3].to_s))
|
55
|
+
@text.gsub!("%APR%", sprintf("%.2f", weight[4].to_s))
|
56
|
+
@text.gsub!("%MAY%", sprintf("%.2f", weight[5].to_s))
|
57
|
+
@text.gsub!("%JUN%", sprintf("%.2f", weight[6].to_s))
|
58
|
+
@text.gsub!("%JUL%", sprintf("%.2f", weight[7].to_s))
|
59
|
+
@text.gsub!("%AUG%", sprintf("%.2f", weight[8].to_s))
|
60
|
+
@text.gsub!("%SEP%", sprintf("%.2f", weight[9].to_s))
|
61
|
+
@text.gsub!("%OCT%", sprintf("%.2f", weight[10].to_s))
|
62
|
+
@text.gsub!("%NOV%", sprintf("%.2f", weight[11].to_s))
|
63
|
+
@text.gsub!("%DEC%", sprintf("%.2f", weight[12].to_s))
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def init
|
69
|
+
@initialized = true
|
70
|
+
|
71
|
+
if @path.exist?
|
72
|
+
File.open(@path) do |f|
|
73
|
+
@text = f.read
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end #module
|
@@ -0,0 +1,192 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
20
|
+
module EnergyPlus
|
21
|
+
|
22
|
+
require 'pathname'
|
23
|
+
|
24
|
+
class StatFile
|
25
|
+
attr_accessor :valid
|
26
|
+
attr_accessor :lat
|
27
|
+
attr_accessor :lon
|
28
|
+
attr_accessor :elevation
|
29
|
+
attr_accessor :gmt
|
30
|
+
attr_accessor :monthlyDB
|
31
|
+
attr_accessor :hdd18
|
32
|
+
attr_accessor :cdd18
|
33
|
+
attr_accessor :hdd10
|
34
|
+
attr_accessor :cdd10
|
35
|
+
|
36
|
+
def initialize(path)
|
37
|
+
@path = Pathname.new(path)
|
38
|
+
@valid = false
|
39
|
+
@lat = []
|
40
|
+
@lon = []
|
41
|
+
@gmt = []
|
42
|
+
@elevation = []
|
43
|
+
@hdd18 = []
|
44
|
+
@cdd18 = []
|
45
|
+
@hdd10 = []
|
46
|
+
@cdd10 = []
|
47
|
+
@monthlyDB = []
|
48
|
+
@deltaDB = []
|
49
|
+
init
|
50
|
+
end
|
51
|
+
|
52
|
+
def valid?
|
53
|
+
return @valid
|
54
|
+
end
|
55
|
+
|
56
|
+
# the mean of the mean monthly dry bulbs
|
57
|
+
def meanDB
|
58
|
+
if not @monthlyDB.empty? then
|
59
|
+
thisSum = 0
|
60
|
+
@monthlyDB.each { |db| thisSum += db }
|
61
|
+
thisMean = thisSum/@monthlyDB.size
|
62
|
+
else
|
63
|
+
thisMean = ""
|
64
|
+
end
|
65
|
+
return thisMean
|
66
|
+
end
|
67
|
+
|
68
|
+
# max - min of the mean monthly dry bulbs
|
69
|
+
def deltaDB
|
70
|
+
if not @monthlyDB.empty? then
|
71
|
+
deltaT = @monthlyDB.max-@monthlyDB.min
|
72
|
+
else
|
73
|
+
deltaT = ""
|
74
|
+
end
|
75
|
+
|
76
|
+
return deltaT
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
# initialize
|
82
|
+
def init
|
83
|
+
if @path.exist?
|
84
|
+
File.open(@path) do |f|
|
85
|
+
text = f.read
|
86
|
+
parse(text)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def parse(text)
|
92
|
+
|
93
|
+
# get lat, lon, gmt
|
94
|
+
regex = /\{(N|S)\s*([0-9]*).\s*([0-9]*)'\}\s*\{(E|W)\s*([0-9]*).\s*([0-9]*)'\}\s*\{GMT\s*(.*)\s*Hours\}/
|
95
|
+
matchData = text.match(regex)
|
96
|
+
if matchData.nil?
|
97
|
+
puts "Can't find lat/lon/gmt"
|
98
|
+
return
|
99
|
+
else
|
100
|
+
|
101
|
+
@lat = matchData[2].to_f + (matchData[3].to_f)/60.0
|
102
|
+
if matchData[1] == 'S'
|
103
|
+
@lat = -@lat
|
104
|
+
end
|
105
|
+
|
106
|
+
@lon = matchData[5].to_f + (matchData[6].to_f)/60.0
|
107
|
+
if matchData[4] == 'W'
|
108
|
+
@lon = -@lon
|
109
|
+
end
|
110
|
+
|
111
|
+
@gmt = matchData[7]
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
# get elevation
|
116
|
+
regex = /Elevation --\s*(.*)m (above|below) sea level/
|
117
|
+
matchData = text.match(regex)
|
118
|
+
if matchData.nil?
|
119
|
+
puts "Can't find elevation"
|
120
|
+
return
|
121
|
+
else
|
122
|
+
@elevation = matchData[1].to_f
|
123
|
+
if matchData[2] == 'below'
|
124
|
+
@elevation = -@elevation
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
# get heating and cooling degree days
|
130
|
+
cdd10Regex = /-\s*(.*) annual \(standard\) cooling degree-days \(10.C baseline\)/
|
131
|
+
matchData = text.match(cdd10Regex)
|
132
|
+
if matchData.nil?
|
133
|
+
puts "Can't find CDD 10"
|
134
|
+
return
|
135
|
+
else
|
136
|
+
@cdd10 = matchData[1].to_f
|
137
|
+
end
|
138
|
+
|
139
|
+
hdd10Regex = /-\s*(.*) annual \(standard\) heating degree-days \(10.C baseline\)/
|
140
|
+
matchData = text.match(hdd10Regex)
|
141
|
+
if matchData.nil?
|
142
|
+
puts "Can't find HDD 10"
|
143
|
+
return
|
144
|
+
else
|
145
|
+
@hdd10 = matchData[1].to_f
|
146
|
+
end
|
147
|
+
|
148
|
+
cdd18Regex = /-\s*(.*) annual \(standard\) cooling degree-days \(18.3.C baseline\)/
|
149
|
+
matchData = text.match(cdd18Regex)
|
150
|
+
if matchData.nil?
|
151
|
+
puts "Can't find CDD 18"
|
152
|
+
return
|
153
|
+
else
|
154
|
+
@cdd18 = matchData[1].to_f
|
155
|
+
end
|
156
|
+
|
157
|
+
hdd18Regex = /-\s*(.*) annual \(standard\) heating degree-days \(18.3.C baseline\)/
|
158
|
+
matchData = text.match(hdd18Regex)
|
159
|
+
if matchData.nil?
|
160
|
+
puts "Can't find HDD 18"
|
161
|
+
return
|
162
|
+
else
|
163
|
+
@hdd18 = matchData[1].to_f
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
#use regex to get the temperatures
|
168
|
+
regex = /Daily Avg(.*)\n/
|
169
|
+
matchData = text.match(regex)
|
170
|
+
if matchData.nil?
|
171
|
+
puts "Can't find outdoor air temps"
|
172
|
+
return
|
173
|
+
else
|
174
|
+
# first match is outdoor air temps
|
175
|
+
monthlyTemps = matchData[1].strip.split(/\s+/)
|
176
|
+
|
177
|
+
# have to be 12 months
|
178
|
+
if monthlyTemps.size != 12
|
179
|
+
puts "Can't find outdoor air temps"
|
180
|
+
return
|
181
|
+
end
|
182
|
+
|
183
|
+
# insert as numbers
|
184
|
+
monthlyTemps.each {|temp| @monthlyDB << temp.to_f}
|
185
|
+
end
|
186
|
+
|
187
|
+
# now we are valid
|
188
|
+
@valid = true
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|