Skip to main content
Version: Next

ts_shape.events.production.line_throughput

Classes
NameDescription
LineThroughputEventsProduction: Line Throughput

LineThroughputEvents​

classsource
LineThroughputEvents(
dataframe: pd.DataFrame,
*,
event_uuid: str = "prod:throughput",
time_column: str = "systime"
) -> None

Bases: Base

Production: Line Throughput

Methods:

  • count_parts: Part counts per fixed window from a monotonically increasing counter.
  • takt_adherence: Cycle time violations against a takt time from step/boolean triggers.
  • cycle_quality_check: Cycles from a trigger signal, flagged when outside the expected range.
  • throughput_oee: Availability, performance and OEE ratios (0-1) per window.
  • throughput_trends: Throughput trend with moving averages and degradation flags.
Functions
NameDescription
count_partsCompute parts per window for a counter uuid.
takt_adherenceFlag cycles whose durations exceed the takt_time.
throughput_oeeCalculate Overall Equipment Effectiveness (OEE) metrics.
throughput_trendsAnalyze throughput trends with moving averages and degradation detection.
cycle_quality_checkEnhanced cycle detection with quality validation.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
event_uuidstrUUID stamped on emitted events.'prod:throughput'
time_columnstrTimestamp column.'systime'

count_parts​

methodsource
count_parts(
counter_uuid: str,
*,
value_column: str = "value_integer",
window: str = "1min",
handle_resets: bool = True
) -> pd.DataFrame

Compute parts per window for a counter uuid.

When handle_resets is True (default), per-reading increments are computed on the raw counter (a decreasing counter is treated as a reset and the post-reset value counted as new production) and summed into each window, and a resets column reports the number of resets per window. When False, the count per window is the window-over-window difference of the counter maximum, clipped at zero, so a window in which the counter resets to a lower value loses that production.

Parameters
NameTypeDescriptionDefault
counter_uuidstrUUID of the part counter signal.required
value_columnstrColumn holding the counter value.'value_integer'
windowstrCount window (pandas offset string, e.g. '1min', '1h').'1min'
handle_resetsboolCount production across counter resets (see above) and add a resets column. Default True.True
Returns
TypeDescription
DataFrameDataFrame with columns: start, end (start + window),
DataFrameduration_seconds, uuid, source_uuid, is_delta, count,
DataFramepart_count (plus resets when handle_resets=True).
DataFrameCanonical twin columns: part_count (after count); it holds
DataFramethe same values as the deprecated column right before it, which is
DataFrameremoved in the next major release.

takt_adherence​

methodsource
takt_adherence(
cycle_uuid: str,
*,
value_column: str = "value_bool",
takt_time: str = "60s",
min_violation: str = "0s"
) -> pd.DataFrame

Flag cycles whose durations exceed the takt_time.

For boolean triggers: detect True rising edges as cycle boundaries. For numeric counters/steps: detect increments as cycle boundaries; a decrease (a counter reset) is not a cycle boundary.

Parameters
NameTypeDescriptionDefault
cycle_uuidstrUUID of the cycle trigger signal.required
value_columnstrColumn holding the trigger. "value_bool" uses rising edges as cycle boundaries; a numeric column uses every increase of the value (a reset or other decrease is not a boundary, so the cycle spanning it runs to the next increase); a non-numeric column (e.g. a string step name) uses every change of value.'value_bool'
takt_timestrTakt time (pandas offset string, e.g. '60s').'60s'
min_violationstrHow far a cycle must exceed takt_time to be a violation: a cycle is a violation when it is strictly longer than takt_time + min_violation. Default "0s": any cycle longer than the takt time counts; a cycle exactly equal to the takt time does not.'0s'
Returns
TypeDescription
DataFrameDataFrame with columns: systime (at the boundary that closes the
DataFramecycle), uuid, source_uuid, is_delta, cycle_time_seconds,
DataFrameviolation.

throughput_oee​

methodsource
throughput_oee(
counter_uuid: str,
*,
value_column: str = "value_integer",
window: str = "1h",
target_rate: float | None = None,
availability_threshold: float = 0.0,
handle_resets: bool = True
) -> pd.DataFrame

Calculate Overall Equipment Effectiveness (OEE) metrics.

OEE = Availability × Performance × Quality

This counter-only estimate has no run-state signal, so availability is a production proxy: a window counts as available when its part count is at least availability_threshold × target_rate. Quality is assumed to be 1.0.

