Skip to main content
Version: Next

ts_shape.events.energy.idle_energy_detection

Classes
NameDescription
IdleEnergyDetectionEventsEnergy: Idle Energy Detection

IdleEnergyDetectionEvents​

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

Bases: Base

Energy: Idle Energy Detection

Cross-reference an energy meter signal with a boolean machine-state signal to detect and quantify energy consumed during idle (non-production) periods.

Supports two data models via constructor parameters:

  • Standard (ts-shape default)::

    IdleEnergyDetectionEvents(df)

    expects: systime | uuid | value_double | value_bool

  • Raw CSV::

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

Methods:

  • idle_energy_by_window: Idle vs running energy per time window.
  • idle_energy_by_shift: Idle waste aggregated per shift.
  • idle_energy_trend: Rolling trend of idle energy waste.
Functions
NameDescription
idle_energy_by_windowAggregate energy consumed during idle periods per time window.
idle_energy_by_shiftAggregate idle energy waste per shift across all dates.
idle_energy_trendRolling trend of idle energy waste over time.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
event_uuidstrUUID stamped on emitted events.'energy:idle'
time_columnstrTimestamp column.'systime'
uuid_columnstrColumn identifying the signal (e.g. "id" for a raw CSV frame).'uuid'

idle_energy_by_window​

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

Aggregate energy consumed during idle periods per time window.

The machine-running share is the share of each window the boolean state signal was True. It is reported as machine_running_ratio (0-1) and as machine_running_pct (0-100). Windows whose ratio is below idle_threshold count as fully idle; otherwise the idle fraction is 1 - machine_running_ratio.

Parameters
NameTypeDescriptionDefault
meter_uuidstrIdentifier of the energy meter signal.required
run_state_uuidstrIdentifier of the boolean machine-state signal (True=running).required
value_column_energystrColumn containing energy readings.'value_double'
value_column_statestrColumn containing boolean state values.'value_bool'
windowstrResample window (e.g. '1h', '15min').'1h'
idle_thresholdfloatRunning ratio (0-1) below which the window is classified as fully idle.0.1
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, total_energy, idle_energy, running_energy, machine_running_pct (0-100), idle_fraction, machine_running_ratio (0-1)

idle_energy_by_shift​

methodsource
idle_energy_by_shift(
meter_uuid: str,
run_state_uuid: str,
*,
value_column_energy: str = "value_double",
value_column_state: str = "value_bool",
shift_definitions: dict[str, tuple[str, str]] | None = None,
idle_threshold: float | None = None,
run_states: Collection[Any] | None = None,
value_range: tuple[float | None, float | None] | None = None
) -> pd.DataFrame

Aggregate idle energy waste per shift across all dates.

The idle fraction of a shift is 1 - running ratio (the mean of the state samples in that shift). Pass idle_threshold to apply the same rule as :meth:idle_energy_by_window: a shift whose running ratio is below the threshold counts as fully idle.

Parameters
NameTypeDescriptionDefault
meter_uuidstrIdentifier of the energy meter signal.required
run_state_uuidstrIdentifier of the boolean machine-state signal.required
value_column_energystrColumn containing energy readings.'value_double'
value_column_statestrColumn containing boolean state values.'value_bool'
shift_definitionsdict[str, tuple[str, str]] | NoneDict mapping shift name → (start_time, end_time). Default: three-shift operation (06-14, 14-22, 22-06).None
idle_thresholdfloat | NoneRunning ratio (0-1) below which a shift counts as fully idle. Default None: no threshold, the idle fraction is always 1 - running ratio; 0.1 matches :meth:idle_energy_by_window.None
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
DataFrameDataFrameshift, total_energy, idle_energy, waste_fraction

idle_energy_trend​

methodsource
idle_energy_trend(
meter_uuid: str,
run_state_uuid: str,
*,
value_column_energy: str = "value_double",
value_column_state: str = "value_bool",
window: str = "1D",
trend_window: int = 7,
idle_threshold: float = 0.1,
run_states: Collection[Any] | None = None,
value_range: tuple[float | None, float | None] | None = None
) -> pd.DataFrame

Rolling trend of idle energy waste over time.

Parameters
NameTypeDescriptionDefault
meter_uuidstrIdentifier of the energy meter signal.required
run_state_uuidstrIdentifier of the boolean machine-state signal.required
value_column_energystrColumn containing energy readings.'value_double'
value_column_statestrColumn containing boolean state values.'value_bool'
windowstrAggregation window (default daily).'1D'
trend_windowintNumber of windows for rolling average.7
idle_thresholdfloatRunning ratio (0-1) below which a window counts as fully idle (see :meth:idle_energy_by_window).0.1
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, idle_energy, rolling_avg_idle_energy, trend_direction