Skip to content

downtime_tracking

downtime_tracking ¤

Downtime tracking by shift and reason.

Essential module for daily downtime analysis: - Downtime by shift - Downtime by reason code - Availability calculations - Downtime trends

DowntimeTracking ¤

DowntimeTracking(
    dataframe: DataFrame,
    *,
    time_column: str = "systime",
    shift_definitions: Optional[
        Dict[str, tuple[str, str]]
    ] = None
)

Bases: Base

Track machine downtimes by shift and reason.

Each UUID represents one signal: - state_uuid: machine state (running/stopped/idle) - reason_uuid: downtime reason code (optional)

Example usage

tracker = DowntimeTracking(df)

Downtime per shift¤

shift_downtime = tracker.downtime_by_shift( state_uuid='machine_state', running_value='Running' )

Downtime by reason¤

reason_analysis = tracker.downtime_by_reason( state_uuid='machine_state', reason_uuid='downtime_reason', stopped_value='Stopped' )

Initialize downtime tracker.

Parameters:

Name Type Description Default
dataframe DataFrame

Input DataFrame with timeseries data

required
time_column str

Name of timestamp column (default: 'systime')

'systime'
shift_definitions Optional[Dict[str, tuple[str, str]]]

Dictionary mapping shift names to (start, end) times Default: 3-shift operation (06:00-14:00, 14:00-22:00, 22:00-06:00)

None

downtime_by_shift ¤

downtime_by_shift(
    state_uuid: str,
    *,
    running_value: str = "Running",
    value_column: str = "value_string"
) -> pd.DataFrame

Calculate downtime duration per shift.

Parameters:

Name Type Description Default
state_uuid str

UUID for machine state signal

required
running_value str

Value that indicates machine is running

'Running'
value_column str

Column containing state values

'value_string'

Returns:

Type Description
DataFrame

DataFrame with downtime by shift:

DataFrame
  • date: Production date
DataFrame
  • shift: Shift name
DataFrame
  • total_minutes: Total shift duration in minutes
DataFrame
  • downtime_minutes: Downtime duration in minutes
DataFrame
  • uptime_minutes: Running time in minutes
DataFrame
  • availability_pct: Uptime percentage
Example

downtime_by_shift('machine_state', running_value='Running') date shift total_minutes downtime_minutes uptime_minutes availability_pct 0 2024-01-01 shift_1 480 45.2 434.8 90.6 1 2024-01-01 shift_2 480 67.5 412.5 85.9 2 2024-01-01 shift_3 480 92.0 388.0 80.8

downtime_by_reason ¤

downtime_by_reason(
    state_uuid: str,
    reason_uuid: str,
    *,
    stopped_value: str = "Stopped",
    value_column_state: str = "value_string",
    value_column_reason: str = "value_string"
) -> pd.DataFrame

Analyze downtime by reason code.

Parameters:

Name Type Description Default
state_uuid str

UUID for machine state signal

required
reason_uuid str

UUID for downtime reason signal

required
stopped_value str

Value indicating machine is stopped

'Stopped'
value_column_state str

Column containing state values

'value_string'
value_column_reason str

Column containing reason codes

'value_string'

Returns:

Type Description
DataFrame

DataFrame with downtime by reason:

DataFrame
  • reason: Reason code
DataFrame
  • occurrences: Number of downtime events
DataFrame
  • total_minutes: Total downtime for this reason
DataFrame
  • avg_minutes: Average downtime per occurrence
DataFrame
  • pct_of_total: Percentage of total downtime
Example

downtime_by_reason('state', 'reason', stopped_value='Stopped') reason occurrences total_minutes avg_minutes pct_of_total 0 Material_Shortage 12 145.5 12.1 35.2 1 Tool_Change 8 98.2 12.3 23.8 2 Quality_Issue 5 76.0 15.2 18.4

top_downtime_reasons ¤

top_downtime_reasons(
    state_uuid: str,
    reason_uuid: str,
    *,
    top_n: int = 5,
    stopped_value: str = "Stopped",
    value_column_state: str = "value_string",
    value_column_reason: str = "value_string"
) -> pd.DataFrame

Get top N downtime reasons (Pareto analysis).

Parameters:

Name Type Description Default
state_uuid str

UUID for machine state signal

required
reason_uuid str

UUID for downtime reason signal

required
top_n int

Number of top reasons to return

5
stopped_value str

Value indicating machine is stopped

'Stopped'
value_column_state str

Column containing state values

'value_string'
value_column_reason str

Column containing reason codes

'value_string'

Returns:

Type Description
DataFrame

DataFrame with top N reasons and cumulative percentage

Example

top_downtime_reasons('state', 'reason', top_n=5) reason total_minutes pct_of_total cumulative_pct 0 Material_Shortage 145.5 35.2 35.2 1 Tool_Change 98.2 23.8 59.0 2 Quality_Issue 76.0 18.4 77.4

availability_trend ¤

availability_trend(
    state_uuid: str,
    *,
    running_value: str = "Running",
    value_column: str = "value_string",
    window: str = "1D"
) -> pd.DataFrame

Calculate availability trend over time.

Parameters:

Name Type Description Default
state_uuid str

UUID for machine state signal

required
running_value str

Value that indicates machine is running

'Running'
value_column str

Column containing state values

'value_string'
window str

Time window for aggregation (e.g., '1D', '1W')

'1D'

Returns:

Type Description
DataFrame

DataFrame with availability trend:

DataFrame
  • period: Time period
DataFrame
  • availability_pct: Availability percentage
DataFrame
  • uptime_minutes: Total uptime
DataFrame
  • downtime_minutes: Total downtime
Example

availability_trend('state', window='1D') period availability_pct uptime_minutes downtime_minutes 0 2024-01-01 87.5 1260.0 180.0 1 2024-01-02 91.2 1313.3 126.7 2 2024-01-03 85.8 1235.5 204.5