Skip to main content
Version: Next

ts_shape.events.engineering.process_window

Classes
NameDescription
ProcessWindowEventsEngineering: Process Window Analysis

ProcessWindowEvents​

classsource
ProcessWindowEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "eng:process_window",
value_column: str = "value_double",
time_column: str = "systime"
) -> None

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.
Functions
NameDescription
windowed_statisticsPer-window descriptive statistics.
detect_mean_shiftFlag windows where mean shifts significantly from the previous window.
detect_variance_changeFlag windows where variance changes significantly.
window_comparisonCompare each window mean to the overall baseline.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
signal_uuidstrUUID of the signal to analyze.required
event_uuidstrUUID stamped on emitted events.'eng:process_window'
value_columnstrColumn holding the signal values.'value_double'
time_columnstrTimestamp column.'systime'

windowed_statistics​

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

Per-window descriptive statistics.

Parameters
NameTypeDescriptionDefault
windowstrResample window (pandas offset string, e.g. '1h', '8h').'1h'
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, count, sample_count, mean, std, min, max, median,
DataFramep25, p75, range. end is start + window. std is the
DataFramesample standard deviation (ddof=1), so it is NaN for a window
DataFramewith a single value.
DataFrameCanonical twin columns: sample_count (after count); it holds the same
DataFramevalues as the deprecated column right before it, which is removed
DataFramein the next major release.

detect_mean_shift​

methodsource
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. A previous window without a std (a single value: NaN) is skipped.

Parameters
NameTypeDescriptionDefault
windowstrResample window passed to :meth:windowed_statistics.'1h'
sensitivityfloatShift between consecutive window means, in multiples of the previous window's std, above which (strictly) a window is flagged.2.0
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, is_delta, prev_mean, current_mean, shift_sigma.
DataFramestart is the previous window's start, end the current
DataFramewindow's start.

detect_variance_change​

methodsource
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). Window pairs where either std is NaN (a single-value window) are skipped. A change from a constant window (prev_std == 0) to a varying one is flagged with variance_factor NaN: the ratio is undefined, never inf.

Parameters
NameTypeDescriptionDefault
windowstrResample window passed to :meth:windowed_statistics.'1h'
ratio_thresholdfloatStd ratio (current / previous) strictly above which, or strictly below whose reciprocal, a window is flagged. Should be > 1.2.0
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, is_delta, prev_std, current_std, variance_ratio,
DataFramevariance_factor (current_std / prev_std). start is the
DataFrameprevious window's start, end the current window's start.
DataFrameCanonical twin columns: variance_factor (after
DataFramevariance_ratio, which is not a 0-1 fraction); it holds the
DataFramesame values as the deprecated column right before it, which is
DataFrameremoved in the next major release.

window_comparison​

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

Compare each window mean to the overall baseline.

Parameters
NameTypeDescriptionDefault
windowstrResample 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
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, mean, z_score_vs_global, is_anomalous.