bw_temporalis.lca
Exceptions
Common base class for all non-exit exceptions. |
Classes
The edge was created dynamically via a datapackage. There is no edge in the database. |
|
Calculate an LCA using graph traversal, with edges using temporal distributions. |
Module Contents
- exception bw_temporalis.lca.MultipleTechnosphereExchanges[source]
Bases:
ExceptionCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- class bw_temporalis.lca.NoExchange[source]
The edge was created dynamically via a datapackage. There is no edge in the database.
- class bw_temporalis.lca.TemporalisLCA(lca_object: bw2calc.LCA, starting_datetime: datetime.datetime | str = 'now', cutoff: float | None = 0.0005, biosphere_cutoff: float | None = 1e-06, max_calc: int | None = 2000, static_activity_indices: set[int] | None = None, skip_coproducts: bool | None = False, functional_unit_unique_id: int | None = -1, graph_traversal: bw_graph_tools.NewNodeEachVisitGraphTraversal | None = NewNodeEachVisitGraphTraversal)[source]
Calculate an LCA using graph traversal, with edges using temporal distributions.
Edges with temporal distributions should store this information using “temporal_distributions”:
- ```python
- exchange[“temporal_distribution”] = bw_temporalis.TemporalDistribution(
times=numpy.array([-2, -1, 0, 1, 2], dtype=”timedelta64[s]”), values=numpy.ones(5)
)
Temporal distribution times must always have the data type timedelta64[s]. Not all edges need to have temporal distributions.
Temporal distributions are not density functions - their values should sum to the exchange amount.
As graph traversal is much slower than matrix calculations, we can limit which nodes get traversed in several ways:
All activities in a database marked as static
Any activity ids passed in static_activity_indices
Any activities whose cumulative impact is below the cutoff score
The output of a Temporalis LCA calculation is a bw_temporalis.Timeline, which can be characterized.
- Parameters:
lca_object (bw2calc.LCA) – The already instantiated and calculated LCA class (i.e. .lci() and .lcia() have already been done)
starting_datetime (datetime.datetime | str) – When the functional unit happens. Must be a point in time. Normally something like “now” or “2023-01-01”.
cutoff (float) – The fraction of the total score below which graph traversal should stop. In range (0, 1).
biosphere_cutoff (float) – The fraction of the total score below which we don’t include separate biosphere nodes to be characterized in the Timeline. In range (0, 1).
max_calc (int) – Total number of LCA inventory calculations to perform during graph traversal
static_activity_indices (set[int]) – Activity database node id values where graph traversal will stop
skip_coproducts (bool) – Should we also traverse edges for the other products in multioutput activities?
functional_unit_unique_id (int) – The unique id of the functional unit. Strongly recommended to leave as default.
graph_traversal (bw_graph_tools.NewNodeEachVisitGraphTraversal) – Optional subclass of NewNodeEachVisitGraphTraversal for advanced usage
- _exchange_value(exchange: bw2data.backends.ExchangeDataset | NoExchange, row_id: int, col_id: int, matrix_label: str) float | bw_temporalis.temporal_distribution.TemporalDistribution[source]
- build_timeline(node_timeline: bool | None = False) bw_temporalis.timeline.Timeline[source]