Skip to main content

Tools for importing and export life cycle inventory databases

Project description

bw2io pypi version bw2io conda-forge version bw2io appveyor build status Test coverage report

This package provides tools for the import, export, and management of inventory databases and impact assessment methods. It is part of the Brightway LCA framework. Online documentation is available, and the source code is hosted on Github.

Bw2io approach

brightway2-io is an ETL library. First, data is extracted into a common format. Next, a series of strategies is employed to uniquely identify each dataset and link datasets internally and to the biosphere. Following internal linking, linking to other background datasets can be performed. Finally, database data is written to disk.

This approach offers a number of benefits that help mitigate some of the serious problems in existing inventory data formats: the number of unlinked exchanges can be easily seen, linking strategies can be iteratively applied, and intermediate results can be saved.

Here is a typical usage. Note that we also have shortcuts for popular LCA databases such as ecoinvent:

In [1]: import bw2io as bi

In [2]: import brightway2 as bw2

In [3]: bi.__version__
Out[3]: (0, 8, 7)

In [4]: bw2.__version__
Out[4]: (2, 4, 1)

In [5]: importer = bi.SingleOutputEcospold2Importer('path/to/ecoinvent/datasets/', 'ei_38_cutoff')
Extracting XML data from 19565 datasets
Extracted 19565 datasets in 19.21 seconds

In [6]: importer.apply_strategies()
Applying strategy: normalize_units
Applying strategy: update_ecoinvent_locations
Applying strategy: remove_zero_amount_coproducts
Applying strategy: remove_zero_amount_inputs_with_no_activity
Applying strategy: remove_unnamed_parameters
Applying strategy: es2_assign_only_product_with_amount_as_reference_product
Applying strategy: assign_single_product_as_activity
Applying strategy: create_composite_code
Applying strategy: drop_unspecified_subcategories
Applying strategy: fix_ecoinvent_flows_pre35
Applying strategy: drop_temporary_outdated_biosphere_flows
Applying strategy: link_biosphere_by_flow_uuid
Applying strategy: link_internal_technosphere_by_composite_code
Applying strategy: delete_exchanges_missing_activity
Applying strategy: delete_ghost_exchanges
Applying strategy: remove_uncertainty_from_negative_loss_exchanges
Applying strategy: fix_unreasonably_high_lognormal_uncertainties
Applying strategy: set_lognormal_loc_value
Applying strategy: convert_activity_parameters_to_list
Applying strategy: add_cpc_classification_from_single_reference_product
Applying strategy: delete_none_synonyms
Applied 21 strategies in 3.62 seconds

In [7]: importer.statistics()
19565 datasets
629959 exchanges
0 unlinked exchanges

Out[7]: (19565, 629959, 0)

In [8]: if importer.statistics()[2] == 0:
...:     importer.write_database()
...: else:
...:     print("There are unlinked exchanges.")
...:     importer.write_excel()
...:
19565 datasets
629959 exchanges
0 unlinked exchanges

Writing activities to SQLite3 database:
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:02:29
Title: Writing activities to SQLite3 database:
Started: 11/07/2022 11:55:57
Finished: 11/07/2022 11:58:26
Total time elapsed: 00:02:29
CPU %: 32.90
Memory %: 11.17
Created database: ei_38_cutoff

Note that brightway2-io can’t magically make problems in databases go away.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bw2io-0.9.16.tar.gz (27.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bw2io-0.9.16-py3-none-any.whl (27.6 MB view details)

Uploaded Python 3

File details

Details for the file bw2io-0.9.16.tar.gz.

File metadata

  • Download URL: bw2io-0.9.16.tar.gz
  • Upload date:
  • Size: 27.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bw2io-0.9.16.tar.gz
Algorithm Hash digest
SHA256 a84ff89ee6743d44f85ee83587848849799c1bc7302486836f7d81fd5fae1e68
MD5 296ef0558a8eb1edfdbcd77e4a9b6ae6
BLAKE2b-256 8ef74636f1a41afa403520aab20b8e81e1c9d476c14f4d91733005292a62e603

See more details on using hashes here.

Provenance

The following attestation bundles were made for bw2io-0.9.16.tar.gz:

Publisher: python-package-deploy.yml on brightway-lca/brightway2-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bw2io-0.9.16-py3-none-any.whl.

File metadata

  • Download URL: bw2io-0.9.16-py3-none-any.whl
  • Upload date:
  • Size: 27.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bw2io-0.9.16-py3-none-any.whl
Algorithm Hash digest
SHA256 e6c9ae5e159f7a1e546e236b8d25bf4b5071515b6d977c9da03c04a66fdbc792
MD5 b7e3094e8016b96e1d56f47dc67bf51d
BLAKE2b-256 8028c55f4b17b3cdb90f663d63701e2bc6e4c16313a26cb0141272d42e2a95cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bw2io-0.9.16-py3-none-any.whl:

Publisher: python-package-deploy.yml on brightway-lca/brightway2-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page