From e16d34bc063e287afb180a08d4de26c3431c7227 Mon Sep 17 00:00:00 2001 From: Junzi Sun Date: Tue, 29 Oct 2019 23:55:25 +0100 Subject: [PATCH] consolidation --- tests/sample_run_adsb.py | 29 ++++++++++++++++++++--------- tests/sample_run_c_adsb.py | 35 ----------------------------------- 2 files changed, 20 insertions(+), 44 deletions(-) delete mode 100644 tests/sample_run_c_adsb.py diff --git a/tests/sample_run_adsb.py b/tests/sample_run_adsb.py index 543d867..f0d5134 100644 --- a/tests/sample_run_adsb.py +++ b/tests/sample_run_adsb.py @@ -1,26 +1,32 @@ +import sys +import time import csv -from pyModeS import adsb -import logging -# logging.basicConfig(level=logging.INFO) +if len(sys.argv) > 1 and sys.argv[1] == "cython": + from pyModeS.c_decoder import adsb +else: + from pyModeS.decoder import adsb -logging.info("===== Decode ADS-B sample data=====") +print("===== Decode ADS-B sample data=====") f = open("tests/data/sample_data_adsb.csv", "rt") msg0 = None msg1 = None +tstart = time.time() for i, r in enumerate(csv.reader(f)): - ts = r[0] - m = r[1] + ts = int(r[0]) + m = r[1].encode() + icao = adsb.icao(m) tc = adsb.typecode(m) + if 1 <= tc <= 4: - logging.info([ts, m, icao, tc, adsb.category(m), adsb.callsign(m)]) + print(ts, m, icao, tc, adsb.category(m), adsb.callsign(m)) if tc == 19: - logging.info([ts, m, icao, tc, adsb.velocity(m)]) + print(ts, m, icao, tc, adsb.velocity(m)) if 5 <= tc <= 18: if adsb.oe_flag(m): msg1 = m @@ -32,4 +38,9 @@ for i, r in enumerate(csv.reader(f)): if msg0 and msg1: pos = adsb.position(msg0, msg1, t0, t1) alt = adsb.altitude(m) - logging.info([ts, m, icao, tc, pos, alt]) + print(ts, m, icao, tc, pos, alt) + + +dt = time.time() - tstart + +print("Execution time: {} seconds".format(dt)) diff --git a/tests/sample_run_c_adsb.py b/tests/sample_run_c_adsb.py deleted file mode 100644 index 02b078a..0000000 --- a/tests/sample_run_c_adsb.py +++ /dev/null @@ -1,35 +0,0 @@ -from pyModeS.c_decoder import adsb -import logging -import csv - -# logging.basicConfig(level=logging.INFO) - -logging.info("===== Decode ADS-B sample data=====") - -f = open("tests/data/sample_data_adsb.csv", "rt") - -msg0 = None -msg1 = None - -for i, r in enumerate(csv.reader(f)): - - ts = int(r[0]) - m = str.encode(r[1]) - icao = adsb.icao(m) - tc = adsb.typecode(m) - if 1 <= tc <= 4: - logging.info([ts, m, icao, tc, adsb.category(m), adsb.callsign(m)]) - if tc == 19: - logging.info([ts, m, icao, tc, adsb.velocity(m)]) - if 5 <= tc <= 18: - if adsb.oe_flag(m): - msg1 = m - t1 = ts - else: - msg0 = m - t0 = ts - - if msg0 and msg1: - pos = adsb.position(msg0, msg1, t0, t1) - alt = adsb.altitude(m) - logging.info([ts, m, icao, tc, pos, alt])