ts_shape.events.production.flow_metrics
Flow metrics and Little's Law analysis for production lines.
Treats a process as a queue between an entry signal and an exit signal and derives the classic flow metrics an industrial engineer relies on:
- work in process (WIP) over time, time-weighted,
- throughput (units out per window),
- lead time (FIFO-matched entry -> exit),
- a flow summary tying them together via Little's Law
(
WIP = throughput x lead_time) plus Process Cycle Efficiency.
Entry and exit are boolean signals; each rising edge is one unit.
| Name | Description |
|---|---|
FlowMetricsEvents | WIP, throughput, lead time and Little's Law metrics for a process. |
FlowMetricsEvents
FlowMetricsEvents(
dataframe: pd.DataFrame,
entry_uuid: str,
exit_uuid: str,
*,
event_uuid: str = "prod:flow_metrics",
value_column: str = "value_bool",
time_column: str = "systime"
) -> None
Bases: Base
WIP, throughput, lead time and Little's Law metrics for a process.
Example usage::
flow = FlowMetricsEvents(df, entry_uuid="u_in", exit_uuid="u_out")
flow.wip_over_time(window="1h")
flow.throughput(window="1h")
flow.lead_time()
flow.flow_summary(value_add_seconds=120, window="1h")
| Name | Description |
|---|---|
wip_over_time | Time-weighted work-in-process per window. |
throughput | Units completed (exit rising edges) per window. |
lead_time | FIFO-matched lead time per unit (entry -> exit). |
flow_summary | Combined flow metrics with a Little's Law consistency check. |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Input DataFrame with timeseries data. | required |
entry_uuid | str | UUID of the boolean unit-entry signal. | required |
exit_uuid | str | UUID of the boolean unit-exit signal. | required |
event_uuid | str | UUID to tag derived events with. | 'prod:flow_metrics' |
value_column | str | Column holding the boolean trigger. | 'value_bool' |
time_column | str | Name of the timestamp column. | 'systime' |
wip_over_time
wip_over_time(window: str = '1h') -> pd.DataFrame
Time-weighted work-in-process per window.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Resample window (e.g. "1h"). | '1h' |
| Type | Description |
|---|---|
DataFrame | Summary-shape DataFrame with columns: start, end, duration_seconds, |
DataFrame | wip_mean, wip_max, wip_min. |
throughput
throughput(window: str = '1h') -> pd.DataFrame
Units completed (exit rising edges) per window.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Resample window. | '1h' |
| Type | Description |
|---|---|
DataFrame | Summary-shape DataFrame with columns: start, end, duration_seconds, |
DataFrame | units_out, throughput_per_hour. |
lead_time
lead_time() -> pd.DataFrame
FIFO-matched lead time per unit (entry -> exit).
The nth entry is matched to the nth exit (first-in-first-out).
| Type | Description |
|---|---|
DataFrame | Point-shape DataFrame with columns: systime (exit time), uuid, |
DataFrame | source_uuid, lead_time_seconds, unit_index. |
flow_summary
flow_summary(
*, value_add_seconds: Number | None = None, window: str = "1h"
) -> pd.DataFrame
Combined flow metrics with a Little's Law consistency check.
Little's Law lead time = WIP / throughput. consistency_factor is the
measured FIFO lead time divided by that prediction (≈ 1 for a stable,
FIFO process). Process Cycle Efficiency = value-add time / lead time.
| Name | Type | Description | Default |
|---|---|---|---|
value_add_seconds | Number | None | Value-add (touch) time per unit, for PCE. Seconds number or offset string; omit to skip the PCE column. | None |
window | str | Resample window. | '1h' |
| Type | Description |
|---|---|
DataFrame | Summary-shape DataFrame with columns: start, end, duration_seconds, |
DataFrame | wip_mean, throughput_per_hour, lead_time_mean_seconds, |
DataFrame | littles_law_lead_time_seconds, consistency_ratio, |
DataFrame | consistency_factor, and process_cycle_efficiency_pct when |
DataFrame | value_add_seconds is given. |
DataFrame | Canonical twin columns: consistency_factor (after |
DataFrame | consistency_ratio, which is not a 0-1 fraction); it holds the |
DataFrame | same values as the deprecated column right before it, which is |
DataFrame | removed in the next major release. |