ts_shape.events.engineering.signal_comparison
Classes
| Name | Description |
|---|---|
SignalComparisonEvents | Engineering: Signal Comparison |
SignalComparisonEvents
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
| Name | Description |
|---|---|
detect_divergence | Detect intervals where |
deviation_statistics | Per-window deviation statistics. |
tracking_error_trend | Track whether deviation is growing or shrinking over time. |
correlation_windows | Per-window Pearson correlation between reference and actual. |
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
reference_uuid | str | UUID of the reference signal (e.g. the setpoint). The compared signal is passed to each method as actual_uuid. | required |
event_uuid | str | UUID stamped on emitted events. | 'eng:signal_comparison' |
value_column | str | Numeric column holding both signals' values. | 'value_double' |
time_column | str | Timestamp column. | 'systime' |
detect_divergence
detect_divergence(
actual_uuid: str, tolerance: float, min_duration: str = "1min"
) -> pd.DataFrame
Detect intervals where |actual - reference| > tolerance.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
actual_uuid | str | UUID of the actual/comparison signal. | required |
tolerance | float | Maximum acceptable absolute deviation. | required |
min_duration | str | Minimum duration of divergence interval. | '1min' |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid (reference and actual uuids, comma-joined), is_delta, |
DataFrame | max_deviation, mean_deviation, direction. |
deviation_statistics
deviation_statistics(actual_uuid: str, window: str = '1h') -> pd.DataFrame
Per-window deviation statistics.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
actual_uuid | str | UUID of the actual signal compared with the reference signal. Deviation is actual minus reference. | required |
window | str | Resample window (pandas offset string, e.g. '1h'). | '1h' |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, mae, |
DataFrame | max_error, rmse, bias. end is start + window. |
tracking_error_trend
tracking_error_trend(actual_uuid: str, window: str = '1D') -> pd.DataFrame
Track whether deviation is growing or shrinking over time.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
actual_uuid | str | UUID of the actual signal compared with the reference signal. | required |
window | str | Resample window passed to :meth:deviation_statistics. | '1D' |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, mae, |
DataFrame | trend_slope, trend_direction. end is start + window. |
correlation_windows
correlation_windows(actual_uuid: str, window: str = '1h') -> pd.DataFrame
Per-window Pearson correlation between reference and actual.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
actual_uuid | str | UUID of the actual signal compared with the reference signal. | required |
window | str | Resample window (pandas offset string). Windows with fewer than two aligned samples are skipped. | '1h' |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, |
DataFrame | correlation, sample_count. end is start + window. |