From ff4bb6eb9cb4271b87b594aaf463e012516c3722 Mon Sep 17 00:00:00 2001 From: Boya Yu Date: Thu, 27 Apr 2017 12:13:07 -0400 Subject: [PATCH 1/2] Fix a bug that sometimes leads to negative outputs --- bpeng/bill/disaggregate.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bpeng/bill/disaggregate.py b/bpeng/bill/disaggregate.py index d0587a4..0a6c9ba 100644 --- a/bpeng/bill/disaggregate.py +++ b/bpeng/bill/disaggregate.py @@ -95,16 +95,14 @@ class BillDisaggregation(): """HDD (for each day)""" if curr_temp > set_temp: return 0 - else: - return set_temp - curr_temp + return set_temp - curr_temp @staticmethod def cooling(curr_temp, set_temp): """ CDD (for each day) """ if curr_temp > set_temp: return curr_temp - set_temp - else: - return 0 + return 0 @staticmethod def regression_r2_op(set_heating, set_cooling, temperature, consumption): @@ -215,6 +213,12 @@ class BillDisaggregation(): self.cooling_load_m = self.cooling_load_m * sum_ratio self.others_m = self.others_m * sum_ratio + if sum(self.others_m < 0) > 0: + self.heating_load_m, self.cooling_load_m = \ + np.array([self.heating_load_m, self.cooling_load_m]) \ + * real_sum / (self.cooling_load_m + self.heating_load_m) + self.others_m = np.zeros(len(self.others_m)) + # For printing output bill_cp = self.bill.copy() bill_cp = bill_cp[['Bill From Date', 'Bill To Date', 'Days In Bill', 'Usage']] -- GitLab From 21129e6605eb590ddd904472af1567b93b8ea32d Mon Sep 17 00:00:00 2001 From: Boya Yu Date: Mon, 1 May 2017 13:50:16 -0400 Subject: [PATCH 2/2] Minor changes --- bpeng/bill/disaggregate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bpeng/bill/disaggregate.py b/bpeng/bill/disaggregate.py index 0a6c9ba..e8849ca 100644 --- a/bpeng/bill/disaggregate.py +++ b/bpeng/bill/disaggregate.py @@ -213,7 +213,7 @@ class BillDisaggregation(): self.cooling_load_m = self.cooling_load_m * sum_ratio self.others_m = self.others_m * sum_ratio - if sum(self.others_m < 0) > 0: + if any(i < 0 for i in self.others_m): self.heating_load_m, self.cooling_load_m = \ np.array([self.heating_load_m, self.cooling_load_m]) \ * real_sum / (self.cooling_load_m + self.heating_load_m) -- GitLab