Skip to content

API

data_disaggregation.types

Type classes for data.

VT_Nominal

Bases: _AbstractVariableType

Type class for nominal (categorical) data.

  • Aggregation method: mode (most commonly used)
  • Examples: regional codes

VT_Numeric

Bases: _AbstractVariableType

Type class for numerical, intensive data.

An intensive variable is one which does not scale with the system size.

  • Aggregation method: weighted average
  • Examples: temperature, density, pressure

VT_NumericExt

Bases: VT_Numeric

Type class for numerical, extensive data.

An extensive variable is one which does scale with the system size (assuming an equal distribution).

  • Aggregation method: weighted sum
  • Examples: population, energy, total cost

VT_Ordinal

Bases: VT_Nominal

Type class for ordinal data (ranked categorical).

  • Aggregation method: median
  • Examples: Level of agreement

data_disaggregation.actions

Functions to perform data transformations.

transform(vtype, data, weight_map, weights_from=None, weights_to=None, weight_rel_threshold=0.0, validate=True)

(dis-)aggregate data.

Parameters:

Name Type Description Default
vtype _AbstractVariableType

Variable type of input data, determines the aggregation method.

required
data Mapping[F, V]

Input data: mapping (usually dict) from any keys (any hashable) to values.

required
weight_map Mapping[Tuple[F, T], float]

weights for combinations of input and output elements (must be positive). Keys must tuples from input/output key pairs.

required
weights_from Mapping[F, float]

optional weights of input elements (must be positive). If not specified, this will be calculated as a sum from weight_map.

None
weights_to Mapping[T, float]

optional weights of output elements (must be positive). If not specified, this will be calculated as a sum from weight_map.

None
weight_rel_threshold float

optional value between 0 and 1: all mappings are dropped if the sum of input weights / output weight is smaller than this threshold. For example, you may want to set it to 0.5 for geographical mappings with extensive data.

0.0
validate bool

if True: run additional (but costly) validations of weights and data.

True

Returns:

Type Description
Mapping[T, V]

output data as a mapping from output keys (any hashable) to values.

transform_pandas(vtype, data, weights, dim_in=None, dim_out=None, validate=True)