First time here? Check our help page!
1

sql_file.endUses.get.subCategories() fails?

I have a simulation for which I know there are sub-categories, such as "CHW Pumps" and "HW Pumps" under the "Pumps" category - eplustbl.html tells me so. Yet,

sql_file.endUses.get.subCategories()

reports "General" as the the only sub-category, and

sql_file.endUses.get.getEndUse(fuel_type,category_type,"HW Pumps")

reports 0. And obviously,

sql_file.endUses.get.getEndUse(fuel_type,category_type)

reports the right value, but only the total of "CHW Pumps" and "HW Pumps". How can I get to the sub-category values? Also, the OpenStudio 3.4.0 SDK documentation for the EndUses class lists a categories() and a fuelTypes() method as Static Public Member Functions, yet calling, for example:

sql_file.endUses.get.fuelTypes()

crashes the measure? Do Static Public Member Functions not get called that way?

mattkoch's avatar
1.1k
mattkoch
asked 2022-09-13 14:31:38 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

Someone can correct me if I'm wrong, but I don't think any of the built-in sqlFile methods can handle custom subcategories; I think the standard EnergyPlus subcategories are hard-coded into OpenStudio.

One way to get the value you want is with a simple SQL query:

query = "SELECT Value FROM TabularDataWithStrings WHERE ReportName='AnnualBuildingUtilityPerformanceSummary' AND ReportForString='Entire Facility' AND TableName='End Uses By Subcategory' AND RowName='Pumps:HW Pumps' AND ColumnName='Electricity' AND Units='GJ'"

value = sql_file.execAndReturnFirstDouble(query).get
shorowit's avatar
11.8k
shorowit
answered 2022-09-13 19:39:34 -0500, updated 2022-09-13 19:41:46 -0500
edit flag offensive 0 remove flag delete link

Comments

Brilliant, thank you! Also, this gives the entire 'Electricity' column:

query = "SELECT Value FROM TabularDataWithStrings WHERE ReportName='AnnualBuildingUtilityPerformanceSummary' AND ReportForString='Entire Facility' AND TableName='End Uses By Subcategory' AND ColumnName='Electricity' AND Units='GJ'"
value = sql_file.execAndReturnVectorOfDouble(query).get
mattkoch's avatar mattkoch (2022-09-14 07:49:46 -0500) edit

... and this gives the categories and subcategories for the column:

query = "SELECT RowName FROM TabularDataWithStrings WHERE ReportName='AnnualBuildingUtilityPerformanceSummary' AND ReportForString='Entire Facility' AND TableName='End Uses By Subcategory' AND ColumnName='Electricity' AND Units='GJ'"
value = sql_file.execAndReturnVectorOfString(query).get

Note that category and subcategory are returned within the same string, separated by a colon (:).

mattkoch's avatar mattkoch (2022-09-14 07:51:28 -0500) edit
add a comment see more comments