Skip to content

Commit

Permalink
gcodev documentation, example
Browse files Browse the repository at this point in the history
  • Loading branch information
aewallin committed Nov 26, 2023
1 parent 703592c commit 0fbd120
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
17 changes: 13 additions & 4 deletions allantools/allantools.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,17 @@ def calc_gcodev_phase(phase_1, phase_2, rate, mj, stride):
def gcodev(data_1, data_2, rate=1.0, data_type="phase", taus=None):
""" Groslambert codeviation a.k.a. Allan Covariance
Ref: (arXiv:1904.05849, https://arxiv.org/abs/1904.05849)
Similarly to the three-cornered hat method, we consider three uncorrelated
oscillators A, B, C. The Groslambert codeviation estimates the noise of
one oscillator (e.g. B), given two synchronous measurements AB and BC.
Unlike three-cordenred hat, Gcodev is not affected by the (uncorrelated) noise of
the measurement devices (time-interval or frequency counter) used for
the measurements AB and BC.
References
----------
* arXiv:1904.05849, https://arxiv.org/abs/1904.05849
* https://rubiola.org/pdf-articles/conference/2016-IFCS-Three-cornered.pdf
Parameters
----------
Expand All @@ -572,14 +582,13 @@ def gcodev(data_1, data_2, rate=1.0, data_type="phase", taus=None):
Returns
-------
(taus, gd): tuple
Tuple of values
Tuple of values
taus: np.array
Tau values for which td computed
Tau values for which gcodev computed
gd: np.array
Computed gcodev for each tau value
"""

phase_1 = input_to_phase(data_1, rate, data_type)
phase_2 = input_to_phase(data_2, rate, data_type)
(phase_1, m, taus_used) = tau_generator(phase_1, rate, taus)
Expand Down
3 changes: 3 additions & 0 deletions docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Papers
Fundamental Frequency and Time Metrology - Random Instabilities
http://dx.doi.org/10.1109/IEEESTD.2008.4797525
.. [Lantz2019] KLTS: A rigorous method to compute the confidence intervals for the Three-Cornered Hat and for Groslambert Covariance
https://arxiv.org/abs/1904.05849
.. [Riley_Stable32] http://www.stable32.com/Handbook.pdf
.. [Riley_CI] Confidence Intervals and Bias Corrections for the Stable32 Variance Functions
Expand Down
11 changes: 10 additions & 1 deletion examples/three-cornered-hat-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def plotline(plt, alpha, amplitude, taus, style, labeltext):
N = 10000
rate = 1.0
# white phase noise => 1/tau ADEV

# these are the 'true' phases of the oscillators, which are not observable.
# we can only measure phases between two oscillators.
ampl_A = 1.0
phaseA = ampl_A*numpy.random.randn(N)
ampl_B = 5.0
Expand Down Expand Up @@ -97,6 +98,14 @@ def plotline(plt, alpha, amplitude, taus, style, labeltext):
phaseCA, phaseAB, phaseBC, rate, t, allantools.oadev)
plt.loglog(taus, devC, 'bv', label='3-C-H estimate for C')

# GCODEV estimates
(taus, devA, err_a, ns_ab) = allantools.gcodev(phaseAB, phaseCA, rate=rate, taus='log10')
plt.loglog(taus, devA, 'r*', label='Gcodev estimate for A')
(taus, devB, err_b, ns_b) = allantools.gcodev(phaseAB, phaseBC, rate=rate, taus='log10')
plt.loglog(taus, devB, 'g*', label='Gcodev estimate for B')
(taus, devC, err_c, ns_c) = allantools.gcodev(phaseCA, phaseBC, rate=rate, taus='log10')
plt.loglog(taus, devC, 'b*', label='Gcodev estimate for C')

print("TCH done.")
plt.title('AllanTools three-cornered-hat example')
plt.xlabel('Tau / s')
Expand Down

0 comments on commit 0fbd120

Please sign in to comment.