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

Creating workflow.osw file in Python

asked 2024-04-16 14:13:36 -0600

codygillmore's avatar

updated 2024-04-19 09:18:38 -0600

Anyone have any tips for creating workflow.osw files programmatically in Python? I have tried the following, but running into various issues:

1) I used this Notebook for inspiration, but am running into an issue with the following script, with the resulting .osw file being blank. I believe the issue is caused by using .append(), but am not 100% sure:

measure_steps=[]
os_results = openstudio.MeasureStep("measures/AddMonthlyJSONUtilityData")
os_results.setArgument("json", "../../../data/electric.json")
os_results.setArgument("variable_name", "Electricity Bill")
os_results.setArgument("set_runperiod", True)
measure_steps.append(os_results)
'# Set the measure steps in the OSW object
measureType = openstudio.MeasureType('ModelMeasure')
osw.setMeasureSteps(measureType,measure_steps)
print(osw)
{
  "created_at" : "20240416T135449Z",
  "steps" : []
}

2) I then used some of the script from this open issue in Github which somewhat works. The osw file results in the arguments, but I had to adjust the setWorkflowSteps() to only include the measure steps because the function only takes one argument. This makes me concerned that I am not defining the MeasureType there may be another issue further down the line.

wf = openstudio.WorkflowJSON()
measure = openstudio.MeasureStep('Measure1')
measure.setArgument('r_value', '45')
stepVector = openstudio.WorkflowStepVector([measure])
measureType=openstudio.MeasureType("ModelMeasure")
wf.setWorkflowSteps(stepVector)
print(wf)
{
  "created_at" : "20240416T155242Z",
  "steps" : 
  [
     {
        "arguments" : 
        {
           "r_value" : "45"
        },
        "measure_dir_name" : "Measure1"
     }
  ],
  "updated_at" : "20240416T155242Z"
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2024-04-19 06:48:01 -0600

codygillmore's avatar

I think method 2 above works fine. I see the Comstock team is using the same methodology in their analysis for anyone that comes across this: https://github.com/NREL/ComStock/blob...

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

1 follower

Stats

Asked: 2024-04-16 11:07:32 -0600

Seen: 270 times

Last updated: Apr 19