LeapSecond.com :: Tools
adev1.exe - Allan Deviation Statistics

14-Mar-2006

Description

The Allan Deviation (or Allan Variance) is a key statistic for analyzing the performance and stability of clocks. There are several programs that compute Allan deviation statistics, including professional tools like Stable32. Below is a very simple command-line tool that I use for many oscillator stability measurement applications.

As with most clock statistics programs, a plain text file of sequential raw phase measurements is all that is required to use adev1. The units don't have to be seconds (adev1 can scale input data) and the data rate does not need to be 1 Hz (adev1 can scale to data collected at slower sample rates). Where you get the file is a separate issue - some people get phase data over GPIB, or USB, or LAN, or RS232, or floppy, etc. I usually keep all my data collection programs separate from data analysis. This tool is an analysis tool.

Adev1 works on everything from pendulum clocks to hydrogen masers. The only restrictions are that the data must be phase (time interval) rather than frequency; the data must be sequential (no gaps); and the data should be free from glitches or outliers.

Sample 1

In this first example the 1 PPS from a GPSDO is measured with a HP 53132A time interval counter and the 9600 8N1 RS-232 serial output captured to a file. The data file looks like this:

C:\tvb> wc <log23202.txt
1.016 MB, 1041 KB, 1065035 chars, 178272 words, 87840 lines
C:\tvb> head log23202.txt
1.239,7 us
1.240,2 us
1.240,4 us
1.239,9 us
1.240,3 us
1.239,6 us
1.240,3 us
1.239,6 us
1.240,1 us
1.240,1 us

In time interval mode the 53131/53132A format includes a units suffix (us for microseconds and s for seconds). Most models also insert commas every three digits. Also in this example 53132A statistics were enabled so every N seconds the data is interrupted with five lines of text and numbers such as: 

1.239,6 us
1.240,1 us
1.239,6 us
N      : 300
STD DEV: 0.000,319 us
MEAN   : 1.240,169 us
MAX    : 1.241,0  us
MIN    : 1.239,4  us
1.240,3  us
1.239,6  us
1.240,3  us

Since I use adev1 frequently with the serial output of these HP counters, the program automatically handles the commas (removed), the time units (data is scaled), and the statistics lines (quietly ignored). Thus, adev1 can be used directly on raw HP phase data files with no manual editing. Here is an example:

C:\tvb> adev1 1 <log23202.txt

** Sampling period: 1 s
** Phase data scale factor: 1.000e+000
** Total phase samples: 86400
** Normal and Overlapping Allan deviation

      1 tau, 6.0265e-010 adev, n=86398,   6.0265e-010 oadev, n=86398
      2 tau, 2.8217e-010 adev, n=43198,   2.8094e-010 oadev, n=86396
      5 tau, 1.0314e-010 adev, n=17278,   1.0339e-010 oadev, n=86390
     10 tau, 5.3691e-011 adev, n=8638,    5.4296e-011 oadev, n=86380
     20 tau, 2.6617e-011 adev, n=4318,    2.7072e-011 oadev, n=86360
     50 tau, 1.1052e-011 adev, n=1726,    1.1085e-011 oadev, n=86300
    100 tau, 5.6781e-012 adev, n=862,     5.7003e-012 oadev, n=86200
    200 tau, 3.0238e-012 adev, n=430,     2.9821e-012 oadev, n=86000
    500 tau, 1.3804e-012 adev, n=171,     1.3755e-012 oadev, n=85400
   1000 tau, 8.0011e-013 adev, n=85,      7.9332e-013 oadev, n=84400
   2000 tau, 6.0141e-013 adev, n=42,      5.1156e-013 oadev, n=82400
   5000 tau, 2.3656e-013 adev, n=16,      2.5303e-013 oadev, n=76400
  10000 tau, 1.4069e-013 adev, n=7,       1.5420e-013 oadev, n=66400
  20000 tau, 8.3392e-014 adev, n=3,       1.0629e-013 oadev, n=46400

Both normal Allan deviation (adev) and overlapping Allan deviation (oadev) are calculated. Statistics are calculated for as many averaging times (tau) as possible given the amount of raw data. By default the stability for several tau per decade is calculated.

The output also includes the number of sample pairs (the n= number) used by the calculation; usually large numbers that can be ignored or small numbers that indicate the accuracy of the calculations is limited. A rule of thumb is that n should be 4 or greater.

Parameters / Options

A file of raw phase data doesn't convey the time interval between measurements. In the raw files seen above there is no way to tell, for example, if they are 1 second samples, or 60 second samples, or 1000 seconds. Thus you must tell adev1 what the sample period is. That is the required first parameter.

Not all raw phase files contain data with units of seconds. If you see a file with numbers like 1.234e-6 you can guess the units are seconds (1.234 microseconds) but a file with numbers like 1.234 could be seconds or milliseconds or microseconds or nanoseconds or cycle periods or whatever. The second parameter permits you to scale the input data by a constant factor so that the data is converted into standard units of seconds as it is read by the program. This parameter is not required for data with time unit suffixes (such as output from a 53131A).

Many Allan deviation tables or graphs show data points at each decade; for example, at 1 second, 10 seconds, 100 seconds, etc. When plotting it is sometimes nice to have more than one statistic per decade. Some Allan deviation tools produce data points for tau 1, 2, 4 and 10, 20, 40, etc. The third parameter can be use to obtain as many or as few data points per decade, including the extreme of one data point for every possible tau.

Sample 2

The next example is a data file from a TSC 5110A time interval analyzer measuring a free-running Austron 2110B. Using a 5 MHz reference the 9600 8N1 RS-232 serial output is a set of phase (integer and fractional period) values at a data rate of 1 Hz. Units are 200 ns (200e-9), the period of 5 MHz frequency, so the raw data must be scaled.

The raw data file looks like this:

C:\tvb> dir log24121.txt

LOG24121 TXT     5,047,477  03-15-06 11:47a log24121.txt

C:\tvb> wc <log24121.txt
4.509 MB, 4618 KB, 4728178 chars, 319299 words, 319299 lines
C:\tvb> head log24121.txt
0.0952987
-0.0859472
-0.2671862
-0.4484271
-0.6296708
-0.8109045
-0.9921413
-1.1733808
-1.3546209
-1.5358569

Here is the adev1 output (note use of period and scale parameters):

C:\tvb> adev1 1 200e-9 <log24121.txt

** Sampling period: 1 s
** Phase data scale factor: 2.000e-007
** Total phase samples: 319299
** Normal and Overlapping Allan deviation

      1 tau, 1.0360e-012 adev, n=319297,  1.0360e-012 oadev, n=319297
      2 tau, 6.9212e-013 adev, n=159648,  6.9116e-013 oadev, n=319295
      5 tau, 4.1615e-013 adev, n=63858,   4.1655e-013 oadev, n=319289
     10 tau, 3.9476e-013 adev, n=31928,   3.9512e-013 oadev, n=319279
     20 tau, 4.1711e-013 adev, n=15963,   4.1953e-013 oadev, n=319259
     50 tau, 4.3894e-013 adev, n=6384,    4.3570e-013 oadev, n=319199
    100 tau, 4.3473e-013 adev, n=3191,    4.3403e-013 oadev, n=319099
    200 tau, 4.4391e-013 adev, n=1595,    4.4587e-013 oadev, n=318899
    500 tau, 4.5632e-013 adev, n=637,     4.5885e-013 oadev, n=318299
   1000 tau, 4.8133e-013 adev, n=318,     4.7183e-013 oadev, n=317299
   2000 tau, 4.9518e-013 adev, n=158,     5.0995e-013 oadev, n=315299
   5000 tau, 5.7621e-013 adev, n=62,      5.5662e-013 oadev, n=309299
  10000 tau, 7.2946e-013 adev, n=30,      7.4078e-013 oadev, n=299299
  20000 tau, 1.2881e-012 adev, n=14,      1.2603e-012 oadev, n=279299
  50000 tau, 3.0409e-012 adev, n=5,       2.8234e-012 oadev, n=219299
 100000 tau, 5.4837e-012 adev, n=2,       4.9924e-012 oadev, n=119299

The "bin" number is a feature that lets you control how many averaging intervals (tau) should be calculated. For the most concise output choose a bin value of 1 - meaning only one statistic is calculated per decade, as in the following example:

C:\tvb> adev1 1 200e-9 1 <log24121.txt

** Sampling period: 1 s
** Phase data scale factor: 2.000e-007
** Total phase samples: 319299
** Normal and Overlapping Allan deviation

      1 tau, 1.0360e-012 adev, n=319297,  1.0360e-012 oadev, n=319297
     10 tau, 3.9476e-013 adev, n=31928,   3.9512e-013 oadev, n=319279
    100 tau, 4.3473e-013 adev, n=3191,    4.3403e-013 oadev, n=319099
   1000 tau, 4.8133e-013 adev, n=318,     4.7183e-013 oadev, n=317299
  10000 tau, 7.2946e-013 adev, n=30,      7.4078e-013 oadev, n=299299
 100000 tau, 5.4837e-012 adev, n=2,       4.9924e-012 oadev, n=119299

Other useful bin numbers are:

Usage message:

C:\tvb> adev1

Compute Allan Deviation over all tau from raw phase data

Usage: adev1 period [scale] [bins] < input

Arguments:
    period  - data sample interval (e.g., 1 second, 60 seconds)
    scale   - input data scale factor if units aren't seconds
    bins    - adev points per decade (special: 0,1,2,3,4,5,10,29)

Examples:
    adev1 1 < 1hzdata.txt         [ pre-scaled 1 Hz TI readings ]
    adev1 100 < hpdata.txt        [ 100 sec HP time interval readings ]
    adev1 60 1e-6 < mins.txt      [ 1 minute phase data, 1 us units ]
    adev1 1 200e-9 < tsc.dat      [ TSC 5110A 200 ns 1 Hz phase data ]
    adev1 1 2e-7 50 <tsc.dat      [ 50 adev points per decade ]

Download


Return to LeapSecond.com home page.
Comments/questions to tvb.