如何在 Brightway2 中手动 link 一个导入的交易所,因为我在 ecoinvent 中找到了正确的交易所
How to manually link in Brightway2 an imported exchange, given I have found the correct one in ecoinvent
我一直在 link 使用
自动处理我的数据
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()
当我用
列出剩余的未linked数据集时
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)
如何link将这些数据集放在一起?
这是来自 ecoinvent 3.2 的数据集,bw2io 还没有 "special" SimaPro 名称的迁移数据。通常从 Simapro 名称(例如 Electricity, low voltage {ENTSO-E}| market group for | Alloc Rec, U
)到 ecoinvent activity 名称和参考产品的转换将由迁移处理 simapro-ecoinvent-3
。但这在这种情况下不起作用:
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"
)
然后将此迁移应用于您未link编辑的数据:
sp.migrate("new-ecoinvent")
迁移仅更改用于link的数据;你仍然需要将 link_iterable_by_fields
应用于实际 link 对抗 ecoinvent 3.2.
我一直在 link 使用
自动处理我的数据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()
当我用
列出剩余的未linked数据集时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)
如何link将这些数据集放在一起?
这是来自 ecoinvent 3.2 的数据集,bw2io 还没有 "special" SimaPro 名称的迁移数据。通常从 Simapro 名称(例如 Electricity, low voltage {ENTSO-E}| market group for | Alloc Rec, U
)到 ecoinvent activity 名称和参考产品的转换将由迁移处理 simapro-ecoinvent-3
。但这在这种情况下不起作用:
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"
)
然后将此迁移应用于您未link编辑的数据:
sp.migrate("new-ecoinvent")
迁移仅更改用于link的数据;你仍然需要将 link_iterable_by_fields
应用于实际 link 对抗 ecoinvent 3.2.