Module: OpenstudioStandards::Weather

Defined in:
lib/openstudio-standards/weather/information.rb

Information collapse

Class Method Details

.model_get_ashrae_climate_zone_number(model) ⇒ Integer

get the ASHRAE climate zone number

Parameters:

  • model (OpenStudio::Model::Model)

    OpenStudio model object

Returns:

  • (Integer)

    ASHRAE climate zone number, 0-8



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/openstudio-standards/weather/information.rb', line 10

def self.model_get_ashrae_climate_zone_number(model)
  # get ashrae climate zone from model

  ashrae_climate_zone = ''
  model.getClimateZones.climateZones.each do |climate_zone|
    if climate_zone.institution == 'ASHRAE'
      ashrae_climate_zone = climate_zone.value
    end
  end

  if ashrae_climate_zone == ''
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Weather', 'Please assign an ASHRAE Climate Zone to your model.')
    return false
  else
    cz_number = ashrae_climate_zone.split(//).first.to_i
  end

  # expected climate zone number should be 0 through 8

  if ![0, 1, 2, 3, 4, 5, 6, 7, 8].include? cz_number
    OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.Weather', 'ASHRAE climate zone number is not within expected range of 1 to 8.')
    return false
  end

  return cz_number
end