comnum.read_sigmf#

comnum.read_sigmf(path, *, channel=Ellipsis, autoscale=False)#

Read a SigMF recording (SigMF 1.x: every data type, little or big endian, several channels, capture headers, trailing bytes, .sigmf archives).

Parameters:
  • path (str | os.PathLike) – the .sigmf-meta or .sigmf-data file, their base name, or a .sigmf archive.

  • channel (int | None) – the channel to read (the first by default, a 1-D array); None: every channel, an array (num_channels, n).

  • autoscale (bool) – divide integer samples by their full scale 2^(b-1) (the values of sigmf-python); otherwise integers are converted without scaling (unsigned types centred by 2^(b-1)).

Returns:

the samples (complex128), the sampling rate fs (Hz) and the metadata (meta["captures"], meta["annotations"]…).

Return type:

tuple[numpy.ndarray, float | None, dict]

Raises:
  • OSError – if a file cannot be read.

  • ValueError – for invalid metadata, an unknown data type or a channel beyond those of the recording.

Examples

>>> import comnum, numpy as np, tempfile, os
>>> base = os.path.join(tempfile.mkdtemp(), "x")
>>> comnum.write_sigmf(base, np.array([1, 1j]), 1e6, fc_hz=2.4e9,
...                   annotations=[{"sample_start": 1, "label": "QPSK"}])
>>> x, fs, meta = comnum.read_sigmf(base)
>>> meta["captures"][0]["core:frequency"], meta["annotations"][0]["core:label"]
(2400000000.0, 'QPSK')