Skip to content

Commit

Permalink
Update for ecoinvent3.7.1. Merging with modernize branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeAgez committed Aug 23, 2021
1 parent f367346 commit c665bcd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 37 deletions.
2 changes: 1 addition & 1 deletion doc/Analyze the hybrid database.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.6.10"
}
},
"nbformat": 4,
Expand Down
40 changes: 16 additions & 24 deletions doc/Running_pyLCAIO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,28 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For this tutorial, ecoinvent3.5 and exiobase3 were chosen as our LCA and IO database respectively. Therefore, you need to download the ecoinvent 3.5_cutoff_ecoSpold02.7z and ecoinvent 3.5_LCIA_implementation.7z files from https://v35.ecoquery.ecoinvent.org/File/Files and __unzip them__. You also need to download a pxp (product by product) file of whichever reference year you want from exiobase3 monatery versions found here: https://www.exiobase.eu/index.php/data-download/exiobase3mon"
"For this tutorial, ecoinvent3.5 and exiobase3 were chosen as our LCA and IO database respectively. Therefore, you need to download the ecoinvent 3.5_cutoff_ecoSpold02.7z and ecoinvent 3.5_LCIA_implementation.7z files from https://v35.ecoquery.ecoinvent.org/File/Files and __unzip them__. You also need to download a pxp (product by product) file of whichever reference year you want from exiobase3 monatery versions found here: https://doi.org/10.5281/zenodo.4588235"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These databases in the format you just downloaded them are not readable by Python (and therefore by pyLCAIO) and must be adapted to a python-readable format. PyLCAIO relies on two external modules to do this: ecospold2matrix (https://github.com/majeau-bettez/ecospold2matrix) and pymrio (https://github.com/konstantinstadler/pymrio). You need to download these two modules.\n",
"\n",
"For ecospold2matrix, you need to download the dev branch and not the master branch."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"images/prtsc1.png\">"
"These databases in the format you just downloaded them are not readable by Python (and therefore by pyLCAIO) and must be adapted to a python-readable format. PyLCAIO relies on two external modules to do this: ecospold2matrix (https://github.com/majeau-bettez/ecospold2matrix) and pymrio (https://github.com/konstantinstadler/pymrio). You need to download these two modules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the dataframe of ecoinvent"
"### Create the dataframes of ecoinvent"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To create the dataframe of ecoinvent, follow the tutorial on the ecospold2matrix Github page (https://github.com/majeau-bettez/ecospold2matrix/blob/master/doc/ecospold2matrix_demo.ipynb)."
"To create the dataframe of ecoinvent, follow the tutorial on the ecospold2matrix Github page (https://github.com/majeau-bettez/ecospold2matrix/blob/master/doc/)."
]
},
{
Expand Down Expand Up @@ -97,7 +88,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"After using ecospold2matrix, you should have in the \"out_dir\" you indicated a pickle file with a similar name to this: ecoinvent3.5.cutoffPandas_symmNorm.gz.pickle which contains the transformed ecoinvent.\n",
"After using ecospold2matrix, you should have in the \"out_dir\" you indicated, a pickle file with a similar name to this: ecoinvent3.5.cutoffPandas_symmNorm.gz.pickle which contains the transformed ecoinvent.\n",
"\n",
"Note: pickle is a storage format, just like .docx or .pdf, except it's only readable by Python."
]
Expand Down Expand Up @@ -228,7 +219,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The information required for the hybridization varies depending on which features you want the resulting hybrid database to have, said features are: endogenization of capitals of the IO database, completion of the environmental extensions of the IO database, regionalization of the impacts, use of impact world+ for results. **All these features are only available for exiobase3 at present**."
"The information required for the hybridization varies depending on which features you want the resulting hybrid database to have, said features are: endogenization of capitals of the IO database, completion of the environmental extensions of the IO database, regionalization of the impacts, use of impact world+ for results. **All these additional features are only available for the hybridization of ecoinvent3.5 and exiobase3 at present**."
]
},
{
Expand Down Expand Up @@ -308,20 +299,21 @@
"metadata": {},
"outputs": [],
"source": [
"lcaio_object = database_loader.combine_ecoinvent_exiobase(path_to_io_database='',path_to_capitals=path_to_capitals,\n",
"lcaio_object = database_loader.combine_ecoinvent_exiobase(path_to_capitals=path_to_capitals,\n",
" complete_extensions=complete_extensions, \n",
" impact_world=impact_world, regionalized=regionalized)"
" impact_world=impact_world, \n",
" regionalized=regionalized)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The lcaio_object was just initialized and ecoinvent and exiobase dataframes along with other essential parameters were transferred to it. We can now hybridize both databases with the method \".hybridize()\". This method requires 2 arguments: \n",
"- A boolean stating if capitals will be endogenized or not\n",
"- the name of the method to correct double counting. There are currently two choices available: 'STAM' or 'binary'. For details on these methods and know which one to use refer to: \n",
"* Agez, Maxime, Guillaume Majeau-Bettez, Manuele Margni, Anders Hammer Strømman, and Réjean Samson. 2019. “Lifting the Veil on the Correction of Double Counting Incidents in Hybrid Life Cycle Assessment.” Journal of Industrial Ecology.\n",
"* Agez, Maxime, Richard Wood, Manuele Margni, Anders Hammer Strømman, Réjean Samson, and Guillaume Majeau-Bettez. 2019. “Hybridization of Complete LCA and MRIO Databases for Comprehensive a Product System Coverage.” Journal of Industrial Ecology."
"The lcaio_object was just initialized and ecoinvent and exiobase dataframes along with other essential parameters were transferred to it. We can now hybridize both databases with the method \".hybridize()\". This method requires 2 arguments:\n",
"- The name of the method to correct double counting. There are currently two choices available: 'STAM' or 'binary'. For details on these methods and know which one to use refer to: \n",
" * Agez, Maxime, Guillaume Majeau-Bettez, Manuele Margni, Anders Hammer Strømman, and Réjean Samson. 2019. “Lifting the Veil on the Correction of Double Counting Incidents in Hybrid Life Cycle Assessment.” Journal of Industrial Ecology.\n",
" * Agez, Maxime, Richard Wood, Manuele Margni, Anders Hammer Strømman, Réjean Samson, and Guillaume Majeau-Bettez. 2019. “Hybridization of Complete LCA and MRIO Databases for Comprehensive a Product System Coverage.” Journal of Industrial Ecology.\n",
"- A boolean stating if capitals will be endogenized or not"
]
},
{
Expand Down Expand Up @@ -362,7 +354,7 @@
"source": [
"The system will be saved in the form of a hybrid_system.pickle and a description_system.txt files in your src/Databases/ folder.\n",
"\n",
"Note that everytime you recalculate a new system (say you change the features), it will dump the newly formed system at the same place with the same name. It is thus highly recommanded to move the two files in a separate folder with a meaningful name (e.g., STAM_capitals_extended_IW_regionalized/hybrid_system.pickle)."
"**_Important_** Note that everytime you recalculate a new system (say you change the features), it will dump the newly formed system at the same place with the same name. It is thus highly recommanded to move the two files in a separate folder with a meaningful name (e.g., STAM_capitals_extended_IW_regionalized/hybrid_system.pickle)."
]
},
{
Expand Down Expand Up @@ -452,7 +444,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.6.10"
}
},
"nbformat": 4,
Expand Down
18 changes: 6 additions & 12 deletions src/pylcaio.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,33 +469,27 @@ def combine_ecoinvent_exiobase(self, path_to_capitals='', complete_extensions=Fa
'/Data/eco' + str(
version_ecoinvent) + '_exio' + str(
version_exiobase) +
'/STAM_categories.txt').decode(
'utf-8'))
'/STAM_categories.txt').decode('utf-8'))
self.categories_same_functionality = ast.literal_eval(
pkg_resources.resource_string(
__name__,
'/Data/eco' + str(version_ecoinvent) + '_exio' + str(
version_exiobase) + '/STAM_functional_categories.txt').decode(
'utf-8'))
version_exiobase) + '/STAM_functional_categories.txt').decode('utf-8'))

