Skip to main content

tintervals

A python package collecting functions and tools to work with time intervals and to convert time data.

The package also provides utilities for handling optical link data developed for the EMPIR project ROCIT and for the European Partnership on Metrology Project TOCK..

Development is available at

Documentation is available at https://tintervals.readthedocs.io

Package is available at https://pypi.org/project/tintervals/

Installation

The package can be installed using pip:

pip install tintervals

or directly from github:

pip install git+https://github.com/INRIM/tintervals.git

Requirements

  • numpy, scipy
  • ciso8601 (for fast ISO format reading)

Basic usage

import tintervals as ti

Functions to convert timetag formats. Fast functions used as converters when importing files:

Function From To
kk2epoch K+K counter format Epoch
iso2epoch ISO format* Epoch
kk2iso K+K counter format ISO format (naive)
iso2datetime ISO format* datetime
datetime2iso datetime ISO format ('Z' notation for UTC)
datetime2epoch datetime* Epoch
epoch2datetime Epoch Datetime
epoch2iso Epoch ISO format ('Z' notation for UTC)
mjd2iso MJD ISO format ('Z' notation for UTC)
epoch2mjd Epoch MJD
mjd2epoch MJD Epoch

Starred inputs (*), if naive are considered as system/local time. K+K format is always naive and interpreted as sytem/local time. ISO format can be read with microseconds but it is printed without. Conversion from Epoch time (Unix) and MJD is done by simple affine function, as both are aligned with UTC and basically ignore leap seconds.

Vectorized functions:

Function From To
mjd_from_epoch Epoch MJD
epoch_from_mjd MJD Epoch
iso_from_epoch Epoch ISO format ('Z' notation for UTC)
iso_from_mjd MJD ISO format ('Z' notation for UTC)

Functions to manipulate array of timetags or array of start/stop intervals:

Function Description
array2intervals convert from an array of timetags to an array of start/stop intervals
intervals2weights convert from start/stop intervals to timetags and weights
intersect take the intersection of two arrays of start/stop intervals
split Subdivide an array of start/stop intervals to a fixed scale (e.g., every 10 s)
regvals retrun regular intervals between a start and stop
raverage Average data with timetags in regular intervals (reshape algorithm)
maverage Average data with timetags in given intervals (mask algorithm)
csaverage Average data start/stop intervals in different start/stop intervals (cumsum algorithm)

Functions to calculate deadtime uncertainty:

Function Description
deadtime.unc_fft calculate deadtime uncertainty from given maser noise (FFT algorithm)

Advanced usage

For handling optical links:

pip install "tintervals[rocitlinks]"

import tintervals.rocitlinks as rl

See the docs for more details.

Extra dependencies:

  • pandas (used only for fast file loading)
  • pyyaml

License

MIT

Acknowledgments

This work is partially funded by the European Metrology Program for Innovation and Research (EMPIR) project 18SIB05 ROCIT. The EMPIR initiative is cofunded by the European Union’s Horizon 2020 research and innovation programme and the EMPIR Participating States.

This work was supported by the projects 22IEM01 TOCK and 25IEM09 Arcsecond. The projects 22IEM01 TOCK and 25IEM09 Arcsecond has received funding from the European Partnership on Metrology, co-financed from the European Union’s Horizon Europe Research and Innovation Programme and by the Participating States.

badge

Authors

(c) 2021-2026 Marco Pizzocaro - Istituto Nazionale di Ricerca Metrologica (INRIM)

Speed test

ti.kk2iso('210922*161141.810')
166 ns ± 2.09 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
ti.kk2epoch('210922*161141.810')
658 ns ± 1.24 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
ti.iso2datetime('20210922T161141.810Z')
222 ns ± 18 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
ti.iso2epoch('20210922T161141.810Z')
473 ns ± 5.11 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
ti.datetime2iso(datetime(2021,9,22,11,12,tzinfo=timezone.utc))
2.51 µs ± 9.92 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
ti.datetime2epoch(datetime(2021,9,22,11,12,tzinfo=timezone.utc))
613 ns ± 3.99 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
ti.epoch2datetime(1632319901)
406 ns ± 2.87 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
ti.mjd_from_epoch(1632319901)
131 ns ± 0.334 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
ti.epoch_from_mjd(59479.356)
99.4 ns ± 0.228 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
ti.iso_from_epoch(1632319901)
19.8 µs ± 86.8 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
ti.iso_from_mjd(59479.356)
23 µs ± 266 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

Metadata

Release files for tintervals 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tintervals 0.3.0
File Size Uploaded Provenance
tintervals-0.3.0.tar.gz 18.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tintervals 0.3.0
File Interpreter ABI Platform
tintervals-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.6 kB

Release files / tintervals-0.3.0.tar.gz

Download URL tintervals-0.3.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7ed57d3653457686fbe54ddd954d506d0ce5903d196f8683422cc8f5aa4afc91
BLAKE2b-256 checksum
How to use checksums
cfd5fd266f8f907ba5caa846b6f50d51c6e8f73867d307bea1133928096fd2eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.15

Release files / tintervals-0.3.0-py3-none-any.whl

Download URL tintervals-0.3.0-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a7d37e5e22c184c94263945a4f54d6370f48a9dee0c697e499297e8963fb9b4
BLAKE2b-256 checksum
How to use checksums
5e89c3fcb9fe8459be642671458848d56e3d12526ee55c13027957025c3963cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.15

Security for tintervals 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page