File: fsk_results.py

package info (click to toggle)
codec2 0.9.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 113,072 kB
  • sloc: ansic: 412,877; python: 4,004; sh: 1,540; objc: 817; asm: 683; makefile: 588
file content (27 lines) | stat: -rw-r--r-- 690 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# fsk_results.py
# David Rowe Sep 2018
#
# Reads JSON files from HF data system and prints some summary results

import json
import time
import sys

if len(sys.argv) == 1:
    print("\nusage: %s filename.json\n" % (sys.argv[0]))
    sys.exit(0)
    
filepath = sys.argv[1]
EbNodB_sum = 0.0

with open(filepath) as fp:
    line = fp.readline()
    cnt = 1
    while line:
        data = json.loads(line)
        time_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data['secs']))
        print((time_str, data['EbNodB'],data['frames']))
        EbNodB_sum += float(data['EbNodB'])
        line = fp.readline()
        cnt += 1
    print("Average EbNodB: %4.2f\n" % (EbNodB_sum/cnt))