Skip to content

Commit 9195ff3

Browse files
Made code updates based on PR input. Still need to work on returning SigMF object instead of dictionary
Updated the last modified date and refactored comments for clarity.
1 parent fe8c0cd commit 9195ff3

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

sigmf/convert/signalhound.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This file is part of sigmf-python. https://github.com/sigmf/sigmf-python
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
6-
# last updated 2-16-26
6+
# last updated 3-02-26
77

88
"""converter for signalhound files to SigMF format."""
99

@@ -30,17 +30,7 @@
3030

3131
import sys
3232

33-
# Define constants for Spike
34-
ENDIANNESS = "<"
35-
DATATYPE = "ci16_le" # complex short int16 little-endian
36-
# DATATYPE_SIZE = 4 # bytes per complex int16 sample (2 bytes I + 2 bytes Q)
37-
38-
logging.basicConfig(
39-
level=logging.INFO,
40-
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
41-
stream=sys.stdout, # ensure logs go to stdout (or use sys.stderr)
42-
)
43-
33+
# Use logging defined in __main__.py
4434
log = logging.getLogger()
4535

4636
def _to_float(x) -> Optional[float]:
@@ -58,7 +48,7 @@ def _to_int(x) -> Optional[int]:
5848
except Exception:
5949
return None
6050

61-
def _parse_preview_trace(text) -> list[float]:
51+
def _parse_preview_trace(text) -> List[float]:
6252
"""Parse PreviewTrace string into list of floats."""
6353
if text is None:
6454
return []
@@ -354,7 +344,8 @@ def signalhound_to_sigmf(
354344
if out_path is None:
355345
create_ncd = True
356346

357-
# TODO: Should time be based on file modification time or the EpochNanos field in the XML metadata? For now using file modification time since it is more likely to be present and accurate for the actual data capture time, whereas the EpochNanos field may be missing or inaccurate in some cases. This can be revisited in the future if needed based on user feedback or specific use cases.
347+
# TODO: Should time be based on file modification time or the EpochNanos field in the XML metadata?
348+
# For now using file modification time
358349
modify_time = signalhound_path.lstat().st_mtime
359350
signalhound_datetime = datetime.fromtimestamp(modify_time, tz=timezone.utc)
360351

@@ -389,18 +380,12 @@ def signalhound_to_sigmf(
389380
annot_metadata = {k: v for k, v in annotation.items()
390381
if k not in [SigMFFile.START_INDEX_KEY, SigMFFile.LENGTH_INDEX_KEY]}
391382
meta.add_annotation(start_idx, length=length, metadata=annot_metadata)
392-
393-
383+
394384
# Manually set the fields that set_data_file() would normally populate
385+
# TODO: Consider refactoring to use set_data_file() for better consistency
395386
meta._data_file_offset = header_bytes
396387
meta._data_file_size = data_bytes
397388
meta._data_file_skip_checksum = True
398-
399-
# TODO: Determine how to use memmap to avoid issues in SigMFFile.
400-
# Explicitly disable memmap for SignalHound files since they may not be compatible with memmap
401-
# meta._data_file_is_memmap = False
402-
# meta._data_file_memmap_shape = None
403-
# meta._data_file_is_binary = True
404389

405390
# Get filenames for metadata, data, and archive based on output path and input file name
406391
filenames = get_sigmf_filenames(out_path)

0 commit comments

Comments
 (0)