lib/measures/CalibrationReportsEnhanced/measure.rb in openstudio-calibration-0.9.0 vs lib/measures/CalibrationReportsEnhanced/measure.rb in openstudio-calibration-0.10.0
- old
+ new
@@ -63,11 +63,11 @@
fuel_oil_cvrmse_limit.setDisplayName('Fuel Oil#2 CVRMSE limit (%)')
fuel_oil_cvrmse_limit.setDefaultValue(15.0)
args << fuel_oil_cvrmse_limit
args
- end # end the arguments method
+ end
def outputs
result = OpenStudio::Measure::OSOutputVector.new
# electric consumption values
@@ -557,10 +557,11 @@
end
period_index += 1
end
next unless os_version >= min_version_feature1
+
if actual_consumption > 0.0
runner.registerValue("#{utility_bill_fuel_type}_consumption_actual",
actual_consumption,
utilityBill.consumptionUnit)
runner.registerValue("#{utility_bill_fuel_type}_consumption_modeled",
@@ -577,10 +578,11 @@
runner.registerValue("#{utility_bill_fuel_type}_peak_demand_nmbe",
100.0 * (modeled_demand - actual_demand) / actual_demand,
'%')
end
next unless !actual_consumption_values.empty? && (actual_consumption_values.size == modeled_consumption_values.size)
+
sum_squares = 0.0
actual_consumption_values.each_index do |i|
sum_squares += (actual_consumption_values[i] - modeled_consumption_values[i])**2
end
rmse = Math.sqrt(sum_squares / actual_consumption_values.size)
@@ -589,30 +591,27 @@
utilityBill.consumptionUnit)
runner.registerValue("#{utility_bill_fuel_type}_dof",
actual_consumption_values.size)
runner.registerValue("#{utility_bill_fuel_type}_rmse",
rmse,
- utilityBill.consumptionUnit + '^0.5')
+ "#{utilityBill.consumptionUnit}^0.5")
end
- if os_version >= min_version_feature1
- if !all_actual_consumption_values.empty? && (all_actual_consumption_values.size == all_modeled_consumption_values.size)
- sum_squares = 0.0
- all_actual_consumption_values.each_index do |i|
- sum_squares += (all_actual_consumption_values[i] - all_modeled_consumption_values[i])**2
- end
- rmse = Math.sqrt(sum_squares / all_actual_consumption_values.size)
- runner.registerValue('total_sum_of_squares',
- sum_squares,
- 'kBtu')
- runner.registerValue('total_dof',
- all_actual_consumption_values.size)
- runner.registerValue('total_rmse',
- rmse,
- 'kBtu^0.5')
+ if os_version >= min_version_feature1 && (!all_actual_consumption_values.empty? && (all_actual_consumption_values.size == all_modeled_consumption_values.size))
+ sum_squares = 0.0
+ all_actual_consumption_values.each_index do |i|
+ sum_squares += (all_actual_consumption_values[i] - all_modeled_consumption_values[i])**2
end
-
+ rmse = Math.sqrt(sum_squares / all_actual_consumption_values.size)
+ runner.registerValue('total_sum_of_squares',
+ sum_squares,
+ 'kBtu')
+ runner.registerValue('total_dof',
+ all_actual_consumption_values.size)
+ runner.registerValue('total_rmse',
+ rmse,
+ 'kBtu^0.5')
end
elecStartDate = elecStartDate[0..-2]
elecStartDate << "],\n"
elecEndDate = elecEndDate[0..-2]
@@ -726,11 +725,11 @@
within_limit = if is_electric
(cvrmse <= electric_cvrmse_limit)
else
(cvrmse <= gas_cvrmse_limit)
end
- result_hash[match_data[1] + '_cvrmse_within_limit'] = within_limit
+ result_hash["#{match_data[1]}_cvrmse_within_limit"] = within_limit
within_limit_i = if within_limit
1
else
0
end
@@ -745,11 +744,11 @@
within_limit = if is_electric
(nmbe.abs <= electric_nmbe_limit)
else
(nmbe.abs <= gas_nmbe_limit)
end
- result_hash[match_data[1] + '_nmbe_within_limit'] = within_limit
+ result_hash["#{match_data[1]}_nmbe_within_limit"] = within_limit
within_limit_i = if within_limit
1
else
0
end
@@ -759,10 +758,10 @@
File.open('./report_guideline.json', 'w') do |f|
f.write(result_hash.to_json)
end
true
- end # end the run method
-end # end the measure
+ end
+end
# this allows the measure to be use by the application
CalibrationReportsEnhanced.new.registerWithApplication