我一直在用
自动链接我的数据import functools
from bw2io.strategies import link_iterable_by_fields
sp.apply_strategy(functools.partial(
link_iterable_by_fields,
other=Database("ecoinvent 3.2 cutoff"),
kind="technosphere",
fields=["reference product", "name", "unit", "location"]
))
sp.statistics()
当我用
列出剩余的未链接数据集时bw2io.importers.simapro_csv.SimaProCSVImporter
输出例如:
Electricity, low voltage {ENTSO-E}| market group for | Alloc Rec, U kilowatt hour ('Electricity/heat',)
鉴于我在ecoinvent中找到了数据集:
'market group for electricity, low voltage' (kilowatt hour, ENTSO-E, None)
如何将这些数据集链接在一起?
答案 0 :(得分:0)
这是来自ecoinvent 3.2的数据集,其中bw2io还没有“特殊”SimaPro名称的迁移数据。通常,迁移Electricity, low voltage {ENTSO-E}| market group for | Alloc Rec, U
将处理从Simapro名称(例如simapro-ecoinvent-3
)到ecoinvent活动名称和参考产品的转换。但是在这种情况下这不起作用:
In [4]: Migration('simapro-ecoinvent-3').load()['Electricity, low voltage {ENTSO-E}| market group for | Alloc Rec, U']
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
您可以编写自己的迁移:
migration_data = {
'fields': ['name'],
'data': [
(
# First element is input data in the order of `fields` above
('Electricity, low voltage {ENTSO-E}| market group for | Alloc Rec, U',),
# Second element is new values
{
'name': 'market group for electricity, low voltage',
'reference product': 'electricity, high voltage',
'location': 'ENTSO-E',
}
)
]
}
Migration("new-ecoinvent").write(
migration_data,
description="New datasets in ecoinvent 3.2"
)
然后将此迁移应用于未链接的数据:
sp.migrate("new-ecoinvent")
迁移仅更改用于链接的数据;你仍然需要申请link_iterable_by_fields
来实际链接ecoinvent 3.2。