Remove rounding in pyModeS (#147)

* Update bds50.py: round roll to 3 places instead of 1

Provide a bit more detail for smaller roll angles.

* remove rounding

* update poetry

* update poetry

* update test

* update bds06

* update workflow

---------

Co-authored-by: Junzi Sun <junzisun@gmail.com>
This commit is contained in:
Paul de Jong
2023-05-22 17:00:58 +02:00
committed by GitHub
parent 8403cb61e4
commit 50864b56aa
13 changed files with 265 additions and 261 deletions

View File

@@ -82,7 +82,7 @@ def airborne_position(
if lon > 180:
lon = lon - 360
return round(lat, 5), round(lon, 5)
return lat, lon
def airborne_position_with_ref(
@@ -129,7 +129,7 @@ def airborne_position_with_ref(
lon = d_lon * (m + cprlon)
return round(lat, 5), round(lon, 5)
return lat, lon
def altitude(msg: str) -> None | int:

View File

@@ -19,7 +19,6 @@ def surface_position(
lat_ref: float,
lon_ref: float,
) -> None | tuple[float, float]:
"""Decode surface position from a pair of even and odd position message,
the lat/lon of receiver must be provided to yield the correct solution.
@@ -92,7 +91,7 @@ def surface_position(
imin = min(range(4), key=dls.__getitem__)
lon = lons[imin]
return round(lat, 5), round(lon, 5)
return lat, lon
def surface_position_with_ref(
@@ -139,12 +138,12 @@ def surface_position_with_ref(
lon = d_lon * (m + cprlon)
return round(lat, 5), round(lon, 5)
return lat, lon
def surface_velocity(
msg: str, source: bool = False
) -> tuple[None | float, float, int, str]:
) -> tuple[None | float, None | float, int, str]:
"""Decode surface velocity from a surface position message
Args:
@@ -173,7 +172,6 @@ def surface_velocity(
trk_status = int(mb[12])
if trk_status == 1:
trk = common.bin2int(mb[13:20]) * 360 / 128
trk = round(trk, 1)
else:
trk = None

View File

@@ -48,7 +48,6 @@ def airborne_velocity(
spd: None | float
if subtype in (1, 2):
v_ew = common.bin2int(mb[14:24])
v_ns = common.bin2int(mb[25:35])
@@ -77,7 +76,7 @@ def airborne_velocity(
trk = math.degrees(trk) # convert to degrees
trk = trk if trk >= 0 else trk + 360 # no negative val
trk_or_hdg = round(trk, 2)
trk_or_hdg = trk
spd_type = "GS"
dir_type = "TRUE_NORTH"
@@ -87,7 +86,6 @@ def airborne_velocity(
hdg = None
else:
hdg = common.bin2int(mb[14:24]) / 1024 * 360.0
hdg = round(hdg, 2)
trk_or_hdg = hdg

View File

@@ -72,7 +72,7 @@ def wind44(msg: str) -> Tuple[Optional[int], Optional[float]]:
speed = common.bin2int(d[5:14]) # knots
direction = common.bin2int(d[14:23]) * 180 / 256 # degree
return round(speed, 0), round(direction, 1)
return speed, direction
def temp44(msg: str) -> Tuple[float, float]:
@@ -96,10 +96,8 @@ def temp44(msg: str) -> Tuple[float, float]:
value = value - 1024
temp = value * 0.25 # celsius
temp = round(temp, 2)
temp_alternative = value * 0.125 # celsius
temp_alternative = round(temp_alternative, 3)
return temp, temp_alternative
@@ -140,7 +138,7 @@ def hum44(msg: str) -> Optional[float]:
hm = common.bin2int(d[50:56]) * 100 / 64 # %
return round(hm, 1)
return hm
def turb44(msg: str) -> Optional[int]:

View File

@@ -171,7 +171,6 @@ def temp45(msg: str) -> Optional[float]:
value = value - 512
temp = value * 0.25 # celsius
temp = round(temp, 1)
return temp

View File

@@ -81,7 +81,7 @@ def roll50(msg: str) -> Optional[float]:
value = value - 512
angle = value * 45 / 256 # degree
return round(angle, 1)
return angle
def trk50(msg: str) -> Optional[float]:
@@ -110,7 +110,7 @@ def trk50(msg: str) -> Optional[float]:
if trk < 0:
trk = 360 + trk
return round(trk, 3)
return trk
def gs50(msg: str) -> Optional[float]:
@@ -154,7 +154,7 @@ def rtrk50(msg: str) -> Optional[float]:
value = value - 512
angle = value * 8 / 256 # degree / sec
return round(angle, 3)
return angle
def tas50(msg: str) -> Optional[float]:

View File

@@ -86,7 +86,7 @@ def hdg53(msg: str) -> Optional[float]:
if hdg < 0:
hdg = 360 + hdg
return round(hdg, 3)
return hdg
def ias53(msg: str) -> Optional[float]:
@@ -122,7 +122,7 @@ def mach53(msg: str) -> Optional[float]:
return None
mach = common.bin2int(d[24:33]) * 0.008
return round(mach, 3)
return mach
def tas53(msg: str) -> Optional[float]:
@@ -140,7 +140,7 @@ def tas53(msg: str) -> Optional[float]:
return None
tas = common.bin2int(d[34:46]) * 0.5 # kts
return round(tas, 1)
return tas
def vr53(msg: str) -> Optional[int]:

View File

@@ -200,7 +200,6 @@ def selected_heading(msg: str) -> None | float:
else:
hdg_sign = int(mb[30])
hdg = (hdg_sign + 1) * common.bin2int(mb[31:39]) * (180 / 256)
hdg = round(hdg, 2)
return hdg

View File

@@ -130,12 +130,12 @@ def flarm(long timestamp, str msg, float refLat, float refLon, **kwargs):
return dict(
timestamp=timestamp,
icao24=icao24,
latitude=round(lat * 1e-7, 6),
longitude=round(lon * 1e-7, 6),
latitude=lat * 1e-7,
longitude=lon * 1e-7,
geoaltitude=altitude,
vertical_speed=raw_vs * mult_factor / 10,
groundspeed=round(speed),
track=round(heading4 - 4 * turningRate(heading4, heading8) / 4),
groundspeed=speed,
track=heading4 - 4 * turningRate(heading4, heading8) / 4,
type=AIRCRAFT_TYPES[aircraft_type],
sensorLatitude=refLat,
sensorLongitude=refLon,