appabuild.database.databases#

Contains classes to import LCI databases in Brightway project. Initialize parameters_registry object which must be filled before Impact Model build.

Attributes#

Classes#

BiosphereDatabase

Class to import biosphere3 database, which is the Brightway database containing all

Database

Abstract class of a Database. Defines two mandatory methods for import.

EcoInventDatabase

Abstract class of a Database. Defines two mandatory methods for import.

ForegroundDatabase

Handles foreground data. Use datasets must have .json, .yaml or .yml extension to

ImpactProxiesDatabase

Impact proxies are datasets used to generate impacts without communicating with

Module Contents#

class appabuild.database.databases.BiosphereDatabase#

Bases: Database

Class to import biosphere3 database, which is the Brightway database containing all biosphere flows. Biosphere flows are used to compute impacts thanks to characterization factors. This class currently works only with EcoInvent 3.9.

Initializes a Database from its name and optionally its path. :param name: name of the database. Should be consistent with the name used in datasets. :param path: path of the database on disk.

execute_at_startup() None#

Method to be executed when running Appa Build to import the database. Default behavior is to reset all params, and to run import method only if its not already present in Brightway project. :return:

import_in_project() None#

Import the database in Brightway project. :return:

class appabuild.database.databases.Database(name: str, path: str | None)#

Abstract class of a Database. Defines two mandatory methods for import.

Initializes a Database from its name and optionally its path. :param name: name of the database. Should be consistent with the name used in datasets. :param path: path of the database on disk.

execute_at_startup() None#

Method to be executed when running Appa Build to import the database. Default behavior is to reset all params, and to run import method only if its not already present in Brightway project. :return:

abstractmethod import_in_project() None#

Import the database in Brightway project. :return:

name#
path#
class appabuild.database.databases.EcoInventDatabase(name, path)#

Bases: Database

Abstract class of a Database. Defines two mandatory methods for import.

Initializes a Database from its name and optionally its path. :param name: name of the database. Should be consistent with the name used in datasets. :param path: path of the database on disk.

import_in_project()#

Import the database in Brightway project. :return:

class appabuild.database.databases.ForegroundDatabase(name, path)#

Bases: Database

Handles foreground data. Use datasets must have .json, .yaml or .yml extension to be imported. Dataset uuid is dataset file’s name without extension.

Initializes a UserDatabase from its name, its path, its reference flow, and parameters if any. Reference flow has to be specified as import is done in a tree way with reference flow as a root. :param name: user database name :param path: user datasets location

declare_parameters() None#

Initialize each object’s parameter as a ImpactModelParam and store it in parameters_registry object. parameters_registry is used to build Impact Model’s parameters section. :return:

execute_at_build_time()#
execute_at_startup()#

Method to be executed when running Appa Build to import the database. Default behavior is to reset all params, and to run import method only if its not already present in Brightway project. :return:

find_activities_on_disk() None#

Scans database’s path to import every matching file as a SerializedActivity. Results are stored in object’s context. :return:

import_in_project() None#

Import user database in Brightway project. Database is declared as foreground for lca_algebraic. This method will transform each used dataset from SerializedActivity and SerializedExchange to Activity and Exchange objects. Parameters are then propagated from the reference flow to the leaf activities. :return:

set_functional_unit(fu_name: str, parameters: dict)#
context#
fu_name = ''#
parameters#
class appabuild.database.databases.ImpactProxiesDatabase#

Bases: Database

Impact proxies are datasets used to generate impacts without communicating with real biosphere flows and corresponding characterization factors. It can be used to easily import datasets from a database not compatible with Brightway by using another LCA software to do impact computation, or to use data from literature which are often given at the impact level, and not the LCI level. One proxy will be created for each LCIA method. Proxy’s name is “{bw_method_name}_technosphere_proxy”.

Initializes a Database from its name and optionally its path. :param name: name of the database. Should be consistent with the name used in datasets. :param path: path of the database on disk.

execute_at_startup()#

Method to be executed when running Appa Build to import the database. Default behavior is to reset all params, and to run import method only if its not already present in Brightway project. :return:

import_in_project() None#

For each LCIA method, one dataset will be created with type biosphere, and another one with type technosphere which will have one unit of the corresponding biosphere proxy as input exchange. Both are necessary as characterization factor has to be connected with a biosphere dataset, and a technosphere dataset is necessary to be used by other technosphere datasets. A characterization factor of one is then added between each method and the corresponding proxy. :return:

appabuild.database.databases.parameters_registry#