Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aewallin committed Nov 25, 2023
1 parent beb1fb3 commit a4c0c60
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 61 deletions.
16 changes: 11 additions & 5 deletions allantools/allantools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,11 +1637,17 @@ def tau_generator(data, rate, taus=None, v=False, even=False, maximum_m=-1):
Alternatively one of the keywords: "all", "octave", "decade".
Defaults to "octave" if omitted.
keyword averaging-factors
"all" 1, 2, 3, 4, ..., len(data)
"octave" 1, 2, 4, 8, 16, ...
"decade" 1, 2, 4, 10, 20, 40, 100, ...
"log10" approx. 10 points per decade
+----------+--------------------------------+
| keyword | averaging-factors |
+==========+================================+
| "all" | 1, 2, 3, 4, ..., len(data) |
+----------+--------------------------------+
| "octave" | 1, 2, 4, 8, 16, 32, ... |
+----------+--------------------------------+
| "decade" | 1, 2, 4, 10, 20, 40, 100, ... |
+----------+--------------------------------+
| "log10" | approx. 10 points per decade |
+----------+--------------------------------+
v:
verbose output if True
even:
Expand Down
134 changes: 78 additions & 56 deletions allantools/noise_kasdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@ class Noise(object):
46th., Proceedings of the 1992 IEEE, pp.274,283, 27-29 May 1992
http://dx.doi.org/10.1109/FREQ.1992.270003
Parameters
----------
nr: integer
length of generated time-series
must be power of two
qd: float
discrete variance
b: float
+----+--------------------------------------------+
| b | noise type |
+====+============================================+
| 0 | White Phase Modulation (WPM) |
+----+--------------------------------------------+
| -1 | Flicker Phase Modulation (FPM) |
+----+--------------------------------------------+
| -2 | White Frequency Modulation (WFM) |
+----+--------------------------------------------+
| -3 | Flicker Frequency Modulation (FFM) |
+----+--------------------------------------------+
| -4 | Random Walk Frequency Modulation (RWFM) |
+----+--------------------------------------------+
Returns
-------
Noise()
A Noise() instance
:Example:
::
Expand All @@ -53,25 +81,7 @@ class Noise(object):
def __init__(self, nr=2, qd=1, b=0):
""" Initialize object with input data
Parameters
-------
nr: integer
length of generated time-series
must be power of two
qd: float
discrete variance
b: float
noise type:
0 : White Phase Modulation (WPM)
-1 : Flicker Phase Modulation (FPM)
-2 : White Frequency Modulation (WFM)
-3 : Flicker Frequency Modulation (FFM)
-4 : Random Walk Frequency Modulation (RWFM)
Returns
-------
Noise()
A Noise() instance
"""
self.nr = nr
Expand All @@ -90,13 +100,22 @@ def set_input(self, nr=2, qd=1, b=0):
qd: float
discrete variance
b: float
noise type:
0 : White Phase Modulation (WPM)
-1 : Flicker Phase Modulation (FPM)
-2 : White Frequency Modulation (WFM)
-3 : Flicker Frequency Modulation (FFM)
-4 : Random Walk Frequency Modulation (RWFM)
noise type
+----+--------------------------------------------+
| b | noise type |
+====+============================================+
| 0 | White Phase Modulation (WPM) |
+----+--------------------------------------------+
| -1 | Flicker Phase Modulation (FPM) |
+----+--------------------------------------------+
| -2 | White Frequency Modulation (WFM) |
+----+--------------------------------------------+
| -3 | Flicker Frequency Modulation (FFM) |
+----+--------------------------------------------+
| -4 | Random Walk Frequency Modulation (RWFM) |
+----+--------------------------------------------+
"""
self.nr = nr
self.qd = qd
Expand Down Expand Up @@ -131,28 +150,31 @@ def generateNoise(self):
self.time_series = time_series

def phase_psd_from_qd(self, tau0=1.0):
""" return phase power spectral density coefficient g_b
""" return phase power spectral density coefficient :math:`g_b`
for noise-type defined by (qd, b, tau0)
where tau0 is the interval between data points
Colored noise generated with (qd, b, tau0) parameters will
show a phase power spectral density of
S_x(f) = Phase_PSD(f) = g_b * f^b
:math:`S_x(f) = Phase_{PSD}(f) = g_b f^b`
[Kasdin1992]_ eqn (39)
"""
return self.qd*2.0*pow(2.0*np.pi, self.b)*pow(tau0, self.b+1.0)

def frequency_psd_from_qd(self, tau0=1.0):
""" return frequency power spectral density coefficient h_a
""" return frequency power spectral density coefficient :math:`h_a`
for the noise type defined by (qd, b, tau0)
Colored noise generated with (qd, b, tau0) parameters will
show a frequency power spectral density of
S_y(f) = Frequency_PSD(f) = h_a * f^a
where the slope a comes from the phase PSD slope b:
a = b + 2
.. math::
S_y(f) = Frequency_{PSD}(f) = h_a f^a
where the slope :math:`a` comes from the phase PSD slope :math:`b`:
:math:`a = b + 2`
[Kasdin1992]_ eqn (39)
"""
Expand Down Expand Up @@ -213,19 +235,28 @@ def adev_from_qd(self, tau0=1.0, tau=1.0):
Colored noise generated with (qd, b, tau0) parameters will
show an Allan variance of:
AVAR = prefactor * h_a * tau^c
.. math::
AVAR = prefactor \\cdot h_a \\cdot \\tau^c
where a = b + 2 is the slope of the frequency PSD.
and h_a is the frequency PSD prefactor S_y(f) = h_a * f^a
where :math:`a = b + 2` is the slope of the frequency PSD.
and :math:`h_a` is the frequency PSD prefactor :math:`S_y(f) = h_a f^a`
The relation between a, b, c is:
a b c(AVAR) c(MVAR)
-----------------------
-2 -4 1 1
-1 -3 0 0
0 -2 -1 -1
+1 -1 -2 -2
+2 0 -2 -3
+---+---+---------+----------+
| a | b | c(AVAR) | c(MVAR) |
+===+===+=========+==========+
|-2 |-4 | 1 | 1 |
+---+---+---------+----------+
|-1 |-3 | 0 | 0 |
+---+---+---------+----------+
| 0 |-2 | -1 | -1 |
+---+---+---------+----------+
|+1 |-1 | -2 | -2 |
+---+---+---------+----------+
|+2 | 0 | -2 | -3 |
+---+---+---------+----------+
Coefficients from [Dawkins2007]_.
Expand Down Expand Up @@ -253,22 +284,13 @@ def mdev_from_qd(self, tau0=1.0, tau=1.0):
Colored noise generated with (qd, b, tau0) parameters will
show an Modified Allan variance of:
.. math::
MVAR = prefactor \\cdot h_a \\cdot \\tau^c
MVAR = prefactor * h_a * tau^c
where a = b + 2 is the slope of the frequency PSD.
and h_a is the frequency PSD prefactor S_y(f) = h_a * f^a
The relation between a, b, c is:
a b c(AVAR) c(MVAR)
-----------------------
-2 -4 1 1
-1 -3 0 0
0 -2 -1 -1
+1 -1 -2 -2
+2 0 -2 -3
Coefficients from [Dawkins2007]_.
where :math:`a = b + 2` is the slope of the frequency PSD.
and :math:`h_a` is the frequency PSD prefactor :math:`S_y(f) = h_a f^a`
"""
g_b = self.phase_psd_from_qd(tau0)
Expand Down

0 comments on commit a4c0c60

Please sign in to comment.