RsWaveform 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/.github/workflows/linting.yml +1 -1
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/.github/workflows/python-publish.yml +5 -4
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/.github/workflows/tests.yml +7 -4
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/PKG-INFO +13 -5
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/README.md +9 -1
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/pyproject.toml +1 -2
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/__init__.py +5 -5
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/iqtar/__init__.py +2 -2
- RsWaveform-0.2.0/src/RsWaveform/iqtar/Load.py → rswaveform-0.4.0/src/RsWaveform/iqtar/load.py +4 -4
- RsWaveform-0.2.0/src/RsWaveform/iqtar/Save.py → rswaveform-0.4.0/src/RsWaveform/iqtar/save.py +4 -4
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/iqw/__init__.py +2 -2
- RsWaveform-0.2.0/src/RsWaveform/iqw/Load.py → rswaveform-0.4.0/src/RsWaveform/iqw/load.py +3 -3
- RsWaveform-0.2.0/src/RsWaveform/iqw/Save.py → rswaveform-0.4.0/src/RsWaveform/iqw/save.py +3 -3
- RsWaveform-0.2.0/src/RsWaveform/LoadInterface.py → rswaveform-0.4.0/src/RsWaveform/load_interface.py +1 -1
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/meta/__init__.py +6 -1
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/meta/defaults.py +3 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/meta/meta_wv.py +30 -2
- rswaveform-0.4.0/src/RsWaveform/npz/README.md +4 -0
- rswaveform-0.4.0/src/RsWaveform/npz/__init__.py +6 -0
- rswaveform-0.4.0/src/RsWaveform/npz/load.py +90 -0
- rswaveform-0.4.0/src/RsWaveform/npz/npz_inteface.py +30 -0
- rswaveform-0.4.0/src/RsWaveform/npz/save.py +33 -0
- RsWaveform-0.2.0/src/RsWaveform/ParentStorage.py → rswaveform-0.4.0/src/RsWaveform/parent_storage.py +16 -4
- RsWaveform-0.2.0/src/RsWaveform/SaveInterface.py → rswaveform-0.4.0/src/RsWaveform/save_interface.py +1 -1
- RsWaveform-0.2.0/src/RsWaveform/Storage.py → rswaveform-0.4.0/src/RsWaveform/storage.py +13 -5
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/utility/file_handling.py +8 -7
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/wv/__init__.py +2 -2
- RsWaveform-0.2.0/src/RsWaveform/wv/Load.py → rswaveform-0.4.0/src/RsWaveform/wv/load.py +9 -9
- RsWaveform-0.2.0/src/RsWaveform/wv/Save.py → rswaveform-0.4.0/src/RsWaveform/wv/save.py +3 -3
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform.egg-info/PKG-INFO +13 -5
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform.egg-info/SOURCES.txt +17 -11
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/conftest.py +8 -2
- rswaveform-0.4.0/tests/data/dummy.npz +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/data/dummy.wv +1 -1
- rswaveform-0.4.0/tests/data/dummy_huge.iq.tar +0 -0
- rswaveform-0.4.0/tests/data/dummy_multi_channel.iq.tar +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_Storage.py +2 -2
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_file_handling.py +1 -1
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_iqtar.py +8 -4
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_iqw.py +3 -3
- rswaveform-0.4.0/tests/test_npz.py +155 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_wv.py +15 -8
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tox.ini +2 -3
- RsWaveform-0.2.0/tests/data/dummy_2.wv +0 -1
- RsWaveform-0.2.0/tests/data/dummy_huge.iq.tar +0 -0
- RsWaveform-0.2.0/tests/data/dummy_multi_channel.iq.tar +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/.gitattributes +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/.github/dependabot.yml +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/.gitignore +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/.readthedocs.yaml +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/CHANGELOG.md +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/LICENSE +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/docs/api.md +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/docs/changelog.md +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/docs/conf.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/docs/contributing.md +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/docs/index.md +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/docs/installation.md +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/docs/usage.md +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/requirements-dev.txt +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/setup.cfg +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/__main__.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/meta/meta_base.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/meta/meta_iqtar.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/py.typed +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/utility/__init__.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/utility/dsp.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/utility/fake_jit.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/utility/integer_indexedproperty.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/utility/meta_utils.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/wv/utility/__init__.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform/wv/utility/array_to_bytes.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform.egg-info/dependency_links.txt +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform.egg-info/requires.txt +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/src/RsWaveform.egg-info/top_level.txt +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/__init__.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/data/dummy.iq.tar +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/data/dummy.iqw +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/data/dummy_huge.iqw +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/data/dummy_mwv.wv +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/data/huge_dummy.wv +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_array_to_bytes.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_dsp.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_fake_jit.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_integer_indexproperty.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_main.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_meta.py +0 -0
- {RsWaveform-0.2.0 → rswaveform-0.4.0}/tests/test_version.py +0 -0
|
@@ -10,7 +10,11 @@ on:
|
|
|
10
10
|
jobs:
|
|
11
11
|
deploy:
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
|
-
|
|
13
|
+
environment:
|
|
14
|
+
name: pypi
|
|
15
|
+
url: https://pypi.org/p/RsWaveform
|
|
16
|
+
permissions:
|
|
17
|
+
id-token: write
|
|
14
18
|
steps:
|
|
15
19
|
- uses: actions/checkout@v4
|
|
16
20
|
- name: Set up Python
|
|
@@ -26,6 +30,3 @@ jobs:
|
|
|
26
30
|
tox -e build
|
|
27
31
|
- name: Publish a Python distribution to PyPI
|
|
28
32
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
29
|
-
with:
|
|
30
|
-
user: __token__
|
|
31
|
-
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -13,7 +13,7 @@ jobs:
|
|
|
13
13
|
fail-fast: true
|
|
14
14
|
matrix:
|
|
15
15
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
16
|
-
python: ["3.
|
|
16
|
+
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
17
17
|
runs-on: ${{ matrix.os }}
|
|
18
18
|
steps:
|
|
19
19
|
- uses: actions/checkout@v4
|
|
@@ -30,7 +30,7 @@ jobs:
|
|
|
30
30
|
run: |
|
|
31
31
|
tox -e test -- --junitxml=results.xml tests/
|
|
32
32
|
- name: Test report
|
|
33
|
-
uses: mikepenz/action-junit-report@
|
|
33
|
+
uses: mikepenz/action-junit-report@v5
|
|
34
34
|
if: always()
|
|
35
35
|
with:
|
|
36
36
|
check_name: Test Report (${{ matrix.os }}, ${{ matrix.python }})
|
|
@@ -59,9 +59,10 @@ jobs:
|
|
|
59
59
|
- name: Run pytest with coverage
|
|
60
60
|
continue-on-error: true
|
|
61
61
|
run: |
|
|
62
|
+
cd ${{ github.workspace }}
|
|
62
63
|
tox -e test${{ matrix.tests }} -- --junitxml=results.xml tests/
|
|
63
64
|
- name: Test report
|
|
64
|
-
uses: mikepenz/action-junit-report@
|
|
65
|
+
uses: mikepenz/action-junit-report@v5
|
|
65
66
|
if: always()
|
|
66
67
|
with:
|
|
67
68
|
check_name: Test Report (${{ matrix.os }}, ${{ matrix.python }}, ${{ matrix.tests }})
|
|
@@ -72,7 +73,9 @@ jobs:
|
|
|
72
73
|
if: always()
|
|
73
74
|
with:
|
|
74
75
|
name: coverage-${{ matrix.python }}-${{ matrix.os }}${{ matrix.tests }}
|
|
75
|
-
|
|
76
|
+
include-hidden-files: true
|
|
77
|
+
path: |
|
|
78
|
+
${{ github.workspace }}/.coverage*
|
|
76
79
|
retention-days: 1
|
|
77
80
|
|
|
78
81
|
# Collectiong and combining all coverage files
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: RsWaveform
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Load, manipulate and save R&S waveform files
|
|
5
5
|
Author-email: "Rohde & Schwarz GmbH & Co. KG" <info@rohde-schwarz.com>
|
|
6
6
|
Maintainer-email: Carsten Sauerbrey <Carsten.Sauerbrey@rohde-schwarz.com>, Daniela Rossetto <Daniela.Rossetto@rohde-schwarz.com>
|
|
@@ -13,12 +13,11 @@ Platform: Windows
|
|
|
13
13
|
Classifier: Development Status :: 4 - Beta
|
|
14
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.9
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
22
|
License-File: LICENSE
|
|
24
23
|
Requires-Dist: numpy
|
|
@@ -37,6 +36,7 @@ Requires-Dist: numba; extra == "jit"
|
|
|
37
36
|
Provides-Extra: msgpack
|
|
38
37
|
Requires-Dist: msgpack; extra == "msgpack"
|
|
39
38
|
Requires-Dist: msgpack-numpy; extra == "msgpack"
|
|
39
|
+
Dynamic: license-file
|
|
40
40
|
|
|
41
41
|
# RsWaveform
|
|
42
42
|
|
|
@@ -64,7 +64,15 @@ Install from pypi.org:
|
|
|
64
64
|
$ pip install RsWaveform
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
You need at least Python 3.
|
|
67
|
+
You need at least Python 3.9.
|
|
68
|
+
|
|
69
|
+
## Setup environment
|
|
70
|
+
|
|
71
|
+
To set up your environment, just run
|
|
72
|
+
|
|
73
|
+
```py
|
|
74
|
+
pip install -r requirements-dev.txt
|
|
75
|
+
```
|
|
68
76
|
|
|
69
77
|
## Usage
|
|
70
78
|
|
|
@@ -24,7 +24,15 @@ Install from pypi.org:
|
|
|
24
24
|
$ pip install RsWaveform
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
You need at least Python 3.
|
|
27
|
+
You need at least Python 3.9.
|
|
28
|
+
|
|
29
|
+
## Setup environment
|
|
30
|
+
|
|
31
|
+
To set up your environment, just run
|
|
32
|
+
|
|
33
|
+
```py
|
|
34
|
+
pip install -r requirements-dev.txt
|
|
35
|
+
```
|
|
28
36
|
|
|
29
37
|
## Usage
|
|
30
38
|
|
|
@@ -15,13 +15,12 @@ classifiers = [
|
|
|
15
15
|
"Development Status :: 4 - Beta",
|
|
16
16
|
"License :: OSI Approved :: MIT License",
|
|
17
17
|
"Operating System :: OS Independent",
|
|
18
|
-
"Programming Language :: Python :: 3.8",
|
|
19
18
|
"Programming Language :: Python :: 3.9",
|
|
20
19
|
"Programming Language :: Python :: 3.10",
|
|
21
20
|
"Programming Language :: Python :: 3.11",
|
|
22
21
|
"Programming Language :: Python :: 3.12",
|
|
23
22
|
]
|
|
24
|
-
requires-python = ">=3.
|
|
23
|
+
requires-python = ">=3.9"
|
|
25
24
|
dependencies = ["numpy", "indexedproperty"]
|
|
26
25
|
dynamic = ["version"]
|
|
27
26
|
|
|
@@ -9,10 +9,10 @@ from importlib.metadata import PackageNotFoundError, version
|
|
|
9
9
|
import numpy as np
|
|
10
10
|
|
|
11
11
|
from . import iqtar, iqw, wv
|
|
12
|
-
from .
|
|
12
|
+
from .load_interface import LoadInterface
|
|
13
13
|
from .meta import Meta
|
|
14
|
-
from .
|
|
15
|
-
from .
|
|
14
|
+
from .parent_storage import ParentStorage
|
|
15
|
+
from .save_interface import SaveInterface
|
|
16
16
|
from .utility.dsp import (
|
|
17
17
|
calculate_par,
|
|
18
18
|
calculate_peak,
|
|
@@ -192,8 +192,8 @@ __all__ = [
|
|
|
192
192
|
"RsWaveform",
|
|
193
193
|
"Iqw",
|
|
194
194
|
"IqTar",
|
|
195
|
-
"
|
|
196
|
-
"
|
|
195
|
+
"load_interface",
|
|
196
|
+
"save_interface",
|
|
197
197
|
"calculate_par",
|
|
198
198
|
"calculate_peak",
|
|
199
199
|
"calculate_rms",
|
RsWaveform-0.2.0/src/RsWaveform/iqtar/Load.py → rswaveform-0.4.0/src/RsWaveform/iqtar/load.py
RENAMED
|
@@ -13,9 +13,9 @@ import numpy as np
|
|
|
13
13
|
from RsWaveform.meta import Meta
|
|
14
14
|
|
|
15
15
|
from ..iqw import Load as LoadIqw
|
|
16
|
-
from ..
|
|
17
|
-
from ..
|
|
18
|
-
from ..
|
|
16
|
+
from ..load_interface import LoadInterface
|
|
17
|
+
from ..parent_storage import ParentStorage
|
|
18
|
+
from ..storage import Storage
|
|
19
19
|
from ..utility.file_handling import read_file_handle, read_file_handle_tar
|
|
20
20
|
from ..utility.meta_utils import map_meta_information_name
|
|
21
21
|
|
|
@@ -101,7 +101,7 @@ class Load(LoadInterface):
|
|
|
101
101
|
if key == "clock":
|
|
102
102
|
value = float(value)
|
|
103
103
|
elif key == "samples":
|
|
104
|
-
|
|
104
|
+
value = int(value)
|
|
105
105
|
elif key == "numberofchannels":
|
|
106
106
|
value = int(value)
|
|
107
107
|
elif key == "scalingfactor":
|
RsWaveform-0.2.0/src/RsWaveform/iqtar/Save.py → rswaveform-0.4.0/src/RsWaveform/iqtar/save.py
RENAMED
|
@@ -5,11 +5,11 @@ import re
|
|
|
5
5
|
import typing
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
-
from ..iqw.
|
|
8
|
+
from ..iqw.save import Save as SaveIqw
|
|
9
9
|
from ..meta.defaults import META_IQTAR_DEFAULTS as META_DEFAULTS
|
|
10
|
-
from ..
|
|
11
|
-
from ..
|
|
12
|
-
from ..
|
|
10
|
+
from ..parent_storage import ParentStorage
|
|
11
|
+
from ..save_interface import SaveInterface
|
|
12
|
+
from ..storage import Storage
|
|
13
13
|
from ..utility.file_handling import write_file_handle, write_file_handle_tar
|
|
14
14
|
|
|
15
15
|
|
|
@@ -6,8 +6,8 @@ import typing
|
|
|
6
6
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
|
|
9
|
-
from ..
|
|
10
|
-
from ..
|
|
9
|
+
from ..load_interface import LoadInterface
|
|
10
|
+
from ..parent_storage import ParentStorage
|
|
11
11
|
from ..utility.fake_jit import jit
|
|
12
12
|
from ..utility.file_handling import read_file_handle
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ class Load(LoadInterface):
|
|
|
20
20
|
|
|
21
21
|
def load(self, file: typing.Union[str, typing.IO, Path]) -> ParentStorage:
|
|
22
22
|
"""Load iwq data from file."""
|
|
23
|
-
parent_storage = ParentStorage()
|
|
23
|
+
parent_storage = ParentStorage(no_defaults=True)
|
|
24
24
|
with read_file_handle(file) as fp:
|
|
25
25
|
content = fp.read()
|
|
26
26
|
iq_data = self._extract_iq(content)
|
|
@@ -7,9 +7,9 @@ import typing
|
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
|
|
10
|
-
from ..
|
|
11
|
-
from ..
|
|
12
|
-
from ..
|
|
10
|
+
from ..parent_storage import ParentStorage
|
|
11
|
+
from ..save_interface import SaveInterface
|
|
12
|
+
from ..storage import Storage
|
|
13
13
|
from ..utility.fake_jit import jit
|
|
14
14
|
from ..utility.file_handling import write_file_handle
|
|
15
15
|
|
|
@@ -5,7 +5,12 @@ from .meta_wv import MetaWv
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class Meta(MetaWv, MetaIqtar):
|
|
8
|
-
"""Meta data for Storage container.
|
|
8
|
+
"""Meta data for Storage container.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
no_defaults (bool, optional): Storage meta data should have no defaults at
|
|
12
|
+
initialization. Defaults to False.
|
|
13
|
+
"""
|
|
9
14
|
|
|
10
15
|
def __init__(self, no_defaults: bool = False, **kwargs):
|
|
11
16
|
"""Initialize Meta class."""
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""WV meta data for Storage container."""
|
|
2
2
|
|
|
3
|
+
import datetime
|
|
3
4
|
import typing
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
@@ -82,7 +83,7 @@ class MetaWv(MetaBase):
|
|
|
82
83
|
|
|
83
84
|
@property
|
|
84
85
|
def rms(self) -> typing.Optional[float]:
|
|
85
|
-
"""
|
|
86
|
+
"""The RMS value of the signal."""
|
|
86
87
|
return self._items.get("rms")
|
|
87
88
|
|
|
88
89
|
@rms.setter
|
|
@@ -91,9 +92,36 @@ class MetaWv(MetaBase):
|
|
|
91
92
|
|
|
92
93
|
@property
|
|
93
94
|
def peak(self) -> typing.Optional[float]:
|
|
94
|
-
"""
|
|
95
|
+
"""The signal peak value of the signal."""
|
|
95
96
|
return self._items.get("peak")
|
|
96
97
|
|
|
97
98
|
@peak.setter
|
|
98
99
|
def peak(self, value: float) -> None:
|
|
99
100
|
self._items["peak"] = value
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def samples(self) -> typing.Optional[int]:
|
|
104
|
+
"""The sample count of the waveform."""
|
|
105
|
+
return self._items.get("samples")
|
|
106
|
+
|
|
107
|
+
@samples.setter
|
|
108
|
+
def samples(self, value: int) -> None:
|
|
109
|
+
self._items["samples"] = value
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def reflevel(self) -> typing.Optional[float]:
|
|
113
|
+
"""The reference value of the signal."""
|
|
114
|
+
return self._items.get("reflevel")
|
|
115
|
+
|
|
116
|
+
@reflevel.setter
|
|
117
|
+
def reflevel(self, value: float) -> None:
|
|
118
|
+
self._items["reflevel"] = value
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
def date(self) -> typing.Optional[datetime.datetime]:
|
|
122
|
+
"""The timestamp of the loaded file."""
|
|
123
|
+
return self._items.get("date")
|
|
124
|
+
|
|
125
|
+
@date.setter
|
|
126
|
+
def date(self, value: float) -> None:
|
|
127
|
+
self._items["date"] = value
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Load implementation for generic waveform."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from ..load_interface import LoadInterface
|
|
11
|
+
from ..meta import Meta
|
|
12
|
+
from ..parent_storage import ParentStorage
|
|
13
|
+
from ..storage import Storage
|
|
14
|
+
from .npz_inteface import NpzInterface
|
|
15
|
+
|
|
16
|
+
if typing.TYPE_CHECKING:
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
LOGGER = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Load(LoadInterface, NpzInterface):
|
|
24
|
+
"""Load class for generic waveform."""
|
|
25
|
+
|
|
26
|
+
def load(self, file: typing.Union[str, typing.IO, Path]) -> ParentStorage:
|
|
27
|
+
"""Load waveform data from npz file."""
|
|
28
|
+
content = np.load(file=file, allow_pickle=True)
|
|
29
|
+
data_objs = content.get("storages")
|
|
30
|
+
if not data_objs:
|
|
31
|
+
raise ValueError(f"File {file} is not compliant to data schema.")
|
|
32
|
+
parent = ParentStorage(number_of_storages=len(data_objs))
|
|
33
|
+
for idx, obj in enumerate(data_objs):
|
|
34
|
+
i_values = obj.get("i")
|
|
35
|
+
q_values = obj.get("q")
|
|
36
|
+
meta = obj.get("meta", {})
|
|
37
|
+
if i_values is None:
|
|
38
|
+
LOGGER.warning(
|
|
39
|
+
(
|
|
40
|
+
"Skipping index %s of file %s content because no i values are"
|
|
41
|
+
" in it."
|
|
42
|
+
),
|
|
43
|
+
idx,
|
|
44
|
+
str(file),
|
|
45
|
+
)
|
|
46
|
+
continue
|
|
47
|
+
if q_values is None:
|
|
48
|
+
q_values = np.zeros(i_values.size)
|
|
49
|
+
if q_values is not None and len(i_values) != len(q_values):
|
|
50
|
+
LOGGER.warning(
|
|
51
|
+
(
|
|
52
|
+
"Skipping index %s of file %s content because i value and"
|
|
53
|
+
" q value lengths are not identical."
|
|
54
|
+
),
|
|
55
|
+
idx,
|
|
56
|
+
str(file),
|
|
57
|
+
)
|
|
58
|
+
continue
|
|
59
|
+
storage = Storage()
|
|
60
|
+
storage.data = i_values.astype(self.dtype) + 1j * q_values.astype(
|
|
61
|
+
self.dtype
|
|
62
|
+
)
|
|
63
|
+
storage.meta = Meta(no_defaults=True, **meta)
|
|
64
|
+
parent.storages[idx] = storage
|
|
65
|
+
return parent
|
|
66
|
+
|
|
67
|
+
def load_in_chunks(
|
|
68
|
+
self,
|
|
69
|
+
file: typing.Union[str, typing.IO, Path],
|
|
70
|
+
samples: int,
|
|
71
|
+
offset: int,
|
|
72
|
+
) -> ParentStorage:
|
|
73
|
+
"""Load chunk waveform data from file."""
|
|
74
|
+
parent = self.load(file)
|
|
75
|
+
for idx, storage in enumerate(parent.storages):
|
|
76
|
+
if offset + samples > len(storage.data):
|
|
77
|
+
raise ValueError(
|
|
78
|
+
f"Could not load chunks for index {idx} of file {file} because "
|
|
79
|
+
f"offset {offset} and sample count {samples} is greater than length"
|
|
80
|
+
f" of available data {len(storage.data)}. "
|
|
81
|
+
)
|
|
82
|
+
storage.data = storage.data[offset : offset + samples]
|
|
83
|
+
return parent
|
|
84
|
+
|
|
85
|
+
def load_meta(self, file: typing.Union[str, typing.IO, Path]) -> ParentStorage:
|
|
86
|
+
"""Load meta information only from wv file."""
|
|
87
|
+
parent = self.load(file)
|
|
88
|
+
for storage in parent.storages:
|
|
89
|
+
storage.data = np.empty((0, 0))
|
|
90
|
+
return parent
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Npz interface."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import numpy.typing as npt
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class NpzInterface:
|
|
8
|
+
"""Interface class for Npz."""
|
|
9
|
+
|
|
10
|
+
def __init__(self) -> None:
|
|
11
|
+
"""Instantiate interface class."""
|
|
12
|
+
self._dtype: npt.DTypeLike = np.dtype(np.float16)
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def dtype(self) -> npt.DTypeLike:
|
|
16
|
+
"""Dtype for loading and saving.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
DTypeLike: Numpy dtype
|
|
20
|
+
"""
|
|
21
|
+
return self._dtype
|
|
22
|
+
|
|
23
|
+
@dtype.setter
|
|
24
|
+
def dtype(self, value: npt.DTypeLike) -> None:
|
|
25
|
+
"""Dtype for loading and saving.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
value (DTypeLike): Numpy dtype
|
|
29
|
+
"""
|
|
30
|
+
self._dtype = value
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Save implementation for generic waveform."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from ..parent_storage import ParentStorage
|
|
10
|
+
from ..save_interface import SaveInterface
|
|
11
|
+
from .npz_inteface import NpzInterface
|
|
12
|
+
|
|
13
|
+
if typing.TYPE_CHECKING:
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Save(SaveInterface, NpzInterface):
|
|
18
|
+
"""Save class for generic waveform."""
|
|
19
|
+
|
|
20
|
+
def save(
|
|
21
|
+
self,
|
|
22
|
+
file: typing.Union[str, typing.IO, Path],
|
|
23
|
+
datas: ParentStorage,
|
|
24
|
+
scale: float = np.power(2, np.iinfo(np.int16).bits - 1),
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Save waveform data to file."""
|
|
27
|
+
data_objs = []
|
|
28
|
+
for storage in datas.storages:
|
|
29
|
+
i_values = np.real(storage.data).astype(self.dtype)
|
|
30
|
+
q_values = np.imag(storage.data).astype(self.dtype)
|
|
31
|
+
meta = storage.meta._items # pylint: disable=W0212
|
|
32
|
+
data_objs.append({"i": i_values, "q": q_values, "meta": meta})
|
|
33
|
+
np.savez_compressed(file=file, storages=data_objs) # type: ignore
|
RsWaveform-0.2.0/src/RsWaveform/ParentStorage.py → rswaveform-0.4.0/src/RsWaveform/parent_storage.py
RENAMED
|
@@ -4,17 +4,29 @@ import abc
|
|
|
4
4
|
import typing
|
|
5
5
|
from datetime import datetime
|
|
6
6
|
|
|
7
|
-
from .
|
|
7
|
+
from .storage import Storage
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ParentStorage(abc.ABC):
|
|
11
|
-
"""ParentStorage class implementation.
|
|
11
|
+
"""ParentStorage class implementation.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Args:
|
|
14
|
+
number_of_storages (int, optional): Initialize number of storages.
|
|
15
|
+
Defaults to 1.
|
|
16
|
+
no_defaults (bool, optional): Storage meta data should have no defaults at
|
|
17
|
+
initialization. Defaults to False.
|
|
18
|
+
|
|
19
|
+
Raises:
|
|
20
|
+
ValueError: If number of storages is smaller than 1.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, number_of_storages: int = 1, no_defaults: bool = False):
|
|
14
24
|
"""Initialize ParentStorage class."""
|
|
15
25
|
if number_of_storages <= 0:
|
|
16
26
|
raise ValueError("Only positive number of storages allowed!")
|
|
17
|
-
self._storages = [
|
|
27
|
+
self._storages = [
|
|
28
|
+
Storage(no_defaults=no_defaults) for _ in range(number_of_storages)
|
|
29
|
+
]
|
|
18
30
|
self._filename: str = ""
|
|
19
31
|
self._timestamp: datetime = datetime.now()
|
|
20
32
|
|
|
@@ -35,16 +35,24 @@ def encode_datetime(obj):
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
class Storage(abc.ABC):
|
|
38
|
-
"""Storage class implementation.
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
"""Storage class implementation.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
serialized (typing.Optional[bytes], optional): Serialized data.
|
|
42
|
+
Defaults to None.
|
|
43
|
+
no_defaults (bool, optional): Storage meta data should have no defaults at
|
|
44
|
+
initialization. Defaults to False.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self, serialized: typing.Optional[bytes] = None, no_defaults: bool = False
|
|
49
|
+
) -> None:
|
|
41
50
|
"""Initialize Storage class."""
|
|
42
51
|
if serialized:
|
|
43
52
|
self.deserialize(serialized)
|
|
44
53
|
else:
|
|
45
54
|
self.data: np.ndarray = np.zeros((1024,), dtype=np.complex128)
|
|
46
|
-
|
|
47
|
-
self.meta: Meta = Meta()
|
|
55
|
+
self.meta: Meta = Meta(no_defaults=no_defaults)
|
|
48
56
|
|
|
49
57
|
@property
|
|
50
58
|
def samples(self) -> int:
|
|
@@ -13,7 +13,7 @@ if typing.TYPE_CHECKING:
|
|
|
13
13
|
|
|
14
14
|
@contextmanager
|
|
15
15
|
def read_file_handle(
|
|
16
|
-
file: typing.Union[str, typing.IO, Path]
|
|
16
|
+
file: typing.Union[str, typing.IO, Path],
|
|
17
17
|
) -> typing.Generator[typing.IO, None, None]:
|
|
18
18
|
"""Read from a waveform file."""
|
|
19
19
|
return _file_handle(file, "rb")
|
|
@@ -21,7 +21,7 @@ def read_file_handle(
|
|
|
21
21
|
|
|
22
22
|
@contextmanager
|
|
23
23
|
def write_file_handle(
|
|
24
|
-
file: typing.Union[str, typing.IO, Path]
|
|
24
|
+
file: typing.Union[str, typing.IO, Path],
|
|
25
25
|
) -> typing.Generator[typing.IO, None, None]:
|
|
26
26
|
"""Write to a waveform file."""
|
|
27
27
|
return _file_handle(file, "wb+")
|
|
@@ -34,7 +34,7 @@ def _file_handle(
|
|
|
34
34
|
) -> typing.Generator[typing.IO, None, None]:
|
|
35
35
|
"""File handler context manager implementation."""
|
|
36
36
|
if isinstance(file, io.IOBase):
|
|
37
|
-
yield file
|
|
37
|
+
yield typing.cast(typing.IO, file)
|
|
38
38
|
else:
|
|
39
39
|
with open(typing.cast(str, file), mode, encoding=encoding) as f:
|
|
40
40
|
yield f
|
|
@@ -42,7 +42,7 @@ def _file_handle(
|
|
|
42
42
|
|
|
43
43
|
@contextmanager
|
|
44
44
|
def read_file_handle_tar(
|
|
45
|
-
file: typing.Union[str, tarfile.TarFile, typing.IO, Path]
|
|
45
|
+
file: typing.Union[str, tarfile.TarFile, typing.IO, Path],
|
|
46
46
|
) -> typing.Generator[tarfile.TarFile, None, None]:
|
|
47
47
|
"""Read from a tar file."""
|
|
48
48
|
return _file_handle_tar(file, "r:")
|
|
@@ -50,14 +50,15 @@ def read_file_handle_tar(
|
|
|
50
50
|
|
|
51
51
|
@contextmanager
|
|
52
52
|
def write_file_handle_tar(
|
|
53
|
-
file: typing.Union[str, tarfile.TarFile, typing.IO, Path]
|
|
53
|
+
file: typing.Union[str, tarfile.TarFile, typing.IO, Path],
|
|
54
54
|
) -> typing.Generator[tarfile.TarFile, None, None]:
|
|
55
55
|
"""Write to a tar file."""
|
|
56
56
|
return _file_handle_tar(file, "w:")
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
def _file_handle_tar(
|
|
60
|
-
file: typing.Union[str, tarfile.TarFile, typing.IO, Path],
|
|
60
|
+
file: typing.Union[str, tarfile.TarFile, typing.IO, Path],
|
|
61
|
+
mode: typing.Literal["w:", "r:"],
|
|
61
62
|
) -> typing.Generator[tarfile.TarFile, None, None]:
|
|
62
63
|
"""File handler context manager implementation."""
|
|
63
64
|
if isinstance(file, tarfile.TarFile):
|
|
@@ -66,5 +67,5 @@ def _file_handle_tar(
|
|
|
66
67
|
with tarfile.open(fileobj=file, mode=mode) as f: # not perfect
|
|
67
68
|
yield f
|
|
68
69
|
else:
|
|
69
|
-
with tarfile.open(typing.cast(str, file), mode) as f:
|
|
70
|
+
with tarfile.open(name=typing.cast(str, file), mode=mode) as f:
|
|
70
71
|
yield f
|