简体   繁体   English

Brightway2 - 导入 Simapro LCIA 方法时未链接和丢失 cfs

[英]Brightway2 - Unlinked and missing cfs when importing Simapro LCIA methods

I am importing Swiss building database UVEK's LCIA methods to Brightway with SimaProLCIACSVImporter()我正在使用SimaProLCIACSVImporter()将瑞士建筑数据库 UVEK 的 LCIA 方法导入 Brightway

Code:代码:

lcia = SimaProLCIACSVImporter(
    "C:\\Users\\...\\UVEK_Simapro_LCIA_2022.CSV",
    biosphere="biosphere3"
)
lcia.apply_strategies()
lcia.statistics()
print("size biosphere3: {0}".format(str(len(Database("biosphere3")))))

Results:结果:

Extracted 34 methods in 0.91 seconds
Applying strategy: normalize_units
Applying strategy: set_biosphere_type
Applying strategy: normalize_simapro_biosphere_categories
Applying strategy: normalize_simapro_biosphere_names
Applying strategy: set_biosphere_type
Applying strategy: drop_unspecified_subcategories
Applying strategy: normalize_biosphere_categories
Applying strategy: normalize_biosphere_names
Applying strategy: link_iterable_by_fields
Applying strategy: match_subcategories
Applied 10 strategies in 0.87 seconds
34 methods
18229 cfs
14312 unlinked cfs

size biosphere3: 4427

I then use add_missing_cfs() with the idea to add the missing flows to the biosphere3 database (in order to easily import the LCI datasets built over those flows).然后我使用add_missing_cfs()将缺失的流添加到biosphere3数据库(以便轻松导入基于这些流构建的 LCI 数据集)。

Code:代码:

lcia.add_missing_cfs()
lcia.statistics()
print("size biosphere3: {0}".format(str(len(Database("biosphere3")))))

Results:结果:

Vacuuming database 
Writing activities to SQLite3 database:
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:00:01
Title: Writing activities to SQLite3 database:
  Started: 06/13/2022 12:23:24
  Finished: 06/13/2022 12:23:25
  Total time elapsed: 00:00:01
  CPU %: 79.20
  Memory %: 1.85
Added 7156 new biosphere flows
34 methods
18229 cfs
14312 unlinked cfs

size biosphere3: 11583

The results shows that the number of unlinked flows is unchanged (~14000).结果显示未链接流的数量没有变化(~14000)。 New flows have been added to the database (~7000) but it doesn't equal the number of unlinked cfs.新流已添加到数据库中 (~7000),但它不等于未链接的 cf 的数量。 Maybe I misunderstood unlinked flows and missing cfs...也许我误解了未链接的流程和缺少 cfs ...

Questions:问题:

What is the relation between biosphere flows, unlinked cfs and missing cfs that have been added to the biosphere db?生物圈流量、未链接的 cfs 和已添加到生物圈数据库的缺失 cfs 之间的关系是什么?

What is the best way to "complete" the biosphere3 db with the missing flows defined in the imported LCIA methods in order to have all the cfs linked?使用导入的 LCIA 方法中定义的缺失流“完成”biosphere3 db 以便链接所有 cfs 的最佳方法是什么?

I managed to overcome this problem, but I am not sure if this is the 100% correct way.我设法克服了这个问题,但我不确定这是否是 100% 正确的方法。 Nevertheless, I thought I would share my solution with you.不过,我想我会与您分享我的解决方案。 Maybe this also serves @Chris Mutel as possible bug fixing...也许这也为@Chris Mutel 提供了可能的 bug 修复……

I had the same problem as discussed in this issue.我遇到了与本期讨论的问题相同的问题。 Some background info: In my case, I created an empty biosphere3 database, then imported my specific LCIA method using LCIACSVImporter which resulted in 12'621 unlinked characterization factors.一些背景信息:在我的例子中,我创建了一个空的biosphere3数据库,然后使用LCIACSVImporter导入了我的特定 LCIA 方法,这导致了 12'621 个未链接的特征因子。 I then applied the strategy add_missing_cfs , which added the missing biosphere flows successfully to the biosphere3 database (Note: I have checked this by extracting all the biosphere3 flows to an excel table, which resulted in a table with 12'621 rows. I therefore assume the addition has worked successfully).然后我应用了策略add_missing_cfs ,它成功地将丢失的biosphere3流添加到 biosphere3 数据库中(注意:我已经通过将所有biosphere3流提取到 excel 表来检查这一点,这导致了一个包含 12'621 行的表。因此我假设添加成功)。

