Skip to content

Commit ce8f266

Browse files
committed
converter homologation
1 parent e21fca8 commit ce8f266

2 files changed

Lines changed: 7 additions & 19 deletions

File tree

sigmf/convert/blue.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def data_loopback(blue_path: Path, data_path: Path, h_fixed: dict) -> None:
328328
numpy.ndarray
329329
Parsed samples. Empty array for zero-sample files.
330330
"""
331-
header_bytes, data_bytes, _ = _get_data_boundaries(blue_path, h_fixed)
331+
header_bytes, data_bytes, _ = _get_blue_boundaries(blue_path, h_fixed)
332332
blue_format = h_fixed.get("format")
333333

334334
# use header data_size field instead of file size calculation
@@ -371,7 +371,7 @@ def data_loopback(blue_path: Path, data_path: Path, h_fixed: dict) -> None:
371371
log.info("wrote SigMF dataset to %s", data_path)
372372

373373

374-
def _get_data_boundaries(blue_path: Path, h_fixed: dict) -> (int, int):
374+
def _get_blue_boundaries(blue_path: Path, h_fixed: dict) -> (int, int):
375375
"""
376376
Extract data boundaries from fixed header.
377377
"""
@@ -434,11 +434,6 @@ def _build_common_metadata(
434434
-------
435435
tuple[dict, dict]
436436
(global_info, capture_info) dictionaries.
437-
438-
Raises
439-
------
440-
SigMFConversionError
441-
If SigMF spec compliance is violated.
442437
"""
443438
# helper to look up extended header values by tag
444439
def get_tag(tag):
@@ -516,16 +511,9 @@ def get_tag(tag):
516511
capture_info[SigMFFile.DATETIME_KEY] = blue_datetime.strftime(SIGMF_DATETIME_ISO8601_FMT)
517512

518513
if get_tag("RF_FREQ") is not None:
519-
# it's possible other keys indicate tune frequency, but RF_FREQ is standard
514+
# it's possible other keys indicate tune frequency, but RF_FREQ is common
520515
capture_info[SigMFFile.FREQUENCY_KEY] = float(get_tag("RF_FREQ"))
521516

522-
# validate SigMF spec compliance: metadata_only and dataset fields are mutually exclusive
523-
if SigMFFile.METADATA_ONLY_KEY in global_info and SigMFFile.DATASET_KEY in global_info:
524-
raise SigMFConversionError(
525-
"SigMF spec violation: core:metadata_only MAY NOT be used in conjunction with "
526-
"Non-Conforming Datasets or the core:dataset field"
527-
)
528-
529517
return global_info, capture_info
530518

531519

@@ -709,7 +697,7 @@ def construct_sigmf_ncd(
709697
SigMFFile
710698
NCD SigMF object pointing to original BLUE file.
711699
"""
712-
header_bytes, data_bytes, trailing_bytes = _get_data_boundaries(blue_path, h_fixed)
700+
header_bytes, data_bytes, trailing_bytes = _get_blue_boundaries(blue_path, h_fixed)
713701

714702
# use shared helper to build common metadata, with NCD-specific additions
715703
global_info, capture_info = _build_common_metadata(

sigmf/convert/wav.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import wave
1313
from datetime import datetime, timezone
1414
from pathlib import Path
15-
from typing import Optional
15+
from typing import Optional, Tuple
1616

1717
import numpy as np
1818

@@ -25,7 +25,7 @@
2525
log = logging.getLogger()
2626

2727

28-
def _calculate_wav_ncd_bytes(wav_path: Path) -> tuple:
28+
def _get_wav_boundaries(wav_path: Path) -> Tuple[int, int]:
2929
"""
3030
Calculate header_bytes and trailing_bytes for WAV NCD.
3131
@@ -120,7 +120,7 @@ def wav_to_sigmf(
120120

121121
# for NCD support, calculate precise byte boundaries
122122
if create_ncd:
123-
header_bytes, trailing_bytes = _calculate_wav_ncd_bytes(wav_path)
123+
header_bytes, trailing_bytes = _get_wav_boundaries(wav_path)
124124
log.debug(f"WAV NCD: header_bytes={header_bytes}, trailing_bytes={trailing_bytes}")
125125

126126
# only read audio data if we're not creating NCD metadata-only

0 commit comments

Comments
 (0)