Skip to content

Commit

Permalink
Start repository
Browse files Browse the repository at this point in the history
  • Loading branch information
mixib committed Oct 31, 2022
0 parents commit 372e646
Show file tree
Hide file tree
Showing 33 changed files with 9,191 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.pyc
activity_overview_for_users_3.1_cut-off.xlsx
correspondence_file_eiv3.3_to_eiv3.4_20170921_final.xlsx
correspondence_file_eiv3.4_to_eiv3.5_20181008.xlsx
correspondence_file_eiv3.5_to_eiv3.6_2.xlsx
correspondence_file_eiv3.6_to_eiv3.7.xlsx
correspondence_file_intermediate-exchangesv2.2_to_v3.0_20130904.xlsx
ecoinvent_correspondence_file_eiv3.2_to_eiv3.3_final.xlsx
ecoinvent_correspondence_file_eiv3_1_to_eiv3_2_updated20151214_2.xlsx
145 changes: 145 additions & 0 deletions BWimport.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. Import databases from the data folder to brightway \n",
"\n",
"Depending on the accessibility to the ecoinvent database, this notebook offers two ways of reproducing the environmental profiles in the paper.\n",
"\n",
" * Option 1: Evaluation of the agggregated processes\n",
" * Option 2: Evaluation of the complete LCA system models"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Option 1: Import aggregated processes based on the LCIs calculated for the reference flows\n",
"\n",
"This option uses the backup file in the folder `<cwd>/data/results`. This file was created based on the LCIs generated for the combinations of reference flows and versions of the ecoinvent database detailed in the accompanying paper. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import brightway2 as bw\n",
"\n",
"filepath = Path.cwd()/(\n",
" 'data/results/'\n",
" 'brightway2-project-REM_aggregatedLCIs-backup.02-February-2022-07-01AM.tar.gz')\n",
"bw.restore_project_directory(filepath)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The project `REM_aggregatedLCIs` should now appear in the list of brightway projects when running the cell below."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"sorted(bw.projects)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `aggregated` database can also be imported by using the [Database Import Wizard](https://www.youtube.com/watch?v=qWzaQjAf8ZU) from the Activity Browser by selecting 'Import local data'>'Local Excel file'. The file to import is `LCIsAsAggregatedProcesses.xlsx`, which is located at `<cwd>/data/bw-harmonised`.\n",
"\n",
"The advantage of using the script in the first code cell of this notebook is that it already contains a setup with the CML-IA method baseline. Therefore, the LCIA methods don't have to be selected from a list. The caveat is that the GZ file to be loaded could have compatibility issues with some packages. The correct functioning of the Jupyter notebooks and related scripts was tested with the versions detailed in the next table.\n",
"\n",
"| Package | Version |\n",
"| :-: | :-: |\n",
"| python | 3.7.10 |\n",
"| bw2io | 0.7.12|\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Option 2: Link the foreground of the LCA system models to versions of the ecoinvent database.\n",
"\n",
"Select or create the brightway project in which the database will be loaded. The project should have the **biosphere3** database and the target **ecoinvent databases preloaded** before running the cell below. In the accompanying paper, the target versions are ecoinvent 2.2 and the cut-off alternatives from versions 3.1 to 3.6. The next table shows the strings used to name each version of the ecoinvent database.\n",
"\n",
"| ecoinvent version | String |\n",
"| :-: | :-: |\n",
"| 2.2 | ei22 |\n",
"| 3.1 cut-off | cutoff31|\n",
"| 3.2 cut-off | cutoff32|\n",
"| 3.3 cut-off | cutoff33|\n",
"| 3.4 cut-off | cutoff34|\n",
"| 3.5 cut-off | cutoff35|\n",
"| 3.6 cut-off | cutoff36|\n",
"\n",
"This option uses the files at `<cwd>/data/bw-harmonised` generated according to the [Harmonise Conventions notebook](harmoniseConventions.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"from IO_XLtoBw import import_from_ExcelFile\n",
"project = 'REM_interoperable' #Should be an existing project with the biosphere3 database and the target ecoinvent databases.\n",
"\n",
"def get_data(variable):\n",
" return 'REM'+ variable + '.xlsx'\n",
"\n",
"variables = [\n",
" ('_replicated_2_2', 'ei22'),\n",
" ('_unlinked_2_2', 'ei22'),\n",
" ('2_2', 'ei22'),\n",
" ('3_1', 'cutoff31'),\n",
" ('3_2', 'cutoff32'),\n",
" ('3_3', 'cutoff33'),\n",
" ('3_4', 'cutoff34'),\n",
" ('3_5', 'cutoff35'),\n",
" ('3_6', 'cutoff36')]\n",
"\n",
"for v in variables:\n",
" import_from_ExcelFile(project, v[1], get_data(v[0]), save=True, newXL=True)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 372e646

Please sign in to comment.