Skip to main content
Version: 0.0.98

ts_shape.events.engineering.signal_comparison

Classes
NameDescription
SignalComparisonEventsEngineering: Signal Comparison

SignalComparisonEvents​

classsource
SignalComparisonEvents(
dataframe: pd.DataFrame,
reference_uuid: str,
*,
event_uuid: str = "eng:signal_comparison",
value_column: str = "value_double",
time_column: str = "systime"
) -> None

Bases: Base

Engineering: Signal Comparison

Compare two related signals (e.g. setpoint vs actual, sensor A vs sensor B) and detect divergence, compute deviation statistics, and track correlation.

Methods:

  • detect_divergence: Intervals where |actual - reference| exceeds tolerance.
  • deviation_statistics: Per-window MAE, max error, RMSE, bias.
  • tracking_error_trend: Whether deviation is growing or shrinking over time.
  • correlation_windows: Per-window Pearson correlation.
Functions
NameDescription
detect_divergenceDetect intervals where
deviation_statisticsPer-window deviation statistics.
tracking_error_trendTrack whether deviation is growing or shrinking over time.
correlation_windowsPer-window Pearson correlation between reference and actual.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
reference_uuidstrUUID of the reference signal (e.g. the setpoint). The compared signal is passed to each method as actual_uuid.required
event_uuidstrUUID stamped on emitted events.'eng:signal_comparison'
value_columnstrNumeric column holding both signals' values.'value_double'
time_columnstrTimestamp column.'systime'

detect_divergence​

methodsource
detect_divergence(
actual_uuid: str, tolerance: float, min_duration: str = "1min"
) -> pd.DataFrame

Detect intervals where |actual - reference| > tolerance.

Parameters
NameTypeDescriptionDefault
actual_uuidstrUUID of the actual/comparison signal.required
tolerancefloatMaximum acceptable absolute deviation.required
min_durationstrMinimum duration of divergence interval.'1min'
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid (reference and actual uuids, comma-joined), is_delta,
DataFramemax_deviation, mean_deviation, direction.

deviation_statistics​

methodsource
deviation_statistics(actual_uuid: str, window: str = '1h') -> pd.DataFrame

Per-window deviation statistics.

Parameters
NameTypeDescriptionDefault
actual_uuidstrUUID of the actual signal compared with the reference signal. Deviation is actual minus reference.required
windowstrResample window (pandas offset string, e.g. '1h').'1h'
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, mae,
DataFramemax_error, rmse, bias. end is start + window.

tracking_error_trend​

methodsource
tracking_error_trend(actual_uuid: str, window: str = '1D') -> pd.DataFrame

Track whether deviation is growing or shrinking over time.

Parameters
NameTypeDescriptionDefault
actual_uuidstrUUID of the actual signal compared with the reference signal.required
windowstrResample window passed to :meth:deviation_statistics.'1D'
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, mae,
DataFrametrend_slope, trend_direction. end is start + window.

correlation_windows​

methodsource
correlation_windows(actual_uuid: str, window: str = '1h') -> pd.DataFrame

Per-window Pearson correlation between reference and actual.

Parameters
NameTypeDescriptionDefault
actual_uuidstrUUID of the actual signal compared with the reference signal.required
windowstrResample window (pandas offset string). Windows with fewer than two aligned samples are skipped.'1h'
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds,
DataFramecorrelation, sample_count. end is start + window.