bw_processing.matrix_entry
Classes
A single entry destined for a matrix cell. |
|
Standard matrix names used in Brightway. |
Functions
|
Create a datapackage from a dictionary of |
Module Contents
- class bw_processing.matrix_entry.MatrixEntry[source]
A single entry destined for a matrix cell.
Multiple instances with the same (row, col) are summed during matrix construction, so this is not necessarily the final cell value.
Field names and defaults match those expected by bw_processing’s
dictionary_formatter. Convert to a plain dict withas_dict()before passing to bw_processing internals.- Parameters:
row – Integer row index in the target matrix.
col – Integer column index in the target matrix.
amount – The numeric value to place at (row, col).
flip – If True, multiply the value by -1 when building the matrix.
uncertainty_type – Probability distribution type (0 = no uncertainty, 2 = lognormal, 3 = normal, etc. — see stats_arrays for full list).
loc – Distribution location parameter. For lognormal this is the log of the median; defaults to NaN (no uncertainty).
scale – Distribution scale parameter (e.g. standard deviation).
shape – Distribution shape parameter.
minimum – Lower bound for distribution sampling.
maximum – Upper bound for distribution sampling.
negative – Whether the underlying value is negative.
- class bw_processing.matrix_entry.MatrixName[source]
Bases:
str,enum.EnumStandard matrix names used in Brightway.
Because this is a
strenum, members can be used anywhere a plain string is accepted — no.valueneeded:MatrixEntry(row=1, col=4, amount=2.5) # inside a dict keyed by MatrixName dp.add_entries(matrix=MatrixName.technosphere, entries=[...])
Derived libraries may define additional matrices as plain strings; these three cover the core Brightway LCA workflow.
Initialize self. See help(type(self)) for accurate signature.
- bw_processing.matrix_entry.create_datapackage_from_entries(data: dict, fs=None, **metadata)[source]
Create a datapackage from a dictionary of
MatrixEntrylists.This is the recommended high-level entry point for building datapackages without working directly with NumPy arrays.
- Parameters:
data –
Dictionary mapping matrix names to lists of
MatrixEntryobjects. UseMatrixNamemembers as keys for the standard Brightway matrices; derived libraries may use plain strings for additional matrices:{ MatrixName.technosphere: [ MatrixEntry(row=1, col=4, amount=2.5), MatrixEntry(row=2, col=5, amount=7.0, flip=True), ], MatrixName.biosphere: [ MatrixEntry(row=10, col=4, amount=0.3), ], }
fs – Optional filesystem. Defaults to an in-memory filesystem.
**metadata – Additional keyword arguments passed to
create_datapackage()(e.g.name,id_).
- Returns:
A
Datapackageinstance.