Analyze contributions
lca_analyze_contributionsBreak down what drives an impact category. ref is a<N> (analyses a saved assessment's setup) or s<N> (analyses a saved system directly, with no prior assessment needed; method and amount then shape the solve). Returns a b<N> breakdown ref, a separate object from the a<N> it analyses. Modes: by='process' ranks contributing processes (total_amount = per-process total, loop-corrected); by='flow' ranks substance drivers by amount × CF; by='upstream' walks the supply chain. For composed (bill-of-materials) systems only process via an a<N> is available; flow, upstream and an s<N> return 422. The first call per solve prepares the engine in the background (about 3–5 s); later calls on the same solve reuse it. Rows carry p<N>/f<N> refs for further detail.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | How to break down the result: rank contributing processes, rank substance flows, or walk the upstream supply-chain tree. Composed (bill-of-materials) systems support process only. | process |
| ref | Yes | `a<N>` — analyse that saved assessment's setup (its system, method and functional unit); `s<N>` — analyse the saved system directly, with NO prior assessment (`method` / `amount` apply only here). List current ones with `lca_get(kind='assessments')` / `lca_get(kind='systems')` — never pass UUIDs. | |
| depth | No | Upstream only: maximum depth of the supply-chain walk (1–6). | |
| top_n | No | Maximum number of rows to return (default 20). | |
| amount | No | `s<N>` only: how many of the system's DECLARED functional units to analyse (N). The solve scales by N x the declared amount, the same way `lca_run_assessment` does. Omit to analyse at the system's declared functional unit (N=1); an explicit value overrides. Ignored with an `a<N>`, which inherits its functional unit — and ignores `amount` entirely — from the saved assessment. | |
| cutoff | No | Upstream only: drop nodes contributing less than this fraction of the total impact (0–1, default 0.01). | |
| method | No | `s<N>` only: preferred LCIA method — fuzzy-matched (substring) against the methods in the connected database; free text is accepted. Defaults to the same house preference `lca_run_assessment` uses. Ignored with an `a<N>`, which inherits its method from the saved assessment. | |
| category | No | Impact category to break down. Defaults to the first category of the method. | |
| direction | No | Flow only: which exchange direction to keep — 'input' = substances taken from the environment (resources, land, water intake); 'output' = released to it (emissions like CO₂ to air); 'both' (the default) applies no filter. Most categories are dominated by one direction anyway; narrow mainly for net-balance categories like water consumption, where withdrawals (input) and returns (output) carry opposite signs and would otherwise both rank as top 'drivers' while largely cancelling. | both |
| workspace | Yes | Name of the workspace to work in, as `lca_get(kind='workspaces')` lists it (backticks optional). Named on every call: several conversations can share one connection, and each names its own workspace. The connection's default is often an empty sandbox rather than the user's work. | |
| compartment | No | Flow only: filter substances to one environmental compartment (medium) — e.g. 'air', 'water', 'soil'. Case-insensitive substring against the compartment path. |