Technical reference¶
- Generating aggregated databases
- Adding unit impacts exchanges to biosphere and unit impact characterization factors to methods
Generating aggregated databases¶
-
class
bw2agg.aggregate.
DatabaseAggregator
(up_db_name, agg_db_name, database_type='LCIA', method_list=[], biosphere='biosphere3', overwrite=False)¶ Generator to aggregate and write an LCI database.
Can be used to generate either:
- an aggregated LCI database (i.e. a database with cradle-to-gate LCI stored in the biosphere matrix)
- an aggregated LCIA database (i.e. a database with cradle-to-gate characterized inventories stored in the biosphere matrix as “unit impact” biosphere exchanges). This requires the creation of unit impact characterization factors and biosphere exchanges.
Instantiating the class will generate the data for the new database. The generate method will write the database.
Parameters: - up_db_name (str) – Name of the unit process database from which results will be calculated. Must be a registered database name.
- agg_db_name (str) – Name of the new aggregated database.
- database_type ({'LCI', 'LCIA'}, default 'LCIA') –
Type of aggregated database to generate.
- ’LCIA’ generates a database with cradle-to-gate inventories stored in the biosphere matrix as “unit impact” biosphere exchanges.
- ’LCI’ generates a database with cradle-to-gate LCI stored in the biosphere matrix.
Note that performance of LCI aggregated databases is very poor due to Brightway2 assuming sparse matrices
- method_list (list, default list(bw.methods)) – List of method ids (tuples) for which to generate LCIA scores. Default is all methods.
- biosphere (str, default 'biosphere3') – Name of the biosphere database
- overwrite (bool, default False) – Determines whether an existing database with name agg_db_name will be overwritten.
The only method you will use after instantiating the DatabaseAggregator
object is generate
, see o quickstart.
-
DatabaseAggregator.
generate
()¶ Generate data and write to database
Adding unit impacts exchanges to biosphere and unit impact characterization factors to methods¶
These steps are done automatically by the DatabaseAggregator
. THey can however be called directly:
-
bw2agg.scores.
add_unit_score_exchange_and_cf
(method, biosphere='biosphere3')¶ Add unit score biosphere exchanges and cfs to biosphere and methods.
Allows the storing of LCIA results in the B matrix for LCI datasets. Makes changes inplace and does not return anything.
Parameters: - method (tuple) – Identification of the LCIA method, using Brightway2 tuple identifiers
- biosphere (str, default biosphere3) – Name of the biosphere database where biosphere exchanges are stored
Note
This function is invoked directly by the DatabaseAggregator
-
bw2agg.scores.
add_all_unit_score_exchanges_and_cfs
(biosphere='biosphere3')¶ Add unit scores and cfs for all methods in project.
Makes changes inplace and does not return anything.
Parameters: biosphere (str, default biosphere3) – Name of the biosphere database where biosphere exchanges are stored