Skip to main content
Version: Next

ts_shape.events.profiling.stops

Mapping-free stop profiling: why does the machine stop, what does it cost?

:class:StopProfileEvents takes the raw signals of one PLC -- no run-state or alarm mapping -- and answers which stop causes cost the most time?

  1. Units. With a cycle anchor (see :class:~ts_shape.events.profiling.cycles.CycleProfileEvents) every pause cycle is a stop and every long cycle a micro-stop; the lost time is the duration beyond the variant's median cycle and the stop is taken to start where the cycle should have ended. Without an anchor (a continuous line) the stops are the off-periods of a discovered run signal: a bool or state value during which a counter keeps counting. Stops that overlap a hole in which no signal logged anything are unknown time, not stops.
  2. Signatures. The events in a window before each stop are compared with the same windows in normal running (:func:~ts_shape.events.production. _unit_profile.enrichment): an event that is much more frequent before stops (lift >= :data:SIGNATURE_MIN_LIFT, q < 0.05) is a stop signature. Each stop gets the earliest of them in its window (first-out); without one, a state that is enriched during stops (door open, manual mode); otherwise unexplained.
  3. Register. Per signature: count, lost time and its share, MTTR (median, P10, P90), MTBF and the potential (lost time beyond the signature's P10).
Classes
NameDescription
StopProfileEventsStops and their causes, learned from the raw signals of one PLC.

StopProfileEvents​

classsource
StopProfileEvents(
dataframe: pd.DataFrame,
*,
cycle_profile: CycleProfileEvents | None = None,
signal_uuids: list[str] | None = None,
pre_window: str | float | None = None,
min_stops: int = 10,
include_micro_stops: bool = True,
time_column: str = "systime",
uuid_column: str = "uuid",
event_uuid: str = "prod:stop_profile",
**cycle_options: Any
) -> None

Bases: _UnitProfiler

Stops and their causes, learned from the raw signals of one PLC.

Example
>>> import ts_shape
>>> frame, truth = ts_shape.make_plc_cycles(
... n_cycles=300, seed=3, stop_causes=4, stop_probability=0.08)
>>> stops = ts_shape.StopProfileEvents(frame)
>>> bool(stops.evaluation_window()["evaluable"].iloc[0])
True
Functions
NameDescription
stop_recordsOne record per stop (and micro-stop), with its signature.
stop_signaturesThe stop register: what each signature costs.
signature_evidenceWhy each event counts as a stop signature (or not).
evaluation_windowWhether the stop profile can be trusted, and why not.
summaryHeadline numbers (JSON-able).
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format signals of one PLC (systime, uuid, value_*).required
cycle_profileCycleProfileEvents | NoneA computed cycle profile of the same signals to reuse; None (default) builds one.None
signal_uuidslist[str] | NoneSignals to use (default: all).None
pre_windowstr | float | NoneLength of the window before a stop in which its cause is looked for (offset string or seconds); default: one median cycle, at least :data:STOP_PRE_MIN_SECONDS.None
min_stopsintFewer stops are not evaluable.10
include_micro_stopsboolTreat long cycles as micro-stops (their time beyond the median is lost time).True
time_columnstrTimestamp column.'systime'
uuid_columnstrSignal column.'uuid'
event_uuidstruuid of the stop records.'prod:stop_profile'
**cycle_optionsAnyOptions of the cycle profile built when cycle_profile is None (n_sigma, pause_factor ...).{}

stop_records​

methodsource
stop_records() -> pd.DataFrame

One record per stop (and micro-stop), with its signature.

Returns
TypeDescription
DataFramePoint events at the stop end: systime, uuid,
DataFramesource_uuid, unit_uuid, start_ns (estimated stop
DataFramestart), end_ns, duration_seconds (of the stop),
DataFramestop_class (stop / micro_stop), variant,
DataFramelost_seconds, signature (the first-out event, a held
DataFramestate, unexplained or data_hole), signature_kind and
DataFramepreceding_events (every signature event in the pre-window).

stop_signatures​

methodsource
stop_signatures() -> pd.DataFrame

The stop register: what each signature costs.

Returns
TypeDescription
DataFrameOne row per signature (data_hole stops are left out):
DataFramesignature, signature_kind, stop_count,
DataFramelost_seconds, lost_share_ratio (of all lost time),
DataFramemttr_median_seconds / mttr_p10_seconds /
DataFramemttr_p90_seconds (stop durations), mtbf_seconds (median
DataFrametime between two stops of the signature), stops_per_hour,
DataFramepotential_seconds (lost time beyond the signature's P10
DataFramestop), lift_factor and q_value (evidence) and
DataFramepotential_rank, most potential first.

signature_evidence​

methodsource
signature_evidence() -> pd.DataFrame

Why each event counts as a stop signature (or not).

Returns
TypeDescription
DataFramefunc:~ts_shape.events.profiling._base.enrichment of
DataFramethe pre-stop windows (window="before") and of the stop
DataFrameintervals (window="during") against normal running:
DataFramewindow, label, unit_count, unit_presence_ratio,
DataFramebaseline_presence_ratio, lift_factor, p_value,
DataFrameq_value, is_significant.

evaluation_window​

methodsource
evaluation_window() -> pd.DataFrame

Whether the stop profile can be trusted, and why not.

Returns
TypeDescription
DataFrameOne row: scope (all), unit_count (stops outside data
DataFrameholes), evaluable, reason (ok, too_few_units,
DataFramebelow_resolution (judged on the stops' own durations, so a
DataFramecycle signal too coarse for cycle times still marks minutes-long
DataFramestops) or no_candidate_signal: run state without an anchor
DataFrameand a run signal),
DataFrametime_resolution_seconds, source (cycles or the run
DataFramesignal), explained_share_ratio (lost time with a signature)
DataFrameand unknown_seconds (stops inside data holes).

summary​

methodsource
summary() -> dict[str, Any]

Headline numbers (JSON-able).

Returns
TypeDescription
dict[str, Any]evaluable, reason, stop_count, lost_hours,
dict[str, Any]explained_share_ratio, top_signature and
dict[str, Any]top_signature_lost_hours.