However, although applying the strategies ( apply.strategies() ) again, I still got 12'200 unlinked characterization factors although the biosphere flows were there in the biosphere3 database.然而,尽管再次应用策略( apply.strategies() ),尽管 biosphere3 数据库中有biosphere3流,但我仍然得到 12'200 个未关联的特征因子。 Having looked at the added biosphere flows, I then saw that the CAS-Nr.查看了添加的生物圈流量后,我看到了 CAS-Nr。 was not imported by the LCIACSVImporter , although the information had been there in the raw CSV file.不是由LCIACSVImporter导入的,尽管信息已经存在于原始 CSV 文件中。 The problem therefore had to be in Brightway's attempt to link data.因此,问题必须出在 Brightway 尝试链接数据的过程中。

The solution to the problem was (at least in my case), to tell Brightway that the linking should be based solely on the code parameter.问题的解决方案是(至少在我的情况下)告诉 Brightway 链接应该仅基于code参数。 And it worked, I'm not sure.它奏效了,我不确定。 what standard procedure is defined by Brightway for linking, I assume, that a combination of the parameters name , CAS_number , categories and unit is used. Brightway 为链接定义了什么标准程序,我假设使用了参数nameCAS_numbercategoriesunit的组合。 If this is true, then it would make very much sense, that linkage would not work, because some information such as CAS_number is currently not available because it is not imported by the LCIACSVImporter .如果这是真的,那么这将非常有意义,该链接将不起作用,因为某些信息(例如CAS_number )当前不可用,因为它不是由LCIACSVImporter导入的。

So, how did I tell Brightway to link solely on the code parameter.那么,我是如何告诉 Brightway 仅在code参数上进行链接的。 I applied the following:我应用了以下内容:

Import your LCIA method as you would normally:像往常一样导入您的 LCIA 方法:

my_method = bw.SimaProLCIACSVImporter('SimaPro_LCIA_file.csv', biosphere = "biosphere3")
my_method.apply_strategies()
my_method.statistics()

After that, write the missing characterization factors:之后,写出缺失的特征因子:

my_method.add_missing_cfs()
my_method.apply_strategies()

Linking on the code parameter can be done this way:可以通过以下方式链接code参数:

import functools
from bw2io.strategies.generic import link_iterable_by_fields

my_method.apply_strategy(functools.partial(
                         link_iterable_by_fields,
                         other = (obj for obj in bw.Database("biosphere3")),
                         kind = "biosphere",
                         fields = ["code"]
                         ))
my_method.statistics()
my_method.write()

Hope that helps!希望有帮助!

An excellent question, but unfortunately not one with an easy answer.一个很好的问题,但不幸的是没有一个简单的答案。 This is something I am looking into, but it will take some time, as it needs to be done correctly.这是我正在研究的事情,但这需要一些时间,因为它需要正确完成。

You probably already know this, but in case you don't - what is matching?您可能已经知道这一点,但万一您不知道 - 什么是匹配的? We need to link the text attributes which identify a product, flow, or activity, with an object in our relational database.我们需要将标识产品、流程或活动的文本属性与关系数据库中的对象链接起来。 In theory, these attributes should match, and our job is easy.从理论上讲,这些属性应该匹配,我们的工作很容易。 It becomes harder when people use inconsistent or incorrect attributes for what are supposed to be the same objects.当人们对应该是相同的对象使用不一致或不正确的属性时,就会变得更加困难。

Different players in the LCA world do their best to make their data and software easy to use, but sometimes this means that the different players make changes to things like names, location identifiers, etc. Moreover, there are different starting lists of names. LCA 世界中的不同玩家尽最大努力使他们的数据和软件易于使用,但这有时意味着不同的玩家会更改名称、位置标识符等内容。此外,名称的起始列表也不同。

The default data in Brightway (what gets installed when you call bw2io.bw2setup() is from ecoinvent version 3.8. This isn't "correct", it is just a default. The database biosphere3 is from ecoinvent version 3. But this isn't the same as UVEK, which is based on ecoinvent version 2. Brightway 中的默认数据(调用bw2io.bw2setup()时安装的数据来自 ecoinvent 版本 3.8。这不是“正确的”,它只是默认值。数据库biosphere3来自 ecoinvent 版本 3。但这不是t 与基于 ecoinvent 版本 2 的 UVEK 相同。

The UVEK database is self-contained and internally consistent, and its LCIA method characterization factors should match the flow names of the UVEK database itself (at least as long as they come from the same source, eg SimaPro CSV export). UVEK 数据库是自包含且内部一致的,其 LCIA 方法特征因子与 UVEK 数据库本身的流程名称匹配(至少只要它们来自同一来源,例如 SimaPro CSV 导出)。 So the best way to use this LCI/LCIA in Brightway would be to use these data in their own set of Brightway databases.因此,在 Brightway 中使用此 LCI/LCIA 的最佳方式是在他们自己的 Brightway 数据库集中使用这些数据。

There will be a project to natively implement UVEK and its LCIA factors in Brightway, but this will only happen by the end of July (at the earliest).将有一个项目在 Brightway 本地实施 UVEK 及其 LCIA 因素,但这只会在 7 月底(最早)发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM