Analyze contributions
lca_analyze_contributionsBreak down what drives an impact category. Takes exactly one target: assessment_ref (a<N>) analyses a saved assessment's setup, or system_ref (s<N>) analyses a saved system directly, with no prior assessment needed. source must match the target; with system_ref, method and amount 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 assessment_ref is available; flow, upstream and system_ref 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 |
| 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 | `system_ref` 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 `assessment_ref`, 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 | `system_ref` 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 `assessment_ref`, which inherits its method from the saved assessment. | |
| source | No | Which kind of target this analysis runs on — set it to match the ref you pass: 'assessment' with `assessment_ref`, 'system' with `system_ref`. | |
| 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. | |
| system_ref | No | Saved-system ref in the form `s<N>` (e.g. `s1`) — analyse this system directly, with NO prior assessment. Mutually exclusive with `assessment_ref`. List current systems with `lca_get(kind='systems')` — never pass UUIDs. | |
| compartment | No | Flow only: filter substances to one environmental compartment (medium) — e.g. 'air', 'water', 'soil'. Case-insensitive substring against the compartment path. | |
| assessment_ref | No | Saved-assessment ref in the form `a<N>` (e.g. `a3`) — analyse the setup this assessment captured (its system, method and functional unit). Mutually exclusive with `system_ref`. List current assessments with `lca_get(kind='assessments')` to pick the right one — never pass UUIDs. |