From 9810c4843316c42c91e01bff3f4c93becaf1c948 Mon Sep 17 00:00:00 2001 From: Chris Mutel Date: Fri, 10 Nov 2023 07:59:42 +0100 Subject: [PATCH] 0.9.dev25 --- CHANGES.md | 5 ++++ README.rst | 67 +++------------------------------------------- bw2io/ecoinvent.py | 38 +++++++++++++++----------- bw2io/version.py | 2 +- 4 files changed, 31 insertions(+), 81 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5ec17967..8a211da9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # `bw2io` Changelog +### 0.9.DEV25 (2023-11-10) + +* Fix missing import from dev24 +* Some documentation improvements + ### 0.9.DEV24 (2023-11-09) * [#227 Add `import_ecoinvent_release` utility](https://github.com/brightway-lca/brightway2-io/pull/227) diff --git a/README.rst b/README.rst index 71a7f97d..b549c147 100644 --- a/README.rst +++ b/README.rst @@ -17,77 +17,16 @@ Brightway2 input and output :target: https://coveralls.io/bitbucket/cmutel/brightway2-io?branch=default :alt: 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 `Brightway2 LCA framework `_. `Online documentation `_ is available, and the source code is hosted on `Github `_. - -Compatibility with Brightway2X ------------------------------- -*Until there is a solution to using seamlessly bw2io to use any flow list (to create the biosphere) regardless of the bw2io and brightway2X package version, specific versions of bw2io must be used for compatibility with specific ecoinvent versions.* - -This code in this repository is used to release packages for both `Brightway25 `_ (the current default branch of this repository `"master" `_) and `Brightway2 `_ (the `"legacy" `_ branch in this repository). - -- For the *Brightway2 compatible* version, use a ``0.8.X`` version. - - use version ``0.8.7`` to have a Brightway2 installation compatible with Ecoinvent 3.8 - - If you have a working environment with brightway2 :: - - conda install -c conda-forge -c cmutel bw2io=0.8.7 - - If you have are starting a new environment :: - - conda install -c conda-forge -c cmutel brightway2 bw2io=0.8.7 - - - - use version ``0.8.8`` to have a Brightway2 installation compatible with Ecoinvent 3.9 :: - - conda install -c conda-forge bw2io=0.8.8 # If you have a working environment with brightway2 - conda install -c conda-forge brightway2 bw2io=0.8.8 # If you are starting a new environment - - - -- For the *Brightway25 compatible* version, use a ``0.9.X`` version. - - use version ``0.9.dev11`` to have a Brightway2 installation compatible with Ecoinvent 3.8. - - *This version is only available through pypi.* - - If you already have a brightway25 environment, do :: - - - pip install bw2io==0.9.dev11 - - - use version ``0.9.dev10`` to have a Brightway2 installation compatible with Ecoinvent 3.9 :: - - conda install -c conda-forge -c cmutel bw2io=0.9.dev10 # If you have a working environment with brightway25 - conda install -c conda-forge -c cmutel brightway25 bw2io=0.9.dev10 # If you are starting a new environment - - -TL;DR -^^^^^ - -Summing up, you need a specific version of bw2io for specific versions of ecoinvent 3.8 and 3.9.:: - - +------------------|-------------------|------------------+ - |Ecoinvent version | Brightway Version | bw2io Version | - +==================|===================|==================+ - |ecoinvent 3.8 | bw2 | bw2io 0.8.7 | - +------------------|-------------------|------------------+ - |ecoinvent 3.9 | bw2 | bw2io 0.8.8 | - +------------------|-------------------|------------------+ - |ecoinvent 3.8 | bw25 | bw2io 0.9.dev11 | - +------------------|-------------------|------------------+ - |ecoinvent 3.9 | bw25 | bw2io 0.9.dev10 | - +------------------|-------------------|------------------+ - - +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 --------------- -In contrast with previous IO functionality in Brightway2, brightway2-io uses an iterative approach to importing and linking data. 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. +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: - +Here is a typical usage. Note that we also have shortcuts for popular LCA databases such as ecoinvent: .. code-block:: python diff --git a/bw2io/ecoinvent.py b/bw2io/ecoinvent.py index 0769bd8a..2cd0f76d 100644 --- a/bw2io/ecoinvent.py +++ b/bw2io/ecoinvent.py @@ -68,11 +68,16 @@ def import_ecoinvent_release( """ Import an ecoinvent LCI and/or LCIA release. - Uses [ecoinvent_interface](https://github.com/brightway-lca/ecoinvent_interface). Auth credentials are optional as they can be set externally (see the `ecoinvent_interface` documentation), and such permanent storage is highly recommended. + Uses [ecoinvent_interface](https://github.com/brightway-lca/ecoinvent_interface). + Auth credentials are optional as they can be set externally (see the + `ecoinvent_interface` documentation), and such permanent storage is highly + recommended. - **DO NOT** run `bw2setup` before using this function - it isn't needed and will cause broken results. + **DO NOT** run `bw2setup` before using this function - it isn't needed and + will cause broken results. - System model strings follow the ecoinvent unofficial API. They are given in a short or long form. The short forms: + System model strings follow the ecoinvent unofficial API. They can be given + in a short or long form. The short forms: * cutoff * consequential @@ -91,7 +96,8 @@ def import_ecoinvent_release( version The ecoinvent release version as a string, e.g. '3.9.1' system_model - The system model as a string in short or long form, e.g. 'apos' or 'Allocation cut-off by classification' + The system model as a string in short or long form, e.g. 'apos' or + 'Allocation cut-off by classification' username ecoinvent username password @@ -99,9 +105,11 @@ def import_ecoinvent_release( lci Flag on whether to import the inventory database lcia - Flag on whether to import the LCIA impact categories + Flag on whether to import the LCIA impact categories. The biosphere + database must exist if `lci` is `False` biosphere_name - Name of database to store biosphere flows. They will be stored in the main LCI database if not specified. + Name of database to store biosphere flows. They will be stored in the + main LCI database if not specified. use_existing_biosphere Flag on whether to create a new biosphere database or use an existing one importer_signal @@ -112,17 +120,14 @@ def import_ecoinvent_release( Get ecoinvent 3.9.1 cutoff in a new project (**without** running `bw2setup` first): - >>> my_ecoinvent_username = "XXX" - >>> my_ecoinvent_password = "XXX" - >>> import ecoinvent_interface as ei >>> import bw2data as bd >>> import bw2io as bi >>> bd.projects.set_current("some new project") >>> bi.import_ecoinvent_release( ... version="3.9.1", ... system_model="cutoff", - ... username=my_ecoinvent_username, - ... password=my_ecoinvent_password, + ... username="XXX", + ... password="XXX"", ... ) >>> bd.databases Databases dictionary with 2 object(s): @@ -136,8 +141,8 @@ def import_ecoinvent_release( >>> bi.import_ecoinvent_release( ... version="3.9.1", ... system_model="apos", - ... username=my_ecoinvent_username, - ... password=my_ecoinvent_password, + ... username="XXX", + ... password="XXX"", ... use_existing_biosphere=True ... ) >>> bd.databases @@ -146,14 +151,15 @@ def import_ecoinvent_release( ecoinvent-3.9.1-biosphere ecoinvent-3.9.1-cutoff - Create a new database but use `biosphere3` for the biosphere database name don't add LCIA methods + Create a new database but use `biosphere3` for the biosphere database name + and don't add LCIA methods: >>> bd.projects.set_current("some other project") >>> bi.import_ecoinvent_release( ... version="3.9.1", ... system_model="cutoff", - ... username=my_ecoinvent_username, - ... password=my_ecoinvent_password, + ... username="XXX", + ... password="XXX", ... biosphere_name="biosphere3", ... lcia=False ... ) diff --git a/bw2io/version.py b/bw2io/version.py index cca4a081..a2afcdfc 100644 --- a/bw2io/version.py +++ b/bw2io/version.py @@ -1 +1 @@ -version = (0, 9, "DEV24") +version = (0, 9, "DEV25")