add [commb], depricate [ehs] and [els]

This commit is contained in:
Junzi Sun 2018-05-17 10:34:14 +02:00
parent 6128c5a18d
commit 2389c12b98
10 changed files with 121 additions and 36 deletions

View File

@ -2,9 +2,11 @@ from __future__ import absolute_import, print_function, division
from .decoder.common import *
from .decoder import adsb
from .decoder import els
from .decoder import ehs
from .decoder import commb
from .decoder import common
from .decoder import bds
from .extra import aero
from .extra import beastclient
from .decoder import els # depricated
from .decoder import ehs # depricated

View File

@ -22,7 +22,7 @@ from __future__ import absolute_import, print_function, division
import numpy as np
from pyModeS.extra import aero
from pyModeS.decoder.common import allzeros
from pyModeS.decoder import common
from pyModeS.decoder.bds import bds05, bds06, bds08, bds09, \
bds10, bds17, bds20, bds30, bds40, bds44, bds50, bds53, bds60
@ -98,9 +98,33 @@ def infer(msg):
String or None: BDS version, or possible versions, or None if nothing matches.
"""
if allzeros(msg):
df = common.df(msg)
if common.allzeros(msg):
return None
# For ADS-B / Mode-S extended squitter
if df == 17:
tc = common.typecode(msg)
if 1 <= tc <= 4:
return 'BDS08' # indentification and category
if 5 <= tc <= 8:
return 'BDS06' # surface movement
if 9 <= tc <= 18:
return 'BDS05' # airborne position, baro-alt
if tc == 19:
return 'BDS09' # airborne velocity
if 20 <= tc <= 22:
return 'BDS05' # airborne position, gnss-alt
if tc == 28:
return 'BDS61' # aircraft status
if tc == 29:
return 'BDS62' # target state and status
if tc == 31:
return 'BDS65' # operational status
# For Comm-B replies, ELS + EHS only
IS10 = bds10.is10(msg)
IS17 = bds17.is17(msg)
IS20 = bds20.is20(msg)

15
pyModeS/decoder/commb.py Normal file
View File

@ -0,0 +1,15 @@
from __future__ import absolute_import, print_function, division
# ELS - elementary surveillance
from pyModeS.decoder.bds.bds10 import *
from pyModeS.decoder.bds.bds17 import *
from pyModeS.decoder.bds.bds20 import *
from pyModeS.decoder.bds.bds30 import *
# ELS - enhanced surveillance
from pyModeS.decoder.bds.bds40 import *
from pyModeS.decoder.bds.bds50 import *
from pyModeS.decoder.bds.bds60 import *
# MRAR
from pyModeS.decoder.bds.bds44 import *

View File

@ -1,12 +1,14 @@
from __future__ import absolute_import, print_function, division
import warnings
warnings.simplefilter('once', DeprecationWarning)
from pyModeS.decoder.bds.bds40 import *
from pyModeS.decoder.bds.bds50 import *
from pyModeS.decoder.bds.bds60 import *
from pyModeS.decoder.bds import infer
warnings.simplefilter('once', DeprecationWarning)
warnings.warn("pms.ehs module is deprecated. Please use pms.commb instead.", DeprecationWarning)
def BDS(msg):
warnings.warn("pms.ehs.BDS() is deprecated, use pms.bds.infer() instead.", DeprecationWarning)
return infer(msg)

View File

@ -4,3 +4,7 @@ from pyModeS.decoder.bds.bds10 import *
from pyModeS.decoder.bds.bds17 import *
from pyModeS.decoder.bds.bds20 import *
from pyModeS.decoder.bds.bds30 import *
import warnings
warnings.simplefilter('once', DeprecationWarning)
warnings.warn("pms.els module is deprecated. Please use pms.commb instead.", DeprecationWarning)

View File

@ -1,32 +1,32 @@
from __future__ import print_function
from pyModeS import ehs, common, bds
from pyModeS import commb, common, bds
# === Decode sample data file ===
def bds_info(BDS, m):
if BDS == "BDS10":
info = [bds.bds10.ovc10(m)]
info = [commb.ovc10(m)]
elif BDS == "BDS17":
info = ([i[-2:] for i in bds.bds17.cap17(m)])
info = ([i[-2:] for i in commb.cap17(m)])
elif BDS == "BDS20":
info = [bds.bds20.cs20(m)]
info = [commb.cs20(m)]
elif BDS == "BDS40":
info = (bds.bds40.alt40mcp(m), bds.bds40.alt40fms(m), bds.bds40.p40baro(m))
info = (commb.alt40mcp(m), commb.alt40fms(m), commb.p40baro(m))
elif BDS == "BDS44":
info = (bds.bds44.wind44(m), bds.bds44.temp44(m), bds.bds44.p44(m), bds.bds44.hum44(m))
info = (commb.wind44(m), commb.temp44(m), commb.p44(m), commb.hum44(m))
elif BDS == "BDS44REV":
info = (bds.bds44.wind44(m, rev=True), bds.bds44.temp44(m, rev=True), bds.bds44.p44(m, rev=True), bds.bds44.hum44(m, rev=True))
info = (commb.wind44(m, rev=True), commb.temp44(m, rev=True), commb.p44(m, rev=True), commb.hum44(m, rev=True))
elif BDS == "BDS50":
info = (bds.bds50.roll50(m), bds.bds50.trk50(m), bds.bds50.gs50(m), bds.bds50.rtrk50(m), bds.bds50.tas50(m))
info = (commb.roll50(m), commb.trk50(m), commb.gs50(m), commb.rtrk50(m), commb.tas50(m))
elif BDS == "BDS60":
info = (bds.bds60.hdg60(m), bds.bds60.ias60(m), bds.bds60.mach60(m), bds.bds60.vr60baro(m), bds.bds60.vr60ins(m))
info = (commb.hdg60(m), commb.ias60(m), commb.mach60(m), commb.vr60baro(m), commb.vr60ins(m))
else:
info = None
@ -34,12 +34,12 @@ def bds_info(BDS, m):
return info
def ehs_decode_all(df, n=None):
def commb_decode_all(df, n=None):
import csv
print("===== Decode EHS sample data (DF=%s)=====" % df)
print("===== Decode Comm-B sample data (DF=%s)=====" % df)
f = open('tests/data/sample_data_ehs_df%s.csv' % df, 'rt')
f = open('tests/data/sample_data_commb_df%s.csv' % df, 'rt')
for i, r in enumerate(csv.reader(f)):
@ -50,7 +50,7 @@ def ehs_decode_all(df, n=None):
m = r[2]
df = common.df(m)
icao = ehs.icao(m)
icao = common.icao(m)
BDS = bds.infer(m)
code = common.altcode(m) if df == 20 else common.idcode(m)
@ -69,6 +69,7 @@ def ehs_decode_all(df, n=None):
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)
commb_decode_all(df=20, n=100)
commb_decode_all(df=21, n=100)

View File

@ -0,0 +1,20 @@
from pyModeS import bds
def test_bds_infer():
assert bds.infer("8D406B902015A678D4D220AA4BDA") == 'BDS08'
assert bds.infer("8FC8200A3AB8F5F893096B000000") == 'BDS06'
assert bds.infer("8D40058B58C901375147EFD09357") == 'BDS05'
assert bds.infer("8D485020994409940838175B284F") == 'BDS09'
assert bds.infer("A800178D10010080F50000D5893C") == 'BDS10'
assert bds.infer("A0000638FA81C10000000081A92F") == 'BDS17'
assert bds.infer("A0001838201584F23468207CDFA5") == 'BDS20'
assert bds.infer("A0001839CA3800315800007448D9") == 'BDS40'
assert bds.infer("A000139381951536E024D4CCF6B5") == 'BDS50'
assert bds.infer("A00004128F39F91A7E27C46ADC21") == 'BDS60'
def test_bds_is50or60():
assert bds.is50or60("A0001838201584F23468207CDFA5", 0, 0, 0) == None
assert bds.is50or60("A0000000FFDA9517000464000000", 182, 237, 1250) == 'BDS50'
assert bds.is50or60("A0000000919A5927E23444000000", 413, 54, 18700) == 'BDS60'

View File

@ -1,37 +1,46 @@
from pyModeS import bds, ehs, els
from pyModeS import bds, commb
from pyModeS import ehs, els # depricated
def test_bds_infer():
assert bds.infer("A0001838201584F23468207CDFA5") == 'BDS20'
assert bds.infer("A0001839CA3800315800007448D9") == 'BDS40'
assert bds.infer("A000139381951536E024D4CCF6B5") == 'BDS50'
assert bds.infer("A00004128F39F91A7E27C46ADC21") == 'BDS60'
def test_bds_is50or60():
assert bds.is50or60("A0001838201584F23468207CDFA5", 0, 0, 0) == None
assert bds.is50or60("A0000000FFDA9517000464000000", 182, 237, 1250) == 'BDS50'
assert bds.is50or60("A0000000919A5927E23444000000", 413, 54, 18700) == 'BDS60'
def test_els_BDS20_callsign():
def test_bds20_callsign():
assert bds.bds20.cs20("A000083E202CC371C31DE0AA1CCF") == 'KLM1017_'
assert bds.bds20.cs20("A0001993202422F2E37CE038738E") == 'IBK2873_'
assert commb.cs20("A000083E202CC371C31DE0AA1CCF") == 'KLM1017_'
assert commb.cs20("A0001993202422F2E37CE038738E") == 'IBK2873_'
assert els.cs20("A000083E202CC371C31DE0AA1CCF") == 'KLM1017_'
assert els.cs20("A0001993202422F2E37CE038738E") == 'IBK2873_'
def test_ehs_BDS40_functions():
def test_bds40_functions():
assert bds.bds40.alt40mcp("A000029C85E42F313000007047D3") == 3008
assert bds.bds40.alt40fms("A000029C85E42F313000007047D3") == 3008
assert bds.bds40.p40baro("A000029C85E42F313000007047D3") == 1020.0
assert commb.alt40mcp("A000029C85E42F313000007047D3") == 3008
assert commb.alt40fms("A000029C85E42F313000007047D3") == 3008
assert commb.p40baro("A000029C85E42F313000007047D3") == 1020.0
assert ehs.alt40mcp("A000029C85E42F313000007047D3") == 3008
assert ehs.alt40fms("A000029C85E42F313000007047D3") == 3008
assert ehs.p40baro("A000029C85E42F313000007047D3") == 1020.0
def test_ehs_BDS50_functions():
def test_bds50_functions():
assert bds.bds50.roll50("A000139381951536E024D4CCF6B5") == 2.1
assert bds.bds50.roll50("A0001691FFD263377FFCE02B2BF9") == -0.4 # signed value
assert bds.bds50.trk50("A000139381951536E024D4CCF6B5") == 114.258
assert bds.bds50.gs50("A000139381951536E024D4CCF6B5") == 438
assert bds.bds50.rtrk50("A000139381951536E024D4CCF6B5") == 0.125
assert bds.bds50.tas50("A000139381951536E024D4CCF6B5") == 424
assert commb.roll50("A000139381951536E024D4CCF6B5") == 2.1
assert commb.roll50("A0001691FFD263377FFCE02B2BF9") == -0.4 # signed value
assert commb.trk50("A000139381951536E024D4CCF6B5") == 114.258
assert commb.gs50("A000139381951536E024D4CCF6B5") == 438
assert commb.rtrk50("A000139381951536E024D4CCF6B5") == 0.125
assert commb.tas50("A000139381951536E024D4CCF6B5") == 424
assert ehs.roll50("A000139381951536E024D4CCF6B5") == 2.1
assert ehs.roll50("A0001691FFD263377FFCE02B2BF9") == -0.4 # signed value
assert ehs.trk50("A000139381951536E024D4CCF6B5") == 114.258
@ -39,12 +48,20 @@ def test_ehs_BDS50_functions():
assert ehs.rtrk50("A000139381951536E024D4CCF6B5") == 0.125
assert ehs.tas50("A000139381951536E024D4CCF6B5") == 424
def test_ehs_BDS60_functions():
def test_bds60_functions():
assert bds.bds60.hdg60("A00004128F39F91A7E27C46ADC21") == 42.715
assert bds.bds60.ias60("A00004128F39F91A7E27C46ADC21") == 252
assert bds.bds60.mach60("A00004128F39F91A7E27C46ADC21") == 0.42
assert bds.bds60.vr60baro("A00004128F39F91A7E27C46ADC21") == -1920
assert bds.bds60.vr60ins("A00004128F39F91A7E27C46ADC21") == -1920
assert commb.hdg60("A00004128F39F91A7E27C46ADC21") == 42.715
assert commb.ias60("A00004128F39F91A7E27C46ADC21") == 252
assert commb.mach60("A00004128F39F91A7E27C46ADC21") == 0.42
assert commb.vr60baro("A00004128F39F91A7E27C46ADC21") == -1920
assert commb.vr60ins("A00004128F39F91A7E27C46ADC21") == -1920
assert ehs.hdg60("A00004128F39F91A7E27C46ADC21") == 42.715
assert ehs.ias60("A00004128F39F91A7E27C46ADC21") == 252
assert ehs.mach60("A00004128F39F91A7E27C46ADC21") == 0.42