Skip to main content
Version: Next

ts_shape.events.quality.sampling_resolution

Classes
NameDescription
SamplingResolutionEventsQuality: Sampling & Resolution Analysis

SamplingResolutionEvents​

classsource
SamplingResolutionEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
value_column: str = "value_double",
event_uuid: str = "quality:sampling_resolution",
time_column: str = "systime"
) -> None

Bases: Base

Quality: Sampling & Resolution Analysis

Analyze digital measurement system limitations: quantization effects, effective resolution, aliasing detection, and sampling synchronization/jitter.

Methods:

  • detect_quantization: Detect A/D quantization in measurements.
  • effective_resolution: Estimate effective vs theoretical resolution.
  • detect_aliasing: Check for Nyquist violations via FFT.
  • sampling_jitter: Measure timing regularity of sampling.
Functions
NameDescription
detect_quantizationDetect A/D quantization effects in measurements.
effective_resolutionEstimate effective measurement resolution from data.
detect_aliasingCheck for Nyquist violations using FFT.
sampling_jitterMeasure timing jitter (variation in sampling interval).
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
signal_uuidstrUUID of the signal to analyze.required
value_columnstrColumn holding the signal values.'value_double'
event_uuidstrUUID stamped on emitted events.'quality:sampling_resolution'
time_columnstrTimestamp column.'systime'

detect_quantization​

methodsource
detect_quantization(
window: str = "1h", threshold_ratio: float = 0.3
) -> pd.DataFrame

Detect A/D quantization effects in measurements.

Identifies if measurements are clustered at discrete levels rather than continuously distributed.

Parameters
NameTypeDescriptionDefault
windowstrResample window size.'1h'
threshold_ratiofloatRatio of unique values to expected unique below which signal is flagged as quantized.0.3
Returns
TypeDescription
DataFrameSummary DataFrame with columns: start, end, duration_seconds
DataFrame(the window bounds), window_start (the resample label; a
DataFramedeprecated twin of start), n_unique_values,
DataFrameunique_value_count, expected_unique, quantization_step,
DataFramequantization_ratio, quantized.
DataFrameCanonical twin columns: unique_value_count (after
DataFramen_unique_values); it holds the same values as the deprecated
DataFramecolumn right before it, which is removed in the next major
DataFramerelease.

effective_resolution​

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

Estimate effective measurement resolution from data.

Parameters
NameTypeDescriptionDefault
windowstrResample window size.'1h'
Returns
TypeDescription
DataFrameSummary DataFrame with columns: start, end, duration_seconds
DataFrame(the window bounds), window_start (the resample label; a
DataFramedeprecated twin of start), theoretical_resolution,
DataFrameeffective_resolution, resolution_ratio, resolution_factor
DataFrame(effective / theoretical resolution; 1 or more, not a 0-1
DataFramefraction), assessment.
DataFrameCanonical twin columns: resolution_factor (after
DataFrameresolution_ratio); it holds the same values as the deprecated
DataFramecolumn right before it, which is removed in the next major
DataFramerelease.

detect_aliasing​

methodsource
detect_aliasing(
window: str = "1h", expected_frequency_hz: float | None = None
) -> pd.DataFrame

Check for Nyquist violations using FFT.

Parameters
NameTypeDescriptionDefault
windowstrResample window size.'1h'
expected_frequency_hzfloat | NoneKnown process frequency in Hz. If None, dominant frequency is estimated from FFT.None

NaN values are dropped before the FFT, and the sampling rate is estimated from the timestamps of the remaining values: a 1 s grid with every other value NaN samples at 0.5 Hz.

Returns
TypeDescription
DataFrameSummary DataFrame with columns: start, end, duration_seconds
DataFrame(the window bounds), window_start (the resample label; a
DataFramedeprecated twin of start), sampling_rate_hz,
DataFramenyquist_hz, dominant_frequency, aliasing_risk.

sampling_jitter​

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

Measure timing jitter (variation in sampling interval).

Parameters
NameTypeDescriptionDefault
windowstrResample window size.'1h'
Returns
TypeDescription
DataFrameSummary DataFrame with columns: start, end, duration_seconds
DataFrame(the window bounds), window_start (the resample label; a
DataFramedeprecated twin of start), mean_interval_ms,
DataFramemean_interval_seconds, std_interval_ms, std_interval_seconds,
DataFramejitter_pct, max_gap_ms, max_gap_seconds, regularity_score. Each
DataFrame*_seconds column follows its legacy *_ms twin (the same
DataFramevalue in seconds); the *_ms columns are deprecated.