summaryrefslogtreecommitdiff
path: root/leapsecond.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-01-19 12:54:47 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-01-19 12:54:47 -0500
commit040222dda3c761123c5f24769fe8fe5b727495ec (patch)
treea33dbb86d3b2505f7dc3c696d55a6d278bbfc3b5 /leapsecond.py
parent016ec3b4315d75d15300cdbb8f3b40087b57153b (diff)
downloadgpsd-040222dda3c761123c5f24769fe8fe5b727495ec.tar.gz
Compute residuals.
Diffstat (limited to 'leapsecond.py')
-rwxr-xr-xleapsecond.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/leapsecond.py b/leapsecond.py
index 977b1b19..dab5ca40 100755
--- a/leapsecond.py
+++ b/leapsecond.py
@@ -167,9 +167,17 @@ def graph_history(filename):
"Generate a GNUPLOT plot of the leap-second history."
raw = fetch_leapsecs(filename)
(b, c) = leastsquares(zip(range(len(raw)), raw))
+ maxerr = 0
+ for (i, r) in enumerate(raw):
+ err = r - (i * b + c)
+ if err > maxerr:
+ maxerr = err
+ maxerr /= (60 * 60 * 24 * 7)
dates = map(lambda t: time.strftime("%Y-%m-%d",time.localtime(t)), raw)
fmt = ''
+ fmt += '# Least-squares approximation of Unix time from leapsecond is:\n'
fmt += 'lsq(x) = %s * x + %s\n' % (b, c)
+ fmt += '# Maximum residual error is %.2f weeks\n' % maxerr
fmt += 'set autoscale\n'
fmt += 'set xlabel "Leap second offset"\n'
fmt += 'set xrange [0:%d]\n' % (len(dates)-1)