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_typ ({'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: A Dataset() instance
Return type: Dataset()
-
inp
= {'data': None, 'data_type': None, 'rate': None, 'taus': None}¶ input data Dict, will be initialized by __init__()
-
out
= {'stat': None, 'stat_err': None, 'stat_id': None, 'stat_n': None, 'stat_unc': None, 'taus': None}¶ 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_typ ({'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
-
compute
(function)¶ Evaluate the passed function with the supplied data.
Stores result in self.out.
Parameters: function (str) – Name of the allantools
function to evaluateReturns: result – The results of the calculation. Return type: dict
-
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)¶ use matplotlib methods for plotting
Parameters: - atDataset (allantools.Dataset()) – a dataset with computed data
- errorbars (boolean) – Plot errorbars. Defaults to False
- grid (boolean) – Plot grid. Defaults to False
-
show
()¶ Calls matplotlib.pyplot.show()
Keeping this separated from
plot()
allows to tweak display before rendering
-