operating_state
operating_state ¤
OperatingStateEvents ¤
OperatingStateEvents(
dataframe: DataFrame,
signal_uuid: str,
*,
event_uuid: str = "prod:operating_state",
value_column: str = "value_double",
time_column: str = "systime"
)
Bases: Base
Production: Operating State Inference
Infer discrete operating states from continuous signals (vibration, current, power, temperature) when no explicit boolean state signal is available. Answers the question "what state is the machine in?"
Unlike :class:MachineStateEvents which requires a boolean run/idle
signal, this class clusters continuous values to discover states
automatically.
Methods: - infer_states: Cluster the signal into N operating states. - state_duration_statistics: How long does each state typically last? - unusual_state_sequence: Did states occur in an unexpected order? - dwell_time_violation: Did the machine stay in a state too long?
infer_states ¤
infer_states(
n_states: int = 2, min_duration: str = "0s"
) -> pd.DataFrame
Cluster the signal into N operating states.
Uses quantile-based binning to assign each sample to a state, then intervalizes consecutive same-state runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_states
|
int
|
Number of states to infer (2 = low/high, 3 = low/mid/high, etc.). |
2
|
min_duration
|
str
|
Discard intervals shorter than this. |
'0s'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start, end, state, state_label, |
DataFrame
|
mean_value, duration_seconds, uuid (event uuid), source_uuid |
DataFrame
|
(signal uuid). Samples without a value are ignored; with fewer |
DataFrame
|
valued samples than |
state_duration_statistics ¤
state_duration_statistics(
n_states: int = 2,
) -> pd.DataFrame
How long does each inferred state typically last?
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_states
|
int
|
Number of states to infer. |
2
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: state, state_label, count, |
DataFrame
|
mean_duration, std_duration, min_duration, max_duration, |
DataFrame
|
total_duration. |
unusual_state_sequence ¤
unusual_state_sequence(
n_states: int = 2,
expected_order: list[int] | None = None,
) -> pd.DataFrame
Detect state transitions that violate an expected order.
By default, the expected order is the most common transition
sequence observed in the data. Supply expected_order to
override (e.g. [0, 1, 2, 1, 0] for a warm-up/run/cool-down
cycle).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_states
|
int
|
Number of states to infer. |
2
|
expected_order
|
list[int] | None
|
List of state IDs defining the expected cycle. If None, the most frequent bigram transitions are treated as "normal". |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: transition_time, from_state, |
DataFrame
|
to_state, from_label, to_label, is_unusual. |
dwell_time_violation ¤
dwell_time_violation(
state: int, max_duration: str, n_states: int = 2
) -> pd.DataFrame
Find intervals where the machine stayed in a state too long.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
int
|
State ID to check (0-based). |
required |
max_duration
|
str
|
Maximum allowed duration (e.g. |
required |
n_states
|
int
|
Number of states to infer. |
2
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start, end, state_label, |
DataFrame
|
duration_seconds, excess_seconds, uuid (event uuid), source_uuid |
DataFrame
|
(signal uuid). |