bw2preagg

bw2preagg is used to generate dependently sampled LCI and LCIA arrays for whole databases.

It uses Brightway2 framework and presamples. The arrays are stored as numpy.ndarray files, and can be integrated in Brightway2 models using other modules (brightway2-aggregated, presamples).

The resulting result arrays allow the use of aggregated LCI or LCIA results (also known as cradle-to-gate results) in LCA while also correctly integrating the uncertainty of LCI data, see Lesage et al. 2018.

Generating samples of cradle-to-gate results for all activities in a database can be a lengthy process, especially when dealing with large LCI databases like ecoinvent. The functions are therefore geared towards large, bulk calculations, by e.g. facilitating multiprocessing and breaking down the task in multiple “batches” that can run on different systems.

The samples are calculated in six steps:

Step 1: Setup
Ready your system for sample generation: setup a brightway2 project, import an ecoinvent database from ecoSpold files, and generate a number of files, stored in common files directory, that will be used by future steps.
Step 2: Generating base presamples
Generate a presamples package for all A and B matrix elements. The presample package will have as many rows as there are matrix elements, and as many columns as the number of requested iterations. These will be injected in A and B matrices during LCI calculations in Step 4.
Step 3: Generating balancing presamples
(Optional) Generate a balanced presamples package for water and another for land transformation exchanges. These are also injected in A and B matrices during LCI calculations in Step 4, overriding the base presamples from Step 2.
Step 4: Generating LCI samples
Generate LCI arrays for all activities in the database. These use the presamples packages from previous steps.
Step 5: Generating LCIA samples
(Optional) Transform the LCI arrays from Step 4 to arrays of LCIA scores.
Step 6: Concatenating samples
(Optional) Concatenate LCI or LCIA arrays from multiple samples_batch folders.

If you just want to run and calculate the samples, you can jump to the Run-through: LCI and LCIA array production section.

The most important concepts, input parameters and the structure of the output directory are summarized in the Glossary.

Indices and tables