Skip to content

consumption_analysis

consumption_analysis ¤

EnergyConsumptionEvents ¤

EnergyConsumptionEvents(
    dataframe: DataFrame,
    *,
    event_uuid: str = "energy:consumption",
    time_column: str = "systime"
)

Bases: Base

Energy: Consumption Analysis

Analyze energy consumption patterns from meter/sensor signals.

Methods: - consumption_by_window: Aggregate energy per time window from a meter UUID. - peak_demand_detection: Flag windows where consumption exceeds a threshold. - consumption_baseline_deviation: Compare actual vs rolling baseline. - energy_per_unit: Energy per production unit when paired with a counter.

consumption_by_window ¤

consumption_by_window(
    meter_uuid: str,
    *,
    value_column: str = "value_double",
    window: str = "1h",
    agg: str = "sum"
) -> pd.DataFrame

Aggregate energy consumption per time window.

Parameters:

Name Type Description Default
meter_uuid str

UUID of the energy meter signal.

required
value_column str

Column containing energy readings.

'value_double'
window str

Resample window (e.g. '1h', '15min', '1D').

'1h'
agg str

Aggregation method ('sum', 'mean', 'max').

'sum'

Returns:

Name Type Description
DataFrame DataFrame

window_start, uuid, source_uuid, is_delta, consumption

peak_demand_detection ¤

peak_demand_detection(
    meter_uuid: str,
    *,
    value_column: str = "value_double",
    window: str = "15min",
    threshold: Optional[float] = None,
    percentile: float = 0.95
) -> pd.DataFrame

Detect peak demand periods exceeding a threshold.

If threshold is None, uses the given percentile of windowed consumption.

Parameters:

Name Type Description Default
meter_uuid str

UUID of the energy meter signal.

required
value_column str

Column containing energy readings.

'value_double'
window str

Resample window for demand calculation.

'15min'
threshold Optional[float]

Absolute demand threshold. If None, auto-calculated.

None
percentile float

Percentile to use for auto-threshold (default 95th).

0.95

Returns:

Name Type Description
DataFrame DataFrame

window_start, uuid, source_uuid, is_delta, demand, threshold, is_peak

consumption_baseline_deviation ¤

consumption_baseline_deviation(
    meter_uuid: str,
    *,
    value_column: str = "value_double",
    window: str = "1h",
    baseline_periods: int = 24,
    deviation_threshold: float = 0.2
) -> pd.DataFrame

Compare actual consumption vs rolling baseline.

Parameters:

Name Type Description Default
meter_uuid str

UUID of the energy meter signal.

required
value_column str

Column containing energy readings.

'value_double'
window str

Resample window for consumption.

'1h'
baseline_periods int

Number of windows for rolling baseline.

24
deviation_threshold float

Fractional deviation to flag (0.2 = 20%).

0.2

Returns:

Name Type Description
DataFrame DataFrame

window_start, uuid, source_uuid, is_delta, consumption, baseline, deviation_pct, is_anomaly

energy_per_unit ¤

energy_per_unit(
    meter_uuid: str,
    counter_uuid: str,
    *,
    energy_column: str = "value_double",
    counter_column: str = "value_integer",
    window: str = "1h"
) -> pd.DataFrame

Calculate energy consumption per production unit.

Parameters:

Name Type Description Default
meter_uuid str

UUID of the energy meter signal.

required
counter_uuid str

UUID of the production counter signal.

required
energy_column str

Column with energy readings.

'value_double'
counter_column str

Column with counter readings.

'value_integer'
window str

Time window for aggregation.

'1h'

Returns:

Name Type Description
DataFrame DataFrame

window_start, uuid, source_uuid, is_delta, energy, units_produced, energy_per_unit