ts_shape.events.production.line_throughput
| Name | Description |
|---|---|
LineThroughputEvents | Production: Line Throughput |
LineThroughputEvents
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.
| Name | Description |
|---|---|
count_parts | Compute parts per window for a counter uuid. |
takt_adherence | Flag cycles whose durations exceed the takt_time. |
throughput_oee | Calculate Overall Equipment Effectiveness (OEE) metrics. |
throughput_trends | Analyze throughput trends with moving averages and degradation detection. |
cycle_quality_check | Enhanced cycle detection with quality validation. |
| 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. | 'prod:throughput' |
time_column | str | Timestamp column. | 'systime' |
count_parts
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.
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid | str | UUID of the part counter signal. | required |
value_column | str | Column holding the counter value. | 'value_integer' |
window | str | Count window (pandas offset string, e.g. '1min', '1h'). | '1min' |
handle_resets | bool | Count production across counter resets (see above) and add a resets column. Default True. | True |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end (start + window), |
DataFrame | duration_seconds, uuid, source_uuid, is_delta, count, |
DataFrame | part_count (plus resets when handle_resets=True). |
DataFrame | Canonical twin columns: part_count (after count); it holds |
DataFrame | the same values as the deprecated column right before it, which is |
DataFrame | removed in the next major release. |
takt_adherence
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.
| Name | Type | Description | Default |
|---|---|---|---|
cycle_uuid | str | UUID of the cycle trigger signal. | required |
value_column | str | Column 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_time | str | Takt time (pandas offset string, e.g. '60s'). | '60s' |
min_violation | str | How 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' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: systime (at the boundary that closes the |
DataFrame | cycle), uuid, source_uuid, is_delta, cycle_time_seconds, |
DataFrame | violation. |
throughput_oee
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.
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid | str | UUID for the part counter signal | required |
value_column | str | Column containing counter values | 'value_integer' |
window | str | Time window for aggregation | '1h' |
target_rate | float | None | Target production rate (parts per window). If None, uses the 95th percentile of observed counts | None |
availability_threshold | float | Fraction 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_resets | bool | When 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 |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end (start + window), |
DataFrame | duration_seconds, uuid, source_uuid, is_delta, actual_count, |
DataFrame | target_count, availability, performance, oee_score, followed by |
DataFrame | the 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) |
DataFrame | Canonical twin columns: availability_ratio (after availability), |
DataFrame | performance_ratio (after performance), oee_ratio (after |
DataFrame | oee_score); each holds the same values as the deprecated column right |
DataFrame | before it, which is removed in the next major release. |
throughput_trends
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.
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid | str | UUID for the part counter signal | required |
value_column | str | Column containing counter values | 'value_integer' |
window | str | Time window for counting parts | '1h' |
trend_window | int | Number of windows for trend calculation | 24 |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end (start + window), |
DataFrame | duration_seconds, uuid, source_uuid, is_delta, count, part_count, |
DataFrame | moving_avg (parts per window), trend_direction, |
DataFrame | degradation_detected. |
DataFrame | Canonical twin columns: part_count (after count); it holds |
DataFrame | the same values as the deprecated column right before it, which is |
DataFrame | removed in the next major release. |
cycle_quality_check
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 %).
| Name | Type | Description | Default |
|---|---|---|---|
cycle_uuid | str | UUID for the cycle trigger signal | required |
value_column | str | Column containing cycle trigger (bool/integer) | 'value_bool' |
expected_cycle_time | float | None | Expected cycle time in seconds. If None, uses median | None |
tolerance_pct | float | Allowed 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_ratio | float | None | The same tolerance as a fraction (0-1, 0.1 = 10 %). When given, it replaces tolerance_pct. | None |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: systime, uuid, source_uuid, is_delta, |
DataFrame | cycle_time_seconds, expected_time, expected_time_seconds (the |
DataFrame | expected cycle time in seconds), deviation_pct (relative |
DataFrame | deviation in percent, 0-100 for a cycle up to twice the expected |
DataFrame | time), deviation_ratio (the same deviation as a fraction, |
DataFrame | deviation_pct / 100), is_valid, quality_flag. |
DataFrame | Canonical twin columns: expected_time_seconds (after |
DataFrame | expected_time); it holds the same values as the deprecated |
DataFrame | column right before it, which is removed in the next major |
DataFrame | release. |