lca_algebraic API documentation

# Module `lca_algebraic`

Expand source code

    #
    # This file defines several utility functions above brightway2 to be used by notebooks
    #

    import lca_algebraic.helpers
    from .base_utils import *
    from .helpers import *
    from .lca import *
    from .stats import *
    from .params import *
    from .io import *

    def deleteDb(db_name) :
        del bw.databases[db_name]

    def resetDb(db_name, foreground=True):
        """ Create or cleanup a user DB"""
        if db_name in bw.databases:
            error("Db %s was here. Reseting it" % db_name)
            del bw.databases[db_name]
        db = bw.Database(db_name)
        db.write(dict())
        if foreground :
            setForeground(db_name)
        else:
            setBackground(db_name)

    def initProject(project_name) :
        '''Setup the project if not already done.'''
        bw.projects.set_current(project_name)
        bw.bw2setup()

    def initDb(project_name) :
        '''Deprecated : use initProject(...) '''
        error("Deprecated : use initProject")
        initProject(project_name)

    def importDb(dbname, path):
        '''Import eco invent DB'''

        if dbname in bw.databases:
            error("Database '%s' has already been imported " % dbname)
        else:
            ei34 = bw.SingleOutputEcospold2Importer(path, dbname)
            ei34.apply_strategies()
            ei34.statistics()
            ei34.write_database()

## Sub-modules

`lca_algebraic.base_utils`
`lca_algebraic.helpers`
`lca_algebraic.io`
`lca_algebraic.lca`
`lca_algebraic.params`
`lca_algebraic.stats`

## Functions

`def deleteDb(db_name)`
  Expand source code

      def deleteDb(db_name) :
          del bw.databases[db_name]

`def importDb(dbname, path)`

  Import eco invent DB

  Expand source code

      def importDb(dbname, path):
          '''Import eco invent DB'''

          if dbname in bw.databases:
              error("Database '%s' has already been imported " % dbname)
          else:
              ei34 = bw.SingleOutputEcospold2Importer(path, dbname)
              ei34.apply_strategies()
              ei34.statistics()
              ei34.write_database()

`def initDb(project_name)`

  Deprecated : use initProject(…)

  Expand source code

      def initDb(project_name) :
          '''Deprecated : use initProject(...) '''
          error("Deprecated : use initProject")
          initProject(project_name)

`def initProject(project_name)`

  Setup the project if not already done.

  Expand source code

      def initProject(project_name) :
          '''Setup the project if not already done.'''
          bw.projects.set_current(project_name)
          bw.bw2setup()

`def resetDb(db_name, foreground=True)`

  Create or cleanup a user DB

  Expand source code

      def resetDb(db_name, foreground=True):
          """ Create or cleanup a user DB"""
          if db_name in bw.databases:
              error("Db %s was here. Reseting it" % db_name)
              del bw.databases[db_name]
          db = bw.Database(db_name)
          db.write(dict())
          if foreground :
              setForeground(db_name)
          else:
              setBackground(db_name)