Skip to content

process_window

process_window ¤

ProcessWindowEvents ¤

ProcessWindowEvents(
    dataframe: DataFrame,
    signal_uuid: str,
    *,
    event_uuid: str = "eng:process_window",
    value_column: str = "value_double",
    time_column: str = "systime"
)

Bases: Base

Engineering: Process Window Analysis

Analyze time-windowed process statistics for shift reports, SPC context, and trend monitoring. Answers 'how is my process doing this hour/shift/day?'

Methods: - windowed_statistics: Per-window count, mean, std, min, max, percentiles. - detect_mean_shift: Flag windows where mean shifts significantly. - detect_variance_change: Flag windows where variance changes significantly. - window_comparison: Compare each window to overall baseline.

windowed_statistics ¤

windowed_statistics(window: str = '1h') -> pd.DataFrame

Per-window descriptive statistics.

Parameters:

Name Type Description Default
window str

Resample window (pandas offset string, e.g. '1h', '8h').

'1h'

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, count, mean, std, min, max, median, p25, p75, range.

DataFrame

end is start + window.

detect_mean_shift ¤

detect_mean_shift(
    window: str = "1h", sensitivity: float = 2.0
) -> pd.DataFrame

Flag windows where mean shifts significantly from the previous window.

A shift is detected when |current_mean - prev_mean| > sensitivity * prev_std.

Parameters:

Name Type Description Default
window str

Resample window passed to :meth:windowed_statistics.

'1h'
sensitivity float

Shift between consecutive window means, in multiples of the previous window's std, above which (strictly) a window is flagged.

2.0

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, is_delta, prev_mean, current_mean, shift_sigma.

DataFrame

start is the previous window's start, end the current

DataFrame

window's start.

detect_variance_change ¤

detect_variance_change(
    window: str = "1h", ratio_threshold: float = 2.0
) -> pd.DataFrame

Flag windows where variance changes significantly.

A change is detected when (current_std / prev_std) > ratio_threshold or < (1 / ratio_threshold).

Parameters:

Name Type Description Default
window str

Resample window passed to :meth:windowed_statistics.

'1h'
ratio_threshold float

Std ratio (current / previous) strictly above which, or strictly below whose reciprocal, a window is flagged. Should be > 1.

2.0

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, is_delta, prev_std, current_std, variance_ratio.

DataFrame

start is the previous window's start, end the current

DataFrame

window's start.

window_comparison ¤

window_comparison(window: str = '1h') -> pd.DataFrame

Compare each window mean to the overall baseline.

Parameters:

Name Type Description Default
window str

Resample window passed to :meth:windowed_statistics. A window is anomalous when its mean is more than 2 std of the window means away from their average.

'1h'

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, mean, z_score_vs_global, is_anomalous.