DowntimeTracking¤
Track machine downtimes by shift and reason from state and reason-code signals.
Module: ts_shape.events.production.downtime_tracking
Guide: Production Monitoring
When to Use¤
Use for downtime Pareto analysis. Categorizes downtime by reason code and shift to identify the biggest availability losses. This is the standard approach for continuous improvement — focus resources on the top downtime reasons to get the greatest return on investment.
Quick Example¤
from ts_shape.events.production.downtime_tracking import DowntimeTracking
import pandas as pd
import numpy as np
np.random.seed(42)
states = np.random.choice([True, False], size=480, p=[0.80, 0.20])
reasons = np.where(states, "RUNNING", np.random.choice(
["MECHANICAL", "ELECTRICAL", "MATERIAL", "CHANGEOVER"], size=480
))
df = pd.DataFrame({
"timestamp": pd.date_range("2024-01-01 06:00", periods=480, freq="1min"),
"machine_state": states,
"reason_code": reasons,
})
dt = DowntimeTracking(df, timestamp_column="timestamp")
by_shift = dt.downtime_by_shift(state_uuid="machine_state")
by_reason = dt.downtime_by_reason(state_uuid="machine_state", reason_uuid="reason_code")
pareto = dt.top_downtime_reasons(state_uuid="machine_state", reason_uuid="reason_code", top_n=5)
trend = dt.availability_trend(state_uuid="machine_state", window="1D")
print(pareto)
Key Methods¤
| Method | Purpose | Returns |
|---|---|---|
downtime_by_shift(state_uuid) |
Aggregate total downtime per shift (morning, afternoon, night) | DataFrame with shift, total_downtime, and event count |
downtime_by_reason(state_uuid, reason_uuid) |
Break down downtime by reason code with duration totals | DataFrame with reason_code, total_downtime, and percentage |
top_downtime_reasons(state_uuid, reason_uuid, top_n=5) |
Pareto analysis of the top N downtime reasons by cumulative duration | DataFrame sorted by duration with cumulative percentage |
availability_trend(state_uuid, window='1D') |
Track availability ratio over time windows for trend analysis | DataFrame with window and availability ratio |
Tips & Notes¤
Define shifts in your configuration
Shift boundaries (e.g., 06:00-14:00, 14:00-22:00, 22:00-06:00) should match your plant's actual schedule. Misaligned shift definitions will attribute downtime to the wrong crew.
Related modules
- Machine State — provides the run/idle signal used to detect downtime intervals
- OEE Calculator — uses availability from downtime analysis
- Alarm Management — correlate alarms with downtime events
- Changeover — distinguish planned changeover downtime from unplanned stops