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

Measure written in Python

asked 2023-03-03 01:32:25 -0500

Kunyu's avatar

Does the measure have to be written in Ruby?

I noticed there is a python version of measure file in OpenStudio Example directory, but when I run it returns the error message “Can’t find measure xxx” in initialization state.

Not sure if I can use python to write measure instead of Ruby.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2023-03-06 02:57:56 -0500

At the moment you cannot write a Measure in python, it has to be written in Ruby if you want to use it as part of a Workflow (OSW).

There is some very experimental support in the labs subcommand of the openstudio command line interface (CLI). You can also write python scripts (or use the python REPL / jupyter notebooks) using the python bindings though.

edit flag offensive delete link more

Comments

Merci Julien.

I got another question: how does the measure XML file be created? Should I code it by hand or is there any command in openstudio-sdk to do the conversion?

Kunyu's avatar Kunyu  ( 2023-03-06 03:33:54 -0500 )edit

You should get an XML when you generate a new measure using the BCL Template (using the OpenStudioApplication for example). Otherwise you can copy an existing one, but make sure you change the the <uid>(get one at https://www.uuidgenerator.net/version4 otherwise) so it's unique and doesn't clash with another measure.

To update the measure.xml use the CLI: openstudio measure --update <measure_dir>. It'll update the name, descriptions, arguments etc. The only things it won't touch are the things that are not in your measure.rb file, so tags, eventually the minimum openstudio version.

Julien Marrec's avatar Julien Marrec  ( 2023-03-06 04:00:42 -0500 )edit

Note that you can also generate a new measure from the template like the OSApp does using the OpenStudio CLI: openstudio -e "OpenStudio::BCLMeasure.new('My measure is cool', 'MyNewMeasure', File.expand_path('./MyNewMeasure'), 'Envelope.Fenestration', 'ModelMeasure'.to_MeasureType, 'This is my measure description', 'This is the developer description', 'Ruby'.to_MeasureLanguage)".

cf SDK documentation at: https://openstudio-sdk-documentation....

Julien Marrec's avatar Julien Marrec  ( 2023-03-06 04:02:03 -0500 )edit
1

got it! Merci beacoup!

Kunyu's avatar Kunyu  ( 2023-03-07 20:12:37 -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

1 follower

Stats

Asked: 2023-03-03 01:32:25 -0500

Seen: 581 times

Last updated: Mar 06 '23