tm-data-types 0.4.0__tar.gz → 0.5.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.0 → tm_data_types-0.5.0}/PKG-INFO +7 -8
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/pyproject.toml +47 -48
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/__init__.py +12 -1
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/datum/waveforms/analog_waveform.py +187 -12
- tm_data_types-0.5.0/src/tm_data_types/datum/waveforms/digital_waveform.py +309 -0
- tm_data_types-0.5.0/src/tm_data_types/datum/waveforms/fastframe_analog_waveform.py +184 -0
- tm_data_types-0.5.0/src/tm_data_types/datum/waveforms/fastframe_common.py +153 -0
- tm_data_types-0.5.0/src/tm_data_types/datum/waveforms/fastframe_digital_waveform.py +137 -0
- tm_data_types-0.5.0/src/tm_data_types/files_and_formats/tss/__init__.py +5 -0
- tm_data_types-0.5.0/src/tm_data_types/files_and_formats/tss/tss_reader.py +235 -0
- tm_data_types-0.5.0/src/tm_data_types/files_and_formats/wfm/data_formats/analog.py +238 -0
- tm_data_types-0.5.0/src/tm_data_types/files_and_formats/wfm/data_formats/digital.py +312 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/wfm/data_formats/iq.py +39 -3
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/wfm/wfm.py +33 -41
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/wfm/wfm_format.py +201 -24
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/helpers/byte_data_class.py +9 -5
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/helpers/class_lookup.py +5 -2
- tm_data_types-0.4.0/src/tm_data_types/datum/waveforms/digital_waveform.py +0 -138
- tm_data_types-0.4.0/src/tm_data_types/files_and_formats/wfm/data_formats/analog.py +0 -98
- tm_data_types-0.4.0/src/tm_data_types/files_and_formats/wfm/data_formats/digital.py +0 -149
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/LICENSE.md +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/README.md +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/datum/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/datum/data_types.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/datum/datum.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/datum/waveforms/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/datum/waveforms/iq_waveform.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/datum/waveforms/waveform.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/abstracted_file.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/csv/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/csv/csv.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/csv/data_formats/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/csv/data_formats/analog.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/csv/data_formats/digital.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/csv/data_formats/iq.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/mat/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/mat/data_formats/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/mat/data_formats/analog.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/mat/data_formats/digital.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/mat/data_formats/iq.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/mat/mat.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/wfm/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/wfm/data_formats/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/files_and_formats/wfm/wfm_data_classes.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/helpers/__init__.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/helpers/byte_data_types.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/helpers/enums.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/helpers/instrument_series.py +0 -0
- {tm_data_types-0.4.0 → tm_data_types-0.5.0}/src/tm_data_types/io_factory_methods.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tm_data_types
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Read and write common Test & Measurement data types.
|
|
5
|
-
License: Apache-2.0
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE.md
|
|
7
7
|
Keywords: Tektronix,Test & Measurement
|
|
8
8
|
Author: Tektronix
|
|
@@ -13,7 +13,6 @@ Requires-Python: >=3.10,<3.14
|
|
|
13
13
|
Classifier: Development Status :: 4 - Beta
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: Intended Audience :: Science/Research
|
|
16
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
16
|
Classifier: Operating System :: OS Independent
|
|
18
17
|
Classifier: Programming Language :: Python :: 3
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -24,14 +23,14 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
24
23
|
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
|
|
25
24
|
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
26
25
|
Requires-Dist: bidict (>=0.23.1,<0.24.0)
|
|
27
|
-
Requires-Dist: numba (>=0.60.0,<0.61.0) ; python_version >= "3.
|
|
26
|
+
Requires-Dist: numba (>=0.60.0,<0.61.0) ; python_version >= "3.10" and python_version < "3.13"
|
|
28
27
|
Requires-Dist: numba (>=0.61.0,<0.62.0) ; python_version >= "3.13"
|
|
29
|
-
Requires-Dist: numpy (>=1.24,<2.0) ; python_version >= "3.
|
|
28
|
+
Requires-Dist: numpy (>=1.24,<2.0) ; python_version >= "3.10" and python_version < "3.13"
|
|
30
29
|
Requires-Dist: numpy (>=2.1,<3.0) ; python_version >= "3.13"
|
|
31
|
-
Requires-Dist: pydantic (>=2.7
|
|
32
|
-
Requires-Dist: python-dateutil (>=2.8
|
|
30
|
+
Requires-Dist: pydantic (>=2.7,<3.0)
|
|
31
|
+
Requires-Dist: python-dateutil (>=2.8,<3.0)
|
|
33
32
|
Requires-Dist: scipy (>=1.14,<2.0) ; python_version >= "3.13"
|
|
34
|
-
Requires-Dist: scipy (>=1.9,<2.0) ; python_version >= "3.
|
|
33
|
+
Requires-Dist: scipy (>=1.9,<2.0) ; python_version >= "3.10" and python_version < "3.13"
|
|
35
34
|
Project-URL: Bug Tracker, https://github.com/tektronix/tm_data_types/issues
|
|
36
35
|
Project-URL: Changelog, https://github.com/tektronix/tm_data_types/blob/main/CHANGELOG.md
|
|
37
36
|
Project-URL: Documentation, https://tm-data-types.readthedocs.io
|
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
build-backend = "poetry.core.masonry.api"
|
|
3
|
-
requires = ["poetry-core
|
|
3
|
+
requires = ["poetry-core~=2.2.0"]
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
authors = [
|
|
7
|
+
{email = "opensource@tektronix.com", name = "Tektronix"},
|
|
8
|
+
]
|
|
9
|
+
dependencies = [
|
|
10
|
+
"bidict~=0.23.1",
|
|
11
|
+
"numba~=0.60.0; python_version >= '3.10' and python_version < '3.13'",
|
|
12
|
+
"numba~=0.61.0; python_version >= '3.13'",
|
|
13
|
+
"numpy~=1.24; python_version >= '3.10' and python_version < '3.13'",
|
|
14
|
+
"numpy~=2.1; python_version >= '3.13'",
|
|
15
|
+
"pydantic~=2.7",
|
|
16
|
+
"python-dateutil~=2.8",
|
|
17
|
+
"scipy~=1.14; python_version >= '3.13'",
|
|
18
|
+
"scipy~=1.9; python_version >= '3.10' and python_version < '3.13'",
|
|
19
|
+
]
|
|
20
|
+
description = "Read and write common Test & Measurement data types."
|
|
21
|
+
dynamic = ["classifiers", "version"]
|
|
22
|
+
keywords = [
|
|
23
|
+
"Tektronix",
|
|
24
|
+
"Test & Measurement",
|
|
25
|
+
]
|
|
26
|
+
license = "Apache-2.0"
|
|
27
|
+
maintainers = [
|
|
28
|
+
{email = "opensource@tektronix.com", name = "Tektronix"},
|
|
29
|
+
]
|
|
30
|
+
name = "tm_data_types"
|
|
31
|
+
readme = "README.md"
|
|
32
|
+
requires-python = ">=3.10,<3.14" # PYTHON VERSION MARKER
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
"Bug Tracker" = "https://github.com/tektronix/tm_data_types/issues"
|
|
36
|
+
"Changelog" = "https://github.com/tektronix/tm_data_types/blob/main/CHANGELOG.md"
|
|
37
|
+
documentation = "https://tm-data-types.readthedocs.io"
|
|
38
|
+
homepage = "https://pypi.org/project/tm_data_types/"
|
|
39
|
+
repository = "https://github.com/tektronix/tm_data_types"
|
|
4
40
|
|
|
5
41
|
[tool.coverage.paths]
|
|
6
42
|
source = [
|
|
@@ -31,7 +67,6 @@ wrap-descriptions = 100
|
|
|
31
67
|
wrap-summaries = 0
|
|
32
68
|
|
|
33
69
|
[tool.poetry]
|
|
34
|
-
authors = ["Tektronix <opensource@tektronix.com>"]
|
|
35
70
|
classifiers = [
|
|
36
71
|
"Development Status :: 4 - Beta",
|
|
37
72
|
"Intended Audience :: Developers",
|
|
@@ -41,38 +76,7 @@ classifiers = [
|
|
|
41
76
|
"Topic :: Scientific/Engineering",
|
|
42
77
|
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
43
78
|
]
|
|
44
|
-
|
|
45
|
-
documentation = "https://tm-data-types.readthedocs.io"
|
|
46
|
-
homepage = "https://pypi.org/project/tm_data_types/"
|
|
47
|
-
keywords = [
|
|
48
|
-
"Tektronix",
|
|
49
|
-
"Test & Measurement",
|
|
50
|
-
]
|
|
51
|
-
license = "Apache-2.0"
|
|
52
|
-
maintainers = ["Tektronix <opensource@tektronix.com>"]
|
|
53
|
-
name = "tm_data_types"
|
|
54
|
-
readme = "README.md"
|
|
55
|
-
repository = "https://github.com/tektronix/tm_data_types"
|
|
56
|
-
version = "0.4.0"
|
|
57
|
-
|
|
58
|
-
[tool.poetry.dependencies]
|
|
59
|
-
bidict = "^0.23.1"
|
|
60
|
-
numba = [
|
|
61
|
-
{python = ">=3.9,<3.13", version = "^0.60.0"},
|
|
62
|
-
{python = ">=3.13", version = "^0.61.0"},
|
|
63
|
-
]
|
|
64
|
-
numpy = [
|
|
65
|
-
# This is required to be duplicated in the "main" and "dev" groups to ensure that the correct version is used in both cases
|
|
66
|
-
{python = ">=3.9,<3.13", version = "^1.24"},
|
|
67
|
-
{python = ">=3.13", version = "^2.1"},
|
|
68
|
-
]
|
|
69
|
-
pydantic = "^2.7.4"
|
|
70
|
-
python = ">=3.10,<3.14" # PYTHON VERSION MARKER
|
|
71
|
-
python-dateutil = "^2.8.2"
|
|
72
|
-
scipy = [
|
|
73
|
-
{python = ">=3.9,<3.13", version = "^1.9"},
|
|
74
|
-
{python = ">=3.13", version = "^1.14"},
|
|
75
|
-
]
|
|
79
|
+
version = "0.5.0"
|
|
76
80
|
|
|
77
81
|
[tool.poetry.group.dev.dependencies]
|
|
78
82
|
docutils-stubs = "^0.0.22"
|
|
@@ -84,21 +88,22 @@ numpy = [
|
|
|
84
88
|
{python = ">=3.13", version = "^2.1"},
|
|
85
89
|
]
|
|
86
90
|
pip = "^26.0"
|
|
87
|
-
poetry = "^
|
|
88
|
-
poetry-audit-plugin = "^0.
|
|
91
|
+
poetry = "^2.2.0"
|
|
92
|
+
poetry-audit-plugin = "^1.0.0"
|
|
89
93
|
poetry-plugin-export = "^1.7.1"
|
|
90
94
|
poetry-pre-commit-plugin = "^0.2.2"
|
|
91
95
|
pre-commit = "^4.2"
|
|
92
|
-
pylint = "4.0.
|
|
93
|
-
pyright = {extras = ["nodejs"], version = "1.1.
|
|
96
|
+
pylint = "4.0.7"
|
|
97
|
+
pyright = {extras = ["nodejs"], version = "1.1.411"}
|
|
94
98
|
pyroma = "^5.0"
|
|
99
|
+
safety = "~3.7.0" # TODO: Remove this version pin once the issue with safety is resolved
|
|
95
100
|
tox = "^4.0"
|
|
96
101
|
tox-gh-actions = "^3.1.0"
|
|
97
|
-
twine = "^
|
|
102
|
+
twine = "^7.0.0"
|
|
98
103
|
types-python-dateutil = "^2.9"
|
|
99
104
|
types-pyyaml = "^6.0"
|
|
100
105
|
types-requests = "^2.31"
|
|
101
|
-
wheel = "^0.
|
|
106
|
+
wheel = "^0.48.0"
|
|
102
107
|
|
|
103
108
|
[tool.poetry.group.docs.dependencies]
|
|
104
109
|
black = "^26.1.0"
|
|
@@ -119,7 +124,7 @@ nodeenv = "^1.9.1"
|
|
|
119
124
|
packaging = "^26.0"
|
|
120
125
|
pydantic = "^2.7.4"
|
|
121
126
|
pygments = "^2.17.2"
|
|
122
|
-
pymdown-extensions = "^
|
|
127
|
+
pymdown-extensions = "^11.0.1"
|
|
123
128
|
requests = "^2.31.0"
|
|
124
129
|
symspellpy = "^6.7.7"
|
|
125
130
|
tomli = "^2.0.1"
|
|
@@ -135,10 +140,6 @@ pytest-github-report = "^0.0.1"
|
|
|
135
140
|
pytest-html = "^4.1.1"
|
|
136
141
|
pytest-order = "^1.2.1"
|
|
137
142
|
|
|
138
|
-
[tool.poetry.urls]
|
|
139
|
-
"Bug Tracker" = "https://github.com/tektronix/tm_data_types/issues"
|
|
140
|
-
"Changelog" = "https://github.com/tektronix/tm_data_types/blob/main/CHANGELOG.md"
|
|
141
|
-
|
|
142
143
|
[tool.pylint.basic]
|
|
143
144
|
good-names = ["_"]
|
|
144
145
|
|
|
@@ -204,9 +205,6 @@ disable = [
|
|
|
204
205
|
"too-many-return-statements", # caught by ruff
|
|
205
206
|
"too-many-statements", # caught by ruff
|
|
206
207
|
"unnecessary-default-type-args", # not necessary to check for
|
|
207
|
-
"unused-argument", # caught by ruff
|
|
208
|
-
"unused-import", # caught by ruff
|
|
209
|
-
"use-implicit-booleaness-not-comparison-to-string", # caught by ruff
|
|
210
208
|
"while-used", # using while loops in example scripts
|
|
211
209
|
"wrong-import-order", # caught by ruff
|
|
212
210
|
]
|
|
@@ -275,6 +273,7 @@ flake8-quotes = {docstring-quotes = "double"}
|
|
|
275
273
|
ignore = [
|
|
276
274
|
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in *args and **kwargs (allowed in this package)
|
|
277
275
|
"COM812", # Trailing comma missing (allowed in this package)
|
|
276
|
+
"CPY001", # Missing copyright notice at top of file (allowed in this package)
|
|
278
277
|
"FA100", # Missing `from __future__ import annotations`, but uses ... (allowed in this package)
|
|
279
278
|
"FBT", # flake8-boolean-trap (allowed in this package)
|
|
280
279
|
"FIX002", # Line contains TO DO (allowed in this package)
|
|
@@ -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",
|
{tm_data_types-0.4.0 → tm_data_types-0.5.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.
|