Skip to main content
Version: Next

ts_shape.events.energy.efficiency_tracking

Classes
NameDescription
EnergyEfficiencyEventsEnergy: Efficiency Tracking

EnergyEfficiencyEvents​

classsource
EnergyEfficiencyEvents(
dataframe: pd.DataFrame,
*,
event_uuid: str = "energy:efficiency",
time_column: str = "systime",
uuid_column: str = "uuid"
) -> None

Bases: Base

Energy: Efficiency Tracking

Track energy efficiency metrics against production and machine state.

Supports two data models via constructor parameters:

  • Standard (ts-shape default)::

    EnergyEfficiencyEvents(df)

    expects: systime | uuid | value_double / value_integer / value_bool

  • Raw CSV (time + id + value)::

    EnergyEfficiencyEvents(df, time_column="time", uuid_column="id")

    pass value_column="value" to each method

Methods:

  • efficiency_trend: Rolling efficiency metric over time.
  • idle_energy_waste: Detect energy consumption during idle periods.
  • specific_energy_consumption: Energy per unit output trend.
  • efficiency_comparison: Compare efficiency across shifts or periods.
  • normalize: Static helper to convert raw CSV format to standard schema.
Functions
NameDescription
normalizeConvert a raw energy DataFrame to the standard ts-shape schema.
efficiency_trendRolling energy efficiency trend (units produced per kWh).
idle_energy_wasteDetect energy consumed during idle periods (waste).
specific_energy_consumptionDaily/periodic specific energy consumption (SEC = energy / output).
efficiency_comparisonCompare energy efficiency across shifts.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
event_uuidstrUUID stamped on emitted events.'energy:efficiency'
time_columnstrTimestamp column.'systime'
uuid_columnstrColumn identifying the signal (e.g. "id" for a raw CSV frame).'uuid'

normalize​

staticmethodsource
normalize(
dataframe: pd.DataFrame,
*,
series_id: str,
time_column: str = "time",
value_column: str = "value",
uuid_column: str | None = None
) -> pd.DataFrame

Convert a raw energy DataFrame to the standard ts-shape schema.

Not the library-wide normalization (:func:ts_shape.utils.normalize.normalize_signal_frame): this reads a raw two-column export (time / value by default) and returns the long systime / uuid / value_double frame the detectors take. A frame that is already long format needs no call.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameRaw DataFrame.required
series_idstrUUID to assign when no uuid_column is provided.required
time_columnstrName of the timestamp column in dataframe.'time'
value_columnstrName of the value column in dataframe.'value'
uuid_columnstr | NoneOptional column name whose values become the uuid.None
Returns
TypeDescription
DataFrameDataFrame with columns: systime, uuid, value_double, is_delta

efficiency_trend​

methodsource
efficiency_trend(
meter_uuid: str,
counter_uuid: str,
*,
value_column_energy: str = "value_double",
value_column_counter: str = "value_integer",
window: str = "1h",
handle_resets: bool = True,
trend_window: int = 24
) -> pd.DataFrame

Rolling energy efficiency trend (units produced per kWh).

Parameters
NameTypeDescriptionDefault
meter_uuidstrUUID of the energy meter signal.required
counter_uuidstrUUID of the production counter signal.required
value_column_energystrColumn with energy readings.'value_double'
value_column_counterstrColumn with counter readings.'value_integer'
windowstrTime window for aggregation.'1h'
trend_windowintNumber of trailing windows (itself included) in rolling_avg_efficiency: their summed units over their summed energy.24
handle_resetsboolTrue (default) treats a decreasing production counter as a reset and sums reset-aware increments per window (see :func:ts_shape.utils.counters.counter_per_window), so a window with a reset still reports what was produced. False uses the per-window max - min.True
Returns
NameTypeDescription
DataFrameDataFramestart, end, duration_seconds, uuid, source_uuid, is_delta, energy, units, efficiency, rolling_avg_efficiency, trend_direction

idle_energy_waste​

