Skip to content

startup_events

startup_events ¤

StartupDetectionEvents ¤

StartupDetectionEvents(
    dataframe: DataFrame,
    target_uuid: str,
    *,
    event_uuid: str = "startup_event",
    value_column: str = "value_double",
    time_column: str = "systime"
)

Bases: Base

Detect equipment startup intervals based on threshold crossings or sustained positive slope in a numeric metric (speed, temperature, etc.).

Schema assumptions (columns): - uuid, sequence_number, systime, plctime, is_delta - value_integer, value_string, value_double, value_bool, value_bytes

detect_startup_by_threshold ¤

detect_startup_by_threshold(
    *,
    threshold: float,
    hysteresis: tuple[float, float] | None = None,
    min_above: str = "0s"
) -> pd.DataFrame

Startup begins at first crossing above threshold (or hysteresis enter) and is valid only if the metric stays above the (exit) threshold for at least min_above.

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, uuid, is_delta, method, threshold.

detect_startup_by_slope ¤

detect_startup_by_slope(
    *,
    min_slope: float,
    slope_window: str = "0s",
    min_duration: str = "0s"
) -> pd.DataFrame

Startup intervals where per-second slope >= min_slope for at least min_duration. slope_window is accepted for API completeness but the current implementation uses instantaneous slope between samples.

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, uuid, is_delta, method, min_slope, avg_slope.

detect_startup_multi_signal ¤

detect_startup_multi_signal(
    signals: Dict[str, Dict[str, Any]],
    logic: str = "all",
    *,
    time_tolerance: str = "30s"
) -> pd.DataFrame

Detect startups based on multiple signals with configurable AND/OR logic.

Parameters:

Name Type Description Default
signals Dict[str, Dict[str, Any]]

Dict mapping uuid to detection config. Each config should contain: - 'method': 'threshold' or 'slope' - For threshold: 'threshold', optional 'hysteresis', 'min_above' - For slope: 'min_slope', optional 'slope_window', 'min_duration'

required
logic str

'all' (AND - all signals must detect) or 'any' (OR - at least one)

'all'
time_tolerance str

Maximum time difference between signals for 'all' logic

'30s'

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, uuid, is_delta, method, signals_triggered, signal_details

detect_startup_adaptive ¤

detect_startup_adaptive(
    *,
    baseline_window: str = "1h",
    sensitivity: float = 2.0,
    min_above: str = "10s",
    lookback_periods: int = 5
) -> pd.DataFrame

Detect startups using adaptive thresholds calculated from historical baseline data.

Parameters:

Name Type Description Default
baseline_window str

Window size for calculating baseline statistics

'1h'
sensitivity float

Multiplier for standard deviation (threshold = mean + sensitivity * std)

2.0
min_above str

Minimum time the value must stay above threshold

'10s'
lookback_periods int

Number of baseline periods to use for statistics

5

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, uuid, is_delta, method, adaptive_threshold, baseline_mean, baseline_std

assess_startup_quality ¤

assess_startup_quality(
    startup_events: DataFrame,
    *,
    smoothness_window: int = 5,
    anomaly_threshold: float = 3.0
) -> pd.DataFrame

Assess the quality of detected startup events.

Parameters:

Name Type Description Default
startup_events DataFrame

DataFrame of detected startup events (must have 'start' and 'end' columns)

required
smoothness_window int

Window size for calculating smoothness metrics

5
anomaly_threshold float

Z-score threshold for detecting anomalies

3.0

Returns:

Type Description
DataFrame

DataFrame with quality metrics for each startup: - duration: Total duration of startup - smoothness_score: Inverse of derivative variance (higher = smoother) - anomaly_flags: Number of anomalous points detected - value_change: Total change in value during startup - avg_rate: Average rate of change - max_value: Maximum value reached - stability_score: Measure of how stable the final state is

track_startup_phases ¤

track_startup_phases(
    phases: List[Dict[str, Any]],
    *,
    min_phase_duration: str = "5s"
) -> pd.DataFrame

Track progression through defined startup phases.

Parameters:

Name Type Description Default
phases List[Dict[str, Any]]

List of phase definitions, each containing: - 'name': Phase name - 'condition': 'threshold', 'range', or 'slope' - For 'threshold': 'min_value' (value must be >= min_value) - For 'range': 'min_value' and 'max_value' (value in range) - For 'slope': 'min_slope' (slope must be >= min_slope)

required
min_phase_duration str

Minimum time to stay in phase to be considered valid

'5s'

Returns:

Type Description
DataFrame

DataFrame with phase transitions: - phase_name: Name of the phase - phase_number: Sequential phase number (0-indexed) - start: Phase start time - end: Phase end time - duration: Time spent in phase - next_phase: Name of the next phase (None for last phase) - completed: Whether full startup sequence completed

detect_failed_startups ¤

detect_failed_startups(
    *,
    threshold: float,
    min_rise_duration: str = "5s",
    max_completion_time: str = "5m",
    completion_threshold: Optional[float] = None,
    required_stability: str = "10s"
) -> pd.DataFrame

Detect failed or aborted startup attempts.

A failed startup is identified when: 1. Value rises above threshold for at least min_rise_duration 2. But fails to reach completion_threshold within max_completion_time 3. Or drops back below threshold before achieving required_stability

Parameters:

Name Type Description Default
threshold float

Initial threshold that must be crossed to begin startup

required
min_rise_duration str

Minimum time above threshold to consider it a startup attempt

'5s'
max_completion_time str

Maximum time allowed to complete startup

'5m'
completion_threshold Optional[float]

Target threshold for successful completion (default: 2x threshold)

None
required_stability str

Time that must be maintained at completion level

'10s'

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, uuid, is_delta, method, failure_reason, max_value_reached, time_to_failure