Step 2: Generating base presamples

Introduction

This step generates a presamples package for all technosphere (A) and biosphere (B) elements for an LCI database. The only function that the user needs for this step is generate_base_presamples, which is imported in the namespace with from bw2preagg import *.

The resulting presample package is stored in the presamples subdirectory of the result_dir directory. Information about the presamples packages are stored in a presamples resource, which are in turn included in a campaign.

The samples_batch argument (int) allows generating presamples in batches: each batch has its own presample package, its own seed, and is associated with its own presamples resource and campaign. Since the seed is determined from the samples_batch value, presample packages produced on different computers are guaranteed to have the same values, increasing reproducibility of preaggregated LCI arrays and of LCA results that are based on these arrays.

Technical reference

bw2preagg.base_presamples.generate_base_presamples(project_name, database_name, result_dir, iterations, samples_batch, overwrite_ps=True, ps_base_name='base')

Generate presamples for all elements of A and B matrices of given database

The presamples are stored in a presamples resource in result_dir and added to a presamples campaign for easy reuse. It is recommended that presamples are generated in batches (e.g. of 1000 iterations each). This is implemented via the samples_batch argument.

Parameters:
  • project_name (str) – Name of the brightway2 project where the database is imported
  • database_name (str) – Name of the LCI database
  • result_dir (str) – Path to directory where results are stored
  • iterations (int) – Number of iterations to include in sample
  • samples_batch (int, default=0) – Integer id for sample batch. Used for campaigns names and for generating a seed for the RNG. The maximum value is 14.
  • overwrite_ps (bool, default=True) – Overwrite presamples package if it exists
  • ps_name_base (str, default="base") – Base name for presamples resource.
Returns:

Return type:

None