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

Revision history [back]

Here is an example where I create a variable interval schedule from a ScheduleRuleset. Keep in mind that you won't be able to inspect the resulting schedule in OpenStudio application.

yd = model.getYearDescription
start_date = yd.makeDate(1,1)
end_date = yd.makeDate(12,31)

values = OpenStudio::DoubleVector.new
day = OpenStudio::Time.new(1.0)
interval = OpenStudio::Time.new(1.0/48.0)
day_schedules = schedule_ruleset.to_ScheduleRuleset.get.getDaySchedules(start_date,end_date)
day_schedules.each do |day_schedule|
  time = interval
  while time < day
    values << day_schedule.getValue(time)
    time += interval
  end
end
time_series = OpenStudio::TimeSeries.new(start_date, interval, OpenStudio::createVector(values), "")
schedule = OpenStudio::Model::ScheduleInterval.fromTimeSeries(time_series, model).get

Here is an example where I create a variable interval schedule ScheduleInterval from a ScheduleRuleset. Keep in mind that you won't be able to inspect the resulting schedule in OpenStudio application.

yd = model.getYearDescription
start_date = yd.makeDate(1,1)
end_date = yd.makeDate(12,31)

values = OpenStudio::DoubleVector.new
day = OpenStudio::Time.new(1.0)
interval = OpenStudio::Time.new(1.0/48.0)
day_schedules = schedule_ruleset.to_ScheduleRuleset.get.getDaySchedules(start_date,end_date)
day_schedules.each do |day_schedule|
  time = interval
  while time < day
    values << day_schedule.getValue(time)
    time += interval
  end
end
time_series = OpenStudio::TimeSeries.new(start_date, interval, OpenStudio::createVector(values), "")
schedule = OpenStudio::Model::ScheduleInterval.fromTimeSeries(time_series, model).get

Here is an example where I create a ScheduleInterval from a ScheduleRuleset. Keep in mind that you won't be able to inspect the resulting schedule in OpenStudio application.application. ScheduleVariableInterval should be similar.

yd = model.getYearDescription
start_date = yd.makeDate(1,1)
end_date = yd.makeDate(12,31)

values = OpenStudio::DoubleVector.new
day = OpenStudio::Time.new(1.0)
interval = OpenStudio::Time.new(1.0/48.0)
day_schedules = schedule_ruleset.to_ScheduleRuleset.get.getDaySchedules(start_date,end_date)
day_schedules.each do |day_schedule|
  time = interval
  while time < day
    values << day_schedule.getValue(time)
    time += interval
  end
end
time_series = OpenStudio::TimeSeries.new(start_date, interval, OpenStudio::createVector(values), "")
schedule = OpenStudio::Model::ScheduleInterval.fromTimeSeries(time_series, model).get

Here is an example where I create a ScheduleInterval from a ScheduleRuleset. Keep in mind that you won't be able to inspect the resulting schedule in OpenStudio application. While it is not as similar to ScheduleVariableInterval should as I thought, it still may be similar.a helpful example.

yd = model.getYearDescription
start_date = yd.makeDate(1,1)
end_date = yd.makeDate(12,31)

values = OpenStudio::DoubleVector.new
day = OpenStudio::Time.new(1.0)
interval = OpenStudio::Time.new(1.0/48.0)
day_schedules = schedule_ruleset.to_ScheduleRuleset.get.getDaySchedules(start_date,end_date)
day_schedules.each do |day_schedule|
  time = interval
  while time < day
    values << day_schedule.getValue(time)
    time += interval
  end
end
time_series = OpenStudio::TimeSeries.new(start_date, interval, OpenStudio::createVector(values), "")
schedule = OpenStudio::Model::ScheduleInterval.fromTimeSeries(time_series, model).get