def _cef_piij(self, i, j): dmu_t = self._dmus_t[i] dmu_t1 = self._dmus_t1[i] if dmu_t.co2[j] != 0.0 and dmu_t1.co2[j] != 0.0: number1 = dmu_t.co2[j] / self._lmdi.co2_sum_t number2 = dmu_t1.co2[j] / self._lmdi.co2_sum_t1 numerator1 = Lmdi.l_function(number1, number2) / self._lmdi.ll cef_i_j_t = self._cef_t[i, j] cef_i_j_t1 = self._cef_t1[i, j] denumnerator1 = Lmdi.l_function(cef_i_j_t1, cef_i_j_t * self.cef) return numerator1 * cef_i_j_t / denumnerator1 else: return 0.0
def _peiij(self, i, j): dmu_t = self._dmus_t[i] dmu_t1 = self._dmus_t1[i] if dmu_t.co2[j] != 0.0 and dmu_t1.co2[j] != 0.0: sij_t = dmu_t.ene[j] / dmu_t.ene.total sij_t1 = dmu_t1.ene[j] / dmu_t1.ene.total __l = Lmdi.l_function(sij_t1, sij_t * exp(sum(list(self._lmdi.emx())))) __L = Lmdi.l_function(dmu_t1.co2[j] / self._lmdi.co2_sum_t1, dmu_t.co2[j] / self._lmdi.co2_sum_t) return __L * sij_t / self._lmdi.ll / __l elif dmu_t.co2[j] != 0.0 and dmu_t1.co2[j] == 0.0: cijt = dmu_t.co2[j] / self._lmdi.co2_sum_t return cijt / self._lmdi.ll / exp(sum(list(self._lmdi.emx()))) else: return 0.0
def _rij(self, i, j, emx): dmu_t = self._dmus_t[i] dmu_t1 = self._dmus_t1[i] if dmu_t.co2[j] != 0.0 and dmu_t1.co2[j] != 0.0: sij_t = dmu_t.ene[j] / dmu_t.ene.total sij_t1 = dmu_t1.ene[j] / dmu_t1.ene.total l_upper = Lmdi.l_function(dmu_t1.co2[j] / self._lmdi.co2_sum_t1, dmu_t.co2[j] / self._lmdi.co2_sum_t) l_low = Lmdi.l_function(sij_t1, sij_t * emx) return (1.0 / self._LL) * (1.0 / self._lmdi.ll) \ *(l_upper / l_low) * (sij_t1 - sij_t) elif dmu_t.co2[j] != 0.0 and dmu_t1.co2[j] == 0.0: cij_t = dmu_t.co2[j] / self._lmdi.co2_sum_t return -1.0 * (1.0 / self._lmdi.ll) * (1.0 / self._LL) * (cij_t / (emx)) elif dmu_t.co2[j] == 0.0 and dmu_t1.co2[j] != 0.0: cij_t = dmu_t1.co2[j] / self._lmdi.co2_sum_t1 return (1.0 / self._lmdi.ll) * (1.0 / self._LL) * cij_t else: return 0.0
def _wi(self, idx): ''' wi factor ''' result = 0.0 dmu_t = self._dmus_t[idx] dmu_t1 = self._dmus_t1[idx] for j in range(self._lmdi.energy_count): if dmu_t.co2[j] != 0.0 and dmu_t1.co2[j] != 0.0: number1 = dmu_t.co2[j] / self._lmdi.co2_sum_t number2 = dmu_t1.co2[j] / self._lmdi.co2_sum_t1 result += Lmdi.l_function(number1, number2) return result / self._lmdi.ll
def _attribution_r(self, func, index): index_key = 'r' + index if not self._cache.has_key(index_key): result = [] for idx, dmu_t_t1 in enumerate(zip(self._dmus_t, self._dmus_t1)): __wi = self._wi(idx) value_t = func(dmu_t_t1[0], idx) value_t1 = func(dmu_t_t1[1], idx, False) pii = __wi / Lmdi.l_function(value_t1, value_t * getattr(self, index)) result.append(pii * value_t) total = sum(result) self._cache[index_key] = [item / total for item in result] return self._cache[index_key]
def rpei(self): ''' r's pei ''' if not self._cache.has_key('rpei'): result = [] __pei = exp(sum(list(self._lmdi.pei()))) for idx, dmu_t_t1 in enumerate(zip(self._dmus_t, self._dmus_t1)): __wi = self._wi(idx) pei_t = self._pei_t_t1(dmu_t_t1[0], idx) pei_t1 = self._pei_t_t1(dmu_t_t1[1], idx, False) pii = __wi / (Lmdi.l_function(pei_t1, pei_t * __pei)) result.append(pii * pei_t) total = sum(result) self._cache['rpei'] = [item / total for item in result] return self._cache['rpei']
def ryct(self): ''' r yct ''' if not self._cache.has_key('ryct'): result = [] __yct = exp(sum(list(self._lmdi.yct()))) for idx, dmu_t_t1 in enumerate(zip(self._dmus_t, self._dmus_t1)): __wi = self._wi(idx) yct_t = self._yct_t_t1(dmu_t_t1[0], idx) yct_t1 = self._yct_t_t1(dmu_t_t1[1], idx, False) pii = __wi / Lmdi.l_function(yct_t1, yct_t * __yct) result.append(pii * yct_t) total = sum(result) self._cache['ryct'] = [item / total for item in result] return self._cache['ryct']
def reue(self): ''' r's eue ''' if not self._cache.has_key('reue'): result = [] __eue = exp(sum(list(self._lmdi.eue()))) for idx, dmu_t_t1 in enumerate(zip(self._dmus_t, self._dmus_t1)): __wi = self._wi(idx) eue_t = self._eue_t_t1(dmu_t_t1[0], idx) eue_t1 = self._eue_t_t1(dmu_t_t1[1], idx, False) pii = __wi / Lmdi.l_function(eue_t1, eue_t * __eue) result.append(pii * eue_t) total = sum(result) self._cache['reue'] = [item / total for item in result] return self._cache['reue']