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

OpenStudio python bindings

asked 2021-07-20 15:34:39 -0500

Michel's avatar

Hello,

I am very new to OpenStudio and I want to integrate the software in a statistical analysis on python. I do not know how to compile and use the python bindings. Can anyone give me a tutorial for it?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
6

answered 2021-07-20 22:11:21 -0500

updated 2021-07-20 22:12:59 -0500

You can install the openstudio python bindings using pip install openstudio.

Then you can test they work:

import openstudio
m = openstudio.model.Model()
print(m)

That results in:

OS:Version,
  {b1c739b0-8af6-4d47-b6a2-96df1d55f3cb}, !- Handle
  3.2.1;                                  !- Version Identifier

You can find more information at https://pypi.org/project/openstudio/

edit flag offensive delete link more

Comments

Thank you, it worked

Michel's avatar Michel  ( 2021-07-21 01:58:19 -0500 )edit
1

Where is the documentation for all the package functions? I want to use some OpenStudio modifications in my python scripts?

mechyai's avatar mechyai  ( 2021-07-21 11:14:49 -0500 )edit

Are you referring to the OpenStudio SDK documentation?

shorowit's avatar shorowit  ( 2021-07-21 11:25:57 -0500 )edit
1

Is there a python-specific version of the above SDK documentation that shows us the syntax of how to call the methods? Thanks

wassimj's avatar wassimj  ( 2021-07-26 02:26:50 -0500 )edit

The SDK documentation is for all languages (Ruby, C#, Python); I don't know what python-specific documentation would look like.

shorowit's avatar shorowit  ( 2021-07-26 08:30:48 -0500 )edit
3

answered 2022-03-15 14:43:39 -0500

To expand on Scott's point, I've been learning how to use the Python bindings for the last couple of weeks. I've put together a Python Jupyter notebook as I've figured out a few of the things I wanted to do. The notation is a little different from Ruby for a few things, but with some practice, you should start to catch the patterns to the differences. Maybe this will help you in your own work.

Github-load_model_add_ruleset_notebook.ipynb

edit flag offensive delete link more

Comments

1

Hi. Are you using the Ruby Documentation and getting this done? I have a Ruby Script that I'm looking to convert to Python. Specifically this (https://github.com/LBNL-ETA/AlphaBuil...). Do you think it's possible to do this? Because openstudio-standards seems to be Ruby only.

asrjy's avatar asrjy  ( 2022-03-17 09:40:16 -0500 )edit
1

Yes, I am. It's not a 1 for 1 syntax match-up, but I'm using it as the starting place for object association.

As for openstudio-standards, I think you're correct. However, since they're all ruby scripts, you could still call them from Python's command-line interface as noted in the comment thread here. I think you can use the OS package in python to do those calls. See this link for ideas.

GFlechas's avatar GFlechas  ( 2022-03-17 10:27:57 -0500 )edit
1

So for that LBNL project, I think you could rewrite the main workflow script in python using the openstudio python bindings, and then call the openstudio-standards gem as needed as command line scripts. Might be a little slower but it certainly looks possible!

GFlechas's avatar GFlechas  ( 2022-03-17 10:29:34 -0500 )edit
1

Yea. I'll try doing that. Having no proper documentation is making the conversion really hard haha. I'll use your notebook as a reference. Thank you.

asrjy's avatar asrjy  ( 2022-03-17 10:44:38 -0500 )edit

Could you please elaborate on using openstudio-standards using command line scripts? In the repository, Openstudio Standards was called using Standards.Build which creates a prototype building model. If I were to write a ruby script to do that, how would I send the created prototype object back to python? I'm stuck there. I finished converting the other part of the script to Python.

asrjy's avatar asrjy  ( 2022-03-22 04:43:14 -0500 )edit

Congrats on getting the other stuff converted!

It sounds like you've got two options. You could look at python packages that communicate between python and scripts written in other languages to find a way to pass the OpenStudio object from a ruby function directly. The other option may be to write a small ruby script that makes a prototype building, saves it, and passes back the location of the saved script which you can then read into the python model. It would take a bit more storage management but might be the simplest to incorporate. This is all new to me though.

GFlechas's avatar GFlechas  ( 2022-03-28 11:52:30 -0500 )edit

Okay. I'll try doing that. Thank you so much for the idea.

asrjy's avatar asrjy  ( 2022-03-28 22:03:08 -0500 )edit

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

3 followers

Stats

Asked: 2021-07-20 15:34:39 -0500

Seen: 1,191 times

Last updated: Mar 15 '22