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

Invalid weather file object when epw_file is assigned via the API

asked 2022-10-27 01:52:24 -0500

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(, 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

  {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, 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?

edit retag flag offensive close merge delete


Does it work if you change your weather_file_path to be an absolute (not relative) path?

shorowit's avatar shorowit  ( 2022-10-27 06:04:13 -0500 )edit

It does actually. Thanks!

Mortar IO's avatar Mortar IO  ( 2022-10-27 10:52:06 -0500 )edit

If you want to follow what the OSApp does, you can see my answer here: The same code can be used with minimal adjustments in Ruby.

Julien Marrec's avatar Julien Marrec  ( 2023-03-07 05:05:01 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2023-02-27 23:34:44 -0500

It should work if you change your weather_file_path to be an absolute (not relative) path.

(Moved comment to an answer.)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Question Tools

1 follower


Asked: 2022-10-27 01:52:24 -0500

Seen: 111 times

Last updated: Mar 07