SignalQualityEvents¤
Detect data quality issues in a numeric signal: missing data, irregular sampling, out-of-range values, and data completeness.
Module: ts_shape.events.quality.signal_quality
Guide: Quality Control & SPC
When to Use¤
Use to validate data quality before analysis. Check for gaps in historian data, irregular sampling from PLCs, or sensor failures producing out-of-range values. Run this as a first step in any analytics pipeline to avoid drawing conclusions from incomplete or corrupted data.
Quick Example¤
from ts_shape.events.quality.signal_quality import SignalQualityEvents
sq = SignalQualityEvents(df, value_column="value_double")
# Find gaps where expected samples are missing
gaps = sq.detect_missing_data(expected_freq="1s", tolerance_factor=2.0)
# Check sampling regularity per hour
regularity = sq.sampling_regularity(window="1h")
# Flag physically impossible readings
out_of_range = sq.detect_out_of_range(min_value=0.0, max_value=100.0)
# Compute hourly completeness percentage
completeness = sq.data_completeness(window="1h", expected_freq="1s")
Key Methods¤
| Method | Purpose | Returns |
|---|---|---|
detect_missing_data(expected_freq='1s', tolerance_factor=2.0) |
Find gaps exceeding expected sampling interval | DataFrame with gap start/end and duration |
sampling_regularity(window='1h') |
Compute inter-sample interval statistics per window | DataFrame with mean, std, min, max intervals |
detect_out_of_range(min_value, max_value) |
Flag values outside physical or expected range | DataFrame with out-of-range flags |
data_completeness(window='1h', expected_freq='1s') |
Calculate percentage of expected samples received | DataFrame with completeness percentages |
Tips & Notes¤
Set tolerance_factor based on your data source
For PLC data with a strict 1-second cycle, a tolerance_factor=2.0 works well. For historian data that may batch-compress, increase to 3.0 or higher to avoid false gap detections.
Related modules
- Outlier Detection — detect statistical outliers after confirming data quality
- Anomaly Classification — classify flatlines and other anomaly types
- Multi-Sensor Validation — cross-check redundant sensors for consistency
See Also¤
- Quality Control & SPC Guide — narrative overview
- API Reference — full parameter docs