Skip to content

Commit

Permalink
v0.2.0, plus ReadMe changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pjamesjoyce committed Mar 10, 2017
1 parent 784bcbf commit 4026024
Show file tree
Hide file tree
Showing 114 changed files with 28,410 additions and 176 deletions.
98 changes: 95 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,104 @@ Life cycle optimisation module

# Installation

Install via pip:
For lcopt to work you should have the latest version of [brightway2](https://brightwaylca.org/) by Chris Mutel installed.
If you already have brightway installed, you can skip to the final step.

The best option is to use conda to create a separate environment, to avoid conflicts.

On the command line/console, create a new environment called lcopt

```
conda create -y -n lcopt python=3.5 lxml cytoolz numpy scipy pandas
```

Then activate the lcopt environment

```
activate lcopt
```

On windows there's an extra dependency
```
conda install -y pywin32
```
pip install https://github.com/pjamesjoyce/lcopt/zipball/master

Then install brightway2 (and its dependecies)
```
conda install wheel && conda update pip wheel setuptools
conda install -q -y -c haasad pypardiso
conda install -q -y ipython ipython-notebook jupyter matplotlib flask requests docopt whoosh xlsxwriter xlrd unidecode appdirs future psutil unicodecsv wrapt
pip install --no-cache-dir eight brightway2
```

Once brightway2 is ready fo go, install lcopt via pip:

```
pip install --no-cache-dir https://github.com/pjamesjoyce/lcopt/zipball/master
```

Note - because lcopt is a work in progress currently, if you're reinstalling to get the latest version make sure you use the --no-cache-dir flag

# Use

## TODO: Write something
The easiest way to use lcopt is via a jupyter notebook.

`cd` into whatever folder you want your notebooks and lcopt models to be stored in, then start jupyter e.g.

```
cd C:\Users\pjjoyce\Documents\01_Lcopt_models
jupyter notebook
```

This will fire up the jupyter notebook server in your browser.
Create a new notebook, give it a meaningful name.

Then in the first cell import lcopt
```python
from lcopt import *
```

Next create your LcoptModel
```python
model = LcoptModel('MyFirstModel')
```

Then launch the interactive model creator/analyser
```python
model.launch_interact()
```
This launches a Flask server that gives you a nice UI to interact with the models. You can add processes, link them together, add biosphere and technosphere exchanges, and create parameter sets and functions using your parameters. It should be pretty intuitive, if you get stuck, try the 'more info...' buttons.

When your model's ready you can export it to SimaPro as a .csv file and the parameter sets you've created as an Excel file (Note: you need SimaPro developer to import the parameter sets from the Excel file).

To run the analyses interactively using brightway2 there's an additional setup step. See below.

The 'QUIT' button in the top right hand corner will shut down the Flask server and tell you to close the window.

This frees up the notebook again so you can run any commands you need to.

One useful command is `model.save()` which will save any unsaved changes (you can also save by clicking on the save button in LcoptInteract, but in case you forget you can use `model.save()`)

The model is saved as a .pickle file in your working directory.

NOTE: The next time you run your notebook you need to change
```python
model = LcoptModel('MyFirstModel')
```
to
```python
model = LcoptModel(load = 'MyFirstModel')
```

If you don't it'll create a new blank model called 'MyFirstModel'. If you do do this by accident fear not - it won't overwrite your .pickle file until you save it.
Quit interact by hitting the QUIT button and go back and change your command (just don't click the save button or run `model.save()` in the meantime)


## Running the analyses in LcoptInteract with brightway2

To use the interactive analysis feature, you need to set up brightway2 to play nicely with lcopt.
Create a project in brightway called `setup_TO_COPY` which contains the biosphere3 database, the methods and the version of ecoinvent/any other external databases you want to use.
The default name that lcopt looks for for ecoinvent is `Ecoinvent3_3_cutoff` (i.e. its database keys need to look like this `('Ecoinvent3_3_cutoff', '41f548bf636724eec735138986b33229')`).

I'll try and add support for other versions asap.

3 changes: 0 additions & 3 deletions build/lib/lcopt/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

import matplotlib.pyplot as plt


import networkx as nx

from copy import deepcopy
from itertools import groupby

Expand Down
1 change: 0 additions & 1 deletion build/lib/lcopt/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
from ast import literal_eval
from lcopt.io import exchange_factory
import mpld3
from collections import OrderedDict
from itertools import groupby

Expand Down
Empty file.
53 changes: 53 additions & 0 deletions build/lib/lcopt/static/css/analysis.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.hello_div{
color:red;
}

.links line {
stroke: #999;
stroke-opacity: 0.6;
}

.node circle {
stroke: #fff;
stroke-width: 1.5px;
}

.node text {
pointer-events: none;
font: 10px sans-serif;
}

polyline{
opacity: .3;
stroke: black;
stroke-width: 2px;
fill: none;
}

.right_align{
text-align: right;
}

.row_title{
font-weight: bold;
}

.table>thead>tr>th{
text-align: center;
vertical-align: middle;
}

.table{
font-size: 10px;
}
.table>tbody>tr>td{
vertical-align: middle;
}
.unit{
font-size: 8px;
color:#999;
}

.legend_item{
font-size: 8px;
}
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions build/lib/lcopt/static/css/cdn_cache/bootstrap-select.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions build/lib/lcopt/static/css/cdn_cache/bootstrap.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions build/lib/lcopt/static/css/cdn_cache/font-awesome.min.css

Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4026024

Please sign in to comment.