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 [ ]:
list(projects)

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

In [3]:
projects.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()
Writing activities to SQLite3 database:
0%                          100%
[                              ]Warning: get_cpu_percent() is deprecated; use cpu_percent() instead
Warning: get_memory_percent() is deprecated; use memory_percent() instead
[##############################] | ETA[sec]: 0.000 
Total time elapsed: 0.357 sec
Applying strategy: drop_unspecified_subcategories
Title: Writing activities to SQLite3 database:
  Started: 05/15/2015 16:43:20
  Finished: 05/15/2015 16:43:20
  Total time elapsed: 0.357 sec
  CPU %: 97.300000
  Memory %: 0.261807
Created database: biosphere3
Applying strategy: set_biosphere_type
Applying strategy: drop_unspecified_subcategories
Applying strategy: link_iterable_by_fields
Wrote 692 LCIA methods with 170915 characterization factors
Warning: get_cpu_percent() is deprecated; use cpu_percent() instead
Warning: get_memory_percent() is deprecated; use memory_percent() instead
In [6]:
list(databases)
Out[6]:
['biosphere3']

Each project is a directory:

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

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

In [8]:
projects.request_directory("my-new-directory")
Out[8]:
'/Users/cmutel/Library/Application Support/Brightway3/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'