Skip to content

Compression Support & New sigmf.fromarray method#146

Merged
Teque5 merged 5 commits intomainfrom
feature/compressed-support
May 1, 2026
Merged

Compression Support & New sigmf.fromarray method#146
Teque5 merged 5 commits intomainfrom
feature/compressed-support

Conversation

@Teque5
Copy link
Copy Markdown
Collaborator

@Teque5 Teque5 commented Apr 25, 2026

Closes #26. Adds read/write support for compressed SigMF archives (.sigmf.gz, .sigmf.xz, .sigmf.zip) using only stdlib so no new dependencies are needed. Compression uses tarfile for gzip/xz and zipfile for zip.

Also fixed performance issue where reading uncompressed .sigmf archives was extracting data to RAM — these are now numpy memmapped directly into the tar.

Also added a sigmf.fromarray() convenience function to mirror sigmf.fromfile(). It infers the SigMF datatype from the numpy dtype. This can then be used with existing tofile() method:

data = np.array([<SOME_STUFF>], dtype=<SOME_DTYPE>)
meta = sigmf.fromarray(data, sample_rate=48000)
meta.tofile("x") # create `x.sigmf-data` and `x.sigmf-meta` pair
meta.tofile("x.sigmf.gz") # create `x.sigmf.gz` compressed archive

@Teque5 Teque5 self-assigned this Apr 25, 2026
@Teque5 Teque5 added the enhancement New feature or request label Apr 25, 2026
@Teque5 Teque5 force-pushed the feature/compressed-support branch from c0147fc to 05ac806 Compare April 29, 2026 17:58
@Teque5
Copy link
Copy Markdown
Collaborator Author

Teque5 commented Apr 30, 2026

I'm actually going to block my own PR here and slightly improve this before we merge it.

  • Allow meta.tofile('some.sigmf') to imply archive=True
  • Allow meta.tofile('some.sigmf.xz') to imply archive=True and compression='xz'

* fromarray() only creates SigMFFile object from numpy array, doesn't
  write files
* SigMFFile.tofile() auto-detects archive/compression from extension
* when data_buffer exists, will also write `.sigmf-data`, like when
  using (SigMFGenerator)
* added more tests
@Teque5 Teque5 changed the title Compression Support & New sigmf.tofile method Compression Support & New sigmf.fromarray method May 1, 2026
@Teque5 Teque5 merged commit eb19378 into main May 1, 2026
10 checks passed
@Teque5 Teque5 deleted the feature/compressed-support branch May 1, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compressed Archive Support

2 participants