NatLabRockies / NatLabRockies/OpenStudio

scheduleRuleset.getActiveRuleIndices doesn't work in cases

Open
#2,708 2 comments 0 reactions 1 assignee View on GitHub

@jmarrec is already working on this.

Since Jun 9, 2021.

component - TimeDate severity - Normal Bug
Dominant language
C++
Stars
646
Forks
237
Avg merge
3d 11h
Merged PRs (30d)
10

Description

It works as as designed of there is no yearDescriptionObject, or if the yearDescription objet looks like this

OS:YearDescription,
  {b216c53e-5b6b-4973-8442-5822dbdeacee}; !- Handle

If the Year Description looks like what is shown below, then all days show value of "-1" as if that day uses the default profile, even when that isn't the case.

OS:YearDescription,
  {83b91053-3870-4f90-86d3-f27ea43c081b}, !- Handle
  ,                                       !- Calendar Year
  Sunday;                                 !- Day of Week for Start Day

or

OS:YearDescription,
  {83b91053-3870-4f90-86d3-f27ea43c081b}, !- Handle
  2017,                                   !- Calendar Year
  ,                                       !- Day of Week for Start Day
  ;                                       !- Is Leap Year

If the year passed in isn't in sync with OS:YearDescription then it will return "-1" for every day of the year. If it can't be different than the inferredYear, then it seems like it shouldn't take that as an input. Well, the exception where it may be useful is when there is no YearDescription object yet, or it is empty.

Here is ruby code I tested it with

      year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new("January"),1,2009)
      year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new("December"),31,2009)
      rules_used_each_day = os_sch.getActiveRuleIndices(year_start_date,year_end_date)
      puts "hello2 num unique profiles used for #{os_sch.name}, #{year_start_date}, #{year_end_date}"
      runner.registerInfo("#{rules_used_each_day.join(',')}")
      runner.registerInfo("#{rules_used_each_day.uniq}")

I updated it to this and works fine

    assumed_year = model.getYearDescription.assumedYear
    year_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new("January"),1,year)
    year_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new("December"),31,year)

This updated code is based on use of method in OpenStudio Standards
https://github.com/NREL/openstudio-standards/blob/0712d0dcab9b0b6d9699125bc3ab425a211f475b/openstudio-standards/lib/openstudio-standards/standards/Standards.ScheduleRuleset.rb#L36

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.