bw2io.ecoinvent
#
Module Contents#
Functions#
|
|
|
Read XML metadata file instead of using openpyxl, which loads the whole workbook. |
|
|
|
Import an ecoinvent LCI and/or LCIA release. |
|
- bw2io.ecoinvent.get_excel_sheet_names(file_path: pathlib.Path) list[str] [source]#
Read XML metadata file instead of using openpyxl, which loads the whole workbook.
- bw2io.ecoinvent.import_ecoinvent_release(version: str, system_model: str, username: str | None = None, password: str | None = None, lci: bool = True, lcia: bool = True, biosphere_name: str | None = None, biosphere_write_mode: str = 'patch', importer_signal: Any = None) None [source]#
Import an ecoinvent LCI and/or LCIA release.
Uses [ecoinvent_interface](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.
System model strings follow the ecoinvent unofficial API. They can be given in a short or long form. The short forms:
cutoff
consequential
apos
EN15804
And the long forms:
Allocation cut-off by classification
Substitution, consequential, long-term
Allocation at the Point of Substitution
Allocation, cut-off, EN15804ā
Parameters#
- 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ā
- username
ecoinvent username
- password
ecoinvent password
- lci
Flag on whether to import the inventory database
- lcia
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.
- biosphere_write_mode
How to handle an existing biosphere database. Must be either replace or patch
- importer_signal
Used by the Activity Browser to provide feedback during the import
Examples#
Get ecoinvent 3.9.1 cutoff in a new project (without running bw2setup first):
>>> 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="XXX", ... password="XXX"", ... ) >>> bd.databases Databases dictionary with 2 object(s): ecoinvent-3.9.1-biosphere ecoinvent-3.9.1-cutoff >>> len(bd.methods) 762
Add ecoinvent 3.9.1 apos to the same project:
>>> bi.import_ecoinvent_release( ... version="3.9.1", ... system_model="apos", ... username="XXX", ... password="XXX"", ... use_existing_biosphere=True ... ) >>> bd.databases Databases dictionary with 3 object(s): ecoinvent-3.9.1-apos ecoinvent-3.9.1-biosphere ecoinvent-3.9.1-cutoff
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="XXX", ... password="XXX", ... biosphere_name="biosphere3", ... lcia=False ... ) >>> bd.databases Databases dictionary with 2 object(s): biosphere3 ecoinvent-3.9.1-cutoff >>> len(bd.methods) 0