milia.data.aggregate#

Group-level profiles: feeders and transformers built from their members.

Functions

aggregate(profiles[, weights])

Weighted sum of member profiles, e.g. kW-rated customers on one feeder.

synthesize(counts, pools, rng)

A synthetic group profile from randomly drawn members of each class.

milia.data.aggregate.aggregate(profiles, weights=None)#

Weighted sum of member profiles, e.g. kW-rated customers on one feeder.

Parameters:
  • profiles (ArrayLike) – Member profiles, shape (members, steps).

  • weights (ArrayLike | None) – One weight per member; equal weights when omitted.

Return type:

ndarray

Returns:

The group profile, shape (steps,).

Raises:

ValueError – If weights does not have one entry per member.

Examples

>>> aggregate([[1.0, 2.0], [3.0, 4.0]])
array([4., 6.])
>>> aggregate([[1.0, 2.0], [3.0, 4.0]], weights=[2.0, 0.0])
array([2., 4.])
milia.data.aggregate.synthesize(counts, pools, rng)#

A synthetic group profile from randomly drawn members of each class.

Used when a network gives each transformer’s customer counts by class (residential, commercial) but not their meters: draw that many profiles from each class’s pool and add them. Draws are without replacement unless a class asks for more members than its pool holds.

Parameters:
  • counts (Mapping[str, int]) – Members of each class, e.g. {"res": 40, "com": 2}.

  • pools (Mapping[str, ArrayLike]) – Candidate profiles per class, each of shape (n, steps).

  • rng (Generator) – Random generator.

Return type:

ndarray

Returns:

The summed profile, shape (steps,).

Raises:

ValueError – If no class has a positive count.

Examples

>>> import numpy as np
>>> pools = {"res": np.ones((5, 3)), "com": np.full((2, 3), 10.0)}
>>> synthesize({"res": 2, "com": 1}, pools, np.random.default_rng(0))
array([12., 12., 12.])