我正在尝试根据其他地区的代理在 Brightway 中创建一个新活动。我希望香肠能够完成繁重的工作并将数据集连接到适当的市场。
在此示例中,我尝试使用瑞士数据集作为代理在魁北克创建低压天然气市场。魁北克有高压天然气市场。还有一个连接低压和高压市场活动的中间过程(减压)。这就是我所做的:
#db_name is the name of my consequential version of ecoinvent 3.4
data= w.extract_brightway2_databases([db_name])
CH_location = [w.equals('location','CH')]
pressure_red=[w.equals('name','natural gas pressure reduction from high to low pressure')]
ch_pressure_red_filter=CH_location+pressure_red
ch_pred=w.get_one(data,*ch_pressure_red_filter)
ch_market_lp_ng_filter=CH_location+[w.equals('name','market for natural gas, low pressure')]
ch_mlp_ng=w.get_one(data,*ch_market_lp_ng_filter)
#create a copy of the datasets and change location
qc_mlp_ng=ch_mlp_ng.copy()
qc_mlp_ng['location']='CA-QC'
qc_pred=ch_pred.copy()
qc_pred['location']='CA-QC'
new_data=[qc_mlp_ng,qc_pred]
w.write_brightway2_database(data+[qc_mlp_ng,qc_pred],'expanded_ecoinvent')
这会引发一个NonuniqueCode 错误,我猜这是因为当我创建副本时,我有几个具有相同代码的数据集。应该怎么做才能避免这个错误?该程序是否会将魁北克所有消耗低压天然气的活动重新链接到我的低压天然气新市场?