methodsource
idle_energy_waste(
meter_uuid: str,
run_state_uuid: str,
*,
value_column_energy: str = "value_double",
value_column_state: str = "value_bool",
window: str = "15min",
idle_threshold: float = 0.0,
time_weighted: bool = True,
run_states: Collection[Any] | None = None,
value_range: tuple[float | None, float | None] | None = None
) -> pd.DataFrame

Detect energy consumed during idle periods (waste).

Compares energy consumption with machine run/idle state to find windows where the machine is idle but still consuming energy.

Parameters
NameTypeDescriptionDefault
meter_uuidstrUUID of the energy meter signal.required
run_state_uuidstrUUID of the boolean machine state signal (True=run).required
value_column_energystrColumn with energy readings.'value_double'
value_column_statestrColumn with boolean state.'value_bool'
windowstrTime window for analysis.'15min'
idle_thresholdfloatEnergy above this during idle is waste.0.0
time_weightedboolTrue (default) weights the machine state by how long it was held (until the next state change) and keeps every energy window. False averages state samples and keeps only windows that contain a state row; that is only right for a densely, uniformly sampled state signal.True
run_statesCollection[Any] | NoneValues of the run signal that mean running (e.g. {2} for a mode signal where 2 is automatic); every other known value is not running. None (default) uses value_range or reads the signal as a bool, with a DataQualityWarning when it is not one (see :func:ts_shape.utils.coerce.run_mask).None
value_rangetuple[float | None, float | None] | None(lower, upper) inclusive bounds; a run-signal value inside counts as running. Used when run_states is None.None
Returns
NameTypeDescription
DataFrameDataFramestart, end, duration_seconds, uuid, source_uuid, is_delta, energy_consumed, machine_running_pct (0-100), machine_running_ratio (0-1), is_idle_waste, waste_energy. A window is idle waste when the machine ran less than 10 % of it and consumed more than idle_threshold.

specific_energy_consumption​

methodsource
specific_energy_consumption(
meter_uuid: str,
counter_uuid: str,
*,
value_column_energy: str = "value_double",
value_column_counter: str = "value_integer",
window: str = "1D",
handle_resets: bool = True
) -> pd.DataFrame

Daily/periodic specific energy consumption (SEC = energy / output).

Lower SEC indicates better efficiency.

Parameters
NameTypeDescriptionDefault
meter_uuidstrUUID of the energy meter signal.required
counter_uuidstrUUID of the production counter.required
value_column_energystrColumn with energy readings.'value_double'
value_column_counterstrColumn with counter readings.'value_integer'
windowstrTime window (default daily).'1D'
handle_resetsboolTrue (default) treats a decreasing production counter as a reset and sums reset-aware increments per window (see :func:ts_shape.utils.counters.counter_per_window), so a window with a reset still reports what was produced. False uses the per-window max - min.True
Returns
NameTypeDescription
DataFrameDataFramestart, end, duration_seconds, uuid, source_uuid, is_delta, total_energy, total_output, sec, sec_trend

efficiency_comparison​

methodsource
efficiency_comparison(
meter_uuid: str,
counter_uuid: str,
*,
value_column_energy: str = "value_double",
value_column_counter: str = "value_integer",
shift_definitions: dict[str, tuple] | None = None
) -> pd.DataFrame

Compare energy efficiency across shifts.

Parameters
NameTypeDescriptionDefault
meter_uuidstrUUID of the energy meter signal.required
counter_uuidstrUUID of the production counter.required
value_column_energystrColumn with energy readings.'value_double'
value_column_counterstrColumn with counter readings.'value_integer'
shift_definitionsdict[str, tuple] | NoneDict mapping shift name to (start_time, end_time) strings. Default: 3-shift operation.None
Returns
NameTypeDescription
DataFrameDataFrameshift, avg_energy, avg_output, avg_efficiency, total_energy, total_output. total_output is the counter increase within the shift (reset-aware) and avg_output the mean increase per counter reading.