Class: OpenstudioStandards::Weather::StatFile

Inherits:
Object
  • Object
show all
Defined in:
lib/openstudio-standards/weather/stat_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ StatFile

Returns a new instance of StatFile.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/openstudio-standards/weather/stat_file.rb', line 37

def initialize(path)
  @text = ''
  @path = Pathname.new(path)
  @valid = false
  @lat = nil
  @lon = nil
  @gmt = nil
  @elevation = nil
  @hdd18 = nil
  @cdd18 = nil
  @hdd10 = nil
  @cdd10 = nil
  @monthly_dry_bulb = []
  @monthly_lagged_dry_bulb = []
  @delta_dry_bulb = nil
  @mean_dry_bulb = nil
  @heating_design_info = []
  @cooling_design_info  = []
  @extremes_design_info = []
  @climate_zone = []
  @standard = []
  @summer_wet_months = []
  @winter_dry_months = []
  @autumn_months = []
  @spring_months = []
  @typical_summer_wet_week = []
  @typical_winter_dry_week = []
  @typical_autumn_week = []
  @typical_spring_week = []
  @monthly_undis_ground_temps_0p5m = []
  @monthly_undis_ground_temps_4p0m = []
  init
end

Instance Attribute Details

#autumn_monthsObject

Returns the value of attribute autumn_months.



28
29
30
# File 'lib/openstudio-standards/weather/stat_file.rb', line 28

def autumn_months
  @autumn_months
end

#cdd10Object

Returns the value of attribute cdd10.



20
21
22
# File 'lib/openstudio-standards/weather/stat_file.rb', line 20

def cdd10
  @cdd10
end

#cdd18Object

Returns the value of attribute cdd18.



18
19
20
# File 'lib/openstudio-standards/weather/stat_file.rb', line 18

def cdd18
  @cdd18
end

#climate_zoneObject

Returns the value of attribute climate_zone.



24
25
26
# File 'lib/openstudio-standards/weather/stat_file.rb', line 24

def climate_zone
  @climate_zone
end

#cooling_design_infoObject

Returns the value of attribute cooling_design_info.



22
23
24
# File 'lib/openstudio-standards/weather/stat_file.rb', line 22

def cooling_design_info
  @cooling_design_info
end

#delta_dry_bulbObject

Returns the value of attribute delta_dry_bulb.



15
16
17
# File 'lib/openstudio-standards/weather/stat_file.rb', line 15

def delta_dry_bulb
  @delta_dry_bulb
end

#elevationObject

Returns the value of attribute elevation.



11
12
13
# File 'lib/openstudio-standards/weather/stat_file.rb', line 11

def elevation
  @elevation
end

#extremes_design_infoObject

Returns the value of attribute extremes_design_info.



23
24
25
# File 'lib/openstudio-standards/weather/stat_file.rb', line 23

def extremes_design_info
  @extremes_design_info
end

#gmtObject

Returns the value of attribute gmt.



12
13
14
# File 'lib/openstudio-standards/weather/stat_file.rb', line 12

def gmt
  @gmt
end

#hdd10Object

Returns the value of attribute hdd10.



19
20
21
# File 'lib/openstudio-standards/weather/stat_file.rb', line 19

def hdd10
  @hdd10
end

#hdd18Object

Returns the value of attribute hdd18.



17
18
19
# File 'lib/openstudio-standards/weather/stat_file.rb', line 17

def hdd18
  @hdd18
end

#heating_design_infoObject

Returns the value of attribute heating_design_info.



21
22
23
# File 'lib/openstudio-standards/weather/stat_file.rb', line 21

def heating_design_info
  @heating_design_info
end

#latObject

Returns the value of attribute lat.



9
10
11
# File 'lib/openstudio-standards/weather/stat_file.rb', line 9

def lat
  @lat
end

#lonObject

Returns the value of attribute lon.



10
11
12
# File 'lib/openstudio-standards/weather/stat_file.rb', line 10

def lon
  @lon
end

#mean_dry_bulbObject

Returns the value of attribute mean_dry_bulb.



16
17
18
# File 'lib/openstudio-standards/weather/stat_file.rb', line 16

def mean_dry_bulb
  @mean_dry_bulb
end

#monthly_dry_bulbObject

Returns the value of attribute monthly_dry_bulb.



13
14
15
# File 'lib/openstudio-standards/weather/stat_file.rb', line 13

def monthly_dry_bulb
  @monthly_dry_bulb
end

#monthly_lagged_dry_bulbObject

Returns the value of attribute monthly_lagged_dry_bulb.



14
15
16
# File 'lib/openstudio-standards/weather/stat_file.rb', line 14

def monthly_lagged_dry_bulb
  @monthly_lagged_dry_bulb
end

#monthly_undis_ground_temps_0p5mObject

Returns the value of attribute monthly_undis_ground_temps_0p5m.



34
35
36
# File 'lib/openstudio-standards/weather/stat_file.rb', line 34

def monthly_undis_ground_temps_0p5m
  @monthly_undis_ground_temps_0p5m
end

#monthly_undis_ground_temps_4p0mObject

Returns the value of attribute monthly_undis_ground_temps_4p0m.



35
36
37
# File 'lib/openstudio-standards/weather/stat_file.rb', line 35

def monthly_undis_ground_temps_4p0m
  @monthly_undis_ground_temps_4p0m
end

#pathObject

Returns the value of attribute path.



7
8
9
# File 'lib/openstudio-standards/weather/stat_file.rb', line 7

def path
  @path
end

#spring_monthsObject

Returns the value of attribute spring_months.



29
30
31
# File 'lib/openstudio-standards/weather/stat_file.rb', line 29

