2.32.4.19. pycsamt.iot.sync#
Clock synchronisation audit for IoT field acquisition.
Offset alone is not enough to certify field-grade timing. This module
adds clock drift (ppm), jitter (ms), GPS-lock accounting, and an
overall SyncQuality grade, plus batch assessment and GPS-dropout
detection across a deployment.
Functions
|
Grade synchronisation from offset, drift, jitter, and GPS lock. |
|
Assess many devices at once and return a status table. |
|
Summarise GPS-lock dropouts across a sample sequence. |
|
Estimate clock drift in parts-per-million. |
|
Estimate timing jitter as the std of drift-corrected offsets (ms). |
|
Estimate median local-reference clock offset in milliseconds. |
|
Return one row per device from sync-status objects. |
Classes
|
Evaluate device clock status against a reference. |
|
Clock-synchronisation tolerances. |
|
Overall synchronisation grade for a device. |
|
Clock-synchronisation status for one device. |
- class pycsamt.iot.sync.SyncConfig(tolerance_ms=1.0, reference='gps', max_drift_ppm=None, max_jitter_ms=None, min_reference_points=2)[source]
Bases:
PyCSAMTObjectClock-synchronisation tolerances.
- Parameters:
- tolerance_ms: float = 1.0
- reference: str = 'gps'
- min_reference_points: int = 2
- validate()[source]
Validate and normalise sync tolerances.
- Return type:
None
- class pycsamt.iot.sync.SyncQuality(*values)[source]
-
Overall synchronisation grade for a device.
- EXCELLENT = 'excellent'
- GOOD = 'good'
- FAIR = 'fair'
- POOR = 'poor'
- UNKNOWN = 'unknown'
- class pycsamt.iot.sync.SyncStatus(device_id, offset_ms, within_tolerance, reference='gps', drift_ppm=nan, jitter_ms=nan, gps_lock=None, n_reference_points=0, quality=SyncQuality.UNKNOWN)[source]
Bases:
PyCSAMTObjectClock-synchronisation status for one device.
- Parameters:
- device_id: str
- offset_ms: float
- within_tolerance: bool
- reference: str = 'gps'
- drift_ppm: float = nan
- jitter_ms: float = nan
- n_reference_points: int = 0
- quality: SyncQuality | str = 'unknown'
- validate()[source]
Validate and normalise sync-status fields.
- Return type:
None
- class pycsamt.iot.sync.ClockSynchronizer(config=None)[source]
Bases:
objectEvaluate device clock status against a reference.
- Parameters:
config (SyncConfig | None)
- pycsamt.iot.sync.estimate_clock_offset_ms(local_timestamps, reference_timestamps)[source]
Estimate median local-reference clock offset in milliseconds.
- pycsamt.iot.sync.estimate_clock_drift_ppm(local_timestamps, reference_timestamps)[source]
Estimate clock drift in parts-per-million.
Fits the local-reference offset (in seconds) against reference time and returns the slope scaled to ppm. Requires at least two distinct reference points; otherwise returns
nan.
- pycsamt.iot.sync.estimate_clock_jitter_ms(local_timestamps, reference_timestamps)[source]
Estimate timing jitter as the std of drift-corrected offsets (ms).
- pycsamt.iot.sync.assess_sync_quality(*, offset_ms, drift_ppm=nan, jitter_ms=nan, gps_lock=None, tolerance_ms=1.0)[source]
Grade synchronisation from offset, drift, jitter, and GPS lock.
- pycsamt.iot.sync.batch_assess_sync(references, *, config=None, api=None)[source]
Assess many devices at once and return a status table.
- Parameters:
references (mapping) –
{device_id: spec}where spec is either a(local, reference)pair or a mapping withlocal/reference(and optionalgps_lock) keys.config (SyncConfig, optional) – Shared tolerances.
api (bool, optional) – Frame-wrapping override passed to
maybe_wrap_frame().
- Return type:
- pycsamt.iot.sync.detect_gps_dropout(gps_lock, timestamps=None, *, min_lock_fraction=0.9)[source]
Summarise GPS-lock dropouts across a sample sequence.
- Parameters:
gps_lock (iterable) – Per-sample lock flags (bool/0-1). Non-finite entries are treated as unlocked.
timestamps (iterable, optional) – Matching sample timestamps (seconds), used to report the longest dropout duration.
min_lock_fraction (float) – Threshold below which
okisFalse.
- Returns:
Keys:
n_samples,n_locked,lock_fraction,n_dropout_events,longest_dropout_samples,longest_dropout_s, andok.- Return type:
- pycsamt.iot.sync.sync_status_table(statuses, *, api=None)[source]
Return one row per device from sync-status objects.
- Parameters:
statuses (SyncStatus | Iterable[SyncStatus])
api (bool | None)
- Return type: