tdata.awk revision 54360
1162271Srwatson# program to produce loran tdata statistics from clockstats files
2162271Srwatson#
3172106Srwatson# usage: awk -f tdata.awk clockstats
4162271Srwatson#
5162271Srwatson# format of input record (missing replaced by -40.0)
6162271Srwatson# 49228 36.852 127.127.10.1 93:241:00:00:20.812 LORAN TDATA
7162271Srwatson# M OK 0 0 1169.14 -7.4 3.16E-07 .424
8162271Srwatson# W CV 0 0 3329.30 -16.4 1.81E-06 
9162271Srwatson# X OK 0 0 1737.19 -10.5 3.44E-07 .358
10162271Srwatson# Y OK 0 0 2182.07 -9.0 4.41E-07 .218
11162271Srwatson#
12162271Srwatson# format of output record (time in nanoseconds, signal values in dB)
13162271Srwatson#  MJD      sec      time     M      W      X      Y      Z
14162271Srwatson# 49228    36.852   175.0   -7.4  -16.4  -10.5   -9.0
15162271Srwatson#
16162271Srwatson# select LORAN TDATA records with valid format
17162271Srwatson{
18162271Srwatson	if (NF >= 7 && $6 == "TDATA") {
19162271Srwatson		m = w = x = y = z = -40.0
20162271Srwatson		for (i = 7; i < NF - 5; i++) {
21162271Srwatson			if ($i == "M" && $(i+1) == "OK") {
22162271Srwatson				i += 5
23162271Srwatson				m = $i
24162271Srwatson			}
25162271Srwatson			else if ($i == "W" && $(i+1) == "OK") {
26162271Srwatson				i += 5
27162271Srwatson				w = $i
28162271Srwatson			}
29162271Srwatson			else if ($i == "X" && $(i+1) == "OK") {
30162271Srwatson				i += 5
31162271Srwatson				x = $i
32162271Srwatson			}
33162271Srwatson			else if ($i == "Y" && $(i+1) == "OK") {
34172106Srwatson				i += 5
35172106Srwatson				y = $i
36172106Srwatson			}
37172106Srwatson			else if ($i == "Z" && $(i+1) == "OK") {
38172106Srwatson				i += 5
39172106Srwatson				z = $i
40162271Srwatson			}
41162271Srwatson                }
42162271Srwatson		printf "%5s %9.3f %6.1f %6.1f %6.1f %6.1f %6.1f\n", $1, $2, m, w, x, y, z
43162271Srwatson	}
44162271Srwatson}
45162271Srwatson
46162271Srwatson