ntpstats.series¶
Time-series container used throughout ntpstats.
Sign convention
offset always follows the ntpd / RFC 5905 convention::
offset = server_time - local_time (seconds)
i.e. a positive offset means the local clock is behind the reference. Some sources use the opposite sign (chrony tracking/statistics logs, linuxptp); the parsers normalise on import so every series in this package can be compared directly.
TimeSeries
dataclass
¶
An offset time series plus optional auxiliary columns.
Attributes:
| Name | Type | Description |
|---|---|---|
t |
ndarray
|
Sample times, POSIX seconds (float64, UTC). |
offset |
ndarray
|
Clock offset in seconds (server - local). |
name |
str
|
Human readable label (file name, peer address...). |
source_format |
str
|
Parser that produced the series ( |
extra |
Dict[str, ndarray]
|
Additional per-sample columns ( |
meta |
Dict[str, object]
|
Free-form metadata (peer address, notes, warnings). |
to_pandas()
¶
DataFrame with a UTC DatetimeIndex (needs pandas; see :mod:ntpstats.adapters).
from_pandas(df, offset='offset', time=None, name=None, negate=False)
classmethod
¶
From a DataFrame (see :func:ntpstats.adapters.from_pandas).
to_parquet(path, compression='zstd')
¶
Write as Parquet (needs pyarrow); every command reads it back.
select(mask)
¶
Return a new series keeping only the samples where mask is true
(mask may also be an integer index array).
sorted()
¶
Return the series sorted by time with exact duplicate times removed.
between(start=None, end=None)
¶
Restrict to start <= t <= end (POSIX seconds, either may be None).
median_interval()
¶
Median sampling interval in seconds (the natural tau0).
regularity()
¶
Fraction of intervals within 10 % of the median interval (1.0 = perfectly regular).
to_uniform(tau0=None, max_gap=3.0)
¶
Resample onto a uniform grid for stability analysis.
Returns (grid_t, x, tau0) where x is the offset (phase) linearly
interpolated on the grid. Grid points that fall inside a gap longer
than max_gap * tau0 are set to NaN so that the stability
estimators simply skip the terms that touch them instead of
inventing data.
mjd_to_unix(mjd, seconds)
¶
Convert (Modified Julian Day, seconds past midnight UTC) to POSIX seconds.