Skip to content

Commit

Permalink
fixed a bug and added notes to spec per discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
Teque5 committed Jul 10, 2021
1 parent 2dd5b36 commit a43e871
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ pip install .
```python
import sigmf
handle = sigmf.sigmffile.fromfile('example.sigmf')
handle.read_samples() # returns timeseries data
handle.get_global_info() # returns 'global' metadata dictionary
handle.get_captures() # returns 'captures' metadata dictionary
handle.read_samples() # returns all timeseries data
handle.get_global_info() # returns 'global' dictionary
handle.get_captures() # returns list of 'captures' dictionaries
handle.get_annotations() # returns list of all annotations
```

Expand Down
12 changes: 9 additions & 3 deletions sigmf-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ dataset file MUST NOT contain any other characters (e.g., delimiters,
whitespace, line-endings, `EOF` characters, etc.,).

Complex samples should be interleaved, with the in-phase component first (i.e.,
`I[0]` `Q[0]` `I[1]` `Q[1]` ... `I[n]` `Q[n]`). Also note that the `type`
applies to not only the real but also the imaginary component of a complex
sample.
`I[0]` `Q[0]` `I[1]` `Q[1]` ... `I[n]` `Q[n]`). When `core:num_channels` in the
`global` object indicates that the recording contains more than one channel,
samples from those channels should be interleaved in the same manner, with
the same index from each channel's sample serially in the recording. For
example, a recording with two channels of `i16_le` representing real-valued
audio data from a stereo recording and here labeled `L` for left and `R` for
right, the data should appear as `L[0]` `R[0]` `L[1]` `R[1]` ... `L[n]` `R[n]`.
The data type specified by `core:data_type` applies to all channels of data
both real and imaginary parts.

### Metadata Format

Expand Down
4 changes: 2 additions & 2 deletions sigmf/sigmffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ def _count_samples(self):
sample_size = self.get_sample_size()
num_channels = self.get_num_channels()
sample_count = file_size // sample_size // num_channels
if file_size % sample_size != 0:
warnings.warn("File '{}' does not contain an integral number of sample. It might not be valid data.".format(self.data_file))
if file_size % sample_count != 0:
warnings.warn("File '{}' does not contain an integer number of samples. It may be invalid data.".format(self.data_file))
if len(annotations) > 0 and annotations[-1][self.START_INDEX_KEY] + annotations[-1][self.LENGTH_INDEX_KEY] > sample_count:
warnings.warn("File '{}' ends before the final annotation in the corresponding SigMF metadata.".format(self.data_file))
self.sample_count = sample_count
Expand Down

0 comments on commit a43e871

Please sign in to comment.