source: ntrip/trunk/BNC/tests/tools/clkjumps.py

Last change on this file was 11219, checked in by stuerze, 2 days ago

minor changes

File size: 1.9 KB
Line 
1#!/usr/bin/env python3
2"""Common jumps of the satellite clocks of a clock RINEX file, per system.
3
4usage: clkjumps.py <clock RINEX file> [threshold_m] (default 0.1 m)
5
6For each satellite the change between consecutive epochs is reduced by the
7median change of the neighbouring epochs (clock drift); the median of these
8reduced changes over the satellites of a system is the common jump of the
9epoch. Epochs with a common jump above the threshold are listed, e.g. a shift
10of all BDS clocks of a combination when the set of combined satellites
11changes (test case combi_bds_level).
12"""
13import sys, collections, statistics
14
15C = 299792458.0
16
17
18def main():
19 path = sys.argv[1]
20 thr = float(sys.argv[2]) if len(sys.argv) > 2 else 0.1
21 clk = collections.defaultdict(dict) # prn -> {epoch seconds: clock [m]}
22 for line in open(path):
23 if not line.startswith('AS '):
24 continue
25 p = line.split()
26 h, m, s = int(p[5]), int(p[6]), float(p[7])
27 clk[p[1]][int(p[4]) * 86400 + h * 3600 + m * 60 + s] = float(p[9]) * C
28
29 reduced = collections.defaultdict(list) # (system, epoch) -> reduced changes
30 for prn, d in clk.items():
31 ts = sorted(d)
32 steps = [(b, d[b] - d[a]) for a, b in zip(ts, ts[1:]) if 0.0 < b - a <= 30.0]
33 for i, (t, v) in enumerate(steps):
34 window = [x for _, x in steps[max(0, i - 6):i + 7]]
35 reduced[(prn[0], t)].append(v - statistics.median(window))
36
37 found = False
38 for (sysc, t), values in sorted(reduced.items()):
39 if len(values) < 5:
40 continue
41 jump = statistics.median(values)
42 if abs(jump) > thr:
43 found = True
44 t = int(round(t)) % 86400
45 print('%s %02d:%02d:%02d common jump %+.2f m (%d satellites)'
46 % (sysc, t // 3600, t % 3600 // 60, t % 60, jump, len(values)))
47 if not found:
48 print('no common clock jumps > %.2f m' % thr)
49
50
51if __name__ == '__main__':
52 main()
Note: See TracBrowser for help on using the repository browser.