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.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/openstudio-standards/weather/stat_file.rb', line 15

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.



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

def autumn_months
  @autumn_months
end

#cdd10Object

Returns the value of attribute cdd10.



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

def cdd10
  @cdd10
end

#cdd18Object

Returns the value of attribute cdd18.



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

def cdd18
  @cdd18
end

#climate_zoneObject

Returns the value of attribute climate_zone.



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

def climate_zone
  @climate_zone
end

#cooling_design_infoObject

Returns the value of attribute cooling_design_info.



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

def cooling_design_info
  @cooling_design_info
end

#delta_dry_bulbObject

Returns the value of attribute delta_dry_bulb.



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

def delta_dry_bulb
  @delta_dry_bulb
end

#elevationObject

Returns the value of attribute elevation.



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

def elevation
  @elevation
end

#extremes_design_infoObject

Returns the value of attribute extremes_design_info.



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

def extremes_design_info
  @extremes_design_info
end

#gmtObject

Returns the value of attribute gmt.



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

def gmt
  @gmt
end

#hdd10Object

Returns the value of attribute hdd10.



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

def hdd10
  @hdd10
end

#hdd18Object

Returns the value of attribute hdd18.



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

def hdd18
  @hdd18
end

#heating_design_infoObject

Returns the value of attribute heating_design_info.



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

def heating_design_info
  @heating_design_info
end

#latObject

Returns the value of attribute lat.



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

def lat
  @lat
end

#lonObject

Returns the value of attribute lon.



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

def lon
  @lon
end

#mean_dry_bulbObject

Returns the value of attribute mean_dry_bulb.



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

def mean_dry_bulb
  @mean_dry_bulb
end

#monthly_dry_bulbObject

Returns the value of attribute monthly_dry_bulb.



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

def monthly_dry_bulb
  @monthly_dry_bulb
end

#monthly_lagged_dry_bulbObject

Returns the value of attribute monthly_lagged_dry_bulb.



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

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.



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

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.



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

def monthly_undis_ground_temps_4p0m
  @monthly_undis_ground_temps_4p0m
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#spring_monthsObject

Returns the value of attribute spring_months.



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

def spring_months
  @spring_months
end

#standardObject

Returns the value of attribute standard.



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

def standard
  @standard
end

#summer_wet_monthsObject

Returns the value of attribute summer_wet_months.



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

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.



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

def typical_autumn_week
  @typical_autumn_week
end

#typical_spring_weekObject

Returns the value of attribute typical_spring_week.



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

def typical_spring_week
  @typical_spring_week
end

#typical_summer_wet_weekObject

Returns the value of attribute typical_summer_wet_week.



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

def typical_summer_wet_week
  @typical_summer_wet_week
end

#typical_winter_dry_weekObject

Returns the value of attribute typical_winter_dry_week.



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

def typical_winter_dry_week
  @typical_winter_dry_week
end

#validObject

Returns the value of attribute valid.



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

def valid
  @valid
end

#winter_dry_monthsObject

Returns the value of attribute winter_dry_months.



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

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



52
53
54
55
56
# File 'lib/openstudio-standards/weather/stat_file.rb', line 52

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



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

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

  delta_t.to_f
end

#mean_dry_bulb_calcObject

the mean of the mean monthly dry bulbs



116
117
118
119
120
121
122
123
124
125
# File 'lib/openstudio-standards/weather/stat_file.rb', line 116

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

  mean.to_f
end

#monthly_lagged_dry_bulb_calcObject

ground temps as monthly dry bulb tempreature lagged 3 months



105
106
107
108
109
110
111
112
113
# File 'lib/openstudio-standards/weather/stat_file.rb', line 105

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

  lagged_temperatures
end

#outputObject

Output for debugging stat routines.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/openstudio-standards/weather/stat_file.rb', line 59

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



96
97
98
# File 'lib/openstudio-standards/weather/stat_file.rb', line 96

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

#valid?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/openstudio-standards/weather/stat_file.rb', line 100

def valid?
  return @valid
end