Projects

A project is a separate workspace which has its own data and preferences. Project management is is done through the projects object:

In [1]:
from brightway2 import *

List existing projects:

In [2]:
list(projects)
Out[2]:
[Project: default]

Switching projects is the same as adding a project - it will be created if it doesn't exist already:

In [3]:
projects.set_current("foo")
list(projects)
Out[3]:
[Project: default, Project: foo]

A new project starts out empty - add default biosphere flows and impact assessment methods if you want:

In [4]:
list(databases)
Out[4]:
[]
In [5]:
bw2setup()
Creating default biosphere

Writing activities to SQLite3 database:
0%                          100%
[##############                ] | ETA[sec]: 0.194 
Applying strategy: normalize_units
Applying strategy: drop_unspecified_subcategories
Applied 2 strategies in 0.01 seconds
[##############################] | ETA[sec]: 0.000 
Total time elapsed: 0.392 sec
Title: Writing activities to SQLite3 database:
  Started: 07/15/2016 11:57:32
  Finished: 07/15/2016 11:57:32
  Total time elapsed: 0.392 sec
  CPU %: 98.800000
  Memory %: 0.363731
Created database: biosphere3
Creating default LCIA methods

Applying strategy: normalize_units
Applying strategy: set_biosphere_type
Applying strategy: drop_unspecified_subcategories
Applying strategy: link_iterable_by_fields
Applied 4 strategies in 0.89 seconds
Wrote 665 LCIA methods with 169551 characterization factors
Creating core data migrations

In [6]:
list(databases)
Out[6]:
['biosphere3']

Each project is a directory:

In [7]:
projects.dir
Out[7]:
'/Users/cmutel/Library/Application Support/Brightway3/default.c21f969b5f03d33d43e04f8f136e7682'

We can add subdirectories if needed (e.g. for custom data):

In [8]:
projects.request_directory("my-new-directory")
Out[8]:
'/Users/cmutel/to/foo.acbd18db4cc2f85cedef654fccc4a4d8/my-new-directory'

Finally, you can copy projects. Note that a copy is made of your current project, so be sure to switch to the project you want to copy first:

In [9]:
projects.copy_project("my copy")

The current project is switched to the copy:

In [10]:
projects.current
Out[10]:
'my copy'