You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取某一活动的命名生命周期清单(Named LCI)?

关于Brightway2中获取带标签LCI数据的问题

我正在计算某一活动的生命周期评价(LCA),代码如下:

act = [
       act for act in ei391cf
       if 'benzaldehyde production' == act['name']
       and 'RER' == act['location']
       ]

lca = bw.LCA(
    {act[0]: 1},
    ('ReCiPe 2016 v1.03, midpoint (H)',
     'water use', 'water consumption potential (WCP)')
    )

lca.lci()
lca.lcia()

我了解lca.biosphere_dict可返回生命周期清单(LCI)的生物圈流,但它仅列出生物圈流的编码,而非名称和类别。我可以自行编写函数获取名称和类别,但这应该是基础功能,肯定有现成函数。

我曾发现get_labelled_inventory函数,但尝试执行ba.lci.get_labeled_inventory(lca)时,返回错误:AttributeError: module 'bw2analyzer' has no attribute 'get_labeled_inventory'。


解决方法

  1. 检查导入方式与版本
    这个函数的正确导入路径是from bw2analyzer.lci import get_labeled_inventory,而非通过ba.lci调用。如果你的bw2analyzer版本过旧,也会导致找不到该函数,先升级:

    pip install --upgrade bw2analyzer
    
  2. 正确使用示例

    from bw2analyzer.lci import get_labeled_inventory
    
    # 完成LCI计算后调用
    labeled_inventory = get_labeled_inventory(lca)
    

    该函数会直接返回包含生物圈流名称、类别及对应流量值的结构化数据,无需手动编码映射。

  3. 备选手动映射方案
    如果暂时无法升级或使用该函数,也可以直接通过生物圈数据库手动匹配编码:

    biosphere_db = bw.Database("biosphere3")
    for code, amount in lca.biosphere_dict.items():
        flow = biosphere_db.get(code)
        print(f"名称: {flow['name']}, 类别: {flow['categories']}, 流量: {amount}")
    

内容的提问来源于stack exchange,提问作者Stücke

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 19:55:01