Parameters
NameTypeDescriptionDefault
counter_uuidstrUUID for the part counter signalrequired
value_columnstrColumn containing counter values'value_integer'
windowstrTime window for aggregation'1h'
target_ratefloat | NoneTarget production rate (parts per window). If None, uses the 95th percentile of observed countsNone
availability_thresholdfloatFraction of target_rate a window must reach to count as available (0.0-1.0). The default 0.0 keeps the historical behavior -- any window with at least one part is available. (Previously this argument was accepted but ignored.)0.0
handle_resetsboolWhen True (default), the part counter is treated as reset-aware (see :meth:count_parts), so a window where the counter resets is not dropped. Default True.True
Returns
TypeDescription
DataFrameDataFrame with columns: start, end (start + window),
DataFrameduration_seconds, uuid, source_uuid, is_delta, actual_count,
DataFrametarget_count, availability, performance, oee_score, followed by
DataFramethe basis of the ratios:
DataFrame- run_seconds: the window length when the window counts as available, else 0 (the counter-only availability proxy)
DataFrame- planned_seconds: the window length
DataFrame- resets (only when handle_resets=True): counter resets in the window (see :meth:count_parts)
DataFrameCanonical twin columns: availability_ratio (after availability),
DataFrameperformance_ratio (after performance), oee_ratio (after
DataFrameoee_score); each holds the same values as the deprecated column right
DataFramebefore it, which is removed in the next major release.
methodsource
throughput_trends(
counter_uuid: str,
*,
value_column: str = "value_integer",
window: str = "1h",
trend_window: int = 24
) -> pd.DataFrame

Analyze throughput trends with moving averages and degradation detection.

Parameters
NameTypeDescriptionDefault
counter_uuidstrUUID for the part counter signalrequired
value_columnstrColumn containing counter values'value_integer'
windowstrTime window for counting parts'1h'
trend_windowintNumber of windows for trend calculation24
Returns
TypeDescription
DataFrameDataFrame with columns: start, end (start + window),
DataFrameduration_seconds, uuid, source_uuid, is_delta, count, part_count,
DataFramemoving_avg (parts per window), trend_direction,
DataFramedegradation_detected.
DataFrameCanonical twin columns: part_count (after count); it holds
DataFramethe same values as the deprecated column right before it, which is
DataFrameremoved in the next major release.

cycle_quality_check​

methodsource
cycle_quality_check(
cycle_uuid: str,
*,
value_column: str = "value_bool",
expected_cycle_time: float | None = None,
tolerance_pct: float = 10.0,
tolerance_ratio: float | None = None
) -> pd.DataFrame

Enhanced cycle detection with quality validation.

A cycle is valid when its relative deviation from the expected cycle time, |cycle_time - expected| / expected, is at most the tolerance. The quality_flag bins derive from the same tolerance: "good" up to the tolerance (the valid cycles), "warning" up to 2.5 times the tolerance, "critical" above. With the default 10 % tolerance these are the former fixed bins (10 % and 25 %).

Parameters
NameTypeDescriptionDefault
cycle_uuidstrUUID for the cycle trigger signalrequired
value_columnstrColumn containing cycle trigger (bool/integer)'value_bool'
expected_cycle_timefloat | NoneExpected cycle time in seconds. If None, uses medianNone
tolerance_pctfloatAllowed deviation from the expected cycle time, in percent (0-100, default 10.0 = 10 %), as MaterialBalanceEvents.balance_check(tolerance_pct=...). Deprecated: a value below 1 is read as the former fraction (0.1 = 10 %) and emits a DeprecationWarning; pass tolerance_pct=10.0 or tolerance_ratio=0.1 instead. Until the next major release, a tolerance below 1 % is given with tolerance_ratio.10.0
tolerance_ratiofloat | NoneThe same tolerance as a fraction (0-1, 0.1 = 10 %). When given, it replaces tolerance_pct.None
Returns
TypeDescription
DataFrameDataFrame with columns: systime, uuid, source_uuid, is_delta,
DataFramecycle_time_seconds, expected_time, expected_time_seconds (the
DataFrameexpected cycle time in seconds), deviation_pct (relative
DataFramedeviation in percent, 0-100 for a cycle up to twice the expected
DataFrametime), deviation_ratio (the same deviation as a fraction,
DataFramedeviation_pct / 100), is_valid, quality_flag.
DataFrameCanonical twin columns: expected_time_seconds (after
DataFrameexpected_time); it holds the same values as the deprecated
DataFramecolumn right before it, which is removed in the next major
DataFramerelease.