Expand description
Reading and writing sampled signals: measured captures and reference sequences.
Three formats cover the usual outputs of oscilloscopes, software-defined radios and numerical tools:
- SigMF (the Signal Metadata Format of GNU Radio and the SDR community): a JSON
file
name.sigmf-metawith the data type and the sampling rate, next to the raw samplesname.sigmf-data;read_sigmf,write_sigmf; - raw interleaved samples with a SigMF data type (
cf32_leis the.cfileof GNU Radio,ci16_lethe IQ format of most SDRs and many oscilloscopes);read_raw,write_raw; - NPY arrays of NumPy (complex, real or integer, one dimension);
read_npy,write_npy,write_npy_i64.
read_samples picks the format from the extension. Integer samples are converted
to floating point without scaling (the receivers normalise the power).
§Examples
use comnum_spec::io::{read_sigmf, write_sigmf, Datatype};
use comnum_math::C64;
let dir = std::env::temp_dir().join("comnum-doc-io");
let x: Vec<C64> = (0..8).map(|k| C64::new(k as f64, -(k as f64))).collect();
write_sigmf(dir.join("capture"), &x, Datatype::CI16, 64e9, None).unwrap();
let c = read_sigmf(dir.join("capture.sigmf-meta")).unwrap();
assert_eq!(c.samples, x);
assert_eq!((c.sample_rate, c.datatype), (Some(64e9), Datatype::CI16));Structs§
- Annotation
- An annotation of a SigMF recording.
- Capture
- A capture segment of a SigMF recording.
- Datatype
- A sample format of SigMF:
[c|r][f32|f64|i32|i16|i8|u32|u16|u8][_le|_be](the 8-bit types without endianness). - Npy
- An NPY array: its shape and its data in C order.
- Samples
- The samples of one channel of a recording (
read_samples). - SigMF
- A SigMF recording.
Enums§
Functions§
- read_
npy - Read an NPY array (little-endian numbers or booleans, C order or one dimension).
- read_
raw - Read raw interleaved samples.
- read_
samples - Read samples from a SigMF recording (
.sigmf-meta,.sigmf-data,.sigmf), an NPY array (.npy) or a raw file of the given data type: the samples ofchanneland the sampling rate when the file records it. - read_
sigmf - Read a SigMF recording from its
.sigmf-metaor.sigmf-datafile, their common base name, or a.sigmfarchive (the first recording of the archive). - write_
npy - Write a one-dimensional complex NPY array (
<c16). - write_
npy_ i64 - Write a one-dimensional integer NPY array (
<i8), e.g. symbol indices. - write_
raw - Write raw interleaved samples (integer types are rounded and saturated).
- write_
sigmf - Write a SigMF recording
base.sigmf-metaandbase.sigmf-data. - write_
sigmf_ annotated - Write a SigMF recording with the centre frequency of its capture (
core:frequency) and annotations (seewrite_sigmf).