example_files/resources/hpxml-measures/HPXMLtoOpenStudio/resources/schedules.rb in urbanopt-cli-0.4.1 vs example_files/resources/hpxml-measures/HPXMLtoOpenStudio/resources/schedules.rb in urbanopt-cli-0.5.0

- old
+ new

@@ -61,11 +61,11 @@ end def calcMaxval() maxval = [@weekday_month_by_hour_values.flatten.max, @weekend_month_by_hour_values.flatten.max].max if maxval == 0.0 - maxval == 1.0 # Prevent divide by zero + maxval = 1.0 # Prevent divide by zero end return maxval end def createSchedule() @@ -176,22 +176,22 @@ # weekday_hourly_values can either be a comma-separated string of 24 numbers or a 24-element array of numbers. # weekend_hourly_values can either be a comma-separated string of 24 numbers or a 24-element array of numbers. # monthly_values can either be a comma-separated string of 12 numbers or a 12-element array of numbers. def initialize(model, sch_name, weekday_hourly_values, weekend_hourly_values, monthly_values, schedule_type_limits_name = nil, normalize_values = true, begin_month = 1, - begin_day_of_month = 1, end_month = 12, end_day_of_month = 31) + begin_day = 1, end_month = 12, end_day = 31) @model = model @sch_name = sch_name @schedule = nil @weekday_hourly_values = validateValues(weekday_hourly_values, 24, 'weekday') @weekend_hourly_values = validateValues(weekend_hourly_values, 24, 'weekend') @monthly_values = validateValues(monthly_values, 12, 'monthly') @schedule_type_limits_name = schedule_type_limits_name @begin_month = begin_month - @begin_day_of_month = begin_day_of_month + @begin_day = begin_day @end_month = end_month - @end_day_of_month = end_day_of_month + @end_day = end_day if normalize_values @weekday_hourly_values = normalizeSumToOne(@weekday_hourly_values) @weekend_hourly_values = normalizeSumToOne(@weekend_hourly_values) @monthly_values = normalizeAvgToOne(@monthly_values) @@ -279,11 +279,11 @@ maxval = @monthly_values.max * @weekday_hourly_values.max else maxval = @monthly_values.max * @weekend_hourly_values.max end if maxval == 0.0 - maxval == 1.0 # Prevent divide by zero + maxval = 1.0 # Prevent divide by zero end return maxval end def calcSchadjust() @@ -309,20 +309,20 @@ if year_description.isLeapYear leap_offset = 1 end num_days_in_each_month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] - num_days_in_each_month[@end_month] = @end_day_of_month + num_days_in_each_month[@end_month] = @end_day num_days_in_each_month.each_index do |i| num_days_in_each_month[i] += leap_offset if i == 2 end orig_day_startm = [0, 1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335] orig_day_startm.each_index do |i| orig_day_startm[i] += leap_offset if i > 2 end day_startm = orig_day_startm.map(&:clone) - day_startm[@begin_month] = orig_day_startm[@begin_month] + @begin_day_of_month - 1 + day_startm[@begin_month] = orig_day_startm[@begin_month] + @begin_day - 1 day_endm = [orig_day_startm, num_days_in_each_month].transpose.map { |i| (i != [0, 0]) ? i.reduce(:+) - 1 : 0 } time = [] for h in 1..24 time[h] = OpenStudio::Time.new(0, h, 0, 0) end @@ -526,9 +526,10 @@ if dryer_exhaust_min_runtime > 0 # Clothes dryer exhaust vent should operate whenever the dryer is operating, # with a minimum runtime in minutes. items.reverse.each_with_index do |val, i| next unless val > 0 + place = (items.length - 1) - i last = place + dryer_exhaust_min_runtime items.fill(1, place...last) end end