API
The Dataset() class
New in version 2016.11
This class allows simple data handling.
- class allantools.Dataset(data=None, rate=1.0, data_type='phase', taus=None)
Dataset class for Allantools
- Example:
import numpy as np # Load random data a = allantools.Dataset(data=np.random.rand(1000)) # compute mdev a.compute("mdev") print(a.out["stat"])
compute() returns the result of the computation and also stores it in the object’s
out
member.- __init__(data=None, rate=1.0, data_type='phase', taus=None)
Initialize object with input data
Parameters
- data: np.array
Input data. Provide either phase or frequency (fractional, adimensional)
- rate: float
The sampling rate for data, in Hz. Defaults to 1.0
- data_type: {‘phase’, ‘freq’}
Data type, i.e. phase or frequency. Defaults to “phase”.
- taus: np.array
Array of tau values, in seconds, for which to compute statistic. Optionally set taus=[“all”|”octave”|”decade”] for automatic calculation of taus list
Returns
- Dataset()
A Dataset() instance
- compute(function)
Evaluate the passed function with the supplied data.
Stores result in self.out.
Parameters
- function: str
Name of the
allantools
function to evaluate
Returns
- result: dict
The results of the calculation.
- inp
input data Dict,
- out
output data Dict, to be populated by compute()
- set_input(data, rate=1.0, data_type='phase', taus=None)
Optionnal method if you chose not to set inputs on init
Parameters
- data: np.array
Input data. Provide either phase or frequency (fractional, adimensional)
- rate: float
The sampling rate for data, in Hz. Defaults to 1.0
- data_type: {‘phase’, ‘freq’}
Data type, i.e. phase or frequency. Defaults to “phase”.
- taus: np.array
Array of tau values, in seconds, for which to compute statistic. Optionally set taus=[“all”|”octave”|”decade”] for automatic
- write_results(filename, digits=5, header_params={})
Output result to text
Save calculation results to disk. Will overwrite any existing file.
Parameters
- filename: str
Path to the output file
- digits: int
Number of significant digits in output
- header_params: dict
Arbitrary dict of params to be included in header
Returns
None
The Plot() class
New in version 2016.11
This class allows simple data plotting.
- class allantools.Plot(no_display=False)
A class for plotting data once computed by Allantools
- Example:
import allantools import numpy as np a = allantools.Dataset(data=np.random.rand(1000)) a.compute("mdev") b = allantools.Plot() b.plot(a) b.show()
Uses matplotlib. self.fig and self.ax stores the return values of matplotlib.pyplot.subplots(). plot() sets various defaults, but you can change them by using standard matplotlib method on self.fig and self.ax
- __init__(no_display=False)
set
no_display
toTrue
when we don’t have an X-window (e.g. for tests)
- plot(atDataset, errorbars=False, grid=False, **kwargs)
Use matplotlib methods for plotting
Additional keywords arguments are passed to
matplotlib.pyplot.plot()
.Parameters
- atDatasetallantools.Dataset()
a dataset with computed data
- errorbarsboolean
Plot errorbars. Defaults to False
- gridboolean
Plot grid. Defaults to False
- save(f)
Save figure to file
- show()
Calls matplotlib.pyplot.show()
Keeping this separated from
plot()
allows to tweak display before rendering