Skip to content

Commit ccc1cbf

Browse files
authored
Track Specification within Repo & Polish (#57)
* Add new sigmf.__specification__ variable that tracks SigMF Spec release version * Fix logo visible in PyPi (only png works there, although svg does render on GitHub) * Replace outdated links from gnuradio to sigmf organization. * Adjust sigmf_convert_wav so that it reads xyz.wav and produces a simple xyz.sigmf. Also basic polish of implementation * Make license statement same across all files.
1 parent 1b03f63 commit ccc1cbf

22 files changed

+262
-254
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<p align="center"><img src="https://github.com/gnuradio/SigMF/blob/sigmf-v1.x/logo/sigmf_logo.svg" alt="Rendered SigMF Logo"/></p>
1+
<p align="center"><img src="https://github.com/sigmf/SigMF/blob/v1.2.0/logo/sigmf_logo.png" alt="Rendered SigMF Logo"/></p>
22

33
This python module makes it easy to interact with Signal Metadata Format
44
(SigMF) recordings. This module works with Python 3.7+ and is distributed
55
freely under the terms GNU Lesser GPL v3 License.
66

77
The [SigMF specification document](https://github.com/sigmf/SigMF/blob/HEAD/sigmf-spec.md)
8-
is located in the [SigMF](https://github.com/gnuradio/SigMF) repository.
8+
is located in the [SigMF](https://github.com/sigmf/SigMF) repository.
99

1010
# Installation
1111

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "SigMF"
33
description = "Easily interact with Signal Metadata Format (SigMF) recordings."
4-
keywords = ["gnuradio"]
4+
keywords = ["gnuradio", "radio"]
55
classifiers = [
66
"Development Status :: 5 - Production/Stable",
77
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
@@ -13,6 +13,8 @@ classifiers = [
1313
"Programming Language :: Python :: 3.10",
1414
"Programming Language :: Python :: 3.11",
1515
"Programming Language :: Python :: 3.12",
16+
"Topic :: Scientific/Engineering",
17+
"Topic :: Communications :: Ham Radio",
1618
]
1719
dynamic = ["version", "readme"]
1820
requires-python = ">=3.7"

sigmf/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# Copyright: Multiple Authors
22
#
3-
# This file is part of SigMF. https://github.com/sigmf/sigmf-python
3+
# This file is part of sigmf-python. https://github.com/sigmf/sigmf-python
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

7-
__version__ = "1.2.0"
7+
# version of this python module
8+
__version__ = "1.2.1"
9+
# matching version of the SigMF specification
10+
__specification__ = "1.2.0"
811

912
from .archive import SigMFArchive
1013
from .sigmffile import SigMFFile, SigMFCollection
1114
from .archivereader import SigMFArchiveReader
1215

1316
from . import archive
17+
from . import archivereader
1418
from . import error
1519
from . import schema
1620
from . import sigmffile
17-
from . import validate
1821
from . import utils
19-
from . import archivereader
22+
from . import validate

sigmf/apps/convert_wav.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
# Copyright: Multiple Authors
22
#
3-
# This file is part of SigMF. https://github.com/sigmf/sigmf-python
3+
# This file is part of sigmf-python. https://github.com/sigmf/sigmf-python
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

77
"""converter for wav containers"""
88

9-
import os
10-
import tempfile
11-
import datetime
12-
import pathlib
139
import argparse
10+
import datetime
1411
import getpass
12+
import logging
13+
import os
14+
import pathlib
15+
import tempfile
1516

1617
from scipy.io import wavfile
1718

19+
from .. import SigMFFile, __specification__
20+
from .. import __version__ as toolversion
1821
from .. import archive
19-
from ..sigmffile import SigMFFile
2022
from ..utils import get_data_type_str
2123

24+
log = logging.getLogger()
25+
2226

2327
def convert_wav(input_wav_filename, archive_filename=None, start_datetime=None, author=None):
2428
"""
2529
read a .wav and write a .sigmf archive
2630
"""
31+
input_path = pathlib.Path(input_wav_filename)
32+
input_stem = input_path.stem
2733
samp_rate, wav_data = wavfile.read(input_wav_filename)
2834

2935
global_info = {
@@ -33,27 +39,27 @@ def convert_wav(input_wav_filename, archive_filename=None, start_datetime=None,
3339
SigMFFile.NUM_CHANNELS_KEY: 1 if len(wav_data.shape) < 2 else wav_data.shape[1],
3440
SigMFFile.RECORDER_KEY: os.path.basename(__file__),
3541
SigMFFile.SAMPLE_RATE_KEY: samp_rate,
42+
SigMFFile.VERSION_KEY: __specification__,
3643
}
3744

3845
if start_datetime is None:
39-
fname = pathlib.Path(input_wav_filename)
40-
mtime = datetime.datetime.fromtimestamp(fname.stat().st_mtime)
46+
mtime = datetime.datetime.fromtimestamp(input_path.stat().st_mtime)
4147
start_datetime = mtime.isoformat() + "Z"
4248

4349
capture_info = {SigMFFile.START_INDEX_KEY: 0}
4450
if start_datetime is not None:
4551
capture_info[SigMFFile.DATETIME_KEY] = start_datetime
4652

4753
tmpdir = tempfile.mkdtemp()
48-
sigmf_data_filename = input_wav_filename + archive.SIGMF_DATASET_EXT
54+
sigmf_data_filename = input_stem + archive.SIGMF_DATASET_EXT
4955
sigmf_data_path = os.path.join(tmpdir, sigmf_data_filename)
5056
wav_data.tofile(sigmf_data_path)
5157

5258
meta = SigMFFile(data_file=sigmf_data_path, global_info=global_info)
5359
meta.add_capture(0, metadata=capture_info)
5460

5561
if archive_filename is None:
56-
archive_filename = os.path.basename(input_wav_filename) + archive.SIGMF_ARCHIVE_EXT
62+
archive_filename = input_stem + archive.SIGMF_ARCHIVE_EXT
5763
meta.tofile(archive_filename, toarchive=True)
5864
return os.path.abspath(archive_filename)
5965

@@ -65,13 +71,22 @@ def main():
6571
parser = argparse.ArgumentParser(description="Convert .wav to .sigmf container.")
6672
parser.add_argument("input", type=str, help="Wavfile path")
6773
parser.add_argument("--author", type=str, default=None, help=f"set {SigMFFile.AUTHOR_KEY} metadata")
74+
parser.add_argument('-v', '--verbose', action='count', default=0)
75+
parser.add_argument('--version', action='version', version=f'%(prog)s v{toolversion}')
6876
args = parser.parse_args()
6977

78+
level_lut = {
79+
0: logging.WARNING,
80+
1: logging.INFO,
81+
2: logging.DEBUG,
82+
}
83+
logging.basicConfig(level=level_lut[min(args.verbose, 2)])
84+
7085
out_fname = convert_wav(
7186
input_wav_filename=args.input,
7287
author=args.author,
7388
)
74-
print("Wrote", out_fname)
89+
log.info(f"Write {out_fname}")
7590

7691

7792
if __name__ == "__main__":

sigmf/apps/gui.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Copyright: Multiple Authors
22
#
3-
# This file is part of SigMF. https://github.com/sigmf/sigmf-python
3+
# This file is part of sigmf-python. https://github.com/sigmf/sigmf-python
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

77
'''GUI for creating & editing SigMF Files'''
88

9-
import os
9+
import argparse
1010
import logging
11+
import os
12+
1113
from PySimpleGUI import *
1214

13-
from ..sigmffile import SigMFFile, fromarchive, dtype_info
15+
from .. import __version__ as toolversion
1416
from ..archive import SIGMF_ARCHIVE_EXT
17+
from ..sigmffile import SigMFFile, dtype_info, fromarchive
1518

1619
log = logging.getLogger()
1720

@@ -381,13 +384,10 @@ def add_capture(capture_data_input, values, capture_selector_dict, file_data, fr
381384

382385

383386
def main():
384-
import argparse
385-
from sigmf import __version__ as toolversion
386-
387387
parser = argparse.ArgumentParser(description='Edit SigMF Archive.')
388388
parser.add_argument('-i', '--input', help='Input SigMF Archive Path.', default=None)
389389
parser.add_argument('-v', '--verbose', action='count', default=0)
390-
parser.add_argument('--version', action='version', version=f'%(prog)s {toolversion}')
390+
parser.add_argument('--version', action='version', version=f'%(prog)s v{toolversion}')
391391
args = parser.parse_args()
392392

393393
level_lut = {
@@ -638,3 +638,6 @@ def main():
638638
break
639639

640640
window.Close()
641+
642+
if __name__ == "__main__":
643+
main()

sigmf/archive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright: Multiple Authors
22
#
3-
# This file is part of SigMF. https://github.com/sigmf/sigmf-python
3+
# This file is part of sigmf-python. https://github.com/sigmf/sigmf-python
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

@@ -13,7 +13,6 @@
1313

1414
from .error import SigMFFileError
1515

16-
1716
SIGMF_ARCHIVE_EXT = ".sigmf"
1817
SIGMF_METADATA_EXT = ".sigmf-meta"
1918
SIGMF_DATASET_EXT = ".sigmf-data"

sigmf/archivereader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright: Multiple Authors
22
#
3-
# This file is part of SigMF. https://github.com/gnuradio/SigMF
3+
# This file is part of sigmf-python. https://github.com/sigmf/SigMF
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

@@ -11,11 +11,11 @@
1111
import tarfile
1212
import tempfile
1313

14-
from . import __version__ #, schema, sigmf_hash, validate
14+
from . import __version__
15+
from .archive import SIGMF_ARCHIVE_EXT, SIGMF_DATASET_EXT, SIGMF_METADATA_EXT, SigMFArchive
16+
from .error import SigMFFileError
1517
from .sigmffile import SigMFFile
16-
from .archive import SigMFArchive, SIGMF_DATASET_EXT, SIGMF_METADATA_EXT, SIGMF_ARCHIVE_EXT
1718
from .utils import dict_merge
18-
from .error import SigMFFileError
1919

2020

2121
class SigMFArchiveReader():

sigmf/error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright: Multiple Authors
22
#
3-
# This file is part of SigMF. https://github.com/sigmf/sigmf-python
3+
# This file is part of sigmf-python. https://github.com/sigmf/sigmf-python
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

sigmf/schema-collection.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$id": "https://github.com/gnuradio/SigMF",
2+
"$id": "https://github.com/sigmf/SigMF",
33
"$schema": "http://json-schema.org/draft-07/schema",
44
"default": {},
55
"required": [
@@ -20,7 +20,7 @@
2020
"$id": "#/properties/collection/properties/core%3Aversion",
2121
"description": "The version of the SigMF specification used to create the Collection file.",
2222
"examples": [
23-
"1.0.0"
23+
"1.2.0"
2424
],
2525
"type": "string"
2626
},

sigmf/schema-meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$id": "https://github.com/gnuradio/SigMF",
2+
"$id": "https://github.com/sigmf/SigMF",
33
"$schema": "http://json-schema.org/draft-07/schema",
44
"default": [
55
"global",

0 commit comments

Comments
 (0)