这个问题与这里提出的问题非常相似。只是我不能使工作成为建议的解决方案(而且我没有添加评论的声誉)。
我想创建一种仅具有与化石燃料燃烧相关的 CO2、CH4 和 N2O 的全球变暖潜力的方法。
查看生物圈数据库,我创建了一个包含流的键和特征因子的元组列表:
flows_list=[]
for flow in bw.Database('biosphere3'):
if 'Carbon dioxide, fossil' in flow['name']:
flows_list.append((flow.key,1.0))
if flow['name']=='Methane':
flows_list.append((flow.key,29.7))
if flow['name']=='Dinitrogen monoxide':
flows_list.append((flow.key,264.8))
接着:
ipcc2013_onlyfossil=bw.Method(('IPCC2013_onlyfossil','climate change','GWP100a'))
ipcc2013_onlyfossil.register(**{'unit':'kg CO2eq',
'num_cfs':11,
'abbreviation':'nonexistent',
'description':'based on IPCC 2013 method but just for fossil CO2, CH4 and N2O',
'filename':'nonexistent'})
(我不明白双 ** 的目的,或者我们是否可以将字典元数据中的键留空)
最后:
ipcc2013_onlyfossil.write(flows_list)
我一定是做错了什么,因为如果我尝试使用这种方法,我会得到一个断言错误,Brightway 找不到模型。
更新:我的代码中有一个错误,新方法工作得很好。
例如,如果我运行:
[m for m in bw.methods if 'IPCC' in m[0]
and 'GWP100' in str(m)]
我得到了方法列表,包括我尝试创建的方法,我可以用它进行 LCA 计算。
(PS:我不太清楚我应该如何使用方法类的 validate() 方法..)