-
Notifications
You must be signed in to change notification settings - Fork 15
#5368 - Wrap OutputTableAnnual and OutputTableMonthly #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| def test_output_tables_rb | ||
| result = sim_test('output_tables.rb') | ||
| end | ||
|
|
||
| def test_output_tables_py | ||
| result = sim_test('output_tables.py') | ||
| end | ||
|
|
||
| # TODO: To be added in the next official release after: 3.9.0 | ||
| # def test_output_tables_osm | ||
| # result = sim_test('output_tables.osm') | ||
| # end | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New Ruby + Python test, with a TODO
| ############################################################################### | ||
| # OUTPUT:TABLE:MONTHLY # | ||
| ############################################################################### | ||
|
|
||
| # Factory method to creates a OutputTableMonthly from the E+ datasets/StandardReports.idf | ||
| # Please use the OutputTableMonthly::validStandardReportNames() static method | ||
| # to look up the valid names as it will throw if it cannot find it | ||
| standardReportName = OpenStudio::Model::OutputTableMonthly.validStandardReportNames.sort.reverse[0] | ||
| output_table_monthly = OpenStudio::Model::OutputTableMonthly.fromStandardReports(model, standardReportName) | ||
|
|
||
| # You can of course create one yourself | ||
| output_table_monthly = OpenStudio::Model::OutputTableMonthly.new(model) | ||
| output_table_monthly.setName('Fan Report') | ||
| output_table_monthly.setDigitsAfterDecimal(4) | ||
|
|
||
| # To add a group, you can use the convenience method | ||
| # bool addMonthlyVariableGroup(std::string variableOrMeterName, std::string aggregationType = "SumOrAverage"); | ||
|
|
||
| groups = [ | ||
| # variableOrMeterName, SumOrAverage | ||
| ['Fan Electricity Energy', 'SumOrAverage'], | ||
| ['Fan Rise in Air Temperature', 'SumOrAverage'], | ||
| ['Fan Electricity Rate', 'Maximum'], | ||
| ['Fan Rise in Air Temperature', 'ValueWhenMaximumOrMinimum'], | ||
| ] | ||
| output_table_monthly.addMonthlyVariableGroup(groups[0][0], groups[0][1]) | ||
|
|
||
| # This will in turn actually use the helper class MonthlyVariableGroup | ||
| output_table_monthly.addMonthlyVariableGroup(OpenStudio::Model::MonthlyVariableGroup.new(groups[1][0], groups[1][1])) | ||
|
|
||
| raise unless output_table_monthly.numberofMonthlyVariableGroups == 2 | ||
| # This is a vector of MonthlyVariableGroup | ||
| raise unless output_table_monthly.monthlyVariableGroups.size == 2 | ||
| first_monthly_group = output_table_monthly.monthlyVariableGroups.first | ||
| # This returns an OptionalMonthlyVariableGroup | ||
| first_monthly_group_ = output_table_monthly.getMonthlyVariableGroup(0) | ||
| raise unless first_monthly_group_.is_initialized | ||
| # The equality operator is defined to check for both variableOrMeterName and | ||
| # aggregationType | ||
| raise unless first_monthly_group == first_monthly_group_.get | ||
| raise unless first_monthly_group.variableOrMeterName == 'Fan Electricity Energy' | ||
| raise unless first_monthly_group.aggregationType == 'SumOrAverage' | ||
|
|
||
| output_table_monthly.removeMonthlyVariableGroup(1) | ||
| output_table_monthly.removeAllMonthlyVariableGroups | ||
|
|
||
| # There is also a batch add | ||
| monthly_groups = groups.map { |g| OpenStudio::Model::MonthlyVariableGroup.new(g[0], g[1]) } | ||
| output_table_monthly.addMonthlyVariableGroups(monthly_groups) | ||
| raise unless output_table_monthly.numberofMonthlyVariableGroups == 4 | ||
|
|
||
| ############################################################################### | ||
| # OUTPUT:TABLE:ANNUAL # | ||
| ############################################################################### | ||
|
|
||
| output_table_annual = OpenStudio::Model::OutputTableAnnual.new(model) | ||
| output_table_annual.setName("Electricity Report") | ||
| output_table_annual.setSchedule(model.alwaysOnDiscreteSchedule) | ||
| output_table_annual.setFilter("Zone 1") | ||
| output_table_annual.resetFilter | ||
|
|
||
| groups = [ | ||
| #variableorMeterorEMSVariableorField, aggregationType, digitsAfterDecimal | ||
| ['Electricity:Facility', 'SumOrAverage', 3], | ||
| ['Electricity:Facility', 'Maximum', 1], | ||
| ] | ||
|
|
||
| output_table_annual.addAnnualVariableGroup(groups[0][0], groups[0][1], groups[0][2]) | ||
|
|
||
| # This will in turn actually use the helper class AnnualVariableGroup | ||
| output_table_annual.addAnnualVariableGroup(OpenStudio::Model::AnnualVariableGroup.new(groups[1][0], groups[1][1], groups[1][2])) | ||
|
|
||
| raise unless output_table_annual.numberofAnnualVariableGroups == 2 | ||
| # This is a vector of AnnualVariableGroup | ||
| raise unless output_table_annual.annualVariableGroups.size == 2 | ||
| first_annual_group = output_table_annual.annualVariableGroups.first | ||
| # This returns an OptionalAnnualVariableGroup | ||
| first_annual_group_ = output_table_annual.getAnnualVariableGroup(0) | ||
| raise unless first_annual_group_.is_initialized | ||
| # The equality operator is defined to check for both variableorMeterorEMSVariableorField and | ||
| # aggregationType | ||
| raise unless first_annual_group == first_annual_group_.get | ||
| raise unless first_annual_group.variableorMeterorEMSVariableorField == 'Electricity:Facility' | ||
| raise unless first_annual_group.aggregationType == 'SumOrAverage' | ||
| raise unless first_annual_group.digitsAfterDecimal == 3 | ||
|
|
||
| output_table_annual.removeAnnualVariableGroup(1) | ||
| output_table_annual.removeAllAnnualVariableGroups | ||
|
|
||
| # There is also a batch add | ||
| annual_groups = groups.map { |g| OpenStudio::Model::AnnualVariableGroup.new(g[0], g[1], g[2]) } | ||
| output_table_annual.addAnnualVariableGroups(annual_groups) | ||
| raise unless output_table_annual.numberofAnnualVariableGroups == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fully demo the extensible API.
…on 1f4d455848) [x86_64-linux], Rubocop 0.81.0)
joseph-robertson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither of these (Monthly or Annual) is a unique object, right? Should we test when there are multiple of each? What about Annual's schedule -- should we test when it's not always On?
|
Neither are unique indeed, and there's no problem instantiating several objects, and we don't have a precedent for testing non-uniqueness I think. This test I added has two Monthly ones too. the OutputTableAnnual_Gtest test (C++) already checks assigning a scheduleconstant. I suppose one thing I could do is to test that the ScheduleTypeRegistry is properly working (something we seldom do, but perhaps we should, I recently fixed an issue related to that) |
|
Tested ScheduleTypeRegistry here: NREL/OpenStudio@1445362 |
Pull request overview
Output:Table:MonthlyOpenStudio#5368Link to the Ubuntu 22.04 .deb installer to use for CI Testing. If not set, it will default to latest official release.
[OpenStudio Installer]: http://openstudio-ci-builds.s3-website-us-west-2.amazonaws.com/PR-5369/OpenStudio-3.10.0-alpha%2Bea0e2a7b64-Ubuntu-22.04-x86_64.deb
This Pull Request is concerning:
NewTest: a new test for a new model API class,Case 1: New test for a new model API class
Please include which class(es) you are adding a test to specifically test for.
Include a link to the OpenStudio Pull Request in which you are adding the new classes, or the class itself if already on develop.
Work Checklist
The following has been checked to ensure compliance with the guidelines:
Tests pass either:
PendingOSMhas been added to this PRmodel_tests.rbhas a TODOout.oswhave been committed as they need to be run with an official OpenStudio versionRuby test is stable: when run multiple times on the same machine, it produces the same total site kBTU.
Please paste the heatmap png generated after running the following commands:
model.getThermalZones.sort_by{|z| z.name.to_s}.each do ...so I am sure I put the same ZoneHVAC systems to the same zones regardless of their order)process_results.py(seepython process_results.py --helpfor usage).Object has been added to
autosize_hvac.rbto ensure the autosizedXXX values methods do work: N/AReview Checklist
# TODOadded tomodel_tests.rbout.oswhave been committedautosize_hvacas appropriateNewTest,TestFix,NewTestForExisting,OtherNewTest: addPendingOSMorAddedOSM