IO Package (ria_toolkit_oss.io)

The IO package contains utilities for input and output operations, such as loading and saving recordings to and from file.

Recording

Utilities for input/output operations on the ria_toolkit_oss.datatypes.Recording object.

ria_toolkit_oss.io.recording.load_rec(file)[source]

Load a recording from file.

Parameters:

file (PathLike) – The directory path to the file(s) to load, with the file extension. To loading from SigMF, the file extension must be one of sigmf, sigmf-data, or sigmf-meta, either way both the SigMF data and meta files must be present for a successful read.

Raises:
  • IOError – If there is an issue encountered during the file reading process.

  • ValueError – If the inferred file extension is not supported.

Returns:

The recording, as initialized from file(s).

Return type:

Recording

ria_toolkit_oss.io.recording.convert_to_serializable(obj)[source]

Recursively convert a JSON-compatible structure into a fully JSON-serializable one. Handles cases like NumPy data types, nested dicts, lists, and sets.

ria_toolkit_oss.io.recording.to_sigmf(recording, filename=None, path=None)[source]

Write recording to a set of SigMF files.

The SigMF io format is defined by the SigMF Specification Project

Parameters:
  • recording (Recording) – The recording to be written to file.

  • filename (PathLike or str, optional) – The name of the file where the recording is to be saved. Defaults to auto generated filename.

  • path (PathLike or str, optional) – The directory path to where the recording is to be saved. Defaults to recordings/.

Raises:

IOError – If there is an issue encountered during the file writing process.

Returns:

None

Examples:

>>> from ria_toolkit_oss.sdr import Synth
>>> from ria_toolkit_oss.data import Recording
>>> from ria_toolkit_oss.io import to_sigmf
>>> sdr = Synth()
>>> rec = sdr.record(center_frequency=2.4e9, sample_rate=20e6)
>>> to_sigmf(recording=rec, file="sample_recording")
ria_toolkit_oss.io.recording.from_sigmf(file)[source]

Load a recording from a set of SigMF files.

Parameters:

file (str or PathLike) – The directory path to the SigMF recording files, without any file extension. The recording will be initialized from file_name.sigmf-data and file_name.sigmf-meta. Both the data and meta files must be present for a successful read.

Raises:

IOError – If there is an issue encountered during the file reading process.

Returns:

The recording, as initialized from the SigMF files.

Return type:

Recording

ria_toolkit_oss.io.recording.to_npy(recording, filename=None, path=None)[source]

Write recording to .npy binary file.

Parameters:
  • recording (Recording) – The recording to be written to file.

  • filename (PathLike or str, optional) – The name of the file where the recording is to be saved. Defaults to auto generated filename.

  • path (PathLike or str, optional) – The directory path to where the recording is to be saved. Defaults to recordings/.

Raises:

IOError – If there is an issue encountered during the file writing process.

Returns:

Path where the file was saved.

Return type:

str

Examples:

>>> from ria_toolkit_oss.sdr import Synth
>>> from ria_toolkit_oss.data import Recording
>>> from ria_toolkit_oss.io import to_npy
>>> sdr = Synth()
>>> rec = sdr.record(center_frequency=2.4e9, sample_rate=20e6)
>>> to_npy(recording=rec, file="sample_recording.npy")
ria_toolkit_oss.io.recording.from_npy(file)[source]

Load a recording from a .npy binary file.

Parameters:

file (str or PathLike) – The directory path to the recording file, with or without the .npy file extension.

Raises:

IOError – If there is an issue encountered during the file reading process.

Returns:

The recording, as initialized from the .npy file.

Return type:

Recording