Skip to main content

Allan deviation and related time/frequency statistics

Project description

https://badge.fury.io/py/AllanTools.svg https://img.shields.io/conda/vn/conda-forge/allantools.svg https://img.shields.io/conda/dn/conda-forge/allantools.svg https://github.com/aewallin/allantools/actions/workflows/python-pytest.yml/badge.svg flake8 Status https://readthedocs.org/projects/allantools/badge/?version=latest https://coveralls.io/repos/github/aewallin/allantools/badge.svg

A python library for calculating Allan deviation and related time & frequency statistics. LGPL v3+ license.

Input data should be evenly spaced observations of either fractional frequency, or phase in seconds. Deviations are calculated for given tau values in seconds.

Function

Description

Comment

adev()

Allan deviation

Classic - use only if required - relatively poor confidence.

oadev()

Overlapping Allan deviation

General purpose - most widely used - first choice

mdev()

Modified Allan deviation

Used to distinguish between White and Flicker Phase Modulation.

tdev()

Time deviation

Based on modified Allan variance.

hdev()

Hadamard deviation

Rejects frequency drift, and handles divergent noise.

ohdev()

Overlapping Hadamard deviation

Better confidence than normal Hadamard.

pdev()

Parabolic deviation

totdev()

Total deviation

Better confidence at long averages for Allan deviation.

mtotdev()

Modified total deviation

Modified Total deviation. Better confidence at long averages for modified Allan

ttotdev()

Time total deviation

htotdev()

Hadamard total deviation

theo1()

Theo1 deviation

Theo1 is a two-sample variance with improved confidence and extended averaging factor range.

mtie()

Maximum Time Interval Error

tierms()

Time Interval Error RMS

gradev()

Gap resistant overlapping Allan deviation

gcodev()

Groslambert Covariance

Noise generators for creating synthetic datasets are also included:

  • violet noise with f^2 PSD

  • white noise with f^0 PSD

  • pink noise with f^-1 PSD

  • Brownian or random walk noise with f^-2 PSD

More details on available statistics and noise generators : full list of available functions

see /tests for tests that compare allantools output to other (e.g. Stable32) programs. More test data, benchmarks, ipython notebooks, and comparisons to known-good algorithms are welcome!

Installation

Install from pypi:

pip install allantools

Latest version + examples, tests, test data, iPython notebooks : clone from github, then install

python setup.py install

(see python setup.py –help install for install options)

These commands should be run as root for system-wide installation, or you can use the –user option to install for your account only. Exact command names may vary depending on your OS / package manager / target python version.

Basic usage

Minimal example, phase data

We can call allantools with only one parameter - an array of phase data. This is suitable for time-interval measurements at 1 Hz, for example from a time-interval-counter measuring the 1PPS output of two clocks.

>>> import allantools
>>> x = allantools.noise.white(10000)        # Generate some phase data, in seconds.
>>> (taus, adevs, errors, ns) = allantools.oadev(x)

when only one input parameter is given, phase data in seconds is assumed when no rate parameter is given, rate=1.0 is the default when no taus parameter is given, taus=’octave’ is the default

Frequency data example

Note that allantools assumes non-dimensional frequency data input. Normalization, by e.g. dividing all data points with the average frequency, is left to the user.

>>> import allantools
>>> import pylab as plt
>>> import numpy as np
>>> t = np.logspace(0, 3, 50)  # tau values from 1 to 1000
>>> y = allantools.noise.white(10000)  # Generate some frequency data
>>> r = 12.3  # sample rate in Hz of the input data
>>> (t2, ad, ade, adn) = allantools.oadev(y, rate=r, data_type="freq", taus=t)  # Compute the overlapping ADEV
>>> fig = plt.loglog(t2, ad) # Plot the results
>>> # plt.show()

New in 2016.11 : simple top-level API, using dedicated classes for data handling and plotting.

import allantools # https://github.com/aewallin/allantools/
import numpy as np

# Compute a deviation using the Dataset class
a = allantools.Dataset(data=np.random.rand(1000))
a.compute("mdev")

# New in 2019.7 : write results to file
a.write_results("output.dat")

# Plot it using the Plot class
b = allantools.Plot()
# New in 2019.7 : additional keyword arguments are passed to
# matplotlib.pyplot.plot()
b.plot(a, errorbars=True, grid=True)
# You can override defaults before "show" if needed
b.ax.set_xlabel("Tau (s)")
b.show()

Jupyter notebooks with examples

Jupyter notebooks are interactive python scripts, embedded in a browser, allowing you to manipulate data and display plots like easily. For guidance on installing jupyter, please refer to https://jupyter.org/install.

See /examples for some examples in notebook format.

github formats the notebooks into nice web-pages, for example

Authors

Project details


Download files

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

Source Distribution

allantools-2024.4.tar.gz (8.8 MB view details)

Uploaded Source

Built Distributions

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

allantools-2024.4-py3-none-any.whl (47.3 kB view details)

Uploaded Python 3

AllanTools-2024.4-py2.py3-none-any.whl (44.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file allantools-2024.4.tar.gz.

File metadata

  • Download URL: allantools-2024.4.tar.gz
  • Upload date:
  • Size: 8.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.10

File hashes

Hashes for allantools-2024.4.tar.gz
Algorithm Hash digest
SHA256 81b3274c83351ee573f754a62a66ad27b4e1ca7b9b36e47674d57d48622ce5be
MD5 6b84864e5c629fc3bdb784ba9223459f
BLAKE2b-256 46c16777e887568133104e785e6adecbf669185aa1a67d180d826529227df2a6

See more details on using hashes here.

File details

Details for the file allantools-2024.4-py3-none-any.whl.

File metadata

  • Download URL: allantools-2024.4-py3-none-any.whl
  • Upload date:
  • Size: 47.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.10

File hashes

Hashes for allantools-2024.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2bbf874976f38f34773ee8268e1681d86a0bcf5b82c955cf2d8e1dde1ee09a18
MD5 4e4b960e6f995b6a83e5c24d2ffc3c64
BLAKE2b-256 2afe759ad4479ea68cea7ec89692ba5567130a639198e33c4fd7451f6f56a72a

See more details on using hashes here.

File details

Details for the file AllanTools-2024.4-py2.py3-none-any.whl.

File metadata

  • Download URL: AllanTools-2024.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 44.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.10

File hashes

Hashes for AllanTools-2024.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5dff241fe10af0adb87fd2a9048adde3062867f2c371c320ff5a23d3b4f37202
MD5 45bbc3609290e7d81084edab93fd31d7
BLAKE2b-256 515d165c2bcffe947650d3c9d310491bc900c706efde745d5fbb420ec354402e

See more details on using hashes here.

Supported by

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