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

How to implement a custom OpenStudio measure

asked 2016-08-05 09:25:53 -0500

jugonzal07 gravatar image

updated 2017-08-05 07:44:12 -0500

Hi all,

I recently became interested in writing my own open studio measures to help automate some processes. I followed the steps found on NREL's github site titled Measure Writer's Reference Guide and have a very basic script I wanted to test to see if I'm understanding things correctly.

I'm likely being dense here, but now that I've written my ruby script, I want to begin debugging it and testing it. How does one go about applying their measure.rb script to a given osm? Is there a custom way for me to import it into OpenStudio to use like other OS measures from the BCL or should I be testing it in ruby elsewhere?

Any information regarding how to actually apply user generated scripts would be greatly appreciated. Thanks in advance!

edit retag flag offensive close merge delete

Comments

2

did you create the measure from inside or outside OS/PAT?

MatthewSteen gravatar image MatthewSteen  ( 2016-08-05 09:57:50 -0500 )edit

I created it outside OS/PAT (I wrote it from scratch in RubyMine). From what I saw, if I create it from within OS, OS will create a sort of "template" for users to fill in the various parts of an OS measure (e.g. the arguments, run, and name function). Does it do more than that?

jugonzal07 gravatar image jugonzal07  ( 2016-08-05 10:28:19 -0500 )edit
4

Starting a measure from the template also creates the measure.xml file that contains information about the measure that the application uses to run the measure using 'Apply Measure Now' or in the Measures tab. This way you can test/debug your measure by running it through the application. Another way is to set up a measure test, as explained in the Measure Testing section of the Measure Writing Reference Guide.

Eric Ringold gravatar image Eric Ringold  ( 2016-08-05 10:51:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
8

answered 2016-08-05 11:55:20 -0500

updated 2016-08-05 11:55:38 -0500

To create a new measure:

  1. Set your My Measures directory

    • Preferences > Change My Measures Directory
  2. Create a new measure from the Measure tab

    • Measures > Library
  3. Name the measure

  4. Describe the measure (optional)

  5. Choose the appropriate measure type and taxonomy

  6. Create measure and open for editing

The measure folder contains the measure.rb file, which contains the measure code, and the measure.xml, which contains the measure meta data that is updated automatically when the RB file is changed.

Open the measure.rb file and start editing it to write your measure or if you've already created a measure outside of OS/PAT, paste in the code and save.

If the measure is an OpenStudio measure, it can be tested in OS using the Apply Measure Now feature. If it's an EnergyPlus measure or Reporting measure, it can be tested by attaching it to the model as an Always Run Measure. Alternatively, OpenStudio's API can be used to test measure snippets from a command line/terminal (see the Optional - Install Ruby instructions).

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

 

Question Tools

1 follower

Stats

Asked: 2016-08-05 09:25:53 -0500

Seen: 1,090 times

Last updated: Aug 05 '16