def spring_months
  @spring_months
end

#standardObject

Returns the value of attribute standard.



25
26
27
# File 'lib/openstudio-standards/weather/stat_file.rb', line 25

def standard
  @standard
end

#summer_wet_monthsObject

Returns the value of attribute summer_wet_months.



26
27
28
# File 'lib/openstudio-standards/weather/stat_file.rb', line 26

def summer_wet_months
  @summer_wet_months
end

#textObject

Returns the value of attribute text.



6
7
8
# File 'lib/openstudio-standards/weather/stat_file.rb', line 6

def text
  @text
end

#typical_autumn_weekObject

Returns the value of attribute typical_autumn_week.



32
33
34
# File 'lib/openstudio-standards/weather/stat_file.rb', line 32

def typical_autumn_week
  @typical_autumn_week
end

#typical_spring_weekObject

Returns the value of attribute typical_spring_week.



33
34
35
# File 'lib/openstudio-standards/weather/stat_file.rb', line 33

def typical_spring_week
  @typical_spring_week
end

#typical_summer_wet_weekObject

Returns the value of attribute typical_summer_wet_week.



30
31
32
# File 'lib/openstudio-standards/weather/stat_file.rb', line 30

def typical_summer_wet_week
  @typical_summer_wet_week
end

#typical_winter_dry_weekObject

Returns the value of attribute typical_winter_dry_week.



31
32
33
# File 'lib/openstudio-standards/weather/stat_file.rb', line 31

def typical_winter_dry_week
  @typical_winter_dry_week
end

#validObject

Returns the value of attribute valid.



8
9
10
# File 'lib/openstudio-standards/weather/stat_file.rb', line 8

def valid
  @valid
end

#winter_dry_monthsObject

Returns the value of attribute winter_dry_months.



27
28
29
# File 'lib/openstudio-standards/weather/stat_file.rb', line 27

def winter_dry_months
  @winter_dry_months
end

Class Method Details

.load(filename) ⇒ Object

load a Stat file as an instance of OpenstudioStandards::Weather::StatFile

Parameters:

  • filename (String)

    full path to Stat file



74
75
76
77
78
# File 'lib/openstudio-standards/weather/stat_file.rb', line 74

def self.load(filename)
  raise "Stat file does not exist: #{filename}" unless File.file?(filename)

  f = OpenstudioStandards::Weather::StatFile.new(filename)
end

Instance Method Details

#delta_dry_bulb_calcObject

max - min of the mean monthly dry bulbs



150
151
152
153
154
155
156
157
158
# File 'lib/openstudio-standards/weather/stat_file.rb', line 150

def delta_dry_bulb_calc
  if !@monthly_dry_bulb.empty?
    delta_t = @monthly_dry_bulb.max - @monthly_dry_bulb.min
  else
    delta_t = ''
  end

  delta_t.to_f
end

#mean_dry_bulb_calcObject

the mean of the mean monthly dry bulbs



138
139
140
141
142
143
144
145
146
147
# File 'lib/openstudio-standards/weather/stat_file.rb', line 138

def mean_dry_bulb_calc
  if !@monthly_dry_bulb.empty?
    sum = @monthly_dry_bulb.inject(:+)
    mean = sum / @monthly_dry_bulb.size
  else
    mean = ''
  end

  mean.to_f
end

#monthly_lagged_dry_bulb_calcObject

ground temps as monthly dry bulb tempreature lagged 3 months



127
128
129
130
131
132
133
134
135
# File 'lib/openstudio-standards/weather/stat_file.rb', line 127

def monthly_lagged_dry_bulb_calc
  if !@monthly_dry_bulb.empty?
    lagged_temperatures = @monthly_dry_bulb.rotate(-3)
  else
    lagged_temperatures = []
  end

  lagged_temperatures
end

#outputObject

Output for debugging stat routines.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/openstudio-standards/weather/stat_file.rb', line 81

def output
  line = ''
  line << "#{@path} , "
  line << "#{@lat} ,"
  line << "#{@lon} ,"
  line << "#{@gmt} ,"
  line << "#{@elevation} ,"
  line << "#{@hdd18} ,"
  line << "#{@cdd18} ,"
  line << "#{@hdd10} ,"
  line << "#{@cdd10} ,"
  line << "#{monthly_dry_bulb} ,"
  line << "#{monthly_lagged_dry_bulb} ,"
  line << "#{delta_dry_bulb} ,"
  line << "#{mean_dry_bulb} ,"
  line << "#{@heating_design_info} ,"
  line << "#{@cooling_design_info}  ,"
  line << "#{@extremes_design_info} ,"
  line << "#{@climate_zone} ,"
  line << "#{@standard} ,"
  line << "#{@summer_wet_months} ,"
  line << "#{@winter_dry_months} ,"
  line << "#{@autumn_months} ,"
  line << "#{@spring_months} ,"
  line << "#{@typical_summer_wet_week} ,"
  line << "#{@typical_winter_dry_week} ,"
  line << "#{@typical_autumn_week} ,"
  line << "#{@typical_spring_week} ,"
  line << "#{@monthly_undis_ground_temps_0p5m} ,"
  line << "#{@monthly_undis_ground_temps_4p0m} ,"
  line << @valid.to_s
end

#to_json(*options) ⇒ String

returns the stat data as a JSON string

Parameters:

  • options (Hash)

    options to pass to as_json

Returns:

  • (String)

    JSON-formatted string



118
119
120
# File 'lib/openstudio-standards/weather/stat_file.rb', line 118

def to_json(*options)
  as_json(*options).to_json(*options)
end

#valid?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/openstudio-standards/weather/stat_file.rb', line 122

def valid?
  return @valid
end