Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

Here's how you would load DDY file, and try to limit yourself to the two most common design days:

  if !OpenStudio::exists(ddy_path)
     raise "Path doesn't exist: #{ddy_path}"
  end
  ddy_idf = OpenStudio::IdfFile::load(ddy_path, "EnergyPlus".to_IddFileType).get
  ddy_workspace = OpenStudio::Workspace.new(ddy_idf)
  reverse_translator = OpenStudio::EnergyPlus::ReverseTranslator.new()
  ddy_model = reverse_translator.translateWorkspace(ddy_workspace)

  # Try to limit to the two main design days
  ddy_objects = ddy_model.getDesignDays().select { |d| d.name.get.include?('.4% Condns DB') || d.name.get.include?('99.6% Condns DB') }
  # Otherwise, get all .4% and 99.6%
  if ddy_objects.size < 2
    ddy_objects = ddy_model.getDesignDays().select { |d| d.name.get.include?('.4%') || d.name.get.include?('99.6%') }
  end
  #add the objects in the ddy file to the model
  model.addObjects(ddy_objects)

This is loosely adapted from what we do in OpenStudio-resources, where we look at the workflow.osw to find the EPW name and load the matching DDY file next to it. See code here