0

我需要找到在 LCA 中使用/排放特定生物圈流的过程。我在这里看到有一些方法看起来像我需要的,但它们被注释掉了。它们真的是我想要的吗?如果没有,有没有办法得到这个?

4

1 回答 1

2

天真的方法

您可以遍历数据库中的所有生物圈交换:

db = Database("ecoinvent 3.2 cutoff")
some_flow = Database("biosphere3").random()
consumers = {
    exc.output 
    for ds in db 
    for exc in ds.biosphere() 
    if exc.input == some_flow
}

这简单易懂,但速度较慢。

先进的方法

您可以对底层数据库执行 SQL 查询:

from bw2data.backends.peewee import ExchangeDataset
consumers_fast = [
    get_activity((db.name, obj[0])) for obj in 
    ExchangeDataset.select(ExchangeDataset.output_code).where(
        (ExchangeDataset.input_database == some_flow['database']) &
        (ExchangeDataset.input_code == some_flow['code']) & 
        (ExchangeDataset.output_database == db.name)
    ).distinct().tuples()
]

注意:高级类型的查询在下一个 Brightway会容易得多

LCA检查对象中的生物圈基质

您还可以从构造的LCA对象中获取此信息:

lca = LCA({db.random(): 1})
lca.lci()
row = lca.biosphere_dict[some_flow]
col_indices = lca.biosphere_matrix[row, :].tocoo()
ra, _, _ = lca.reverse_dict()
consumers_lca = [get_activity(ra[index]) for index in col_indices.col]
consumers_lca

如果您还想从构造LCA对象中获取库存数量:

lca = LCA({db.random(): 1})
lca.lci()
row = lca.biosphere_dict[some_flow]
col_indices = lca.biosphere_matrix[row, :].tocoo()
ra, _, _ = lca.reverse_dict()
amount_consumers_lca = [lca.inventory[row, index] for index in col_indices.col]
amount_consumers_lca

有了这个,您可以从构造LCA对象中获取库存量,仅用于某些过程(list_of_processes)使用/发射生物圈流(some_flow):

process_keys = [obj.key for obj in Database("lci_db") if obj["name"] in list_of_processes]
lca = LCA({db.random(): 1})
lca.lci()
row = lca.biosphere_dict[some_flow]
col_indices = lca.biosphere_matrix[row, :].tocoo()
ra, _, _ = lca.reverse_dict()
amount_process_keys_lca = [lca.inventory[row, index] for index in col_indices.col if ra[index] in process_keys]

amount_process_keys_lca
于 2017-01-25T14:49:10.410 回答