Skip to content

Commit

Permalink
updated notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelweinold committed Sep 18, 2023
1 parent 44706a5 commit b6bab3a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 56 deletions.
2 changes: 1 addition & 1 deletion content/home.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# "Learn Brightway" Homepage
# "Learn Brightway" Book

## What is Brightway

Expand Down
2 changes: 1 addition & 1 deletion content/notebooks/BW25_for_beginners.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# BW2 for Beginners"
"# BW25 for Beginners"
]
},
{
Expand Down
132 changes: 78 additions & 54 deletions content/notebooks/BW2_for_beginners.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@
"# Brightway2 for Beginners"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "RCPHvRQxC6Wk"
},
"source": [
"<h3>Table of contents:</h3>\n",
"\n",
"1. [Installing anaconda](#Installing-anaconda)\n",
"2. [Using Conda to download the brightway2 package](#Using-Conda-to-download-the-brightway2-package)\n",
"3. [Setting up an environment](#Setting-up-an-environment)\n",
"4. [Opening an environment](#Opening-an-environment)\n",
"5. [Channels](#Channels)\n",
"6. [Maintaining an environment](#Maintaining-an-environment)\n",
"7. [Saving, sharing and restoring an environment](#Saving,-sharing-and-restoring-an-environment)\n",
"8. [Recap: Installing brightway2 and activity browser on your computer](#Recap:-Installing-brightway2-and-activity-browser-on-your-computer)\n",
"9. [Preparing the Notebook](#Preparing-the-Notebook)\n",
"10. [Using Brightway](#Using-Brightway)"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -44,13 +24,13 @@
"id": "lxki6djrDTJ_"
},
"source": [
"Anaconda is a python distribution that can manage different packages and deploy them using 'conda'. The distribution is available in two forms.\n",
"1. <b><a href=https://www.anaconda.com/about-us>Anaconda</a></b> is a full fledged distribution with multiple packages installed. It comes with a wide range of data analysis, machine learning, and scientific computing libraries pre-installed, making it a comprehensive package for data scientists.\n",
"Anaconda can be installed from the <a href=https://www.anaconda.com/download>download page</a> of their website. It downloads an installer based on your operating system.\n",
"2. <b><a href=https://docs.conda.io/projects/miniconda/en/latest/>Miniconda</a></b> is a minimal distribution that only includes python and conda.Miniconda can be downloaded directly from their main page, its lightweight and installs quickly.\n",
"[Anaconda is a python distribution](https://en.wikipedia.org/wiki/Anaconda_(Python_distribution) comes with the useful `conda` package manager. The distribution is available in two forms:\n",
"\n",
"1. **[Anaconda](https://www.anaconda.com/about-us)** is a full fledged distribution with multiple packages installed. It comes with a wide range of data analysis, machine learning, and scientific computing libraries pre-installed, making it a comprehensive package for data scientists.\n",
"Anaconda can be installed from the [Anaconda download page](https://www.anaconda.com/download).\n",
"1. **[Miniconda](https://docs.conda.io/projects/miniconda/en/latest/)** is a minimal distribution that only includes `python` and `conda`. This allows you to create a lightweight and customized Python environment. With Miniconda, you have more control over which packages you want to install, making it a good choice for users who want to build their own Python environments tailored to their specific needs. Miniconda can be installed from the [Anaconda download page](https://www.anaconda.com/download).\n",
"\n",
"Both Anaconda and Miniconda can be used to download Brightway into your computer. <br>\n",
"<i><b>INFO:</b> We recommend downloading Anaconda distribution.</i>"
"Both Anaconda and Miniconda can be used to download Brightway into your computer."
]
},
{
Expand All @@ -68,33 +48,64 @@
"id": "JfIcrN3IDkIG"
},
"source": [
"There are different versions of Brightway (1, 2 & 2.5) and the differences between them are explained in this <a href =https://docs.brightway.dev/en/latest/content/faq/brightway.html>page</a>.\n",
"\n",
"This notebook will demonstrate the use of <b>Brightway version 2</b>.\n",
"\n",
"A documentation explaining how to <a href=https://docs.brightway.dev/en/legacy/content/faq/brightway.html>install brightway</a> is available in the documentation which is the same as explained below.<br>\n",
"Once you install Anaconda or Miniconda, you can access the Anaconda Navigator <b>(See option 1</b>, <i>only if you download the Anaconda distribution)</i> or you can access the Anaconda prompt <b>(See option 2</b>, <i>available in both Anaconda & Miniconda distribution).</i>\n",
"1. <b>Anaconda Navigator</b> is a Graphical User Inteface to download the required packages. It is recommended to <i><b>create an environment</i></b> where you will install brightway. An environment allows you to have different versions of installed packages. For instance, brightway 2 requires a specific version of background libraries that are necessary to run brightway smoothly.<br>\n",
"If you install all your projects in the same environment, you might run into issues. Creating an environment avoids such issues. More information on how to handle environments are explained below.<br>\n",
"To create environment, click on the <b>Environments</b> tab in the left and below you will find an option called <b>Create</b> which will create a new environment with your desired name. <br><br>\n",
"<i><b>Note: </b>An environment name cannot be repeated.</i><br><br>\n",
"Once you create an environment, on the <i><b>top right corner</i></b> in the search bar search for <i><b>brightway2</i></b> and install (all the necessary libraries are automatically installed).<br>\n",
"To run jupyter notebook, click on <b>Home</b> from the top left corner of the navigator (Ensure the correnct environment is selected i.e <i>bw</i>) and then click on <b>Launch</b> under Jupyterlab or Jupter notebook.<br>\n",
"To deactivate an environment after work, simply click on the base or another environment from the Anaconda Navigator.<br><br>\n",
"<i><b>Note:</b> The notebook launches in the default directory i.e., the home directory. Changing it is complicated that to use Anaconda prompt to install jupyter which is explained below.</i><br><br>\n",
"2. <b>Anaconda prompt</b> is a console environment that is available in both Anaconda and Miniconda distributions. Copy the following code into the anaconda prompt.\n",
"<pre><code>conda create -n bw brightway2 jupyterlab</code></pre>\n",
"This code creates an environment named <i><b>'bw'</i></b> that can be changed and it also installs <i><b>jupyterlab</i></b> that allows to use a web based interface to execute python code.<br>\n",
"There are different versions of Brightway (1, 2 & 2.5) and the differences between them are explained in this [page](https://docs.brightway.dev/en/latest/content/faq/brightway.html).\n",
"\n",
"This notebook will demonstrate the use of **Brightway version 2**.\n",
"\n",
"A documentation explaining how to [install brightway](https://docs.brightway.dev/en/legacy/content/faq/brightway.html) is available in the documentation which is the same as explained below.\n",
"\n",
"Once you install Anaconda or Miniconda, you can access the Anaconda Navigator **(See option 1**, *only if you download the Anaconda distribution*) or you can access the Anaconda prompt **(See option 2**, *available in both Anaconda & Miniconda distribution).*\n",
"\n",
"1. **Anaconda Navigator** is a Graphical User Inteface to download the required packages. It is recommended to *create an environment* where you will install brightway. An environment allows you to have different versions of installed packages. For instance, brightway 2 requires a specific version of background libraries that are necessary to run brightway smoothly.\n",
"\n",
"If you install all your projects in the same environment, you might run into issues. Creating an environment avoids such issues. More information on how to handle environments are explained below.\n",
"\n",
"To create environment, click on the **Environments** tab in the left and below you will find an option called **Create** which will create a new environment with your desired name.\n",
"\n",
"**Note: An environment name cannot be repeated.**\n",
"\n",
"Once you create an environment, on the *top right corner* in the search bar search for *brightway2* and install (all the necessary libraries are automatically installed).\n",
"\n",
"To run jupyter notebook, click on **Home** from the top left corner of the navigator (Ensure the correnct environment is selected i.e *bw*) and then click on **Launch** under Jupyterlab or Jupter notebook.\n",
"\n",
"To deactivate an environment after work, simply click on the base or another environment from the Anaconda Navigator.\n",
"\n",
"**Note: The notebook launches in the default directory i.e., the home directory. Changing it is complicated that to use Anaconda prompt to install jupyter which is explained below.**\n",
"\n",
"2. **Anaconda prompt** is a console environment that is available in both Anaconda and Miniconda distributions. Copy the following code into the anaconda prompt.\n",
"\n",
"```bash\n",
"conda create -n bw brightway2 jupyterlab\n",
"```\n",
"\n",
"\n",
"This code creates an environment named *'bw'* that can be changed and it also installs *jupyterlab* that allows to use a web based interface to execute python code.\n",
"\n",
"In order to use brightway, you must activate the environment using the following code:\n",
"<pre></code>conda activate bw</code></pre>\n",
"<i><b>Note</b></i>: <i>If you are using another editor or an Integrated Development Environment (IDE) such as pycharm, VSCode, spyder or others remember to select/setup the appropriate environment before executing the code.</i><br><br>\n",
"\n",
"```bash\n",
"conda activate bw\n",
"```\n",
"\n",
"Note: If you are using another editor or an Integrated Development Environment (IDE) such as pycharm, VSCode, spyder or others remember to select/setup the appropriate environment before executing the code.\n",
"\n",
"To use jupter notebook such as this file, after activating the environment run the following code:\n",
"<pre></code>jupter notebook</code></pre>\n",
"<i><b>Note</i></b>: <i>Remember to navigate to the desired folder before executing the above code as it is complicated to go out of the folder to save your notebook after it starts</i>.<br><br>\n",
"\n",
"```bash\n",
"jupter notebook\n",
"```\n",
"\n",
"Note: Remember to navigate to the desired folder before executing the above code as it is complicated to go out of the folder to save your notebook after it starts.\n",
"\n",
"To deactivate the environment after working on your project use the following code:\n",
"<pre></code>conda deactivate</code></pre>\n",
"<i><b>Note:</b> In order to deactivate, you must first save and close the jupyter notebook. <b>Save your work before quitting</b>. Go to the home page of the notebook (the page that shows you the directory and different files and click on <b>quit</b></i>.<br><br>\n",
"<i><b>Imp Note:</b> Clicking on <b>logout</b> will not quit the jupyter notebook and you cannot provide an input into the terminal. In such cases, press <b>CNTRL+C</b> (Windows & Mac) to quit jupyter notebook which allows you to then deactivate the environment.\n",
"\n",
"```bash\n",
"conda deactivate\n",
"```\n",
"\n",
"Note: In order to deactivate, you must first save and close the jupyter notebook. Save your work before quitting. Go to the home page of the notebook (the page that shows you the directory and different files and click on `quit`.\n",
"\n",
"Imp Note: Clicking on `logout` will not quit the jupyter notebook and you cannot provide an input into the terminal. In such cases, press `CTR+C`(Windows & Mac) to quit jupyter notebook which allows you to then deactivate the environment.\n",
"\n",
"After working with brightway, remember to deactivate the environment either using Anaconda Navigator or Anaconda prompt."
]
Expand Down Expand Up @@ -129,7 +140,10 @@
"**\"A conda environment is a directory that contains a specific collection of conda packages that you have installed.\"** When you install Brightway, they will be installed in a specific environment which will contain all necessary packages. You can e.g. have one environment for brightway2, and one for brightway25.\n",
"\n",
"When you will install e.g. Brightway2, you will execute this line:\n",
"<pre></code>conda create -n bw brightway2 jupyterlab</code></pre>\n",
"\n",
"```bash\n",
"conda create -n bw brightway2 jupyterlab\n",
"```\n",
"\n",
"This is the conda command for creating a new environment, which is called **\"bw\"**. Only running '''\"conda create -n bw\"''' would simply set up a new env, but empty without any packages in it. Adding \"brightway2\" or \"jupyterlab\" or \"python\" will install the respective package. You can also specify the **version number of the package**, e.g. ***\"python =3.10\"***. This is sometimes useful, when packages are not yet aligned well in terms of versions, i.e. bw is not yet adapted to use the very latest version of python. You can add as many packages as you want to the conda create command. See [below](#Maintaining-an-environment) for an explanation how conda knows where to fetch the packages. \n",
"\n",
Expand Down Expand Up @@ -244,7 +258,7 @@
"id": "5eTohz02C6Wp"
},
"source": [
"## Recap: Installing brightway2 and activity browser on your computer"
"## Recap: Installing brightway2 on your computer"
]
},
{
Expand Down Expand Up @@ -420,6 +434,16 @@
"### Access the saved project"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#If you want to know, where the project is saved on your computer (directory, you can do this)\n",
"bw.projects.dir"
]
},
{
"cell_type": "code",
"execution_count": 60,
Expand Down Expand Up @@ -564,7 +588,7 @@
"\n",
"Since most of the LCA practitioners use Ecoinvent to model their processes, in this example we show how to import Ecoinvent database into brightway. Please note same steps can be adopted to import any other database into brightway.<br>\n",
"***Note:** Brightway can load in different data formats such as 'ecospold', 'excel'. If using ecoinvent ecospold format, provide the directory where the extracted datasets are available* \n",
"***Imp Note:** Always asign a variable to load all the data which is later used to perform other functions.*"
"***Imp Note:** Always assign a variable to load all the data which is later used to perform other functions.*"
]
},
{
Expand Down Expand Up @@ -736,7 +760,7 @@
"id": "g7SGNBjwC6Ww"
},
"source": [
"Now lets see what databases are existing in our project. Use <code>.databases<./code> to **bw** variable."
"Now lets see what databases are existing in our project. Use <code>.databases</code> to **bw** variable."
]
},
{
Expand Down

0 comments on commit b6bab3a

Please sign in to comment.