comnum.ais_decode#
- comnum.ais_decode(bits)#
Decode the bits of an AIS message (ITU-R M.1371-5, Annex 8): the position reports (messages 1, 2, 3, 18), the base station report (4), the static and voyage data (5) and the class B static data (24); any other message gives its type and MMSI.
- Parameters:
bits (array_like) – the message bits, most significant first (the payload of a sentence,
ais_messages()).- Returns:
msg_type,mmsi,repeatand the fields of the message: aposition(lon_deg,lat_deg,accurate,sog_knots,cog_deg,heading_deg,timestamp;Nonefor a value “not available”) andnav_status,rot_raw,manoeuvre,raim(1, 2, 3);utc,epfd(4);imo,callsign,shipname,ship_type,dimensions,eta,draught_m,destination,dte(5);cs_unit(18);partandshipnameorship_type,vendor,model,serial,callsign,dimensions(24).- Return type:
- Raises:
ValueError – for fewer than 38 bits, a type outside 1 to 27 or a message shorter than its table.
Examples
>>> import comnum >>> bits = comnum.ais_position_report(200000001, lat_deg=46.12, lon_deg=-9.88, sog_knots=8.0) >>> m = comnum.ais_decode(bits) >>> m["msg_type"], m["mmsi"], round(m["position"]["lat_deg"], 2) (1, 200000001, 46.12)