update sample run data and scripts

This commit is contained in:
junzis 2017-07-27 13:41:21 +02:00
parent 8c90371111
commit 8693c51998
6 changed files with 5115 additions and 92 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,92 +0,0 @@
from __future__ import print_function
from pyModeS import adsb, ehs, util
# === Decode sample data file ===
def adsb_decode_all(n=None):
print("===== Decode all ADS-B sample data=====")
import csv
f = open('tests/sample_data_adsb.csv', 'rt')
msg0 = None
msg1 = None
for i, r in enumerate(csv.reader(f)):
if n and i > n:
break
ts = r[0]
m = r[1]
icao = adsb.icao(m)
tc = adsb.typecode(m)
if 1 <= tc <= 4:
print(ts, m, icao, tc, adsb.category(m), adsb.callsign(m))
if tc == 19:
print(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)
print(ts, m, icao, tc, pos, alt)
def ehs_decode_all(n=None):
print("===== Decode all Mode-S EHS sample data=====")
import csv
f = open('tests/sample_data_ehs.csv', 'rt')
for i, r in enumerate(csv.reader(f)):
if n and i > n:
break
ts = r[1]
m = r[2]
df = util.df(m)
icao = ehs.icao(m)
vBDS = ehs.BDS(m)
alt = ehs.df20alt(m) if df==20 else None
if vBDS:
if isinstance(vBDS, list):
print(ts, m, icao, df, alt, vBDS)
if vBDS == "BDS20":
print(ts, m, icao, df, alt, vBDS, ehs.callsign(m))
if vBDS == "BDS40":
print(ts, m, icao, df, alt, vBDS, ehs.alt40mcp(m),
ehs.alt40fms(m), ehs.p40baro(m))
if vBDS == "BDS44":
print(ts, m, icao, df, alt, vBDS, ehs.wind44(m),
ehs.temp44(m), ehs.p44(m), ehs.hum44(m))
if vBDS == "BDS44REV":
print(ts, m, icao, df, alt, vBDS, ehs.wind44(m, rev=True),
ehs.temp44(m, rev=True), ehs.p44(m, rev=True), ehs.hum44(m, rev=True))
if vBDS == "BDS50":
print(ts, m, icao, df, alt, vBDS, ehs.roll50(m), ehs.trk50(m),
ehs.gs50(m), ehs.rtrk50(m), ehs.tas50(m))
if vBDS == "BDS53":
print(ts, m, icao, df, alt, vBDS, ehs.hdg53(m), ehs.ias53(m),
ehs.mach53(m), ehs.tas53(m), ehs.vr53(m))
if vBDS == "BDS60":
print(ts, m, icao, df, alt, vBDS, ehs.hdg60(m), ehs.ias60(m),
ehs.mach60(m), ehs.vr60baro(m), ehs.vr60ins(m))
else:
print(ts, m, icao, df, alt, 'UNKNOWN')
if __name__ == '__main__':
adsb_decode_all(100)
ehs_decode_all(100)

41
tests/sample_run_adsb.py Normal file
View File

@ -0,0 +1,41 @@
from __future__ import print_function
from pyModeS import adsb, ehs, util
# === Decode sample data file ===
def adsb_decode_all(n=None):
print("===== Decode ADS-B sample data=====")
import csv
f = open('tests/data/sample_data_adsb.csv', 'rt')
msg0 = None
msg1 = None
for i, r in enumerate(csv.reader(f)):
if n and i > n:
break
ts = r[0]
m = r[1]
icao = adsb.icao(m)
tc = adsb.typecode(m)
if 1 <= tc <= 4:
print(ts, m, icao, tc, adsb.category(m), adsb.callsign(m))
if tc == 19:
print(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)
print(ts, m, icao, tc, pos, alt)
if __name__ == '__main__':
adsb_decode_all(n=100)

75
tests/sample_run_ehs.py Normal file
View File

@ -0,0 +1,75 @@
from __future__ import print_function
from pyModeS import adsb, ehs, util
# === Decode sample data file ===
def bds_info(BDS, m):
if BDS == "BDS17":
info = ([i[-2:] for i in ehs.cap17(m)])
elif BDS == "BDS20":
info = ehs.callsign(m)
elif BDS == "BDS40":
info = (ehs.alt40mcp(m), ehs.alt40fms(m), ehs.p40baro(m))
elif BDS == "BDS44":
info = (ehs.wind44(m), ehs.temp44(m), ehs.p44(m), ehs.hum44(m))
elif BDS == "BDS44REV":
info = (ehs.wind44(m, rev=True), ehs.temp44(m, rev=True), ehs.p44(m, rev=True), ehs.hum44(m, rev=True))
elif BDS == "BDS50":
info = (ehs.roll50(m), ehs.trk50(m), ehs.gs50(m), ehs.rtrk50(m), ehs.tas50(m))
elif BDS == "BDS53":
info = (ehs.hdg53(m), ehs.ias53(m), ehs.mach53(m), ehs.tas53(m), ehs.vr53(m))
elif BDS == "BDS60":
info = (ehs.hdg60(m), ehs.ias60(m), ehs.mach60(m), ehs.vr60baro(m), ehs.vr60ins(m))
else:
info = None
return info
def ehs_decode_all(df, n=None):
import csv
print("===== Decode EHS sample data (DF=%s)=====" % df)
f = open('tests/data/sample_data_ehs_df%s.csv' % df, 'rt')
for i, r in enumerate(csv.reader(f)):
if n and i > n:
break
ts = r[0]
m = r[2]
df = util.df(m)
icao = ehs.icao(m)
BDS = ehs.BDS(m)
code = ehs.df20alt(m) if df==20 else ehs.df21id(m)
if not BDS:
print(ts, m, icao, df, '%5s'%code, 'UNKNOWN')
continue
if isinstance(BDS, list):
print(ts, m, icao, df, '%5s'%code, end=' ')
for i, bds in enumerate(BDS):
if i == 0:
print(bds, *bds_info(bds, m))
else:
print(' '*55, bds, *bds_info(bds, m))
else:
print(ts, m, icao, df, '%5s'%code, BDS, *bds_info(BDS, m))
if __name__ == '__main__':
ehs_decode_all(df=20, n=100)
ehs_decode_all(df=21, n=100)