comnum.write_sigmf#

comnum.write_sigmf(base, samples, fs, *, datatype='cf64', fc_hz=None, annotations=None, global_meta=None)#

Write a SigMF recording base.sigmf-meta and base.sigmf-data.

Parameters:
  • base (str | os.PathLike) – path without the extensions.

  • samples (array_like) – complex samples.

  • fs (float) – sampling rate (Hz).

  • datatype (str) – the sample format, as the dump block: cf64 (the default), cf32 or ci16; every SigMF type is accepted ([c|r][f32|f64|i32|i16|i8|u32|u16|u8][_le|_be]; integers are rounded and saturated: scale the samples first).

  • fc_hz (float | None) – the centre frequency of the capture (Hz).

  • annotations (list[dict] | None) – annotations, with the keys sample_start, and optionally sample_count, label, comment, freq_lower_edge, freq_upper_edge.

  • global_meta (dict, optional) – keys added to the global object of the metadata (a description, the symbol rate, …).

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

  • ValueError – for an unknown data type or an invalid annotation.

Examples

>>> import comnum, numpy as np, tempfile, os
>>> base = os.path.join(tempfile.mkdtemp(), "x")
>>> comnum.write_sigmf(base, np.array([1, 1j]), 1e6)
>>> x, fs, meta = comnum.read_sigmf(base)
>>> x.tolist(), fs, meta["global"]["core:datatype"]
([(1+0j), 1j], 1000000.0, 'cf64_le')