xref: /freebsd/contrib/ntp/scripts/stats/tdata.awk (revision 595e514d0df2bac5b813d35f83e32875dbf16a83)
1# program to produce loran tdata statistics from clockstats files
2#
3# usage: awk -f tdata.awk clockstats
4#
5# format of input record (missing replaced by -40.0)
6# 49228 36.852 127.127.10.1 93:241:00:00:20.812 LORAN TDATA
7# M OK 0 0 1169.14 -7.4 3.16E-07 .424
8# W CV 0 0 3329.30 -16.4 1.81E-06
9# X OK 0 0 1737.19 -10.5 3.44E-07 .358
10# Y OK 0 0 2182.07 -9.0 4.41E-07 .218
11#
12# format of output record (time in nanoseconds, signal values in dB)
13#  MJD      sec      time     M      W      X      Y      Z
14# 49228    36.852   175.0   -7.4  -16.4  -10.5   -9.0
15#
16# select LORAN TDATA records with valid format
17{
18	if (NF >= 7 && $6 == "TDATA") {
19		m = w = x = y = z = -40.0
20		for (i = 7; i < NF - 5; i++) {
21			if ($i == "M" && $(i+1) == "OK") {
22				i += 5
23				m = $i
24			}
25			else if ($i == "W" && $(i+1) == "OK") {
26				i += 5
27				w = $i
28			}
29			else if ($i == "X" && $(i+1) == "OK") {
30				i += 5
31				x = $i
32			}
33			else if ($i == "Y" && $(i+1) == "OK") {
34				i += 5
35				y = $i
36			}
37			else if ($i == "Z" && $(i+1) == "OK") {
38				i += 5
39				z = $i
40			}
41                }
42		printf "%5s %9.3f %6.1f %6.1f %6.1f %6.1f %6.1f\n", $1, $2, m, w, x, y, z
43	}
44}
45
46