PyONDE 0.1.7__tar.gz → 0.1.8__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.
- {pyonde-0.1.7 → pyonde-0.1.8}/PKG-INFO +21 -1
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE/_version.py +3 -3
- pyonde-0.1.8/PyONDE/bin/ondeview.py +208 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE/onde.py +379 -21
- pyonde-0.1.8/PyONDE/viewer/__init__.py +51 -0
- pyonde-0.1.8/PyONDE/viewer/access.py +91 -0
- pyonde-0.1.8/PyONDE/viewer/app.py +567 -0
- pyonde-0.1.8/PyONDE/viewer/blit.py +122 -0
- pyonde-0.1.8/PyONDE/viewer/controls.py +436 -0
- pyonde-0.1.8/PyONDE/viewer/dependency.py +203 -0
- pyonde-0.1.8/PyONDE/viewer/export.py +138 -0
- pyonde-0.1.8/PyONDE/viewer/inspector.py +184 -0
- pyonde-0.1.8/PyONDE/viewer/model.py +560 -0
- pyonde-0.1.8/PyONDE/viewer/render.py +406 -0
- pyonde-0.1.8/PyONDE/viewer/state.py +208 -0
- pyonde-0.1.8/PyONDE/viewer/testdata.py +522 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE.egg-info/PKG-INFO +21 -1
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE.egg-info/SOURCES.txt +34 -0
- pyonde-0.1.8/PyONDE.egg-info/entry_points.txt +2 -0
- pyonde-0.1.8/PyONDE.egg-info/scm_file_list.json +69 -0
- pyonde-0.1.8/PyONDE.egg-info/scm_version.json +8 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/README.md +20 -0
- pyonde-0.1.8/VIEWER-NOTES.md +441 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/source/index.rst +1 -0
- pyonde-0.1.8/doc/source/installation.rst +30 -0
- pyonde-0.1.8/doc/source/viewer.rst +310 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/pyproject.toml +10 -0
- pyonde-0.1.8/screenshot-bscan.png +0 -0
- pyonde-0.1.8/screenshot-export.png +0 -0
- pyonde-0.1.8/screenshot-metadata.png +0 -0
- pyonde-0.1.8/screenshot-tscan.png +0 -0
- pyonde-0.1.8/screenshot-viewer.png +0 -0
- pyonde-0.1.8/tests/conftest.py +54 -0
- pyonde-0.1.8/tests/test_viewer_access.py +152 -0
- pyonde-0.1.8/tests/test_viewer_app.py +350 -0
- pyonde-0.1.8/tests/test_viewer_blit.py +271 -0
- pyonde-0.1.8/tests/test_viewer_cli.py +85 -0
- pyonde-0.1.8/tests/test_viewer_export.py +180 -0
- pyonde-0.1.8/tests/test_viewer_inspector.py +234 -0
- pyonde-0.1.8/tests/test_viewer_library_versions.py +507 -0
- pyonde-0.1.8/tests/test_viewer_model.py +175 -0
- pyonde-0.1.8/tests/test_viewer_optional_dependency.py +372 -0
- pyonde-0.1.8/tests/test_viewer_roundtrip.py +93 -0
- pyonde-0.1.8/tests/test_viewer_state.py +128 -0
- pyonde-0.1.8/tests/test_viewer_toolbar.py +219 -0
- pyonde-0.1.7/PyONDE.egg-info/scm_file_list.json +0 -36
- pyonde-0.1.7/PyONDE.egg-info/scm_version.json +0 -8
- pyonde-0.1.7/doc/source/installation.rst +0 -19
- {pyonde-0.1.7 → pyonde-0.1.8}/.github/workflows/doc.yml +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/.github/workflows/push-to-pypi.yml +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/.gitignore +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/.vscode/settings.json +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/LICENSE.txt +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE/__init__.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE/bin/__init__.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE/onde_versions/ONDE_fields_v0.9.1pre.csv +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE/onde_versions/ONDE_fields_v0.9.2.csv +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE/onde_versions/ONDE_fields_v0.9.2pre.csv +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE.egg-info/dependency_links.txt +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE.egg-info/not-zip-safe +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/PyONDE.egg-info/top_level.txt +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/demos/build_onde_file.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/demos/build_onde_graph.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/demos/build_simple_graph.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/demos/graph_modification.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/demos/load_onde_file.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/LowLevel_Class_Structure.md +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/Makefile +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/source/PyONDE.rst +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/source/about.rst +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/source/architecture.rst +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/source/conf.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/source/modules.rst +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/doc/source/quickstart.rst +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/setup.cfg +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/setup.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/tests/try_array.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/tests/try_csv_read.py +0 -0
- {pyonde-0.1.7 → pyonde-0.1.8}/tests/try_dictionary.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyONDE
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: PyONDE library for reading, modifying, and writing ONDE files
|
|
5
5
|
Home-page: http://github.com/isuthermography/PyONDE
|
|
6
6
|
Author: Stephen D. Holland
|
|
@@ -29,6 +29,26 @@ More information and documentation in the doc/ folder and at
|
|
|
29
29
|
https://isuthermography.github.io/PyONDE/ and at
|
|
30
30
|
https://github.com/isuthermography/PyONDE
|
|
31
31
|
|
|
32
|
+
Viewing ONDE files
|
|
33
|
+
------------------
|
|
34
|
+
|
|
35
|
+
PyONDE includes ``ondeview``, a dimension-driven viewer for the data in an ONDE
|
|
36
|
+
file, built entirely on matplotlib and matplotlib.widgets::
|
|
37
|
+
|
|
38
|
+
ondeview --list scan.onde # datasets, shapes, axes (no matplotlib needed)
|
|
39
|
+
pip install matplotlib # only the interactive viewer needs it
|
|
40
|
+
ondeview scan.onde # the interactive viewer
|
|
41
|
+
|
|
42
|
+
It shows any DATA array with one or two axes mapped to the display and a slider
|
|
43
|
+
fixing each of the rest, reading the coordinates, units and calibration from
|
|
44
|
+
INDEX_DIMENSIONS, so an A-scan file opens as a waveform and a T-scan file as a
|
|
45
|
+
zone image without either being a special case. Slices and figures can be
|
|
46
|
+
exported, and a second window shows the ONDE subgraph behind the dataset.
|
|
47
|
+
|
|
48
|
+
See doc/source/viewer.rst, or https://isuthermography.github.io/PyONDE/ , for
|
|
49
|
+
details.
|
|
50
|
+
|
|
51
|
+
|
|
32
52
|
Acknowledgments
|
|
33
53
|
---------------
|
|
34
54
|
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
21
|
+
__version__ = version = '0.1.8'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 8)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'g67508c3d1'
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"""Command line entry point for the ONDE viewer.
|
|
2
|
+
|
|
3
|
+
``ondeview FILE`` open the interactive viewer (Phase 2)
|
|
4
|
+
``ondeview --list FILE`` one line per dataset: key, type, shape, label
|
|
5
|
+
``ondeview --info KEY FILE`` axes, calibration and metadata for one dataset
|
|
6
|
+
|
|
7
|
+
The listing paths need only numpy and h5py, so they work on a plain
|
|
8
|
+
``pip install PyONDE``. The viewer additionally needs matplotlib, which
|
|
9
|
+
PyONDE does not declare as a dependency; ``ondeview FILE`` says so, in a
|
|
10
|
+
message box as well as on stderr, when it is not installed.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
from ..viewer.model import OndeDocument
|
|
18
|
+
|
|
19
|
+
#: Opening a file costs roughly its size in RAM, because PyONDE reads every
|
|
20
|
+
#: HDF5 dataset eagerly. Warn rather than let a big file look like a hang.
|
|
21
|
+
LARGE_FILE_BYTES = 1 << 30
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _print_warnings(document, stream):
|
|
25
|
+
for message in document.warnings:
|
|
26
|
+
print(f"warning: {message}", file=stream)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _format_axes(model):
|
|
30
|
+
lines = []
|
|
31
|
+
for axis in model.axes:
|
|
32
|
+
span_low, span_high = axis.extent_edges()
|
|
33
|
+
factor, unit_label = axis.display_scale()
|
|
34
|
+
lines.append(
|
|
35
|
+
f" axis {axis.index}: {axis.length:>6} x {axis.coordinate:<14} "
|
|
36
|
+
f"[{axis.kind:<7}] "
|
|
37
|
+
f"{span_low * factor:.4g} .. {span_high * factor:.4g} {unit_label}"
|
|
38
|
+
+ (" (spec defaults)" if axis.is_default else ""))
|
|
39
|
+
return lines
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _dump_tree(tree, stream, indent=6):
|
|
43
|
+
pad = " " * indent
|
|
44
|
+
if isinstance(tree, dict):
|
|
45
|
+
for name, value in tree.items():
|
|
46
|
+
if isinstance(value, (dict, list)):
|
|
47
|
+
print(f"{pad}{name}:", file=stream)
|
|
48
|
+
_dump_tree(value, stream, indent + 2)
|
|
49
|
+
else:
|
|
50
|
+
print(f"{pad}{name}: {value}", file=stream)
|
|
51
|
+
elif isinstance(tree, list):
|
|
52
|
+
for position, value in enumerate(tree):
|
|
53
|
+
if isinstance(value, (dict, list)):
|
|
54
|
+
print(f"{pad}[{position}]:", file=stream)
|
|
55
|
+
_dump_tree(value, stream, indent + 2)
|
|
56
|
+
else:
|
|
57
|
+
print(f"{pad}[{position}]: {value}", file=stream)
|
|
58
|
+
else:
|
|
59
|
+
print(f"{pad}{tree}", file=stream)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def command_list(document, stream):
|
|
63
|
+
print(f"{document.path}", file=stream)
|
|
64
|
+
version = document.file_version or "unknown"
|
|
65
|
+
filetype = ", ".join(document.filetype) or "unspecified"
|
|
66
|
+
print(f" ONDE:VERSION {version} ONDE:FILETYPE {filetype} "
|
|
67
|
+
f"read with class definitions {document.onde_version}", file=stream)
|
|
68
|
+
if not document.datasets:
|
|
69
|
+
print(" (no dataset entry points found)", file=stream)
|
|
70
|
+
return 0
|
|
71
|
+
header = f"{'key':>8} {'type':<24} {'shape':<28} label"
|
|
72
|
+
print(f" {header}", file=stream)
|
|
73
|
+
for model in document.datasets:
|
|
74
|
+
print(f" {model.summary()}", file=stream)
|
|
75
|
+
_print_warnings(document, stream)
|
|
76
|
+
return 0
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def command_info(document, key, stream):
|
|
80
|
+
model = document.get(key)
|
|
81
|
+
if model is None:
|
|
82
|
+
print(f"error: no dataset {key!r}; known keys: "
|
|
83
|
+
f"{', '.join(m.short_key for m in document.datasets)}",
|
|
84
|
+
file=sys.stderr)
|
|
85
|
+
return 2
|
|
86
|
+
print(f"{model.short_key} {model.label}", file=stream)
|
|
87
|
+
print(f" UUID {model.full_key}", file=stream)
|
|
88
|
+
print(f" type chain {' -> '.join(model.type_chain)}", file=stream)
|
|
89
|
+
if not model.has_data:
|
|
90
|
+
print(" DATA absent (permitted by the specification)", file=stream)
|
|
91
|
+
else:
|
|
92
|
+
print(f" DATA {'x'.join(str(n) for n in model.shape)} "
|
|
93
|
+
f"{model.dtype} ({model.size_bytes / 1e6:.1f} MB in memory)",
|
|
94
|
+
file=stream)
|
|
95
|
+
amplitude = model.amplitude
|
|
96
|
+
print(f" amplitude {amplitude.coordinate} ({amplitude.units}) "
|
|
97
|
+
f"scale={amplitude.scale:g} offset={amplitude.offset:g}"
|
|
98
|
+
+ (" (spec defaults)" if amplitude.is_default else ""), file=stream)
|
|
99
|
+
for line in _format_axes(model):
|
|
100
|
+
print(line, file=stream)
|
|
101
|
+
for message in model.warnings:
|
|
102
|
+
print(f" warning: {message}", file=stream)
|
|
103
|
+
print(" metadata:", file=stream)
|
|
104
|
+
_dump_tree(model.metadata_tree(), stream)
|
|
105
|
+
return 0
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
#: Backends that can render a figure but cannot show a window.
|
|
109
|
+
NON_INTERACTIVE_BACKENDS = frozenset(
|
|
110
|
+
("agg", "cairo", "pdf", "pgf", "ps", "svg", "template"))
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def command_view(document, key, stream):
|
|
114
|
+
from ..viewer import (report_missing_matplotlib, require_matplotlib,
|
|
115
|
+
view_document)
|
|
116
|
+
try:
|
|
117
|
+
require_matplotlib()
|
|
118
|
+
except ImportError:
|
|
119
|
+
# Not just a message on stderr: this is the one command that may have
|
|
120
|
+
# been started from a desktop launcher or a file association, with
|
|
121
|
+
# nowhere for the text to land. report_missing_matplotlib also puts
|
|
122
|
+
# it in a box when the machine can draw one.
|
|
123
|
+
report_missing_matplotlib()
|
|
124
|
+
return 3
|
|
125
|
+
|
|
126
|
+
import matplotlib
|
|
127
|
+
backend = matplotlib.get_backend()
|
|
128
|
+
if backend.lower() in NON_INTERACTIVE_BACKENDS:
|
|
129
|
+
print(f"error: matplotlib is using the non-interactive {backend!r} "
|
|
130
|
+
f"backend, so no window can be opened. Try:\n"
|
|
131
|
+
f" MPLBACKEND=QtAgg ondeview {document.path}\n"
|
|
132
|
+
f"(or TkAgg, or install PyQt5/PySide6). "
|
|
133
|
+
f"'ondeview --list' works on any backend.", file=sys.stderr)
|
|
134
|
+
return 4
|
|
135
|
+
|
|
136
|
+
if not document.viewable:
|
|
137
|
+
print("error: no dataset in this file carries DATA to display",
|
|
138
|
+
file=sys.stderr)
|
|
139
|
+
return 5
|
|
140
|
+
|
|
141
|
+
for message in document.warnings:
|
|
142
|
+
print(f"warning: {message}", file=sys.stderr)
|
|
143
|
+
view_document(document, dataset=key, show=True)
|
|
144
|
+
return 0
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def build_parser():
|
|
148
|
+
parser = argparse.ArgumentParser(
|
|
149
|
+
prog="ondeview",
|
|
150
|
+
description="View multidimensional data stored in ONDE files.")
|
|
151
|
+
parser.add_argument("file", help="path to an .onde (HDF5) file")
|
|
152
|
+
parser.add_argument("-l", "--list", action="store_true",
|
|
153
|
+
help="list the datasets in the file and exit")
|
|
154
|
+
parser.add_argument("-i", "--info", metavar="KEY",
|
|
155
|
+
help="describe one dataset (axes, calibration, metadata)")
|
|
156
|
+
parser.add_argument("-d", "--dataset", metavar="KEY",
|
|
157
|
+
help="dataset to show first in the viewer")
|
|
158
|
+
from ..viewer.access import DEFAULT_ONDE_VERSION
|
|
159
|
+
parser.add_argument("--onde-version", default=DEFAULT_ONDE_VERSION,
|
|
160
|
+
help="ONDE class definitions to read with (default: "
|
|
161
|
+
"%(default)s). This selects which fields PyONDE "
|
|
162
|
+
"knows about by their short names, not what the "
|
|
163
|
+
"file must contain.")
|
|
164
|
+
return parser
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def main(argv=None):
|
|
168
|
+
arguments = build_parser().parse_args(argv)
|
|
169
|
+
stream = sys.stdout
|
|
170
|
+
|
|
171
|
+
if not os.path.exists(arguments.file):
|
|
172
|
+
print(f"error: no such file: {arguments.file}", file=sys.stderr)
|
|
173
|
+
return 2
|
|
174
|
+
|
|
175
|
+
size = os.path.getsize(arguments.file)
|
|
176
|
+
if size > LARGE_FILE_BYTES:
|
|
177
|
+
print(f"note: {size / 1e9:.1f} GB file; PyONDE loads ONDE files entirely "
|
|
178
|
+
f"into memory, so this may take a while and needs comparable RAM.",
|
|
179
|
+
file=sys.stderr)
|
|
180
|
+
|
|
181
|
+
try:
|
|
182
|
+
document = OndeDocument.open(arguments.file,
|
|
183
|
+
onde_version=arguments.onde_version)
|
|
184
|
+
except Exception as err:
|
|
185
|
+
print(f"error: cannot read {arguments.file}: "
|
|
186
|
+
f"{type(err).__name__}: {err}", file=sys.stderr)
|
|
187
|
+
return 1
|
|
188
|
+
|
|
189
|
+
try:
|
|
190
|
+
if arguments.info:
|
|
191
|
+
return command_info(document, arguments.info, stream)
|
|
192
|
+
if arguments.list:
|
|
193
|
+
return command_list(document, stream)
|
|
194
|
+
return command_view(document, arguments.dataset, stream)
|
|
195
|
+
except BrokenPipeError:
|
|
196
|
+
# `ondeview --list big.onde | head` closes the pipe under us; a
|
|
197
|
+
# listing tool should stop quietly rather than print a traceback.
|
|
198
|
+
try:
|
|
199
|
+
sys.stdout.close()
|
|
200
|
+
except Exception:
|
|
201
|
+
pass
|
|
202
|
+
return 0
|
|
203
|
+
finally:
|
|
204
|
+
document.close()
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if __name__ == "__main__":
|
|
208
|
+
sys.exit(main())
|