Module: OpenStudio::Workflow::Util::WeatherFile

Included in:
RunInitialization
Defined in:
lib/openstudio/workflow/util/weather_file.rb

Overview

The current precedence rules for weather files are defined in this module. Best practice is to only use the

#get_weather_file method, as it will be forward compatible

Instance Method Summary collapse

Instance Method Details

#get_weather_file(directory, wf, wf_search_array, model, logger = nil) ⇒ String?

Returns the weather file with precedence

Parameters:

  • directory (String)

    The directory to append all relative directories to, see #get_weather_file_from_fs

  • wf (String)

    The weather file being searched for. If not the name of the file this parameter should be the absolute path specifying it’s location

  • wf_search_array (Array)

    The set of precedence ordered relative directories to search for the wf in. A typical entry might look like ‘[’files’, ‘../../files’, ‘../../weather’]‘

  • model (Object)

    The OpenStudio::Model object to parse, see #get_weather_file_from_osm

Returns:

  • (String, nil)

    The weather file with precedence if defined, nil if not, and a failure if the wf is defined but not in the filesystem



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/openstudio/workflow/util/weather_file.rb', line 56

def get_weather_file(directory, wf, wf_search_array, model, logger = nil)
  # TODO: this logic needs some updating, weather file should come from current model, found using search paths
  logger ||= ::Logger.new($stdout) unless logger
  if wf
    weather_file = get_weather_file_from_fs(directory, wf, wf_search_array, logger)
    raise 'Could not locate the weather file in the filesystem. Please see the log' if weather_file == false
  end
  weather_file = get_weather_file_from_osm(model, logger) if weather_file.nil?
  raise 'Could not locate the weather file in the filesystem. Please see the log' if weather_file == false

  logger.warn 'The weather file could not be determined. Please see the log for details' unless weather_file
  weather_file
end