ts_shape.events.energy.efficiency_tracking
| Name | Description |
|---|---|
EnergyEfficiencyEvents | Energy: Efficiency Tracking |
EnergyEfficiencyEvents
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.
| Name | Description |
|---|---|
normalize | Convert a raw energy DataFrame to the standard ts-shape schema. |
efficiency_trend | Rolling energy efficiency trend (units produced per kWh). |
idle_energy_waste | Detect energy consumed during idle periods (waste). |
specific_energy_consumption | Daily/periodic specific energy consumption (SEC = energy / output). |
efficiency_comparison | Compare energy efficiency across shifts. |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
event_uuid | str | UUID stamped on emitted events. | 'energy:efficiency' |
time_column | str | Timestamp column. | 'systime' |
uuid_column | str | Column identifying the signal (e.g. "id" for a raw CSV frame). | 'uuid' |
normalize
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.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Raw DataFrame. | required |
series_id | str | UUID to assign when no uuid_column is provided. | required |
time_column | str | Name of the timestamp column in dataframe. | 'time' |
value_column | str | Name of the value column in dataframe. | 'value' |
uuid_column | str | None | Optional column name whose values become the uuid. | None |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: systime, uuid, value_double, is_delta |
efficiency_trend
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).
| Name | Type | Description | Default |
|---|---|---|---|
meter_uuid | str | UUID of the energy meter signal. | required |
counter_uuid | str | UUID of the production counter signal. | required |
value_column_energy | str | Column with energy readings. | 'value_double' |
value_column_counter | str | Column with counter readings. | 'value_integer' |
window | str | Time window for aggregation. | '1h' |
trend_window | int | Number of trailing windows (itself included) in rolling_avg_efficiency: their summed units over their summed energy. | 24 |
handle_resets | bool | True (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 |
| Name | Type | Description |
|---|---|---|
DataFrame | DataFrame | start, end, duration_seconds, uuid, source_uuid, is_delta, energy, units, efficiency, rolling_avg_efficiency, trend_direction |
idle_energy_waste
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.
| Name | Type | Description | Default |
|---|---|---|---|
meter_uuid | str | UUID of the energy meter signal. | required |
run_state_uuid | str | UUID of the boolean machine state signal (True=run). | required |
value_column_energy | str | Column with energy readings. | 'value_double' |
value_column_state | str | Column with boolean state. | 'value_bool' |
window | str | Time window for analysis. | '15min' |
idle_threshold | float | Energy above this during idle is waste. | 0.0 |
time_weighted | bool | True (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_states | Collection[Any] | None | Values 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_range | tuple[float | None, float | None] | None | (lower, upper) inclusive bounds; a run-signal value inside counts as running. Used when run_states is None. | None |
| Name | Type | Description |
|---|---|---|
DataFrame | DataFrame | start, 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
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.
| Name | Type | Description | Default |
|---|---|---|---|
meter_uuid | str | UUID of the energy meter signal. | required |
counter_uuid | str | UUID of the production counter. | required |
value_column_energy | str | Column with energy readings. | 'value_double' |
value_column_counter | str | Column with counter readings. | 'value_integer' |
window | str | Time window (default daily). | '1D' |
handle_resets | bool | True (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 |
| Name | Type | Description |
|---|---|---|
DataFrame | DataFrame | start, end, duration_seconds, uuid, source_uuid, is_delta, total_energy, total_output, sec, sec_trend |
efficiency_comparison
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.
| Name | Type | Description | Default |
|---|---|---|---|
meter_uuid | str | UUID of the energy meter signal. | required |
counter_uuid | str | UUID of the production counter. | required |
value_column_energy | str | Column with energy readings. | 'value_double' |
value_column_counter | str | Column with counter readings. | 'value_integer' |
shift_definitions | dict[str, tuple] | None | Dict mapping shift name to (start_time, end_time) strings. Default: 3-shift operation. | None |
| Name | Type | Description |
|---|---|---|
DataFrame | DataFrame | shift, 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. |