tm-data-types 0.4.1__tar.gz → 0.6.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.
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/PKG-INFO +7 -9
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/pyproject.toml +22 -31
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/__init__.py +12 -1
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/data_types.py +4 -3
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/waveforms/analog_waveform.py +187 -12
- tm_data_types-0.6.0/src/tm_data_types/datum/waveforms/digital_waveform.py +309 -0
- tm_data_types-0.6.0/src/tm_data_types/datum/waveforms/fastframe_analog_waveform.py +184 -0
- tm_data_types-0.6.0/src/tm_data_types/datum/waveforms/fastframe_common.py +153 -0
- tm_data_types-0.6.0/src/tm_data_types/datum/waveforms/fastframe_digital_waveform.py +137 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/mat/mat.py +3 -3
- tm_data_types-0.6.0/src/tm_data_types/files_and_formats/tss/__init__.py +5 -0
- tm_data_types-0.6.0/src/tm_data_types/files_and_formats/tss/tss_reader.py +235 -0
- tm_data_types-0.6.0/src/tm_data_types/files_and_formats/wfm/data_formats/analog.py +238 -0
- tm_data_types-0.6.0/src/tm_data_types/files_and_formats/wfm/data_formats/digital.py +312 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/wfm/data_formats/iq.py +39 -3
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/wfm/wfm.py +33 -41
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/wfm/wfm_format.py +201 -24
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/helpers/byte_data_class.py +14 -9
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/helpers/byte_data_types.py +1 -1
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/helpers/class_lookup.py +5 -2
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/io_factory_methods.py +34 -28
- tm_data_types-0.4.1/src/tm_data_types/datum/waveforms/digital_waveform.py +0 -138
- tm_data_types-0.4.1/src/tm_data_types/files_and_formats/wfm/data_formats/analog.py +0 -98
- tm_data_types-0.4.1/src/tm_data_types/files_and_formats/wfm/data_formats/digital.py +0 -149
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/LICENSE.md +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/README.md +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/datum.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/waveforms/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/waveforms/iq_waveform.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/waveforms/waveform.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/abstracted_file.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/csv/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/csv/csv.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/csv/data_formats/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/csv/data_formats/analog.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/csv/data_formats/digital.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/csv/data_formats/iq.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/mat/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/mat/data_formats/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/mat/data_formats/analog.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/mat/data_formats/digital.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/mat/data_formats/iq.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/wfm/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/wfm/data_formats/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/files_and_formats/wfm/wfm_data_classes.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/helpers/__init__.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/helpers/enums.py +0 -0
- {tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/helpers/instrument_series.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tm_data_types
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Read and write common Test & Measurement data types.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE.md
|
|
@@ -9,28 +9,26 @@ Author: Tektronix
|
|
|
9
9
|
Author-email: opensource@tektronix.com
|
|
10
10
|
Maintainer: Tektronix
|
|
11
11
|
Maintainer-email: opensource@tektronix.com
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.11,<3.16
|
|
13
13
|
Classifier: Development Status :: 4 - Beta
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: Intended Audience :: Science/Research
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
22
|
Classifier: Topic :: Scientific/Engineering
|
|
23
23
|
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
|
|
24
24
|
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
25
25
|
Requires-Dist: bidict (>=0.23.1,<0.24.0)
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist: numba (>=0.
|
|
28
|
-
Requires-Dist: numpy (>=
|
|
29
|
-
Requires-Dist: numpy (>=2.1,<3.0) ; python_version >= "3.13"
|
|
26
|
+
Requires-Dist: certifi (>=2026.7.22)
|
|
27
|
+
Requires-Dist: numba (>=0.68.0,<0.69.0)
|
|
28
|
+
Requires-Dist: numpy (>=2.0,<3.0)
|
|
30
29
|
Requires-Dist: pydantic (>=2.7,<3.0)
|
|
31
30
|
Requires-Dist: python-dateutil (>=2.8,<3.0)
|
|
32
|
-
Requires-Dist: scipy (>=1.
|
|
33
|
-
Requires-Dist: scipy (>=1.9,<2.0) ; python_version >= "3.10" and python_version < "3.13"
|
|
31
|
+
Requires-Dist: scipy (>=1.13,<2.0)
|
|
34
32
|
Project-URL: Bug Tracker, https://github.com/tektronix/tm_data_types/issues
|
|
35
33
|
Project-URL: Changelog, https://github.com/tektronix/tm_data_types/blob/main/CHANGELOG.md
|
|
36
34
|
Project-URL: Documentation, https://tm-data-types.readthedocs.io
|
|
@@ -8,14 +8,12 @@ authors = [
|
|
|
8
8
|
]
|
|
9
9
|
dependencies = [
|
|
10
10
|
"bidict~=0.23.1",
|
|
11
|
-
"
|
|
12
|
-
"numba~=0.
|
|
13
|
-
"numpy~=
|
|
14
|
-
"numpy~=2.1; python_version >= '3.13'",
|
|
11
|
+
"certifi>=2026.7.22",
|
|
12
|
+
"numba~=0.68.0",
|
|
13
|
+
"numpy~=2.0",
|
|
15
14
|
"pydantic~=2.7",
|
|
16
15
|
"python-dateutil~=2.8",
|
|
17
|
-
"scipy~=1.
|
|
18
|
-
"scipy~=1.9; python_version >= '3.10' and python_version < '3.13'",
|
|
16
|
+
"scipy~=1.13",
|
|
19
17
|
]
|
|
20
18
|
description = "Read and write common Test & Measurement data types."
|
|
21
19
|
dynamic = ["classifiers", "version"]
|
|
@@ -29,7 +27,7 @@ maintainers = [
|
|
|
29
27
|
]
|
|
30
28
|
name = "tm_data_types"
|
|
31
29
|
readme = "README.md"
|
|
32
|
-
requires-python = ">=3.
|
|
30
|
+
requires-python = ">=3.11,<3.16" # PYTHON VERSION MARKER
|
|
33
31
|
|
|
34
32
|
[project.urls]
|
|
35
33
|
"Bug Tracker" = "https://github.com/tektronix/tm_data_types/issues"
|
|
@@ -38,7 +36,6 @@ documentation = "https://tm-data-types.readthedocs.io"
|
|
|
38
36
|
homepage = "https://pypi.org/project/tm_data_types/"
|
|
39
37
|
repository = "https://github.com/tektronix/tm_data_types"
|
|
40
38
|
|
|
41
|
-
|
|
42
39
|
[tool.coverage.paths]
|
|
43
40
|
source = [
|
|
44
41
|
"src/tm_data_types",
|
|
@@ -77,33 +74,29 @@ classifiers = [
|
|
|
77
74
|
"Topic :: Scientific/Engineering",
|
|
78
75
|
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
79
76
|
]
|
|
80
|
-
version = "0.
|
|
77
|
+
version = "0.6.0"
|
|
81
78
|
|
|
82
79
|
[tool.poetry.group.dev.dependencies]
|
|
83
80
|
docutils-stubs = "^0.0.22"
|
|
84
81
|
matplotlib = "^3.8"
|
|
85
82
|
nodeenv = "^1.9.1"
|
|
86
|
-
numpy = [
|
|
87
|
-
# This is required to be duplicated in the "main" and "dev" groups to ensure that the correct version is used in both cases
|
|
88
|
-
{python = ">=3.9,<3.13", version = "^1.24"},
|
|
89
|
-
{python = ">=3.13", version = "^2.1"},
|
|
90
|
-
]
|
|
91
83
|
pip = "^26.0"
|
|
92
84
|
poetry = "^2.2.0"
|
|
93
85
|
poetry-audit-plugin = "^1.0.0"
|
|
94
86
|
poetry-plugin-export = "^1.7.1"
|
|
95
87
|
poetry-pre-commit-plugin = "^0.2.2"
|
|
96
88
|
pre-commit = "^4.2"
|
|
97
|
-
pylint = "4.0.
|
|
98
|
-
pyright = {extras = ["nodejs"], version = "1.1.
|
|
89
|
+
pylint = "4.0.7"
|
|
90
|
+
pyright = {extras = ["nodejs"], version = "1.1.411"}
|
|
99
91
|
pyroma = "^5.0"
|
|
92
|
+
safety = "~3.7.0" # TODO: Remove this version pin once the issue with safety is resolved
|
|
100
93
|
tox = "^4.0"
|
|
101
94
|
tox-gh-actions = "^3.1.0"
|
|
102
|
-
twine = "^
|
|
95
|
+
twine = "^7.0.0"
|
|
103
96
|
types-python-dateutil = "^2.9"
|
|
104
97
|
types-pyyaml = "^6.0"
|
|
105
98
|
types-requests = "^2.31"
|
|
106
|
-
wheel = "^0.
|
|
99
|
+
wheel = "^0.48.0"
|
|
107
100
|
|
|
108
101
|
[tool.poetry.group.docs.dependencies]
|
|
109
102
|
black = "^26.1.0"
|
|
@@ -120,11 +113,11 @@ mkdocs-section-index = "^0.3.10"
|
|
|
120
113
|
mkdocs-spellcheck = "^1.2.0"
|
|
121
114
|
mkdocstrings = "^1.0.2"
|
|
122
115
|
mkdocstrings-python = "^2.0.1"
|
|
123
|
-
nodeenv = "^1.
|
|
116
|
+
nodeenv = "^1.12.0"
|
|
124
117
|
packaging = "^26.0"
|
|
125
118
|
pydantic = "^2.7.4"
|
|
126
119
|
pygments = "^2.17.2"
|
|
127
|
-
pymdown-extensions = "^
|
|
120
|
+
pymdown-extensions = "^11.0.1"
|
|
128
121
|
requests = "^2.31.0"
|
|
129
122
|
symspellpy = "^6.7.7"
|
|
130
123
|
tomli = "^2.0.1"
|
|
@@ -157,7 +150,7 @@ ignore-patterns = [
|
|
|
157
150
|
"^\\.vscode",
|
|
158
151
|
"^temp_.*\\..*",
|
|
159
152
|
]
|
|
160
|
-
jobs =
|
|
153
|
+
jobs = 1
|
|
161
154
|
load-plugins = """
|
|
162
155
|
pylint.extensions.check_elif,
|
|
163
156
|
pylint.extensions.code_style,
|
|
@@ -176,7 +169,7 @@ pylint.extensions.set_membership,
|
|
|
176
169
|
pylint.extensions.typing,
|
|
177
170
|
pylint.extensions.while_used
|
|
178
171
|
"""
|
|
179
|
-
py-version = "3.
|
|
172
|
+
py-version = "3.11" # PYTHON VERSION MARKER
|
|
180
173
|
recursive = true
|
|
181
174
|
|
|
182
175
|
[tool.pylint."messages control"]
|
|
@@ -205,9 +198,6 @@ disable = [
|
|
|
205
198
|
"too-many-return-statements", # caught by ruff
|
|
206
199
|
"too-many-statements", # caught by ruff
|
|
207
200
|
"unnecessary-default-type-args", # not necessary to check for
|
|
208
|
-
"unused-argument", # caught by ruff
|
|
209
|
-
"unused-import", # caught by ruff
|
|
210
|
-
"use-implicit-booleaness-not-comparison-to-string", # caught by ruff
|
|
211
201
|
"while-used", # using while loops in example scripts
|
|
212
202
|
"wrong-import-order", # caught by ruff
|
|
213
203
|
]
|
|
@@ -229,7 +219,7 @@ ignore = [
|
|
|
229
219
|
"temp_*.py",
|
|
230
220
|
]
|
|
231
221
|
pythonPlatform = "All"
|
|
232
|
-
pythonVersion = "3.
|
|
222
|
+
pythonVersion = "3.11" # PYTHON VERSION MARKER
|
|
233
223
|
reportCallInDefaultInitializer = "error"
|
|
234
224
|
reportImplicitOverride = "error"
|
|
235
225
|
reportImplicitStringConcatenation = "error"
|
|
@@ -266,7 +256,7 @@ line-length = 100
|
|
|
266
256
|
namespace-packages = ["docs/**", "examples/**", "scripts/**", "tests/**"]
|
|
267
257
|
output-format = "concise"
|
|
268
258
|
src = ["docs", "examples", "scripts", "src", "tests"]
|
|
269
|
-
target-version = "
|
|
259
|
+
target-version = "py311" # always generate Python 3.11 compatible code # PYTHON VERSION MARKER
|
|
270
260
|
|
|
271
261
|
[tool.ruff.lint]
|
|
272
262
|
allowed-confusables = []
|
|
@@ -276,6 +266,7 @@ flake8-quotes = {docstring-quotes = "double"}
|
|
|
276
266
|
ignore = [
|
|
277
267
|
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in *args and **kwargs (allowed in this package)
|
|
278
268
|
"COM812", # Trailing comma missing (allowed in this package)
|
|
269
|
+
"CPY001", # Missing copyright notice at top of file (allowed in this package)
|
|
279
270
|
"FA100", # Missing `from __future__ import annotations`, but uses ... (allowed in this package)
|
|
280
271
|
"FBT", # flake8-boolean-trap (allowed in this package)
|
|
281
272
|
"FIX002", # Line contains TO DO (allowed in this package)
|
|
@@ -350,22 +341,22 @@ legacy_tox_ini = """
|
|
|
350
341
|
[tox]
|
|
351
342
|
requires = tox>4
|
|
352
343
|
isolated_build = True
|
|
353
|
-
envlist =
|
|
344
|
+
envlist = py311,py312,py313,py314,py315,tests,docs,doctests # PYTHON VERSION MARKER
|
|
354
345
|
skip_missing_interpreters = True
|
|
355
346
|
labels =
|
|
356
|
-
basic =
|
|
347
|
+
basic = py311,py312,py313,py314,py315,tests # PYTHON VERSION MARKER
|
|
357
348
|
documentation = docs,doctests
|
|
358
349
|
|
|
359
350
|
[gh-actions]
|
|
360
351
|
python = # PYTHON VERSION MARKER
|
|
361
|
-
3.10: py310
|
|
362
352
|
3.11: py311
|
|
363
353
|
3.12: py312
|
|
364
354
|
3.13: py313
|
|
355
|
+
3.14: py314
|
|
356
|
+
3.15: py315
|
|
365
357
|
|
|
366
358
|
[testenv]
|
|
367
359
|
package = wheel
|
|
368
|
-
install_command = python -I -m pip install --upgrade --upgrade-strategy=eager {opts} {packages}
|
|
369
360
|
deps =
|
|
370
361
|
poetry
|
|
371
362
|
passenv =
|
|
@@ -8,10 +8,16 @@ from importlib.metadata import version
|
|
|
8
8
|
from tm_data_types.datum.data_types import Normalized, RawSample
|
|
9
9
|
from tm_data_types.datum.waveforms.analog_waveform import AnalogWaveform, AnalogWaveformMetaInfo
|
|
10
10
|
from tm_data_types.datum.waveforms.digital_waveform import DigitalWaveform, DigitalWaveformMetaInfo
|
|
11
|
+
from tm_data_types.datum.waveforms.fastframe_analog_waveform import (
|
|
12
|
+
FastFrameAnalogWaveform,
|
|
13
|
+
FrameTimingInfo,
|
|
14
|
+
)
|
|
15
|
+
from tm_data_types.datum.waveforms.fastframe_digital_waveform import FastFrameDigitalWaveform
|
|
11
16
|
from tm_data_types.datum.waveforms.iq_waveform import IQWaveform, IQWaveformMetaInfo
|
|
12
17
|
from tm_data_types.datum.waveforms.waveform import Waveform, WaveformMetaInfo
|
|
18
|
+
from tm_data_types.files_and_formats.tss.tss_reader import TSSReader
|
|
13
19
|
from tm_data_types.helpers.class_lookup import FileExtensions
|
|
14
|
-
from tm_data_types.helpers.enums import SIBaseUnit
|
|
20
|
+
from tm_data_types.helpers.enums import SIBaseUnit, SummaryFrameType
|
|
15
21
|
from tm_data_types.io_factory_methods import (
|
|
16
22
|
read_file,
|
|
17
23
|
read_files_in_parallel,
|
|
@@ -27,12 +33,17 @@ __all__ = [
|
|
|
27
33
|
"AnalogWaveformMetaInfo",
|
|
28
34
|
"DigitalWaveform",
|
|
29
35
|
"DigitalWaveformMetaInfo",
|
|
36
|
+
"FastFrameAnalogWaveform",
|
|
37
|
+
"FastFrameDigitalWaveform",
|
|
30
38
|
"FileExtensions",
|
|
39
|
+
"FrameTimingInfo",
|
|
31
40
|
"IQWaveform",
|
|
32
41
|
"IQWaveformMetaInfo",
|
|
33
42
|
"Normalized",
|
|
34
43
|
"RawSample",
|
|
35
44
|
"SIBaseUnit",
|
|
45
|
+
"SummaryFrameType",
|
|
46
|
+
"TSSReader",
|
|
36
47
|
"Waveform",
|
|
37
48
|
"WaveformMetaInfo",
|
|
38
49
|
"read_file",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"""The different formats which are wrapped by a MeasuredData class."""
|
|
2
2
|
|
|
3
|
+
import decimal
|
|
4
|
+
|
|
3
5
|
from abc import abstractmethod
|
|
4
|
-
from decimal import Decimal
|
|
5
6
|
from typing import Any, List, Optional, Type, Union
|
|
6
7
|
|
|
7
8
|
import numpy as np
|
|
@@ -58,8 +59,8 @@ def type_ratio(dtype_from: PossibleTypes, dtype_to: PossibleTypes) -> float:
|
|
|
58
59
|
Returns:
|
|
59
60
|
The ratio between the two dtypes.
|
|
60
61
|
"""
|
|
61
|
-
old_dtype_range = Decimal(type_max(dtype_from)) - Decimal(type_min(dtype_from))
|
|
62
|
-
new_dtype_range = Decimal(type_max(dtype_to)) - Decimal(type_min(dtype_to))
|
|
62
|
+
old_dtype_range = decimal.Decimal(type_max(dtype_from)) - decimal.Decimal(type_min(dtype_from))
|
|
63
|
+
new_dtype_range = decimal.Decimal(type_max(dtype_to)) - decimal.Decimal(type_min(dtype_to))
|
|
63
64
|
return float(new_dtype_range / old_dtype_range)
|
|
64
65
|
|
|
65
66
|
|
{tm_data_types-0.4.1 → tm_data_types-0.6.0}/src/tm_data_types/datum/waveforms/analog_waveform.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Handles information pertaining to analog waveforms."""
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import Any, Optional, Type
|
|
4
|
+
from typing import Any, Iterator, Optional, Type
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
|
|
@@ -62,7 +62,7 @@ class AnalogWaveformMetaInfo(WaveformMetaInfo):
|
|
|
62
62
|
real_data_start_index: Optional[int] = None
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
class AnalogWaveform(Waveform):
|
|
65
|
+
class AnalogWaveform(Waveform): # pylint: disable=too-many-instance-attributes,too-many-public-methods
|
|
66
66
|
"""Class which represents an analog waveform with a y-axis and x-axis."""
|
|
67
67
|
|
|
68
68
|
################################################################################################
|
|
@@ -85,6 +85,27 @@ class AnalogWaveform(Waveform):
|
|
|
85
85
|
self.y_axis_spacing: float = 1.0
|
|
86
86
|
self.y_axis_offset: float = 0.0
|
|
87
87
|
self.y_axis_units: str = SIBaseUnit.VOLTS.value
|
|
88
|
+
self._frame_data: Optional[np.ndarray] = None
|
|
89
|
+
self._frame_count: int = 1
|
|
90
|
+
self._current_frame: int = 0
|
|
91
|
+
self._tt_offsets: Optional[np.ndarray] = None
|
|
92
|
+
self._frame_gmt_sec: Optional[np.ndarray] = None
|
|
93
|
+
self._frame_gmt_fract: Optional[np.ndarray] = None
|
|
94
|
+
self._summary_frame: int = -1
|
|
95
|
+
self._frame_precharge: Optional[np.ndarray] = None
|
|
96
|
+
self._frame_postcharge: Optional[np.ndarray] = None
|
|
97
|
+
self._precharge_length: int = 0
|
|
98
|
+
self._postcharge_length: int = 0
|
|
99
|
+
|
|
100
|
+
def __getattribute__(self, key: str) -> Any:
|
|
101
|
+
"""Return the active frame view when accessing y_axis_values on FastFrame data."""
|
|
102
|
+
if key == "y_axis_values":
|
|
103
|
+
frame_data = object.__getattribute__(self, "__dict__").get("_frame_data")
|
|
104
|
+
if frame_data is not None:
|
|
105
|
+
current_frame = object.__getattribute__(self, "_current_frame")
|
|
106
|
+
return RawSample(frame_data[current_frame])
|
|
107
|
+
return object.__getattribute__(self, "__dict__")["y_axis_values"]
|
|
108
|
+
return super().__getattribute__(key)
|
|
88
109
|
|
|
89
110
|
def __setattr__(self, key: str, value: Any) -> None:
|
|
90
111
|
"""Set the attributes for the waveform class.
|
|
@@ -93,22 +114,118 @@ class AnalogWaveform(Waveform):
|
|
|
93
114
|
key: The attribute name to set as a string.
|
|
94
115
|
value: The value that the attribute is set to.
|
|
95
116
|
"""
|
|
96
|
-
if key in {"y_axis_values", "y_axis_spacing", "y_axis_offset"}:
|
|
117
|
+
if key in {"y_axis_values", "y_axis_spacing", "y_axis_offset", "_frame_data"}:
|
|
97
118
|
self.__dict__.pop("normalized_vertical_values", None)
|
|
98
119
|
|
|
99
120
|
if key == "y_axis_values":
|
|
100
|
-
|
|
121
|
+
if self.__dict__.get("_frame_data") is not None:
|
|
122
|
+
msg = "Cannot set y_axis_values directly on FastFrame waveform. Use fill_frame()."
|
|
123
|
+
raise ValueError(msg)
|
|
101
124
|
if not isinstance(value, MeasuredData):
|
|
102
125
|
super().__setattr__("y_axis_values", RawSample(value))
|
|
103
126
|
else:
|
|
104
127
|
super().__setattr__("y_axis_values", value)
|
|
128
|
+
elif key == "current_frame":
|
|
129
|
+
frame_count = self.__dict__.get("_frame_count", 1)
|
|
130
|
+
if not 0 <= value < frame_count:
|
|
131
|
+
msg = f"Frame {value} out of range [0, {frame_count})"
|
|
132
|
+
raise IndexError(msg)
|
|
133
|
+
super().__setattr__("_current_frame", value)
|
|
105
134
|
else:
|
|
106
135
|
super().__setattr__(key, value)
|
|
107
136
|
|
|
137
|
+
def __iter__(self) -> Iterator[NDArray[Any]]:
|
|
138
|
+
"""Iterate over all frames as numpy array views."""
|
|
139
|
+
if self._frame_data is not None:
|
|
140
|
+
for index in range(self._frame_count):
|
|
141
|
+
yield self._frame_data[index]
|
|
142
|
+
else:
|
|
143
|
+
yield np.asarray(self.y_axis_values)
|
|
144
|
+
|
|
108
145
|
################################################################################################
|
|
109
146
|
# Public Methods
|
|
110
147
|
################################################################################################
|
|
111
148
|
|
|
149
|
+
@classmethod
|
|
150
|
+
def create_fastframe(
|
|
151
|
+
cls,
|
|
152
|
+
frame_count: int,
|
|
153
|
+
record_length: int,
|
|
154
|
+
dtype: PossibleTypes = np.int16,
|
|
155
|
+
precharge_length: int = 0,
|
|
156
|
+
postcharge_length: int = 0,
|
|
157
|
+
**kwargs: Any,
|
|
158
|
+
) -> "AnalogWaveform":
|
|
159
|
+
"""Pre-allocate a FastFrame waveform.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
frame_count: Number of frames to allocate.
|
|
163
|
+
record_length: Samples per frame.
|
|
164
|
+
dtype: Sample data type.
|
|
165
|
+
precharge_length: Samples per frame in the precharge region.
|
|
166
|
+
postcharge_length: Samples per frame in the postcharge region.
|
|
167
|
+
**kwargs: Additional waveform attributes.
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
Pre-allocated AnalogWaveform ready for fill_frame() calls.
|
|
171
|
+
"""
|
|
172
|
+
waveform = cls()
|
|
173
|
+
waveform._frame_data = np.empty((frame_count, record_length), dtype=dtype)
|
|
174
|
+
waveform._frame_count = frame_count
|
|
175
|
+
waveform._current_frame = 0
|
|
176
|
+
waveform._tt_offsets = np.zeros(frame_count, dtype=np.float64)
|
|
177
|
+
waveform._frame_gmt_sec = np.zeros(frame_count, dtype=np.int64)
|
|
178
|
+
waveform._frame_gmt_fract = np.zeros(frame_count, dtype=np.float64)
|
|
179
|
+
waveform._precharge_length = precharge_length
|
|
180
|
+
waveform._postcharge_length = postcharge_length
|
|
181
|
+
if precharge_length:
|
|
182
|
+
waveform._frame_precharge = np.zeros((frame_count, precharge_length), dtype=dtype)
|
|
183
|
+
if postcharge_length:
|
|
184
|
+
waveform._frame_postcharge = np.zeros((frame_count, postcharge_length), dtype=dtype)
|
|
185
|
+
for key, val in kwargs.items():
|
|
186
|
+
setattr(waveform, key, val)
|
|
187
|
+
return waveform
|
|
188
|
+
|
|
189
|
+
def fill_frame(self, frame_idx: int, data: np.ndarray) -> None:
|
|
190
|
+
"""Copy frame data into the pre-allocated buffer."""
|
|
191
|
+
if self._frame_data is None:
|
|
192
|
+
msg = "Not a FastFrame waveform. Use create_fastframe() first."
|
|
193
|
+
raise ValueError(msg)
|
|
194
|
+
self._frame_data[frame_idx] = data
|
|
195
|
+
self.__dict__.pop("normalized_vertical_values", None)
|
|
196
|
+
|
|
197
|
+
def set_frame_timing(
|
|
198
|
+
self,
|
|
199
|
+
frame_idx: int,
|
|
200
|
+
tt_offset: float,
|
|
201
|
+
gmt_sec: int = 0,
|
|
202
|
+
gmt_fract: float = 0.0,
|
|
203
|
+
) -> None:
|
|
204
|
+
"""Set per-frame timing metadata."""
|
|
205
|
+
if self._tt_offsets is not None:
|
|
206
|
+
self._tt_offsets[frame_idx] = tt_offset
|
|
207
|
+
if self._frame_gmt_sec is not None:
|
|
208
|
+
self._frame_gmt_sec[frame_idx] = gmt_sec
|
|
209
|
+
if self._frame_gmt_fract is not None:
|
|
210
|
+
self._frame_gmt_fract[frame_idx] = gmt_fract
|
|
211
|
+
|
|
212
|
+
def frame_data(self, idx: int) -> NDArray[Any]:
|
|
213
|
+
"""Get a specific frame's data without changing current_frame."""
|
|
214
|
+
if self._frame_data is not None:
|
|
215
|
+
return self._frame_data[idx]
|
|
216
|
+
if not idx:
|
|
217
|
+
return np.asarray(self.y_axis_values)
|
|
218
|
+
frame_count = self.__dict__.get("_frame_count", 1)
|
|
219
|
+
msg = f"Frame {idx} out of range [0, {frame_count})"
|
|
220
|
+
raise IndexError(msg)
|
|
221
|
+
|
|
222
|
+
def frame(self, index: int) -> "AnalogWaveform":
|
|
223
|
+
"""Return this waveform for single-frame data (TekHSI compat)."""
|
|
224
|
+
if index == self.current_frame:
|
|
225
|
+
return self
|
|
226
|
+
msg = f"Single-frame waveform has no frame {index}"
|
|
227
|
+
raise ValueError(msg)
|
|
228
|
+
|
|
112
229
|
def transform_to_normalized(self) -> "AnalogWaveform":
|
|
113
230
|
"""Convert the waveform to normalized."""
|
|
114
231
|
copied_waveform = self.copy()
|
|
@@ -128,14 +245,7 @@ class AnalogWaveform(Waveform):
|
|
|
128
245
|
self,
|
|
129
246
|
as_type: Type[ByteData] | Type[PossibleTypes] | PossibleTypes,
|
|
130
247
|
) -> "AnalogWaveform":
|
|
131
|
-
"""Convert the waveform to a new type.
|
|
132
|
-
|
|
133
|
-
Args:
|
|
134
|
-
as_type: The type to convert to.
|
|
135
|
-
|
|
136
|
-
Returns:
|
|
137
|
-
A copy of the waveform transformed to raw sample values.
|
|
138
|
-
"""
|
|
248
|
+
"""Convert the waveform to a new type."""
|
|
139
249
|
copied_waveform = self.copy()
|
|
140
250
|
copied_waveform.y_axis_offset = self.y_axis_values.calculate_offset(self.y_axis_offset)
|
|
141
251
|
copied_waveform.y_axis_values = RawSample(copied_waveform.y_axis_values, as_type=as_type)
|
|
@@ -154,6 +264,71 @@ class AnalogWaveform(Waveform):
|
|
|
154
264
|
# Properties
|
|
155
265
|
################################################################################################
|
|
156
266
|
|
|
267
|
+
@property
|
|
268
|
+
def frame_count(self) -> int:
|
|
269
|
+
"""Number of frames.
|
|
270
|
+
|
|
271
|
+
1 for normal waveforms, >1 for FastFrame.
|
|
272
|
+
"""
|
|
273
|
+
return self._frame_count
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def is_fastframe(self) -> bool:
|
|
277
|
+
"""True if this waveform contains multiple FastFrame acquisitions."""
|
|
278
|
+
return self._frame_count > 1
|
|
279
|
+
|
|
280
|
+
@property
|
|
281
|
+
def current_frame(self) -> int:
|
|
282
|
+
"""Active frame index."""
|
|
283
|
+
return self._current_frame
|
|
284
|
+
|
|
285
|
+
@property
|
|
286
|
+
def tt_offsets(self) -> Optional[np.ndarray]:
|
|
287
|
+
"""Per-frame trigger-to-trigger offsets in seconds."""
|
|
288
|
+
return self._tt_offsets
|
|
289
|
+
|
|
290
|
+
@property
|
|
291
|
+
def summary_frame(self) -> int:
|
|
292
|
+
"""Index of the summary frame, or -1 if none."""
|
|
293
|
+
return self._summary_frame
|
|
294
|
+
|
|
295
|
+
@property
|
|
296
|
+
def all_frames(self) -> Optional[np.ndarray]:
|
|
297
|
+
"""Direct access to the 2D frame array."""
|
|
298
|
+
return self._frame_data
|
|
299
|
+
|
|
300
|
+
@property
|
|
301
|
+
def frame_gmt_sec(self) -> Optional[np.ndarray]:
|
|
302
|
+
"""Per-frame GMT seconds array."""
|
|
303
|
+
return self._frame_gmt_sec
|
|
304
|
+
|
|
305
|
+
@property
|
|
306
|
+
def frame_gmt_fract(self) -> Optional[np.ndarray]:
|
|
307
|
+
"""Per-frame GMT fractional seconds array."""
|
|
308
|
+
return self._frame_gmt_fract
|
|
309
|
+
|
|
310
|
+
@property
|
|
311
|
+
def precharge_length(self) -> int:
|
|
312
|
+
"""Number of precharge samples stored per frame."""
|
|
313
|
+
return self._precharge_length
|
|
314
|
+
|
|
315
|
+
@property
|
|
316
|
+
def postcharge_length(self) -> int:
|
|
317
|
+
"""Number of postcharge samples stored per frame."""
|
|
318
|
+
return self._postcharge_length
|
|
319
|
+
|
|
320
|
+
def frame_precharge(self, idx: int) -> Optional[NDArray[Any]]:
|
|
321
|
+
"""Return precharge samples for a frame when present."""
|
|
322
|
+
if self._frame_precharge is None:
|
|
323
|
+
return None
|
|
324
|
+
return self._frame_precharge[idx]
|
|
325
|
+
|
|
326
|
+
def frame_postcharge(self, idx: int) -> Optional[NDArray[Any]]:
|
|
327
|
+
"""Return postcharge samples for a frame when present."""
|
|
328
|
+
if self._frame_postcharge is None:
|
|
329
|
+
return None
|
|
330
|
+
return self._frame_postcharge[idx]
|
|
331
|
+
|
|
157
332
|
@cached_property
|
|
158
333
|
def normalized_vertical_values(self) -> Normalized: # pyright: ignore [reportIncompatibleMethodOverride]
|
|
159
334
|
"""Cache the y values with the extent and offset are applied.
|