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

command line interface OpenStudio 2.2.0

asked 2017-08-31 09:01:34 -0600

Matt Koch gravatar image

updated 2017-08-31 09:29:35 -0600

So, I am trying to run OpenStudio from the command line in Windows 7 Pro 64. I have managed to cobble together a .OSW file as follows:

  "seed_file": "Model (IECC 2015 & ASHRAE 90-1-2013 - RTU-FPB).osm",
  "steps": [

Notice that (for now), I am not defining any measures under "steps".

Furthermore, I am calling this .OSW file from a .BAT file as follows:

openstudio run --debug --workflow "Run (IECC 2015 & ASHRAE 90-1-2013 - RTU-FPB).osw"

The idea is to eventually add more lines to the .BAT file. Also, each .OSM file has its own weather file defined within it.

However, when I execute the .BAT file, I get the following error snippet regarding the weather file.

[08:56:58.378468 DEBUG] Getting the initial weather file
[08:56:58.394067 DEBUG] No weather file specified in OSW, looking in model
[08:56:58.394067 DEBUG] Searching for weather file #{weather_path}
[08:56:58.394067 ERROR] Found error in state 'initialization' with message ["Wea
ther file 'USA_TX_Corpus.Christi.NAS.722515_TMY3.epw' specified but cannot be fo
_initialization.rb:158:in `perform'\n:/ruby/2.2.0/gems/openstudio-workflow-1.3.1
/lib/openstudio/workflow/run.rb:261:in `step'\n:/ruby/2.2.0/gems/openstudio-work
flow-1.3.1/lib/openstudio/workflow/run.rb:210:in `run'\n:/openstudio_cli.rb:804:
in `execute'\n:/openstudio_cli.rb:620:in `execute'\n:/openstudio_cli.rb:1517:in
`<main>'\neval:85:in `eval'\neval:85:in `require_embedded_absolute'\neval:70:in
`block in require'\neval:64:in `each'\neval:64:in `require'\neval:2:in `<main>'"
[08:56:58.394067 INFO] Finished workflow - communicating results and zipping fil
[08:56:58.409667 INFO] Workflow complete

So, I am wondering how can I make the command line interface find the weather file? I know it does exist, because when I run the .OSM from the OpenStudio GUI, it works just fine. So it must be a path issue. I even tried adding a "file_paths" entry to the .OSW, but that failed, probably because I did not get the syntax correct.

Any advice would be appreciated.

edit retag flag offensive close merge delete


Open your OSM in a text editor, and look for "OS:WeatherFile", what's the value of the "URL" field?

Julien Marrec gravatar image Julien Marrec  ( 2017-08-31 09:34:43 -0600 )edit

OK, here is the relevant line in OS:WeatherFile:

file:files/USA_TX_Corpus.Christi.NAS.722515_TMY3.epw, !- Url

Looks like the folder is not listed, just the file, and I think that is at the heart of the problem?

Matt Koch gravatar image Matt Koch  ( 2017-08-31 10:37:59 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-08-31 09:31:15 -0600

updated 2017-09-01 02:51:10 -0600

You can try placing your weather file next to your .osm, and run this OSW:

  "seed_file": "Model (IECC 2015 & ASHRAE 90-1-2013 - RTU-FPB).osm",
  "weather_file": "USA_TX_Corpus.Christi.NAS.722515_TMY3.epw",
  "steps": [  ]

This will overwrite the weather file actually used by the model, so beware.

Test 1: provide a file that is in the same folder:

I created an empty.osm model, didn't not set a weather file. (I opened a terminal, loaded ruby bindings, and just did model = then'empty.osm'). I put a weather file next to it in the same folder, USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw. Created a test.osw:

  "seed_file": "empty.osm",
  "weather_file": "USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw",

Here's the content of my folder:

$ ls

Then $ openstudio run -w test.osw

Worked perfectly.

As you can see, stepsisn't required (it works with it though).

Test 2: provide a file_paths argument

Only changed the OSW:

  "file_paths": ["/Applications/EnergyPlus-8-7-0/WeatherData/"],
  "seed_file": "empty.osm",
  "weather_file": "USA_VA_Sterling-Washington.Dulles.Intl.AP.724030_TMY3.epw",

The Sterling weather file is NOT in the current directory, but it is in the directory I pointed for "file_paths".

Worked perfectly too.

Note that you can also have relative paths (compared to root, if root isn't set, that's the directory containing the osw. See the JSON Schema

Test 3: set the weather file in the OSM itself.

I opened empty.osm and set the weather file to another EPW (Tampa).

[4] TestOSW(main)> puts model.weatherFile.get
  {9b78b8e8-0d6e-4674-b157-cd24f9a09e21}, !- Handle
  Tampa International Ap,                 !- City
  FL,                                     !- State Province Region
  USA,                                    !- Country
  TMY3,                                   !- Data Source
  722110,                                 !- WMO Number
  27.97,                                  !- Latitude {deg}
  -82.53,                                 !- Longitude {deg}
  -5,                                     !- Time Zone {hr}
  6,                                      !- Elevation {m}
  file:USA_FL_Tampa.Intl.AP.722110_TMY3.epw, !- Url
  847DE5F2;                               !- Checksum

The weather file, as expected, got copied to ./empty/files/USA_FL_Tampa.Intl.AP.722110_TMY3.epw.

Changed OSW to:

  "seed_file": "empty.osm",
  "steps": []

=> Did not work.:

$ openstudio run -w test.osw
[09:44:54.432491 ERROR] Found error in state 'initialization' with message ["Weather file 'USA_FL_Tampa.Intl.AP.722110_TMY3.epw' specified but cannot be found::/ruby/2.2.0/gems/openstudio-workflow-1.3.1/lib/openstudio/workflow/jobs/run_initialization.rb:158:in `perform'\n:/ruby/2.2.0/gems/openstudio-workflow-1.3.1/lib/openstudio/workflow/run.rb:261:in `step'\n:/ruby/2.2.0/gems/openstudio-workflow-1.3.1/lib/openstudio/workflow/run.rb:210:in `run'\n:/openstudio_cli.rb:804:in `execute'\n:/openstudio_cli.rb:620:in `execute'\n:/openstudio_cli.rb:1517:in `<main>'\neval:85:in `eval'\neval:85:in `require_embedded_absolute'\neval:70:in `block in require'\neval:64:in `each'\neval:64:in `require'\neval:2:in `<main>'"]}

I think it should work, so I'd consider that a bug.

edit flag offensive delete link more


Yes, I did not mention it, but I tried this as well, with the same "cannot be found" error. This is also where I tried to insert a "file_paths" line before the "seed_file" line, but I am pretty sure I got the format wrong for that. I think if the weather file path can be specified in the .OSW file, that would help.

{ "file_paths": ["C:\Software\WeatherData"], "seed_file": "Model (IECC 2015 & ASHRAE 90-1-2013 - RTU-FPB).osm", "weather_file": "USA_TX_Corpus.Christi.NAS.722515_TMY3.epw", "steps": [ ] }

Also, if I have no steps, do I need that entry at all?

Matt Koch gravatar image Matt Koch  ( 2017-08-31 10:47:53 -0600 )edit

See my edit. And no, steps isn't required. I don't have a windows machine to test, but it can be a path format issue: try C:\Software\WeatherData\ (I don't expect that to work), C:\\Software\\WeatherData\\ and C:/Software/WeatherData/ (I expect both of these two last to work)

Julien Marrec gravatar image Julien Marrec  ( 2017-09-01 02:53:29 -0600 )edit

Thank you Julien Marrec, that was a lot of work you did. However, I think it will benefit a large number of people as documentation on CLI is still a little sparse and this post could help get people off dead center. As you pointed out in your comment, it was indeed a path format issue in Windows. The version below works just fine now - note the use of "/" instead of "\"!

{ "file_paths": ["C:/Software/WeatherData"], "seed_file": "Model (IECC 2015 & ASHRAE 90-1-2013 - RTU-FPB).osm", "weather_file": "USA_TX_Corpus.Christi.NAS.722515_TMY3.epw", "steps": [ ] }

Matt Koch gravatar image Matt Koch  ( 2017-09-01 09:24:32 -0600 )edit

So, is it correct that any and all measures in the .OSW file are applied first, then the simulation is run, so that there is only one run incorporating all the measures at once? This would be in contrast to having as many runs as there are measures in the .OSW file, thus having as many results, and each only reflecting one measure? Based on a test run, I believe the "one run" case is true, but wanted to confirm that here. Thanks.

Matt Koch gravatar image Matt Koch  ( 2017-09-05 08:49:27 -0600 )edit

Yes, read "Workflow Steps" in doc

Julien Marrec gravatar image Julien Marrec  ( 2017-09-06 02:29:04 -0600 )edit

Your Answer

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

Add Answer


Question Tools

1 follower


Asked: 2017-08-31 09:01:34 -0600

Seen: 372 times

Last updated: Sep 01 '17