Python生命周期分析: Brightway2 报错unlink exchange的调试方法
作者:互联网
点赞发Nature
关注中Science
用brightway2
和构建基于excel的生命周期数据库时,常出现一下报错
link = r"path\to\database.xlsx"
db = bw.ExcelImporter(link)
db.apply_strategies()
db.match_database(
db_name="ecoinvent 3.6",
fields=["name", "unit", "location", ],
)
db.statistics()
> Extracted 1 worksheets in 0.02 seconds
> Applying strategy: csv_restore_tuples
> Applying strategy: csv_restore_booleans
> Applying strategy: csv_numerize
> Applying strategy: csv_drop_unknown
> Applying strategy: csv_add_missing_exchanges_section
> Applying strategy: normalize_units
> Applying strategy: normalize_biosphere_categories
> Applying strategy: normalize_biosphere_names
> Applying strategy: strip_biosphere_exc_locations
> Applying strategy: set_code_by_activity_hash
> Applying strategy: link_iterable_by_fields
> Applying strategy: assign_only_product_as_production
> Applying strategy: link_technosphere_by_activity_hash
> Applying strategy: drop_falsey_uncertainty_fields_but_keep_zeros
> Applying strategy: convert_uncertainty_types_to_integers
> Applying strategy: convert_activity_parameters_to_list
> Applied 16 strategies in 0.33 seconds
> Applying strategy: link_iterable_by_fields
> Writing activities to SQLite3 database:
> 6 datasets
> 24 exchanges
> 15 unlinked exchanges
Type technosphere: 15 unique unlinked exchanges
此时,我们可以查看到底时那些exchange
未连接,使用以下语句可以到相应路径下查看输出excel,找到unlink exchanges,做相应的调试
db.write_excel()
db.write_database()
> Wrote matching file to:
> <user path>\AppData\Local\pylca\Brightway3\SOFC.6b6e45b646d3f7510875adf749c4e552\output\database.xlsx
————————
我是仁荷大学的博士生(我的google scholar, 我的Github),关注能源转型过程中的环境、经济问题。
专注于分享利用python科研的技巧,欢迎一起交流、学习、合作。
关于我的博客内容、其他相关的研究问题,有问题可以下方
标签:Applying,exchange,Python,db,strategy,报错,exchanges,link,csv 来源: https://blog.csdn.net/weixin_46090057/article/details/121198452