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

How to Share Data Between Measures in OpenStudio

asked 2015-09-18 16:42:56 -0600

Phylroy Lopez's avatar

updated 2015-09-18 23:13:39 -0600

When using the measure framework in OpenStudio, measures are applied one after the other. These measures can store information for later analysis using the following method.

runner.registerValue( "ValueName","Value")

There are times when applying two measures that measure #2 needs information that was stored in measure #1. Is there any mechanism that can accomplish this?

Cheers,

Phylroy

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
7

answered 2015-09-21 11:06:36 -0600

updated 2015-09-21 23:33:00 -0600

The server has implemented an Extended Runner class which automates the process of persisting measures and their argument values across a datapoint. The class is implemented here. The following command inside the run method of a measure returns a hash of previous measures and their arguments:

runner.former_workflow_arguments

An example of this hash, saved as a json, is as follows:

{ "set_dr_weather_file":{"weather_directory_name":"weather","weather_file_name":"USA_CO_Denver.Intl.AP.725650_TMY3.epw"}, "idf_reference_building_selector":{"building_type":"Stand-aloneRetailNew2004"}, "set_timestep":{"timestep":"60"}, "hardsize_dx_coil":{"cfm_per_ton":"370","square_foot_per_ton":"350"} }

This functionality is currently in the EnergyPlus-8.3.0 branch of the Workflow Gem, and has not yet been released on rubygems. To use it ensure your Gemfile has the following line in it:

gem "openstudio-workflow", :github => "NREL/OpenStudio-workflow-gem", :branch => 'EnergyPlus-8.3.0'

Finally, run bundle update and bundle install from the command line to set your openstudio-workflow gem to the E+ 8.3.0 branch of github.

edit flag offensive delete link more

Comments

In the next year we hope to transition OpenStudio over to using the OpenStudio Workflow Gem instead of RunManager. Once that is complete, the OpenStudio application and PAT will also have access to this functionality.

macumber's avatar macumber  ( 2015-09-21 12:46:17 -0600 )edit

Hi all,

It's been a few years and I can't seem to find if runner.former_workflow_arguments or something similar has migrated to the non-server OpenStudio ecosystem.

Do any of you know what the current best practice is to pass arguments from one measure instance to another?

GFlechas's avatar GFlechas  ( 2023-09-18 16:46:14 -0600 )edit
5

answered 2015-09-21 09:59:19 -0600

You can also have each measure write its own file and have the other measures read it. For this to work on both PAT( OS-app) and the OS-server, the following directories should work:

 json_path = '../OtherMeasureDirectoryName/results.json'  #this is the path structure on the server
if File.exist? ems_path
  ems_string = File.read(ems_path)
  if File.exist? json_path
    json = JSON.parse(File.read(json_path))
  end
else
  json_path2 = Dir.glob('../../**/results.json')  #this will parse the directory structure with PAT/OS-app
  json_path1 = json_path2[0]
  if File.exist? json_path
    json = JSON.parse(File.read(json_path))
  end

end

This will probably change next year once OS-server and OS-App use the same workflow manager, but this is a way off.

edit flag offensive delete link more
1

answered 2015-09-18 23:26:15 -0600

updated 2015-09-19 00:04:05 -0600

When we needed this with OpenStudio server we created a file named "resource.json" in the lib directory. We made a helper method to read and write to this file that measures had access to. This allowed us to pass information across measures. On OpenStudio server we use a relative path to the resource file. For a local run with OS app or PAT you might need an absolute path, but I haven't tested this.

You can file a user voice request to allow direct access to log messages from earlier measures in the workflow.

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

Training Workshops

Careers

Question Tools

2 followers

Stats

Asked: 2015-09-18 16:42:08 -0600

Seen: 323 times

Last updated: Sep 21 '15