-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
bugSomething isn't workingSomething isn't working
Description
When reading samples from signals the current implementation is a bit quirky and deviates from expectations when reading memory mapped samples from a file IF those samples need to be scaled.
Consider the case where we read the sigmf logo from the main repository. This is a 2-channel real-valued audio file with samples stored as 16-bit integers.
>>> logo = sigmf.sigmffile.fromfile('sigmf_logo')
>>> logo.read_samples(count=3)
array([[-3.0517578e-05, 0.0000000e+00],
[ 6.1035156e-05, 0.0000000e+00],
[-6.1035156e-05, 0.0000000e+00]], dtype=float32)
>>> logo[0:3]
memmap([[-1, 0],
[ 2, 0],
[-2, 0]], dtype=int16)This happens because when using read_samples the scale factor is applied, but this is not done for the memory map.
I'm not sure the exact best solution for this, but I think we should fix #15 simultaneously since it will require tinkering with the same code.
Solutions I propose:
- Leave as-is
- When accesing the memory-map of a file that requires scaling, return of a copy of the data instead (by using
read_samplesprobably) - When accessing a memory-map return a scale parameter along with the data? or maybe a warning?
Fixing #15 I believe requires using the offset kwarg of np.memmap.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working