Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ htmlcov/*
# docs related
docs/_build/
docs/source/_autosummary/

# dev related
.vscode/
55 changes: 45 additions & 10 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ Read a SigMF Recording

import sigmf
handle = sigmf.fromfile("example.sigmf")
handle.read_samples() # returns all timeseries data
# reading data
handle.read_samples() # read all timeseries data
handle[10:50] # read memory slice of samples 10 through 50
# accessing metadata
handle.sample_rate # get sample rate attribute
handle.get_global_info() # returns 'global' dictionary
handle.get_captures() # returns list of 'captures' dictionaries
handle.get_annotations() # returns list of all annotations
handle[10:50] # return memory slice of samples 10 through 50

-----------------------------------
Verify SigMF Integrity & Compliance
Expand All @@ -52,16 +55,16 @@ Save a Numpy array as a SigMF Recording
data = np.zeros(1024, dtype=np.complex64)

# write those samples to file in cf32_le
data.tofile('example_cf32.sigmf-data')
data.tofile("example.sigmf-data")

# create the metadata
meta = SigMFFile(
data_file='example_cf32.sigmf-data', # extension is optional
data_file="example.sigmf-data", # extension is optional
global_info = {
SigMFFile.DATATYPE_KEY: get_data_type_str(data), # in this case, 'cf32_le'
SigMFFile.DATATYPE_KEY: get_data_type_str(data), # in this case, "cf32_le"
SigMFFile.SAMPLE_RATE_KEY: 48000,
SigMFFile.AUTHOR_KEY: '[email protected]',
SigMFFile.DESCRIPTION_KEY: 'All zero complex float32 example file.',
SigMFFile.AUTHOR_KEY: "[email protected]",
SigMFFile.DESCRIPTION_KEY: "All zero complex float32 example file.",
}
)

Expand All @@ -75,8 +78,40 @@ Save a Numpy array as a SigMF Recording
meta.add_annotation(100, 200, metadata = {
SigMFFile.FLO_KEY: 914995000.0,
SigMFFile.FHI_KEY: 915005000.0,
SigMFFile.COMMENT_KEY: 'example annotation',
SigMFFile.COMMENT_KEY: "example annotation",
})

# check for mistakes & write to disk
meta.tofile('example_cf32.sigmf-meta') # extension is optional
# validate & write to disk
meta.tofile("example.sigmf-meta") # extension is optional

----------------------------------
Attribute Access for Global Fields
----------------------------------

SigMF-Python provides convenient attribute read/write access for core global
metadata fields, allowing you use simple dot notation alongside the traditional
method-based approach.

.. code-block:: python

import sigmf

# read some recording
meta = sigmf.SigMFFile("sigmf_logo")

# read global metadata
print(f"Sample rate: {meta.sample_rate}")
print(f"License: {meta.license}")

# set global metadata
meta.description = "Updated description via attribute access"
meta.author = "[email protected]"

# validate & write changes to disk
meta.tofile("sigmf_logo_updated")

.. note::

Only core **global** fields support attribute access. Capture and annotation
fields must still be accessed using the traditional ``get_captures()`` and
``get_annotations()`` methods.
2 changes: 1 addition & 1 deletion sigmf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-later

# version of this python module
__version__ = "1.2.12"
__version__ = "1.3.0"
# matching version of the SigMF specification
__specification__ = "1.2.5"

Expand Down
Loading