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

Status of OpenStudio SDK python bindings

asked 2024-04-11 01:02:54 -0500

antonszilasi's avatar

updated 2024-04-15 09:09:18 -0500

Hello all,

I am attempted to write a reporting measure with Python using the OpenStudio SDK, however, try as I might I ran into many problems with Python bindings not working as an example:

sqlFile = runner.lastEnergyPlusSqlFile().get() - # works

hours_simulated = sqlFile.hoursSimulated().get() -  # Returns an error then nothing

sqlFile.availableEnvPeriods() = # Returns nothing

So may I ask what is the current status of the Python bindings should I expect these to? It seems to me that it is still WIP.

Thank you,

Anton

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2024-04-15 11:43:49 -0500

updated 2024-04-15 12:20:42 -0500

Edit: I found the same behavior with Ruby. It's because the default measures do sql_file.close at the end. So you can't query it.

You need to do

if not sqlFile.connectionOpen():
    sqlFile.reopen()

Filed it at https://github.com/NREL/OpenStudio/is... for clarifications


First off, I understand the logic of thinking it's because Python Measures aren't prime ready that you're having an issue.

I don't have anything to go on to pinpoint exactly what's your problem, but I don't think it's related to Python Measures (until proven otherwise).

I can run a Python reporting measure fine. For example the template one at https://github.com/NREL/OpenStudio/bl...

Which you can generate from:

openstudio measure new -c PythonReporting -t ReportingMeasure -l Python -n "Python Reporting Measure" -d "A sample reporting measure in python " -m "Tests loading sql and co" --taxonomy-tag "Reporting.QAQC" ./python_reporting_measure

Here's a link to a working example: https://drive.google.com/file/d/1l7ug...

openstudio run -w workflow.osw

This produces a reports/reporting_measure_name_report.html that works fine and displays the SQL file's outdoor dry bulb conditions.

image description

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-11 01:02:54 -0500

Seen: 160 times

Last updated: Apr 15