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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tintervals-0.3.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tintervals-0.3.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file tintervals-0.3.0.tar.gz.

File metadata

  • Download URL: tintervals-0.3.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for tintervals-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7ed57d3653457686fbe54ddd954d506d0ce5903d196f8683422cc8f5aa4afc91
MD5 cb3b75130d71e1a3d174a60519d2f158
BLAKE2b-256 cfd5fd266f8f907ba5caa846b6f50d51c6e8f73867d307bea1133928096fd2eb

See more details on using hashes here.

File details

Details for the file tintervals-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: tintervals-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for tintervals-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a7d37e5e22c184c94263945a4f54d6370f48a9dee0c697e499297e8963fb9b4
MD5 57a2d977e301321cb3783e802e2c0be1
BLAKE2b-256 5e89c3fcb9fe8459be642671458848d56e3d12526ee55c13027957025c3963cf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page