Step 6: Concatenating samples

Introduction

This optional step allows the concatenation of samples across multiple samples_batch folders.

It can be used for LCI or LCIA arrays, and results can be saved in a new directory.

Technical reference

concat_samples_arrays_in_result_type_dir

To concatenate LCI arrays or LCIA arrays for which the name of the folder is known, use concat_samples_arrays_in_result_type_dir:

bw2preagg.concat_batches.concat_samples_arrays_in_result_type_dir(result_dir, sb_id_list=None, result_type_dirname='LCI', totals_or_per_exchanges=None, sim_name=None, dest=None, fail_if_samples_batches_different=False, ignore_missing=True)

Concatenate and save LCI sample arrays in result dir

Parameters:
  • result_type (str) – Path to the directory where data used or generated by bw2preagg is saved.
  • sb_id_list (list, default=None) – List of samples_batch ids. If None, all samples_batch are processed.
  • result_type_dirname (str, default="LCI") – Name of the result type subdirectory where samples batches are found
  • sim_name (str, default=None) – Name to give the directory in which results will be saved
  • dest (str) – Path to location where concatenated array directory will be saved
  • fail_if_samples_batches_different (bool, default=False) – If False, will raise ValueError if arrays available in samples_batch folders are not the same If True, will concatenate only those arrays that are available in all samples_batch folders
  • ignore_missing (bool, default=True) – If False, will concatenate arrays in LCI folder only if all expected LCI arrays are present

concat_lcia_samples_arrays_from_method_tuple

To concatenate LCIA arrays from a method tuple, use concat_lcia_samples_arrays_from_method_tuple:

bw2preagg.concat_batches.concat_lcia_samples_arrays_from_method_tuple(result_dir, method, sb_id_list=None, totals_or_per_exchanges='totals', project_name=None, sim_name=None, dest=None, fail_if_samples_batches_different=False, ignore_missing=True)

Concatenate and save LCIA sample arrays in result dir

Parameters:
  • result_type (str) – Path to the directory where data used or generated by bw2preagg is saved.
  • method (tuple) – LCIA method identification in brightway2 (tuple)
  • sb_id_list (list) – List of samples_batch ids. If None, all samples_batch are processed.
  • totals_or_per_exchanges (str, default="totals") – Deal with totals or results per elementary flows
  • project_name (str) – Name of the brightway2 project where the database is imported
  • sim_name (str, default=None) – Name to give the directory in which results will be saved. If None, a default name is generated from sb_id_list
  • dest (str) – Path to location where concatenated array directory will be saved
  • fail_if_samples_batches_different (bool, default=False) – If False, will raise ValueError if arrays available in samples_batch folders are not the same If True, will concatenate only those arrays that are available in all samples_batch folders
  • ignore_missing (bool, default=True) – If False, will concatenate arrays in LCI folder only if all expected LCI arrays are present