pulpo.utils.uncertainty.preparer#
Import of the uncertainty data an impact X(s) = sum_e q_e sum_j b_ej s_j depends on.
Which parameters#
Every entry b_ej of the intervention matrix on a flow e that the LCIA
method characterizes, and every characterization factor q_e of the method
on a flow that occurs in the intervention matrix. Nothing else can move X:
an entry on an uncharacterized flow is multiplied by a CF of exactly zero, and
an entry that is zero in B is no coefficient at all. No contribution
filter is applied, so the parameter set does not depend on a reference
solution.
Technosphere exchanges are not parameters, as of now: A is deterministic
and any distribution the database declares for its entries is not read. The
closed-form moments and the reduced space both rely on that.
Declared and undeclared#
A parameter is declared when the database or the method gives it a
distribution (uncertainty_type > 0) and undeclared otherwise. Undeclared
parameters are deterministic in every result (mean = amount, variance 0); they
are kept, under 'undeclared', so that the screening of undeclared parameters
can rank them. uncertainty_type = 1 (“no uncertainty”) is a declaration of
an exact value and is kept under 'declared' with variance 0.
The container (UncertaintyData) is a nested dict:
{'If': {database: {'declared': {(e, j): spec}, 'undeclared': {(e, j): spec}}},
'Cf': {method: {'declared': {e: spec}, 'undeclared': {e: spec}}}}
with spec a stats_arrays-style dict (uncertainty_type, amount,
loc, scale, shape, minimum, maximum, negative) and
(e, j) the (flow row, process column) of the entry in B.
Module Contents#
Classes#
One parameter's declared distribution, in stats_arrays' field names. |
|
The parameters of one database or method, split by whether they declare a distribution. |
|
The uncertainty data of an impact: |
Functions#
|
|
|
|
|
|
|
The parameters of the worker's impact and their declared distributions. |
|
|
|
|
|
Declare or replace distributions, e.g. from expert elicitation. |
|
|
|
One row per group, subgroup and family: how many parameters each holds. |
Attributes#
- class pulpo.utils.uncertainty.preparer.UncertaintySpec[source]#
Bases:
TypedDictOne parameter’s declared distribution, in stats_arrays’ field names.
Initialize self. See help(type(self)) for accurate signature.
- class pulpo.utils.uncertainty.preparer.ParameterBlock[source]#
Bases:
TypedDictThe parameters of one database or method, split by whether they declare a distribution.
Initialize self. See help(type(self)) for accurate signature.
- declared: Dict[ParamIndex, UncertaintySpec][source]#
- undeclared: Dict[ParamIndex, UncertaintySpec][source]#
- class pulpo.utils.uncertainty.preparer.UncertaintyData[source]#
Bases:
TypedDictThe uncertainty data of an impact:
'If'per database,'Cf'for the method.Initialize self. See help(type(self)) for accurate signature.
- If: Dict[str, ParameterBlock][source]#
- Cf: Dict[str, ParameterBlock][source]#
- pulpo.utils.uncertainty.preparer._SPEC_FIELDS = ('uncertainty_type', 'amount', 'loc', 'scale', 'shape', 'minimum', 'maximum', 'negative')[source]#
- pulpo.utils.uncertainty.preparer._record(row) UncertaintySpec[source]#
- pulpo.utils.uncertainty.preparer.import_declared(worker, method=None) UncertaintyData[source]#
The parameters of the worker’s impact and their declared distributions.
- Parameters:
worker (PulpoOptimizer) – a worker after
get_lci_data().method (str, optional) – the LCIA method; defaults to the worker’s only one.
- Returns:
see the module docstring.
- Return type:
- pulpo.utils.uncertainty.preparer._validate(spec: UncertaintySpec, index=None)[source]#
- pulpo.utils.uncertainty.preparer.override(uncertainty_data: UncertaintyData, group: str, subgroup: str, specs: Dict[ParamIndex, UncertaintySpec]) UncertaintyData[source]#
Declare or replace distributions, e.g. from expert elicitation.
Each spec replaces the parameter’s distribution;
amount(the value the deterministic model uses) is kept unless the spec gives one. A parameter that is not in the data raisesKeyError: it is not a coefficient of the impact (a zero entry ofB, or an uncharacterized flow).- Parameters:
uncertainty_data – from
import_declared(); modified in place and returned.group –
'If'or'Cf'.subgroup – the database (
'If') or the method ('Cf').specs –
{index: spec}withindex=(flow row, process column)for'If'and the flow row for'Cf'.
- pulpo.utils.uncertainty.preparer.undeclared(uncertainty_data: UncertaintyData) Dict[str, Dict[str, Dict[ParamIndex, UncertaintySpec]]][source]#
{group: {subgroup: {index: spec}}}of every undeclared parameter.
- pulpo.utils.uncertainty.preparer.counts(uncertainty_data: UncertaintyData) List[dict][source]#
One row per group, subgroup and family: how many parameters each holds.