bw2analyzer.contribution#
Classes#
Module Contents#
- class bw2analyzer.contribution.ContributionAnalysis[source]#
-
- annotated_top_emissions(lca, names=True, **kwargs)[source]#
Get list of most damaging biosphere flows in an LCA, sorted by
abs(direct impact).Returns a list of tuples:
(lca score, inventory amount, activity). Ifnamesis False, they returns the process key as the last element.
- annotated_top_processes(lca, names=True, **kwargs)[source]#
Get list of most damaging processes in an LCA, sorted by
abs(direct impact).Returns a list of tuples:
(lca score, supply, activity). Ifnamesis False, they returns the process key as the last element.
- d3_treemap(matrix, rev_bio, rev_techno, limit=0.025, limit_type='percent')[source]#
Construct treemap input data structure for LCA result. Output like:
{ "name": "LCA result", "children": [{ "name": process 1, "children": [ {"name": emission 1, "size": score}, {"name": emission 2, "size": score}, ], }] }
- sort_array(data, limit=25, limit_type='number', total=None)[source]#
Common sorting function for all
topmethods. Sorts by highest value first.Operates in either
numberorpercentmode. Innumbermode, returnlimitvalues. Inpercentmode, return all values >= (total * limit); where0 < limit <= 1.Returns 2-d numpy array of sorted values and row indices, e.g.:
ContributionAnalysis().sort_array((1., 3., 2.))
returns
( (3, 1), (2, 2), (1, 0) )
- Parameters:
data (*) – A 1-d array of values to sort.
limit (*) – Number of values to return, or percentage cutoff.
limit_type (*) – Either
numberorpercent.total (*) – Optional specification of summed data total.
- Returns:
2-d numpy array of values and row indices.
- top_matrix(matrix, rows=5, cols=5)[source]#
Find most important (i.e. highest summed) rows and columns in a matrix, as well as the most corresponding non-zero individual elements in the top rows and columns.
Only returns matrix values which are in the top rows and columns. Element values are returned as a tuple:
(row, col, row index in top rows, col index in top cols, value).Example:
matrix = [ [0, 0, 1, 0], [2, 0, 4, 0], [3, 0, 1, 1], [0, 7, 0, 1], ]
In this matrix, the row sums are
(1, 6, 5, 8), and the columns sums are(5, 7, 6, 2). Therefore, the top rows are(3, 1)and the top columns are(1, 2). The result would therefore be:( ( (3, 1, 0, 0, 7), (3, 2, 0, 1, 1), (1, 2, 1, 1, 4) ), (3, 1), (1, 2) )
- Parameters:
matrix (*) – Any Python object that supports the
.sum(axis=)syntax.rows (*) – Number of rows to select.
cols (*) – Number of columns to select.
- Returns:
(elements, top rows, top columns)