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

Invalid weather file object when epw_file is assigned via the API

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

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?

edit retag flag offensive close merge delete

Comments

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 -0600 )edit

It does actually. Thanks!

MapMortar's avatar MapMortar  ( 2022-10-27 10:52:06 -0600 )edit
1

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

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

1 Answer

Sort by ยป oldest newest most voted
2

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

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

Careers

Question Tools

1 follower

Stats

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

Seen: 211 times

Last updated: Mar 07 '23