comnum.ais_receive#

comnum.ais_receive(x, fs)#

The packets of an AIS channel at baseband: the polar discriminator, an integrator over half a bit, the frequency offset of the transmitter removed, a bit clock from the zero crossings, NRZI decoding and the HDLC frames whose frame check sequence is correct, decoded by ais_decode(). The channel (161.975 or 162.025 MHz, 25 kHz wide) is brought to baseband by select_channel() at fs.

Parameters:
  • x (array_like) – the channel at baseband.

  • fs (float) – its sampling rate, an even multiple of 9600 Hz (16 samples per bit, 153 600 Hz, is the rate of the receiver’s design).

Returns:

for every packet, start_bit (the bit of the line where its flag starts; the time is start_bit / 9600), bits (uint8), aivdm (the sentences, channel A), and message (the dictionary of ais_decode()) or error (why it could not be decoded).

Return type:

list[dict]

Raises:

ValueError – for the sampling rate, or fewer than 64 bits of signal.

Examples

>>> import comnum
>>> fs = comnum.ais_front_end_rate()
>>> bits = comnum.ais_position_report(200000001, lat_deg=46.12, lon_deg=-9.88)
>>> x = comnum.ais_transmit([bits], fs)
>>> [p["message"]["mmsi"] for p in comnum.ais_receive(x, fs)]
[200000001]