# GEOGRAPHY CONCORDANCE

self.listcountry = ast.literal_eval(
pkg_resources.resource_string(
__name__,
'/Data/eco' + str(version_ecoinvent) + '_exio' + str(version_exiobase) + '/countries.txt').decode(
'utf-8'))
pkg_resources.resource_string(__name__,
'/Data/eco' + str(version_ecoinvent) + '_exio' + str(version_exiobase) + '/countries.txt').decode('utf-8'))

self.countries_per_regions = ast.literal_eval(
pkg_resources.resource_string(
__name__,
'/Data/eco' + str(version_ecoinvent) + '_exio' + str(version_exiobase) +
__name__, '/Data/eco' + str(version_ecoinvent) + '_exio' + str(version_exiobase) +
'/countries_per_regions.txt').decode('utf-8'))

self.replacements = ast.literal_eval(
pkg_resources.resource_string(
__name__,
'/Data/eco' + str(version_ecoinvent) + '_exio' + str(version_exiobase) +
__name__, '/Data/eco' + str(version_ecoinvent) + '_exio' + str(version_exiobase) +
'/geography_replacements.txt').decode('utf-8'))
self.PRO_f['io_geography'] = [self.replacements[i] if i in self.replacements else i for i in self.PRO_f.geography]

Expand Down

0 comments on commit c665bcd

Please sign in to comment.