4

How to implement a custom OpenStudio measure

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!

jugonzal07's avatar
681
jugonzal07
asked 2016-08-05 09:25:53 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2017-08-05 07:44:12 -0500
edit flag offensive 0 remove flag close merge delete

Comments

2

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

MatthewSteen's avatar 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's avatar jugonzal07 (2016-08-05 10:28:19 -0500) edit
5

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.

ericringold's avatar ericringold (2016-08-05 10:51:29 -0500) edit
add a comment see more comments

1 Answer

9

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).

MatthewSteen's avatar
10.1k
MatthewSteen
answered 2016-08-05 11:55:20 -0500, updated 2016-08-05 11:55:38 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments