multiLCA对象的特征库存矩阵在Brightway2中代表什么?我本来希望在对象中找到几个这样的矩阵,代表不同活动的特征清单和不同的影响评估方法。
对于简单的LCA对象,特征库存矩阵的所有元素的总和给出了该活动的总影响。但似乎不是MultiLCA对象的情况(例如)
#impact assessment method
i2002=[('IMPACT 2002+ (Endpoint)', 'resources', 'total'),
('IMPACT 2002+ (Endpoint)', 'climate change', 'climate change'),
('IMPACT 2002+ (Endpoint)', 'human health', 'total'),
('IMPACT 2002+ (Endpoint)', 'ecosystem quality', 'total')
]
fu=[]
for j in range(1,11):
fu.append({bw.Database('ei_33c').random():1})
testsetup_i2002 ={'inv': fu, 'ia':i2002}
bw.calculation_setups['testsetup_i2002'] = testsetup_i2002
mlca_test=bw.MultiLCA('testsetup_i2002')
result=mlca_test.lca.characterized_inventory.sum()
结果与从
获得的分数或得分总和不同mlca_test.results()
答案 0 :(得分:0)
您可以看到MultiLCA
source code,这相对简单。它会为计算的每个步骤覆盖characterized_inventory
矩阵,并仅将结果存储在Numpy数组中:self.results = np.zeros((len(self.func_units), len(self.methods)))
。为了得到你想要的 - 为功能单元和LCIA方法的每个组合分别表征库存矩阵 - 你必须编写自己的子类。这是一个例子:
from bw2calc.multi_lca import *
class PersistentMultiLCA(MultiLCA):
def __init__(self, cs_name):
if not calculation_setups:
raise ImportError
assert cs_name in calculation_setups
try:
cs = calculation_setups[cs_name]
except KeyError:
raise ValueError(
"{} is not a known `calculation_setup`.".format(cs_name)
)
self.func_units = cs['inv']
self.methods = cs['ia']
self.lca = LCA(demand=self.all, method=self.methods[0])
self.lca.lci(factorize=True)
self.method_matrices = []
self.results = {}
for method in self.methods:
self.lca.switch_method(method)
self.method_matrices.append(self.lca.characterization_matrix)
for row, func_unit in enumerate(self.func_units):
self.lca.redo_lci(func_unit)
for col, cf_matrix in enumerate(self.method_matrices):
self.lca.characterization_matrix = cf_matrix
self.lca.lcia_calculation()
self.results[row, col] = self.lca.characterized_inventory.copy()