Skip to content

timeerror

Time-error metrics for packet timing (ITU-T G.8260 definitions, G.8273.2 usage).

Time error is TE(t) = T(t) - T_ref(t): the clock under test minus the reference, i.e. local - reference. ntpstats series use the opposite convention (reference - local), so they are negated here unless input_is_te=True (e.g. a time-interval counter measuring DUT - REF).

Metrics, computed on a uniform grid with gaps left out:

max_abs_te maximum absolute time error, unfiltered. cte constant time error: the mean of TE over the record. cte_windows are the means over consecutive cte_window-second windows (1000 s is the usual observation interval), and max_abs_cte_window is the worst one. tel / max_abs_tel TE low-pass filtered by a first-order filter of bandwidth lpf_hz (0.1 Hz by default), and its maximum absolute value (max|TEL|). dte_l dynamic low-frequency time error, TEL - cTE, evaluated with MTIE and TDEV (mtie/tdev results) and as a peak-to-peak value. dte_h dynamic high-frequency time error, TE - TEL, peak-to-peak.

The filter is causal, discretised exactly for the sample interval (y[n] = y[n-1] + a (x[n] - y[n-1]), a = 1 - exp(-2 pi f tau0)) and restarted after each gap; the first :data:SETTLE time constants after each (re)start (8 s at 0.1 Hz) are left out of the filtered metrics. It needs samples faster than the filter bandwidth: at tau0 above 1 / (2 lpf_hz) it cannot separate dTE_L and dTE_H, which the result reports in warnings.

Limits are user supplied (no standards text is bundled): a file of metric,value lines, see :func:load_limits, plus optional MTIE/TDEV masks for dTE_L (:mod:ntpstats.masks).

lowpass(x, tau0, hz, settle=0.0)

First-order low-pass of x (NaN = gap; the filter restarts after gaps).

The first settle time constants after every (re)start are returned as NaN, so start-up transients do not count as time error.

time_error(series, tau0=None, lpf_hz=0.1, cte_window=1000.0, input_is_te=False, max_gap=3.0, taus='octave')

Compute the time-error metrics of series (see the module docstring).

load_limits(source)

Scalar limits from metric,value lines (path, file object or text).

Metrics: max_te, cte, cte_window, max_tel, dte_l_pp, dte_h_pp. Values are seconds unless suffixed (30ns, 1.1us). # starts a comment. Example (user-chosen numbers)::

max_te, 30ns
cte_window, 10ns

check(result, limits=None, masks=())

Compare a result with scalar limits and MTIE/TDEV masks (for dTE_L).

Returns {"passed": bool | None, "checks": [...]}; passed is None when nothing could be checked.