feat: add SigMFReader for .sigmf-data/.sigmf-meta file pairs (closes #282)#463
Open
easton-ring wants to merge 7 commits into
Open
feat: add SigMFReader for .sigmf-data/.sigmf-meta file pairs (closes #282)#463easton-ring wants to merge 7 commits into
easton-ring wants to merge 7 commits into
Conversation
Implements FileReader subclass that loads SigMF file pairs as TorchSig datasets without requiring the sigmf library. Supports cf32, cf64, ci32, ci16, ci8, cu8 datatypes. Handles multi-file roots (annotations from all .sigmf-data files are concatenated in sorted order). Closes TorchDSP#282. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix _find_meta_for_data candidate_a path for foo.sigmf-meta convention - Sanitize colon-keyed annotation fields (lora:x → lora_x) for attribute access - Raise ValueError on sample_count=0 instead of returning empty Signal - Replace unreachable class_index=-1 fallback with assert - Set writer_class=None (never reachable; create_handler raises for write mode) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 tests covering: - Dtype roundtrips (cf32_le, ci16_le/be, ci8, cu8) - Byte offset indexing (single and multi-file) - Metadata mapping (sample_rate, center_freq, class_name/index, custom fields) - Both .sigmf-meta naming conventions - StaticTorchSigDataset integration - Error cases (no files, bad dtype, sample_count=0, write mode) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gMFReader Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le_handlers Remove the inline BYODExampleFileHandler class definition; import and use the new SigMFReader directly. Add a multi-file demo cell showing two .sigmf pairs in one root with annotation counts verified via assert.
Add overwrite=True to both meta.tofile() calls so re-execution does not raise SigMFFileExistsError. Move kernelspec from top-level notebook JSON into metadata where nbformat schema expects it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ca286b0 to
911817f
Compare
Collaborator
|
This code looks really useful, so thank you. If you could resolve the merge conflicts I can merge it into main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SigMFReader(FileReader)andSigMFFileHandler(BaseFileHandler)totorchsig.utils.file_handlers, enabling users to load.sigmf-data+.sigmf-metafile pairs as TorchSig datasets viaStaticTorchSigDataset.Closes #282.
What's new
torchsig/utils/file_handlers/sigmf.py— newSigMFReader+SigMFFileHandlercf32_le/be,cf64_le,ci32_le/be,ci16_le/be,ci8,cu8np.complex64import sigmfdependency — JSON parsed directly (avoids >2 GB memmap limitation).sigmf-metaand.sigmf-data.sigmf-metanaming conventionscore:num_channels > 1) raisesNotImplementedErrorwith a clear messagetorchsig/utils/file_handlers/__init__.py—SigMFReader,SigMFFileHandleradded to exportstests/utils/test_sigmf_reader.py— 25 tests covering dtype handling, indexing, metadata mapping,StaticTorchSigDatasetintegration, andSigMFFileHandlerexamples/bring_your_own_data_sigmf_example.ipynb— updated to use the newSigMFReaderimport; inline class definition removed; multi-file usage cell addedUsage
Test plan
pytest tests/utils/test_sigmf_reader.py -v— 25 tests pass, 0 failurespytest tests/ -x -q— full suite passes, 0 regressionspylint --rcfile=.pylintrc torchsig/utils/file_handlers/sigmf.py tests/utils/test_sigmf_reader.py— both score 10.00/10python -c "import torchsig; print(torchsig.__version__)"→2.1.2import sigmfanywhere intorchsig/utils/file_handlers/sigmf.py