Skip to content

Math

calculate_adev_errors(tau, adev, tau0, N, alpha=0, d=2, overlapping=True, modified=False)

Calculate non-naive Allan deviation errors. Equivalent to Stable32.

Ref

https://github.com/aewallin/allantools/blob/master/examples/ci_demo.py https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20050061319.pdf

Parameters:

Name Type Description Default
tau list of floats

list of tau_values for which deviations were computed

required
adev list of floats

list of ADEV (or another statistic) deviations

required
tau0 float

averaging factor; average interval between measurements

required
N int

number of frequency observations

required
alpha int

+2,...,-4 noise type, either estimated or known

0
d int

statistic code: 1 first-difference variance, 2 allan variance, 3 hadamard variance

2
overlapping bool

True if overlapping statistic used. False if standard statistic used

True
modified bool

True if modified statistic used. False if standard statistic used.

False

Returns:

Name Type Description
err_lo list of floats

non-naive lower 1-sigma confidence interval for each point over which deviations were computed

err_high list of floats

non-naive higher 1-sigma confidence interval for each point over which deviations were computed

calculate_allan_dev(ds, taus='octave', measurement_rate=None)

Calculate the overlapped Allan deviation of a time series.

Parameters:

Name Type Description Default
ds Series

Time series of frequency input data.

required
taus array or str

Time differences (tau), in seconds, for which the Allan deviation is calculated. Specify "all", "octave" or "decade" for automatic generation. See allantools.oadev documentation.

'octave'
measurement_rate float

Sampling rate of the input data, in Hz. Specify None to calculate from average interval.

None

Returns:

Type Description
Series

Allan deviation at different taus

get_adev_wn_range(adev_data, n_tau_min=3)

Find averaging time range of white noise section of Allan Deviation data.

Using a simple bruteforce method, the RMSE error between the Allan Deviation data and a fitted line with slope -0.5 is computed for many possible sections of varying length of the Allan Deviation data. Longer sections are favored by normalization of the RMSE using squared length of the section. Finally the white noise section is defined via the minimum normalized RMSE value.

Parameters:

Name Type Description Default
adev_data DataFrame

Dataframe of computed Allan Deviation data including averaging time tau as index and Allan Deviation values as adev column.

required
n_tau_min int

Minimum number of datapoints to use for fitting of the line.

3

Returns:

Name Type Description
wn_tau0 float

Averaging time at start of white noise section.

wn_tau1 float

Averaging time at end of white noise section.

interval_means(series, interval, min_count=None, name=None, err='sem')

Calculate interval means of a time series

See pandas.DataFrame.resample.

Parameters:

Name Type Description Default
series Series

Input time series.

required
interval str

Resampling interval, e. g. "1h".

required
min_count int | float

Minimum number of samples required in each interval. For intervals with fewer samples, the mean value is set to NaN. A fractional value 0 < min_count < 1 is interpreted as a fraction of the maximum number of samples.

None
name str

Prefix of the output dataframe's columns. If unspecified, the input series' name attribute is used, or "y", if it does not have a name.

None
err str

Statistical function to use for error column. Options are "sem" (standard error of the mean) and "std" (standard deviation).

'sem'

Returns:

Type Description
DataFrame

Time series of mean value, standard error of the mean (SEM), and count of samples per interval.

truncate(x, digits=0)

Truncate a float number to specified digits

weighted_mean(values, errors)

Weighted mean, standard deviation and standard error of the mean