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

Revision history [back]

Invalid weather file object when epw_file is assigned via the API

I am experiencing a strange behaviour when I assign the weather file using the SDK.

I am geneerating the model using the SDK and I assign the weather file as follows

(First, I copy all the files in working_dir)

weather_file_name = "USA_CA_San.Francisco-Presidio.994016_TMYx.2007-2021.epw"
weather_file_path = File.join("weather", weather_file_name)
FileUtils.cp(weather_file_path, File.join(working_dir, weather_file_name))
epw_file = OpenStudio::EpwFile.load(OpenStudio::Path.new(weather_file_path), true)
OpenStudio::Model::WeatherFile::setWeatherFile(model, epw_file.get)

I run the simulation with

workflow_path = File.join(working_dir, "workflow.osw")
`openstudio run -w #{workflow_path}`

Everything works fine and the correct weather file is used in the simulation. Also, the content of the osm model shows the lines

OS:WeatherFile,
  {67db8403-241d-4616-83a2-c7d3177aa76a}, !- Handle
  San.Francisco-Presidio,                 !- City
  CA,                                     !- State Province Region
  USA,                                    !- Country
  SRC-TMYx,                               !- Data Source
  994016,                                 !- WMO Number
  37.8043,                                !- Latitude {deg}
  -122.4749,                              !- Longitude {deg}
  -8,                                     !- Time Zone {hr}
  63,                                     !- Elevation {m}
  weather/USA_CA_San.Francisco-Presidio.994016_TMYx.2007-2021.epw, !- Url
  47E9BF69,                               !- Checksum
  ,                                       !- Start Date Actual Year
  Sunday;                                 !- Start Day of Week

However, if I save the model with model.save(path, true) and I open it with the Openstudio application, I get this error

image description

Any suggestion on what I am doing wrong? I had a look at the change location measure. Do I need to do something similar and update all the properties of the weather object?